Plugin Directory

Changeset 2292204


Ignore:
Timestamp:
04/26/2020 07:08:37 PM (6 years ago)
Author:
atilbian
Message:

1.0.2 shortcodes added ! :D

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

    r2279624 r2292204  
    1313 * Plugin URI:        https://gitlab.com/atilb/automatic-page-load-progress-bar-wordpress-plugin
    1414 * Description:       Add smooth and beautifull progress bar for your website. THX to : https://github.hubspot.com/pace/docs/welcome/#
    15  * Version:           1.0.0
     15 * Version:           1.0.2
    1616 * Author:            Arnaud TILBIAN
    1717 * Author URI:        https://www.arnaudtilbian.com
     
    2020 */
    2121 
    22 function aplpb_hook_javascript () {
    23     wp_enqueue_script( 'aplpb', plugins_url( 'public/js/pace.js', __FILE__ ), array(), false, false );
     22function aplpb_hook_javascript() {
     23    $drawGlobally = get_option( 'aplpb_option_checkbox ');
     24    if($drawGlobally == '1')
     25    {
     26        aplpb_add_javascript();
     27    }
     28}
     29
     30function aplpb_add_javascript() {
     31    wp_enqueue_script( 'aplpb', plugins_url( 'public/js/pace.js', __FILE__ ), array(), false, false );
    2432}
    2533
    2634function 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();
    3539    }
    3640}
    3741
     42function 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
    3857function 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' );
    4262    register_setting( 'aplpb_options_group', 'aplpb_option_color' );
     63    register_setting( 'aplpb_options_group', 'aplpb_option_checkbox' );
    4364}
    4465
     
    5879            <table>
    5980                <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                     <?php
    64                     $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>
    7899                </tr>
    79100                <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>
    84111                </tr>
    85112            </table>
     
    96123}
    97124
     125function 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}
     137add_shortcode( 'aplpb_shortcode', 'aplpb_shortcode');
     138
    98139
    99140add_action( 'admin_init','aplpb_register_settings');
  • automatic-page-load-progress-bar/trunk/readme.txt

    r2278697 r2292204  
    1313== Description ==
    1414This 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.
     15Simple admin setting to change color and progress bar theme. You can choose to add them globally to your website or page by page.
    1616
    1717I really like adding nice progress bar to my website, giving user a fancy way to make this boring moment fun !
     
    1919
    2020It's a PACE (https://github.hubspot.com/pace/docs/welcome/# , developed by hubspot) wrapper with themes from various authors.
     21
     22
     23Shortcode give you a way to add specific shortcode for each page.
     24Example of use:
     25[aplpb_shortcode theme="minimal" color="blue"]
     26
    2127
    2228== Installation ==
     
    3541Move to the plugin settings, change your theme style and save it.
    3642
     43= How to activate the progress bar for all my website ? =
     44Move 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 ? =
     47Use the shortcode functionnality so you can create page specific loading bar.
     48[aplpb_shortcode theme="minimal" color="blue"]
     49
    3750= How to create new smoothy theme ? =
    3851Hey ! 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
     
    43562. Choose color and theme
    44573. 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.