Better Font Awesome - Version 1.1.0

Version Description

  • Implement Ajax to save plugin settings (thanks Braad)
Download this release

Release Info

Developer McGuive7
Plugin Icon 128x128 Better Font Awesome
Version 1.1.0
Comparing to
See all releases

Code changes from version 1.0.10 to 1.1.0

Files changed (4) hide show
  1. better-font-awesome.php +68 -5
  2. css/admin.css +20 -0
  3. js/admin.js +46 -0
  4. readme.txt +8 -2
better-font-awesome.php CHANGED
@@ -12,7 +12,7 @@
12
  * Plugin Name: Better Font Awesome
13
  * Plugin URI: http://wordpress.org/plugins/better-font-awesome
14
  * Description: The ultimate Font Awesome icon plugin for WordPress.
15
- * Version: 1.0.10
16
  * Author: MIGHTYminnow & Mickey Kay
17
  * Author URI: mickey@mickeykaycreative.com
18
  * License: GPLv2+
@@ -166,6 +166,10 @@ class Better_Font_Awesome_Plugin {
166
  // Set up the admin settings page.
167
  add_action( 'admin_menu', array( $this, 'add_settings_page' ) );
168
  add_action( 'admin_init', array( $this, 'add_settings' ) );
 
 
 
 
169
 
170
  }
171
 
@@ -318,17 +322,20 @@ class Better_Font_Awesome_Plugin {
318
  */
319
  public function create_admin_page() {
320
  ?>
321
- <div class="wrap">
322
  <?php screen_icon(); ?>
323
  <h2><?php echo $this->plugin_display_name; ?></h2>
324
- <form method="post" action="options.php">
325
  <?php
326
  // This prints out all hidden setting fields
327
  settings_fields( 'option_group' );
328
  do_settings_sections( self::SLUG );
329
- submit_button();
330
- echo $this->get_usage_text();
331
  ?>
 
 
 
 
 
332
  </form>
333
  </div>
334
  <?php
@@ -401,6 +408,62 @@ class Better_Font_Awesome_Plugin {
401
 
402
  }
403
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
404
  /**
405
  * Get all Font Awesome versions available from the jsDelivr API.
406
  *
12
  * Plugin Name: Better Font Awesome
13
  * Plugin URI: http://wordpress.org/plugins/better-font-awesome
14
  * Description: The ultimate Font Awesome icon plugin for WordPress.
15
+ * Version: 1.1.0
16
  * Author: MIGHTYminnow & Mickey Kay
17
  * Author URI: mickey@mickeykaycreative.com
18
  * License: GPLv2+
166
  // Set up the admin settings page.
167
  add_action( 'admin_menu', array( $this, 'add_settings_page' ) );
168
  add_action( 'admin_init', array( $this, 'add_settings' ) );
169
+ add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
170
+
171
+ // Handle saving options via AJAX
172
+ add_action( 'wp_ajax_bfa_save_options', array( $this, 'save_options' ) );
173
 
174
  }
175
 
322
  */
323
  public function create_admin_page() {
324
  ?>
325
+ <div class="wrap bfa-settings">
326
  <?php screen_icon(); ?>
327
  <h2><?php echo $this->plugin_display_name; ?></h2>
328
+ <form method="post" action="options.php" id="bfa-settings-form">
329
  <?php
330
  // This prints out all hidden setting fields
331
  settings_fields( 'option_group' );
332
  do_settings_sections( self::SLUG );
 
 
333
  ?>
334
+ <p>
335
+ <span class="button-primary bfa-save-settings-button"><?php _e( 'Save Settings', 'better-font-awesome' ); ?></span> <img class="bfa-loading-gif" src="<?php echo includes_url() . 'images/spinner.gif'; ?>" />
336
+ </p>
337
+ <div class="bfa-ajax-response-holder"></div>
338
+ <?php echo $this->get_usage_text(); ?>
339
  </form>
340
  </div>
341
  <?php
408
 
409
  }
410
 
411
+ /**
412
+ * Enqueue admin scripts and styles.
413
+ *
414
+ * @since 1.0.10
415
+ */
416
+ public function admin_enqueue_scripts( $hook ) {
417
+
418
+ if ( 'settings_page_better-font-awesome' === $hook ) {
419
+
420
+ wp_enqueue_style(
421
+ self::SLUG . '-admin',
422
+ plugin_dir_url( __FILE__ ) . 'css/admin.css'
423
+ );
424
+
425
+ wp_enqueue_script(
426
+ self::SLUG . '-admin',
427
+ plugin_dir_url( __FILE__ ) . 'js/admin.js',
428
+ array( 'jquery' )
429
+ );
430
+
431
+ wp_localize_script(
432
+ self::SLUG . '-admin',
433
+ 'bfa_ajax_object',
434
+ array(
435
+ 'ajax_url' => admin_url( 'admin-ajax.php' )
436
+ )
437
+ );
438
+
439
+ }
440
+
441
+ }
442
+
443
+ /**
444
+ * Save options via AJAX.
445
+ *
446
+ * @since 1.0.10
447
+ */
448
+ public function save_options() {
449
+
450
+ $options = array(
451
+ 'version' => $_POST['version'],
452
+ 'minified' => $_POST['minified'],
453
+ 'remove_existing_fa' => $_POST['remove_existing_fa'],
454
+ 'hide_admin_notices' => $_POST['hide_admin_notices'],
455
+ );
456
+
457
+ // Sanitize and update the options.
458
+ update_option( $this->option_name, $options );
459
+
460
+ // Return a message.
461
+ echo '<div class="updated"><p>' . esc_html( 'Settings saved.', 'better-font-awesome' ) . '</p></div>';
462
+
463
+ wp_die();
464
+
465
+ }
466
+
467
  /**
468
  * Get all Font Awesome versions available from the jsDelivr API.
469
  *
css/admin.css ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Better Font Awesome Admin CSS
3
+ *
4
+ * @since 1.1.0
5
+ */
6
+
7
+ .bfa-loading-gif {
8
+ display: none;
9
+ vertical-align: middle;
10
+ }
11
+
12
+ .bfa-ajax-response-holder {
13
+ display: none;
14
+ padding-bottom: 1em;
15
+ }
16
+
17
+ .bfa-ajax-response-holder div.updated {
18
+ margin: 0;
19
+ }
20
+
js/admin.js ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Better Font Awesome Admin JS
3
+ *
4
+ * @since 1.0.10
5
+ */
6
+ ( function( $ ) {
7
+
8
+ 'use strict';
9
+
10
+ $( document ).ready( function() {
11
+
12
+ $( '.bfa-save-settings-button' ).on( 'click', function() {
13
+
14
+ $( '.bfa-ajax-response-holder' ).empty();
15
+ $( '.bfa-loading-gif' ).fadeIn();
16
+
17
+ var $bfaSettingsForm, data, version, minified, remove_existing_fa, hide_admin_notices;
18
+
19
+ $bfaSettingsForm = $( '#bfa-settings-form' );
20
+
21
+ version = $bfaSettingsForm.find( 'select#version' ).val();
22
+ minified = $bfaSettingsForm.find( 'input#minified' ).is( ':checked' ) ? 1 : 0;
23
+ remove_existing_fa = $bfaSettingsForm.find( 'input#remove_existing_fa' ).is( ':checked' ) ? 1 : 0;
24
+ hide_admin_notices = $bfaSettingsForm.find( 'input#hide_admin_notices' ).is( ':checked' ) ? 1 : 0;
25
+
26
+ data = {
27
+ 'action': 'bfa_save_options',
28
+ 'version': version,
29
+ 'minified': minified,
30
+ 'remove_existing_fa': remove_existing_fa,
31
+ 'hide_admin_notices': hide_admin_notices,
32
+ };
33
+
34
+ $.post(
35
+ bfa_ajax_object.ajax_url, // Array passed via wp_localize_script()
36
+ data,
37
+ function( response ) {
38
+ $( '.bfa-loading-gif' ).fadeOut( function() {
39
+ $( '.bfa-ajax-response-holder' ).html( response ).slideDown().delay(2000).fadeTo(600, 0).delay(300).slideUp().fadeTo(0, 100);
40
+ });
41
+ }
42
+ );
43
+
44
+ });
45
+ });
46
+ })( jQuery );
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: McGuive7, MIGHTYminnow
3
  Tags: better, font, awesome, icon, icons, bootstrap, fontstrap, cdn, shortcode
4
  Donate link: http://mightyminnow.com
5
  Requires at least: 3.0
6
- Tested up to: 4.2
7
- Stable tag: 1.0.10
8
  License: GPLv2+
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -108,6 +108,9 @@ Better Font Awesome does it's best to load after any existing Font Awesome CSS,
108
 
109
  == Changelog ==
110
 
 
 
 
111
  = 1.0.10 =
112
  * Fix SSL bug breaking wp_remote_get() from https.
113
 
@@ -178,6 +181,9 @@ Better Font Awesome does it's best to load after any existing Font Awesome CSS,
178
 
179
  == Upgrade Notice ==
180
 
 
 
 
181
  = 1.0.10 =
182
  * Fix SSL bug breaking wp_remote_get() from https
183
 
3
  Tags: better, font, awesome, icon, icons, bootstrap, fontstrap, cdn, shortcode
4
  Donate link: http://mightyminnow.com
5
  Requires at least: 3.0
6
+ Tested up to: 4.3
7
+ Stable tag: 1.1.0
8
  License: GPLv2+
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
108
 
109
  == Changelog ==
110
 
111
+ = 1.1.0 =
112
+ * Implement Ajax to save plugin settings (thanks [Braad](https://profiles.wordpress.org/braad))
113
+
114
  = 1.0.10 =
115
  * Fix SSL bug breaking wp_remote_get() from https.
116
 
181
 
182
  == Upgrade Notice ==
183
 
184
+ = 1.1.0 =
185
+ * Implement Ajax to save plugin settings (thanks [Braad](https://profiles.wordpress.org/braad))
186
+
187
  = 1.0.10 =
188
  * Fix SSL bug breaking wp_remote_get() from https
189