Changeset 2293517
- Timestamp:
- 04/28/2020 01:10:39 PM (6 years ago)
- Location:
- automatic-page-load-progress-bar/trunk
- Files:
-
- 2 edited
-
automatic-page-load-progress-bar.php (modified) (7 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
automatic-page-load-progress-bar/trunk/automatic-page-load-progress-bar.php
r2292927 r2293517 12 12 * Plugin Name: Automatic Page Load Progress Bar 13 13 * Plugin URI: https://gitlab.com/atilb/automatic-page-load-progress-bar-wordpress-plugin 14 * Description: Add smooth and beautifull progress bar for your website. THX to : https://github.hubspot.com/pace/docs/welcome/#15 * Version: 1.0. 314 * Description: Light and efficient extension to add a progress bar in less than a minute. 15 * Version: 1.0.4 16 16 * Author: Arnaud TILBIAN 17 17 * Author URI: https://www.arnaudtilbian.com … … 20 20 */ 21 21 22 function aplpb_hook_javascript() { 23 $drawGlobally = get_option( 'aplpb_option_checkbox '); 24 if($drawGlobally == '1') 22 function aplpb_hook_progress_bar_front_content($isShortcode = FALSE, $theme = NULL, $color = NULL) { 23 24 if($theme == NULL) 25 $theme = get_option( 'aplpb_option_theme' ); 26 if($color == NULL) 27 $color = get_option( 'aplpb_option_color' ); 28 29 if($isShortcode) // if progress bar come from shortcode 25 30 { 26 31 aplpb_add_javascript(); 32 aplpb_add_style($theme, $color); 27 33 } 28 } 34 else 35 { 36 if( (get_post_type( get_the_ID() ) == 'page' && get_option("aplpb_option_checkbox_page") == '1') || (get_post_type( get_the_ID() ) == 'post' && get_option("aplpb_option_checkbox_post") == '1') ) 37 { 38 $page_id = get_queried_object_id(); 39 $page_object = get_page( $page_id ); 40 if ( !has_shortcode($page_object->post_content, "aplpb_shortcode") ) // and the page didn't contain any progress bar shortcode 41 { 42 aplpb_add_javascript(); 43 aplpb_add_style($theme, $color); 44 } 45 } 46 } 47 } 29 48 30 49 function aplpb_add_javascript() { … … 32 51 } 33 52 34 function aplpb_hook_style_dynamic_content() { 35 $drawGlobally = get_option( 'aplpb_option_checkbox '); 36 if($drawGlobally == '1') 37 { 38 $page_id = get_queried_object_id(); 39 $page_object = get_page( $page_id ); 40 if ( !has_shortcode($page_object->post_content, "aplpb_shortcode")) 41 { 42 aplpb_add_dynamic_content(); 43 } 44 } 45 } 46 47 function aplpb_add_dynamic_content($theme = NULL, $color = NULL) { 48 if($theme == NULL) 49 { 50 $theme = get_option( 'aplpb_option_theme' ); 51 } 52 if($color == NULL) 53 { 54 $color = get_option( 'aplpb_option_color' ); 55 } 56 53 function aplpb_add_style($theme, $color) { 57 54 wp_enqueue_style( $theme, plugins_url( 'public/css/' . $theme . '.css' , __FILE__ ), array(), false, false); 58 55 $custom_css = " .pace .pace-progress{ background:" . $color . "!important;border:" . $color . "!important; }"; … … 67 64 add_option( 'aplpb_option_theme', 'minimal'); 68 65 add_option( 'aplpb_option_color', '#ffffff'); 69 add_option( 'aplpb_option_checkbox', '1'); 66 add_option( 'aplpb_option_checkbox_page', '1'); 67 add_option( 'aplpb_option_checkbox_post', '1'); 70 68 register_setting( 'aplpb_options_group', 'aplpb_option_theme' ); 71 69 register_setting( 'aplpb_options_group', 'aplpb_option_color' ); 72 register_setting( 'aplpb_options_group', 'aplpb_option_checkbox' ); 70 register_setting( 'aplpb_options_group', 'aplpb_option_checkbox_page' ); 71 register_setting( 'aplpb_options_group', 'aplpb_option_checkbox_post' ); 73 72 } 74 73 … … 85 84 <form method="post" action="options.php"> 86 85 <?php settings_fields( 'aplpb_options_group' ); ?> 87 <h3>Change progress bar theme and color easily</h3>88 86 <table> 89 87 <tr valign="top"> 90 <th scope="row"><label for="aplpb_option_theme">Choose theme</label></th>91 88 <td> 89 <label for="aplpb_option_theme">Choose theme</label> 92 90 <select id="aplpb_option_theme" name="aplpb_option_theme"> 93 91 <?php … … 108 106 </tr> 109 107 <tr valign="top"> 110 <th scope="row"><label for="aplpb_option_color">Choose color</label></th>111 108 <td> 109 <label for="aplpb_option_color">Choose color</label> 112 110 <input type="color" id="aplpb_option_color" name="aplpb_option_color" value="<?php echo get_option( 'aplpb_option_color' ); ?>"/> 113 111 </td> 114 112 </tr> 115 113 <tr valign="top"> 116 <th scope="row"><label for="aplpb_option_checkbox">Enable on all pages(shortcodes can override it for page specfic loading bar)</label></th>117 114 <td> 118 <input type="checkbox" id="aplpb_option_checkbox" name="aplpb_option_checkbox" value="1" <?php checked( get_option( 'aplpb_option_checkbox' ), '1' ); ?>/> 115 <label for="aplpb_option_checkbox_page">Enable on all static page</label> 116 <input type="checkbox" id="aplpb_option_checkbox_page" name="aplpb_option_checkbox_page" value="1" <?php checked( get_option( 'aplpb_option_checkbox_page' ), '1' ); ?>/> 117 </td> 118 </tr> 119 <tr valign="top"> 120 <td> 121 <label for="aplpb_option_checkbox_post">Enable on blog post</label> 122 <input type="checkbox" id="aplpb_option_checkbox_post" name="aplpb_option_checkbox_post" value="1" <?php checked( get_option( 'aplpb_option_checkbox_post' ), '1' ); ?>/> 119 123 </td> 120 124 </tr> … … 134 138 function aplpb_shortcode($atts) { 135 139 $a = shortcode_atts( array( 136 'theme' => 'minimal',137 'color' => 'red'140 'theme' => NULL, 141 'color' => NULL 138 142 ), $atts); 139 140 aplpb_add_javascript(); 141 aplpb_add_dynamic_content(esc_html( $a['theme'] ), esc_html( $a['color'] )); 143 144 aplpb_hook_progress_bar_front_content(true, esc_html( $a['theme'] ), esc_html( $a['color'] )); 142 145 } 143 add_shortcode( 'aplpb_shortcode', 'aplpb_shortcode');144 146 147 148 $plugin = plugin_basename( __FILE__ ); 145 149 146 150 add_action( 'admin_init','aplpb_register_settings'); 147 151 add_action( 'admin_menu','aplpb_register_options_page'); 148 add_action( 'wp_head', 'aplpb_hook_javascript');149 add_action( 'wp_head', 'aplpb_hook_style_dynamic_content');150 151 $plugin = plugin_basename( __FILE__ );152 152 add_filter( "plugin_action_links_$plugin", 'aplpb_add_setting_link'); 153 add_shortcode( 'aplpb_shortcode', 'aplpb_shortcode'); 154 add_action( 'wp_head', 'aplpb_hook_progress_bar_front_content'); -
automatic-page-load-progress-bar/trunk/readme.txt
r2293501 r2293517 1 === Simple LoadingProgress Bar ===1 === Automatic Page Load Progress Bar === 2 2 Donate link: 3 3 Contributors: atilbian … … 61 61 62 62 = 1.0.4 = 63 * Progress bar can now be shown on selected content type(page, post, or both) . And plugin name changed! :D63 * Progress bar can now be shown on selected content type(page, post, or both), and added a new plugin logo ! :D 64 64 65 65 = 1.0.3 =
Note: See TracChangeset
for help on using the changeset viewer.