Plugin Directory

Changeset 2293517


Ignore:
Timestamp:
04/28/2020 01:10:39 PM (6 years ago)
Author:
atilbian
Message:

v1.0.4 : name rollback

Location:
automatic-page-load-progress-bar/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • automatic-page-load-progress-bar/trunk/automatic-page-load-progress-bar.php

    r2292927 r2293517  
    1212 * Plugin Name:       Automatic Page Load Progress Bar
    1313 * 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.3
     14 * Description:       Light and efficient extension to add a progress bar in less than a minute.
     15 * Version:           1.0.4
    1616 * Author:            Arnaud TILBIAN
    1717 * Author URI:        https://www.arnaudtilbian.com
     
    2020 */
    2121 
    22 function aplpb_hook_javascript() {
    23     $drawGlobally = get_option( 'aplpb_option_checkbox ');
    24     if($drawGlobally == '1')
     22function 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
    2530    {
    2631        aplpb_add_javascript();
     32        aplpb_add_style($theme, $color);
    2733    }
    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}   
    2948
    3049function aplpb_add_javascript() {
     
    3251}
    3352
    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 
     53function aplpb_add_style($theme, $color) {
    5754    wp_enqueue_style( $theme, plugins_url( 'public/css/' . $theme . '.css' , __FILE__ ), array(), false, false);
    5855    $custom_css = " .pace .pace-progress{ background:" . $color . "!important;border:" . $color . "!important; }";
     
    6764    add_option( 'aplpb_option_theme', 'minimal');
    6865    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');
    7068    register_setting( 'aplpb_options_group', 'aplpb_option_theme' );
    7169    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' );
    7372}
    7473
     
    8584        <form method="post" action="options.php">
    8685            <?php settings_fields( 'aplpb_options_group' ); ?>
    87             <h3>Change progress bar theme and color easily</h3>
    8886            <table>
    8987                <tr valign="top">
    90                     <th scope="row"><label for="aplpb_option_theme">Choose theme</label></th>
    9188                    <td>
     89                        <label for="aplpb_option_theme">Choose theme</label>
    9290                        <select id="aplpb_option_theme" name="aplpb_option_theme">
    9391                        <?php
     
    108106                </tr>
    109107                <tr valign="top">
    110                     <th scope="row"><label for="aplpb_option_color">Choose color</label></th>
    111108                    <td>
     109                    <label for="aplpb_option_color">Choose color</label>
    112110                        <input type="color" id="aplpb_option_color" name="aplpb_option_color" value="<?php echo get_option( 'aplpb_option_color' ); ?>"/>
    113111                    </td>
    114112                </tr>
    115113                <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>
    117114                    <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' ); ?>/>
    119123                    </td>
    120124                </tr>
     
    134138function aplpb_shortcode($atts) {
    135139    $a = shortcode_atts( array(
    136         'theme' => 'minimal',
    137         'color' => 'red'
     140        'theme' => NULL,
     141        'color' => NULL
    138142    ), $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'] ));
    142145}
    143 add_shortcode( 'aplpb_shortcode', 'aplpb_shortcode');
    144146
     147
     148$plugin = plugin_basename( __FILE__ );
    145149
    146150add_action( 'admin_init','aplpb_register_settings');
    147151add_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__ );
    152152add_filter( "plugin_action_links_$plugin", 'aplpb_add_setting_link');
     153add_shortcode( 'aplpb_shortcode', 'aplpb_shortcode');
     154add_action( 'wp_head', 'aplpb_hook_progress_bar_front_content');
  • automatic-page-load-progress-bar/trunk/readme.txt

    r2293501 r2293517  
    1 === Simple Loading Progress Bar ===
     1=== Automatic Page Load Progress Bar ===
    22Donate link:
    33Contributors: atilbian
     
    6161
    6262 = 1.0.4 =
    63 * Progress bar can now be shown on selected content type(page, post, or both). And plugin name changed ! :D
     63* Progress bar can now be shown on selected content type(page, post, or both), and added a new plugin logo ! :D
    6464
    6565 = 1.0.3 =
Note: See TracChangeset for help on using the changeset viewer.