Social Media Follow Buttons Bar - Version 4.21

Version Description

  • The hard coded HTML radio options are replaced with the PHP function that dynamically creates radio.
Download this release

Release Info

Developer Arthur Gareginyan
Plugin Icon 128x128 Social Media Follow Buttons Bar
Version 4.21
Comparing to
See all releases

Code changes from version 4.20 to 4.21

inc/php/controls.php CHANGED
@@ -179,3 +179,51 @@ function spacexchimp_p005_control_link( $name, $label, $placeholder, $help, $lin
179
  // Print a help text
180
  spacexchimp_p005_control_help( $help );
181
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
179
  // Print a help text
180
  spacexchimp_p005_control_help( $help );
181
  }
182
+
183
+ /**
184
+ * Generator of the switches for saving plugin settings to database
185
+ */
186
+ function spacexchimp_p005_control_choice( $name, $items, $label, $help, $default ) {
187
+
188
+ // Read options from database and declare variables
189
+ $options = get_option( SPACEXCHIMP_P005_SETTINGS . '_settings' );
190
+ $option = !empty( $options[$name] ) ? $options[$name] : '';
191
+ $list_item = '';
192
+
193
+ foreach ( $items as $item_key => $item_value ) {
194
+ if ( empty( $option ) AND $item_key == $default ) {
195
+ $selected = "checked='checked'";
196
+ } elseif ( $option == $item_key ) {
197
+ $selected = "checked='checked'";
198
+ } else {
199
+ $selected = "";
200
+ }
201
+ $list_item .= "<li>
202
+ <input
203
+ type='radio'
204
+ name='" . SPACEXCHIMP_P005_SETTINGS . "_settings[$name]'
205
+ value='$item_key'
206
+ $selected
207
+ >
208
+ $item_value
209
+ <li>";
210
+ }
211
+
212
+ // Generate a part of table
213
+ $out = "<tr>
214
+ <th scope='row'>
215
+ $label
216
+ </th>
217
+ <td>
218
+ <ul class='control-list $name'>
219
+ $list_item
220
+ </ul>
221
+ </td>
222
+ </tr>";
223
+
224
+ // Print the generated part of table
225
+ echo $out;
226
+
227
+ // Print a help text
228
+ spacexchimp_p005_control_help( $help );
229
+ }
inc/php/settings.php CHANGED
@@ -16,14 +16,6 @@ defined( 'ABSPATH' ) or die( "Restricted access!" );
16
  <form action="options.php" method="post" enctype="multipart/form-data">
17
  <?php settings_fields( SPACEXCHIMP_P005_SETTINGS . '_settings_group' ); ?>
18
 
19
- <?php
20
- // Get options from the database
21
- $options = get_option( SPACEXCHIMP_P005_SETTINGS . '_settings' );
22
-
23
- // Set default value if option is empty
24
- $alignment = !empty( $options['alignment'] ) ? $options['alignment'] : '';
25
- ?>
26
-
27
  <button type="submit" name="submit" id="submit" class="btn btn-info btn-lg button-save-top">
28
  <i class="fa fa-save" aria-hidden="true"></i>
29
  <span><?php _e( 'Save changes', $text ); ?></span>
@@ -75,35 +67,16 @@ defined( 'ABSPATH' ) or die( "Restricted access!" );
75
  __( 'Enter the size of space (in pixels) between icons in your social media follow buttons bar.', $text ),
76
  '10'
77
  );
78
- ?>
79
-
80
- <tr>
81
- <th scope='row'>
82
- <?php _e( 'Alignment', $text ); ?>
83
- </th>
84
- <td>
85
- <ul class="alignment">
86
- <li>
87
- <input type="radio" name="spacexchimp_p005_settings[alignment]" value="left" <?php checked( 'left', $alignment ); ?> >
88
- <?php _e( 'Left', $text ); ?>
89
- </li>
90
- <li>
91
- <input type="radio" name="spacexchimp_p005_settings[alignment]" value="center" <?php checked( '', $alignment ); ?> <?php checked( 'center', $alignment ); ?> >
92
- <?php _e( 'Center', $text ); ?>
93
- </li>
94
- <li>
95
- <input type="radio" name="spacexchimp_p005_settings[alignment]" value="right" <?php checked( 'right', $alignment ); ?> >
96
- <?php _e( 'Right', $text ); ?>
97
- </li>
98
- </ul>
99
- </td>
100
- </tr>
101
- <tr>
102
- <td></td>
103
- <td class='help-text'><?php _e( 'You can choose the alignment of the buttons bar.', $text ); ?></td>
104
- </tr>
105
-
106
- <?php
107
  spacexchimp_p005_control_field( 'caption',
108
  __( 'Caption', $text ),
109
  __( 'Enter the caption to your social media follow buttons bar. It will be displays before the toolbar.', $text ),
16
  <form action="options.php" method="post" enctype="multipart/form-data">
17
  <?php settings_fields( SPACEXCHIMP_P005_SETTINGS . '_settings_group' ); ?>
18
 
 
 
 
 
 
 
 
 
19
  <button type="submit" name="submit" id="submit" class="btn btn-info btn-lg button-save-top">
20
  <i class="fa fa-save" aria-hidden="true"></i>
21
  <span><?php _e( 'Save changes', $text ); ?></span>
67
  __( 'Enter the size of space (in pixels) between icons in your social media follow buttons bar.', $text ),
68
  '10'
69
  );
70
+ spacexchimp_p005_control_choice( 'alignment',
71
+ array(
72
+ 'left' => __( 'Left', $text ),
73
+ 'center' => __( 'Center', $text ),
74
+ 'right' => __( 'Right', $text )
75
+ ),
76
+ __( 'Alignment', $text ),
77
+ __( 'You can choose the alignment of the buttons bar.', $text ),
78
+ 'center'
79
+ );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  spacexchimp_p005_control_field( 'caption',
81
  __( 'Caption', $text ),
82
  __( 'Enter the caption to your social media follow buttons bar. It will be displays before the toolbar.', $text ),
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: icon, icon set, button, social, media, social button, social media, social
4
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=8A88KC7TFF6CS
5
  Requires at least: 3.9
6
  Tested up to: 4.8
7
- Stable tag: 4.20
8
  License: GPL3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -251,6 +251,9 @@ Commercial licensing (e.g. for projects that can’t use an open-source license)
251
 
252
  == Changelog ==
253
 
 
 
 
254
  = 4.20 =
255
  * Added the top level menu item of the brand.
256
  * The submenu item of the plugin has moved to the menu item of the brand.
4
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=8A88KC7TFF6CS
5
  Requires at least: 3.9
6
  Tested up to: 4.8
7
+ Stable tag: 4.21
8
  License: GPL3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
251
 
252
  == Changelog ==
253
 
254
+ = 4.21 =
255
+ * The hard coded HTML radio options are replaced with the PHP function that dynamically creates radio.
256
+
257
  = 4.20 =
258
  * Added the top level menu item of the brand.
259
  * The submenu item of the plugin has moved to the menu item of the brand.
social-media-buttons-toolbar.php CHANGED
@@ -5,7 +5,7 @@
5
  * Description: Easily add the smart bar with social media follow buttons (not share, only link to your profiles) to any place of your WordPress website.
6
  * Author: Arthur Gareginyan
7
  * Author URI: https://www.arthurgareginyan.com
8
- * Version: 4.20
9
  * License: GPL3
10
  * Text Domain: social-media-buttons-toolbar
11
  * Domain Path: /languages/
5
  * Description: Easily add the smart bar with social media follow buttons (not share, only link to your profiles) to any place of your WordPress website.
6
  * Author: Arthur Gareginyan
7
  * Author URI: https://www.arthurgareginyan.com
8
+ * Version: 4.21
9
  * License: GPL3
10
  * Text Domain: social-media-buttons-toolbar
11
  * Domain Path: /languages/