Changeset 2331815
- Timestamp:
- 06/28/2020 02:43:28 AM (6 years ago)
- Location:
- simple-reading-progress-bar
- Files:
-
- 15 added
- 7 edited
-
tags/1.1 (added)
-
tags/1.1/README.md (added)
-
tags/1.1/css (added)
-
tags/1.1/css/admin-simple-progress-reading-bar.css (added)
-
tags/1.1/js (added)
-
tags/1.1/js/admin-simple-progress-reading-bar.js (added)
-
tags/1.1/js/srpb_scripts.js (added)
-
tags/1.1/php (added)
-
tags/1.1/php/class-admin.php (added)
-
tags/1.1/php/class-bar.php (added)
-
tags/1.1/php/class-plugin.php (added)
-
tags/1.1/readme.txt (added)
-
tags/1.1/simple-reading-progress-bar.php (added)
-
tags/1.1/templates (added)
-
tags/1.1/templates/admin-page.php (added)
-
trunk/css/admin-simple-progress-reading-bar.css (modified) (1 diff)
-
trunk/php/class-admin.php (modified) (5 diffs)
-
trunk/php/class-bar.php (modified) (4 diffs)
-
trunk/php/class-plugin.php (modified) (1 diff)
-
trunk/readme.txt (modified) (1 diff)
-
trunk/simple-reading-progress-bar.php (modified) (1 diff)
-
trunk/templates/admin-page.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
simple-reading-progress-bar/trunk/css/admin-simple-progress-reading-bar.css
r2331002 r2331815 3 3 margin-top: 1em; 4 4 } 5 6 .srpb-post-type-list { 7 margin-left: 18px; 8 } 9 10 .form-table td p.srpb-input { 11 margin-top: 10px; 12 } -
simple-reading-progress-bar/trunk/php/class-admin.php
r2331002 r2331815 74 74 'bar_color' => '#eeee22', 75 75 'bar_height' => '10', 76 'bar_position' => 'top' 76 'bar_position' => 'top', 77 'post_types' => array( 78 'post' => true 79 ) 77 80 ); 78 81 … … 81 84 return array( 82 85 'bar_color' => array( 83 'label' => __( 'Bar Color ', 'simple-reading-progress-bar' ),86 'label' => __( 'Bar Color: ', 'simple-reading-progress-bar' ), 84 87 'value' => $value['bar_color'] 85 88 ), 86 89 'bar_height' => array( 87 'label' => __( 'Bar Height ', 'simple-reading-progress-bar' ),90 'label' => __( 'Bar Height: ', 'simple-reading-progress-bar' ), 88 91 'value' => $value['bar_height'] 89 92 ), 90 93 'bar_position' => array( 91 'label' => __( 'Bar Position ', 'simple-reading-progress-bar' ),94 'label' => __( 'Bar Position: ', 'simple-reading-progress-bar' ), 92 95 'value' => $value['bar_position'] 96 ), 97 'post_types' => array( 98 'label' => __( 'Display on these post types: ', 'simple-reading-progress-bar' ), 99 'value' => $value['post_types'] 93 100 ), 94 101 ); … … 102 109 */ 103 110 public function sanitize_settings( $settings ) { 111 /** 112 * Make this setting actual booleans. 113 */ 114 foreach ( $settings['post_types'] as $post_type => $enabled ) { 115 if( 'on' === $enabled ) { 116 $settings['post_types'][ $post_type ] = true; 117 } 118 } 119 104 120 $settings['bar_color'] = ! empty( $settings['bar_color'] ) ? sanitize_hex_color( $settings['bar_color'] ) : '#eeee22'; 105 121 $settings['bar_height'] = ( ! empty( $settings['bar_height'] ) || 0 === $settings['bar_height'] ) ? intval( $settings['bar_height'] ) : '10'; … … 115 131 register_setting( 116 132 'reading', 117 self::OPTION,133 self::OPTION, 118 134 array( $this, 'sanitize_settings' ) 119 135 ); … … 121 137 add_settings_field( 122 138 'simple_reading_progress_bar_settings', 123 'Progress Bar Settings :',139 'Progress Bar Settings', 124 140 array( $this, 'render_settings' ), 125 141 'reading', -
simple-reading-progress-bar/trunk/php/class-bar.php
r2331002 r2331815 46 46 */ 47 47 public function bar_styles() { 48 $settings = $this->plugin->components->admin->settings; 49 ?> 50 <style> 51 progress { 52 position: fixed; 53 left: 0; 48 if ( $this->is_bar_active() ) { 49 $settings = $this->plugin->components->admin->settings; 50 ?> 51 <style> 52 progress { 53 position: fixed; 54 left: 0; 54 55 <?php echo esc_attr( $settings['bar_position']['value'] ); ?>: 0; 55 z-index: 9999999;56 width: 100%;57 height: <?php echo esc_attr( $settings['bar_height']['value'] . 'px' ); ?>;58 border: none;59 background-color: transparent;60 -webkit-appearance: none;61 -moz-appearance: none;62 }56 z-index: 9999999; 57 width: 100%; 58 height: <?php echo esc_attr( $settings['bar_height']['value'] . 'px' ); ?>; 59 border: none; 60 background-color: transparent; 61 -webkit-appearance: none; 62 -moz-appearance: none; 63 } 63 64 64 progress::-webkit-progress-bar {65 background-color: transparent;66 }65 progress::-webkit-progress-bar { 66 background-color: transparent; 67 } 67 68 68 progress::-webkit-progress-value {69 background-color: <?php echo esc_attr( $settings['bar_color']['value'] ); ?>;70 }69 progress::-webkit-progress-value { 70 background-color: <?php echo esc_attr( $settings['bar_color']['value'] ); ?>; 71 } 71 72 72 progress::-moz-progress-bar { 73 background-color: <?php echo esc_attr( $settings['bar_color']['value'] ); ?>; 74 } 75 </style> 76 <?php 73 progress::-moz-progress-bar { 74 background-color: <?php echo esc_attr( $settings['bar_color']['value'] ); ?>; 75 } 76 </style> 77 <?php 78 } 77 79 } 78 80 … … 81 83 */ 82 84 public function render_bar() { 83 if ( is_single() ) {85 if ( $this->is_bar_active() ) { 84 86 ?> 85 87 <progress value="100" id="progressBar"> … … 96 98 */ 97 99 public function load_bar_styles() { 98 if ( is_single() ) {100 if ( $this->is_bar_active() ) { 99 101 wp_enqueue_style( 'srpb', plugins_url( '../css/srpb.css', __FILE__ ), array(), Plugin::VERSION ); 100 102 } … … 105 107 */ 106 108 public function load_bar_scripts() { 107 if ( is_single() ) {109 if ( $this->is_bar_active() ) { 108 110 wp_enqueue_script( 'srpb_scripts', plugins_url( '../js/srpb_scripts.js', __FILE__ ), array( 'jquery' ), Plugin::VERSION, true ); 109 111 } 110 112 } 113 114 /** 115 * Return whether the bar has been activated for the current post type. 116 * 117 * @return bool 118 */ 119 public function is_bar_active() { 120 $settings = $this->plugin->components->admin->settings; 121 $post_type = get_post_type(); 122 123 if ( ! empty( $settings['post_types']['value'][ $post_type ] ) && true === $settings['post_types']['value'][ $post_type ] ) { 124 return true; 125 } else { 126 return false; 127 } 128 } 111 129 } -
simple-reading-progress-bar/trunk/php/class-plugin.php
r2331002 r2331815 20 20 * @var string 21 21 */ 22 const VERSION = '1. 0';22 const VERSION = '1.1'; 23 23 24 24 /** -
simple-reading-progress-bar/trunk/readme.txt
r2331704 r2331815 5 5 Requires at least: 4.6 6 6 Tested up to: 5.4.2 7 Stable tag: 1. 07 Stable tag: 1.1 8 8 License: GPLv2 (or later) 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html 10 10 11 Enhance your readers experience by adding a simple, yet professional progress bar to your post content. 11 A simple and easy to custom progress bar at the top of your posts! 12 12 13 13 == Description == 14 14 15 Make a better impression to your readers by adding a Progress Bar displaying on all of your posts. 16 17 Ever wanted to display a progress bar like the big news sites do? Now it is possible with one click! 18 19 Have questions, suggestions or want to contribute? I am happy to hear from you! 15 Display a simple progress bar at the top of your posts. With customization options. 20 16 21 17 == Installation == 22 18 23 * Upload the folder to your /wp-content/plugins/ directory. 24 * Activate the plugin through the ‘Plugins’ menu in WordPress. 25 * Go to Settings -> Reading (wp-admin/options-reading.php) and adjust the bar display settings. 19 * Upload the folder to your /wp-content/plugins/ directory 20 * Activate the plugin through the ‘Plugins’ menu in WordPress 26 21 27 22 == Changelog == 23 24 = 1.1 = 25 26 * Adds per post type support for public post types. 27 * Improves form markup 28 28 29 29 = 1.0 = -
simple-reading-progress-bar/trunk/simple-reading-progress-bar.php
r2331002 r2331815 5 5 * Text Domain: simple-reading-progress-bar 6 6 * Plugin URI: https://github.com/oscarssanchez/simple-reading-progress-bar 7 * Version: 1. 07 * Version: 1.1 8 8 * Author: Oscar Sańchez 9 9 * Author URI: http://oscarssanchez.com -
simple-reading-progress-bar/trunk/templates/admin-page.php
r2331002 r2331815 8 8 defined( 'WPINC' ) or die; 9 9 ?> 10 <div class="wrap"> 11 <table class="form-table"> 12 <tr valign="top"> 13 <th scope="row"><label><?php echo esc_html( $this->settings['bar_color']['label'] ); ?></label></th> 14 <td><input name="<?php echo esc_attr( self::OPTION ); ?>[bar_color]" type="text" id="color-<?php echo esc_attr( $this->settings['bar_color']['value'] ); ?>" value="<?php echo esc_attr( $this->settings['bar_color']['value'] ); ?>" class="colorpicker" autocomplete="off" /></td> 15 </tr> 16 <tr valign="top"> 17 <th scope="row"><label><?php echo esc_html( $this->settings['bar_height']['label'] ); ?></label></th> 18 <td><input name="<?php echo esc_attr( self::OPTION ); ?>[bar_height]" type="number" class="barheight" value="<?php echo esc_attr( $this->settings['bar_height']['value'] ); ?>"> px</td> 19 </tr> 20 <tr valign="top"> 21 <th scope="row"><label><?php echo esc_html( $this->settings['bar_position']['label'] ); ?></label></th> 22 <td><select name="<?php echo esc_attr( self::OPTION ); ?>[bar_position]"> 23 <option value="top" <?php selected( $this->settings['bar_position']['value'], 'top' ); ?>><?php esc_html_e( 'Top', 'simple-reading-progress-bar' ); ?></option> 24 <option value="bottom" <?php selected( $this->settings['bar_position']['value'], 'bottom' ); ?>><?php esc_html_e( 'Bottom', 'simple-reading-progress-bar' ); ?></option> 25 </select> 26 </td> 27 </tr> 28 </table> 29 </div> 10 <fieldset> 11 <p class="srpb-input"> 12 <label><?php echo esc_html( $this->settings['bar_color']['label'] ); ?></label> 13 <input name="<?php echo esc_attr( self::OPTION ); ?>[bar_color]" type="text" id="color-<?php echo esc_attr( $this->settings['bar_color']['value'] ); ?>" value="<?php echo esc_attr( $this->settings['bar_color']['value'] ); ?>" class="colorpicker" autocomplete="off" /> 14 </p> 15 <p class="srpb-input"> 16 <label><?php echo esc_html( $this->settings['bar_height']['label'] ); ?></label> 17 <input name="<?php echo esc_attr( self::OPTION ); ?>[bar_height]" type="number" class="barheight" value="<?php echo esc_attr( $this->settings['bar_height']['value'] ); ?>"> px 18 </p> 19 <p class="srpb-input"> 20 <label><?php echo esc_html( $this->settings['bar_position']['label'] ); ?></label> 21 <select name="<?php echo esc_attr( self::OPTION ); ?>[bar_position]"> 22 <option value="top" <?php selected( $this->settings['bar_position']['value'], 'top' ); ?>><?php esc_html_e( 'Top', 'simple-reading-progress-bar' ); ?></option> 23 <option value="bottom" <?php selected( $this->settings['bar_position']['value'], 'bottom' ); ?>><?php esc_html_e( 'Bottom', 'simple-reading-progress-bar' ); ?></option> 24 </select> 25 </p> 26 <p class="srpb-input"><label><?php echo esc_html( $this->settings['post_types']['label'] ); ?></label></p> 27 <ul class="srpb-post-type-list srpb-input"> 28 <?php 29 foreach ( get_post_types( array( 'public' => true ) ) as $post_type ) : 30 $enabled = $this->settings['post_types']['value'][ $post_type ]; 31 ?> 32 <li><?php echo esc_html( ucwords( $post_type ) ); ?> 33 <input type="checkbox" value="on" <?php checked( $enabled ); ?> name="<?php echo esc_attr( self::OPTION ); ?>[post_types][<?php echo esc_attr( $post_type ); ?>]"> 34 </li> 35 <?php 36 endforeach; 37 ?> 38 </ul> 39 </fieldset>
Note: See TracChangeset
for help on using the changeset viewer.