Skip to content

Commit

Permalink
Plugin updated to version 4.10
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurGareginyan committed Jun 4, 2017
1 parent a6f059a commit 7a07e6a
Show file tree
Hide file tree
Showing 16 changed files with 473 additions and 357 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ It give you finer control over buttons. You can configure they on plugins settin
* Skype
* Personal website
* Email
* Telephone
* RSS Feed

**Got more ideas? Tell me!**
Expand Down
6 changes: 5 additions & 1 deletion inc/css/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @uthor Arthur Gareginyan
* @link http://www.arthurgareginyan.com
* @copyright Copyright (c) 2016-2017 Arthur Gareginyan. All Rights Reserved.
* @since 4.2
* @since 4.10
*/


Expand Down Expand Up @@ -142,6 +142,10 @@ h3.title {
#side-sortables .paypal {
font-size: 18px;
}
#side-sortables .version {
color: #888888;
text-align: right;
}

/* Support - addition section
-------------------------------------------------------------- */
Expand Down
Binary file removed inc/img/social-media-icons/beam.png
Binary file not shown.
Binary file added inc/img/social-media-icons/mixer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added inc/img/social-media-icons/telephone.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 14 additions & 6 deletions inc/php/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/**
* Render Settings Tab
*
* @since 4.9
* @since 4.10
*/
?>
<!-- SIDEBAR -->
Expand All @@ -21,6 +21,7 @@
<h3 class="title"><?php _e( 'About', SMEDIABT_TEXT ); ?></h3>
<div class="inside">
<p><?php _e( 'This plugin allows you to easily add the social media follow buttons bar to any place of your website.', SMEDIABT_TEXT ); ?></p>
<p class="version"><?php _e( 'Version', SMEDIABT_TEXT ); ?> <?php echo SMEDIABT_VERSION; ?></p>
</div>
</div>

Expand Down Expand Up @@ -306,11 +307,11 @@
'//store.steampowered.com'
);
?>
<?php smbtoolbar_media( 'beam',
'Beam',
'http://beam.pro/YourUsernameHere',
__( 'Enter the link to your Beam profile page', SMEDIABT_TEXT ),
'//beam.pro'
<?php smbtoolbar_media( 'mixer',
'Mixer',
'https://mixer.com/YourUsernameHere',
__( 'Enter the link to your Mixer profile page', SMEDIABT_TEXT ),
'//mixer.com'
);
?>
<?php smbtoolbar_media( 'discord',
Expand Down Expand Up @@ -418,6 +419,13 @@
''
);
?>
<?php smbtoolbar_media( 'telephone',
'Telephone',
'tel://1-555-555-5555',
__( 'Enter your telephone number with prefix <b>tel://</b>', SMEDIABT_TEXT ),
''
);
?>
<?php smbtoolbar_media( 'rss-feed',
'RSS Feed',
'http://YourDomainNameHere.com/feed',
Expand Down
33 changes: 33 additions & 0 deletions inc/php/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,36 @@
* @since 0.1
*/
defined( 'ABSPATH' ) or die( "Restricted access!" );

/**
* Upgrade plugin data in the database to version 4.10
*
* @since 4.10
*/
function smbtoolbar_upgrade_4_10_settings() {

// Read plugin settings from the database
$settings = get_option( SMEDIABT_SETTINGS . '_settings' );
$array = !empty( $settings['media'] ) ? $settings['media'] : array();
$old_key = 'beam';
$new_key = 'mixer';

// Exit if the upgrade is not needed or alreade done
if ( ! array_key_exists( $old_key, $array ) ) {
return;
}

// Replace the key name from "beam" to "mixer"
$keys = array_keys( $array );
$keys[ array_search( $old_key, $keys ) ] = $new_key;
$settings['media'] = array_combine( $keys, $array );

// Replace the value of the key "label" and "slug"
$settings['media']['mixer']['label'] = 'Mixer';
$settings['media']['mixer']['slug'] = 'mixer';

// Update plugin setting in the database
update_option( SMEDIABT_SETTINGS . '_settings', $settings );

}
smbtoolbar_upgrade_4_10_settings();
77 changes: 0 additions & 77 deletions inc/php/version.php

This file was deleted.

107 changes: 107 additions & 0 deletions inc/php/versioning.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<?php

/**
* Prevent Direct Access
*
* @since 0.1
*/
defined( 'ABSPATH' ) or die( "Restricted access!" );

/**
* Function for managing information about the version number of the plugin
*
* @since 4.10
*/
function smbtoolbar_versioning() {

///////////////////////////////////////////////////////////////////
// SETTING VARIABLES //
///////////////////////////////////////////////////////////////////

$version_files = SMEDIABT_VERSION;
$settings = SMEDIABT_SETTINGS;

// Read the plugin service information from the database and put it into an array
$info = get_option( $settings . '_service_info' );

// Make the "$info" array if the plugin service information in the database is not exist
if ( ! is_array( $info ) ) $info = array();

// Get the current plugin version number from the database
$version_db = !empty( $info['version'] ) ? $info['version'] : '0';

///////////////////////////////////////////////////////////////////
// FORMATTING NUMBERS //
///////////////////////////////////////////////////////////////////

// Clean the version number from extra digits
$version_db = substr( $version_db, 0, 4 );
$version_files = substr( $version_files, 0, 4 );
if ( ! is_numeric( $version_db ) ) {
$version_db = number_format( floor( $version_db * 100 ) / 100, 1, '.', '' );
}
if ( ! is_numeric( $version_files ) ) {
$version_files = number_format( floor( $version_files * 100 ) / 100, 1, '.', '' );
}

// Count the number of decimal digits in version number
$version_db_count = strlen( substr( strrchr( $version_db, "."), 1 ) );
$version_files_count = strlen( substr( strrchr( $version_files, "."), 1 ) );

// Fix decimals if the number of decimal digits in version number is 1
if ( $version_db_count == '1' ) {
$version_db_formated = ( $version_db - floor( $version_db ) ) / 10;
$version_db_formated = ( floor( $version_db ) + $version_db_formated );
$version_db = sprintf( '%0.2f', $version_db_formated );
}
if ( $version_files_count == '1' ) {
$version_files_formated = ( $version_files - floor( $version_files ) ) / 10;
$version_files_formated = ( floor( $version_files ) + $version_files_formated );
$version_files = sprintf( '%0.2f', $version_files_formated );
}

///////////////////////////////////////////////////////////////////
// COMPARING NUMBERS //
///////////////////////////////////////////////////////////////////

// If the version number in the database is same as the new version number:
// - Reset the "old_version" marker in the database
// - Exit from this function
if ( $version_files == $version_db ) {

if ( $info['old_version'] == '1' ) {

$info['old_version'] = '0';
update_option( $settings . '_service_info', $info );

}

return;
}

// If the version number in the database is smaller than the new version number:
// - Save the new version number to the database
// - Update the "old_version" marker in the database
// - Exit from this function
if ( $version_files > $version_db ) {

$info['version'] = $version_files;
$info['old_version'] = '0';
update_option( $settings . '_service_info', $info );

return;
}

// If the version number in the database is greater than the new version number:
// - Save the "old_version" marker to the database
// - Exit from this function
if ( $version_files < $version_db ) {

$info['old_version'] = '1';
update_option( $settings . '_service_info', $info );

return;
}

}
smbtoolbar_versioning();
Binary file modified languages/social-media-buttons-toolbar-es_ES.mo
Binary file not shown.
Loading

0 comments on commit 7a07e6a

Please sign in to comment.