Changeset 2292204
- Timestamp:
- 04/26/2020 07:08:37 PM (6 years ago)
- Location:
- automatic-page-load-progress-bar/trunk
- Files:
-
- 2 edited
-
automatic-page-load-progress-bar.php (modified) (4 diffs)
-
readme.txt (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
automatic-page-load-progress-bar/trunk/automatic-page-load-progress-bar.php
r2279624 r2292204 13 13 * Plugin URI: https://gitlab.com/atilb/automatic-page-load-progress-bar-wordpress-plugin 14 14 * Description: Add smooth and beautifull progress bar for your website. THX to : https://github.hubspot.com/pace/docs/welcome/# 15 * Version: 1.0. 015 * Version: 1.0.2 16 16 * Author: Arnaud TILBIAN 17 17 * Author URI: https://www.arnaudtilbian.com … … 20 20 */ 21 21 22 function aplpb_hook_javascript () { 23 wp_enqueue_script( 'aplpb', plugins_url( 'public/js/pace.js', __FILE__ ), array(), false, false ); 22 function aplpb_hook_javascript() { 23 $drawGlobally = get_option( 'aplpb_option_checkbox '); 24 if($drawGlobally == '1') 25 { 26 aplpb_add_javascript(); 27 } 28 } 29 30 function aplpb_add_javascript() { 31 wp_enqueue_script( 'aplpb', plugins_url( 'public/js/pace.js', __FILE__ ), array(), false, false ); 24 32 } 25 33 26 34 function aplpb_hook_style_dynamic_content() { 27 $theme = get_option( 'aplpb_option_choice' ); 28 $color = get_option( 'aplpb_option_color' ); 29 wp_enqueue_style( $theme, plugins_url( 'public/css/' . $theme . '.css' , __FILE__ ), array(), false, false); 30 $custom_css = " .pace .pace-progress{ background:" . $color . "!important;border:" . $color . "!important; }"; 31 wp_add_inline_style( $theme, $custom_css ); 32 33 if ( is_admin_bar_showing() ) { 34 wp_add_inline_style( $theme, ".pace .pace-progress{z-index:100000;}" ); 35 $drawGlobally = get_option( 'aplpb_option_checkbox '); 36 if($drawGlobally == '1') 37 { 38 aplpb_add_dynamic_content(); 35 39 } 36 40 } 37 41 42 function aplpb_add_dynamic_content($theme = NULL, $color = NULL) { 43 if($theme == NULL) 44 $theme = get_option( 'aplpb_option_theme' ); 45 if($color == NULL) 46 $color = get_option( 'aplpb_option_color' ); 47 48 wp_enqueue_style( $theme, plugins_url( 'public/css/' . $theme . '.css' , __FILE__ ), array(), false, false); 49 $custom_css = " .pace .pace-progress{ background:" . $color . "!important;border:" . $color . "!important; }"; 50 wp_add_inline_style( $theme, $custom_css ); 51 52 if ( is_admin_bar_showing() ) { 53 wp_add_inline_style( $theme, ".pace .pace-progress{z-index:100000;}" ); 54 } 55 } 56 38 57 function aplpb_register_settings() { 39 add_option( 'aplpb_option_choice', 'minimal'); 40 add_option( 'aplpb_option_color', '#ffffff'); 41 register_setting( 'aplpb_options_group', 'aplpb_option_choice' ); 58 add_option( 'aplpb_option_theme', 'minimal'); 59 add_option( 'aplpb_option_color', '#ffffff'); 60 add_option( 'aplpb_option_checkbox', '1'); 61 register_setting( 'aplpb_options_group', 'aplpb_option_theme' ); 42 62 register_setting( 'aplpb_options_group', 'aplpb_option_color' ); 63 register_setting( 'aplpb_options_group', 'aplpb_option_checkbox' ); 43 64 } 44 65 … … 58 79 <table> 59 80 <tr valign="top"> 60 <th scope="row"><label for="aplpb_option_choice">Choose theme</label></th>61 <td>62 <select id="aplpb_option_choice" name="aplpb_option_choice">63 <?php64 $file_paths = glob( plugin_dir_path( __FILE__ ) . "/public/css/*.css");65 $lastChoiceValue = get_option( 'aplpb_option_choice' );66 echo "<option value='$lastChoiceValue '>$lastChoiceValue </option>";67 foreach($file_paths as $file)68 {69 $fileName = basename($file, '.css');70 if($fileName != $lastChoiceValue)71 {72 echo "<option value='$fileName'>$fileName</option>";73 }74 }75 ?>76 </select>77 </td>81 <th scope="row"><label for="aplpb_option_theme">Choose theme</label></th> 82 <td> 83 <select id="aplpb_option_theme" name="aplpb_option_theme"> 84 <?php 85 $file_paths = glob( plugin_dir_path( __FILE__ ) . "/public/css/*.css"); 86 $lastChoiceValue = get_option( 'aplpb_option_theme' ); 87 echo "<option value='$lastChoiceValue '>$lastChoiceValue </option>"; 88 foreach($file_paths as $file) 89 { 90 $fileName = basename($file, '.css'); 91 if($fileName != $lastChoiceValue) 92 { 93 echo "<option value='$fileName'>$fileName</option>"; 94 } 95 } 96 ?> 97 </select> 98 </td> 78 99 </tr> 79 100 <tr valign="top"> 80 <th scope="row"><label for="aplpb_option_color">Choose color</label></th> 81 <td> 82 <input type="color" id="aplpb_option_color" name="aplpb_option_color" value="<?php echo get_option( 'aplpb_option_color' ); ?>"/> 83 </td> 101 <th scope="row"><label for="aplpb_option_color">Choose color</label></th> 102 <td> 103 <input type="color" id="aplpb_option_color" name="aplpb_option_color" value="<?php echo get_option( 'aplpb_option_color' ); ?>"/> 104 </td> 105 </tr> 106 <tr valign="top"> 107 <th scope="row"><label for="aplpb_option_checkbox">Enable on all pages(shortcodes won't be active)</label></th> 108 <td> 109 <input type="checkbox" id="aplpb_option_checkbox" name="aplpb_option_checkbox" value="1" <?php checked( get_option( 'aplpb_option_checkbox' ), '1' ); ?>/> 110 </td> 84 111 </tr> 85 112 </table> … … 96 123 } 97 124 125 function aplpb_shortcode($atts) { 126 $a = shortcode_atts( array( 127 'theme' => 'minimal', 128 'color' => 'red' 129 ), $atts); 130 $drawGlobally = get_option( 'aplpb_option_checkbox '); 131 if($drawGlobally != '1') 132 { 133 aplpb_add_javascript(); 134 aplpb_add_dynamic_content(esc_html( $a['theme'] ), esc_html( $a['color'] )); 135 } 136 } 137 add_shortcode( 'aplpb_shortcode', 'aplpb_shortcode'); 138 98 139 99 140 add_action( 'admin_init','aplpb_register_settings'); -
automatic-page-load-progress-bar/trunk/readme.txt
r2278697 r2292204 13 13 == Description == 14 14 This free plugin give you the ability to add different kind of loading bar for your website. 15 Simple admin setting to change color and progress bar theme. 15 Simple admin setting to change color and progress bar theme. You can choose to add them globally to your website or page by page. 16 16 17 17 I really like adding nice progress bar to my website, giving user a fancy way to make this boring moment fun ! … … 19 19 20 20 It's a PACE (https://github.hubspot.com/pace/docs/welcome/# , developed by hubspot) wrapper with themes from various authors. 21 22 23 Shortcode give you a way to add specific shortcode for each page. 24 Example of use: 25 [aplpb_shortcode theme="minimal" color="blue"] 26 21 27 22 28 == Installation == … … 35 41 Move to the plugin settings, change your theme style and save it. 36 42 43 = How to activate the progress bar for all my website ? = 44 Move to the plugin settings, check the box and your progress bar will appear on each page ! 45 46 = How to create a page specfiic progress bar ? = 47 Use the shortcode functionnality so you can create page specific loading bar. 48 [aplpb_shortcode theme="minimal" color="blue"] 49 37 50 = How to create new smoothy theme ? = 38 51 Hey ! You are going in the right direction. Go to the plugin repository(https://gitlab.com/atilb/automatic-page-load-progress-bar-wordpress-plugin), fork it and give me some nice pull requests ! :D … … 43 56 2. Choose color and theme 44 57 3. Examples of loading screen/bar/wheel 58 59 == Changelog == 60 61 = 1.0.2 = 62 * Shortcode functionnality added
Note: See TracChangeset
for help on using the changeset viewer.