Changeset 2834451
- Timestamp:
- 12/15/2022 01:18:42 PM (3 years ago)
- Location:
- font-resizer-with-post-reading-time/trunk
- Files:
-
- 1 added
- 2 edited
-
fsc-color-picker-script.js (added)
-
index.php (modified) (15 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
font-resizer-with-post-reading-time/trunk/index.php
r2832099 r2834451 4 4 Plugin URI: https://getwebexperts.com/font-resizer-with-post-reading-time 5 5 Description: With this plugin, you can easily display post reading time and a font resizing option on every single blog page. 6 Version: 1.0. 26 Version: 1.0.3 7 7 Author: Get Web Experts 8 8 Author URI: https://getwebexperts.com/ … … 12 12 define("fsc_ASSETS_DIR", plugin_dir_url(__FILE__) . "assets/"); 13 13 define("fsc_ASSETS_PUBLIC_DIR", plugin_dir_url(__FILE__) . "assets/public"); 14 define( "fsc_ASSETS_ADMIN_DIR", plugin_dir_url( __FILE__ ) . "assets/admin");14 define("fsc_ASSETS_ADMIN_DIR", plugin_dir_url(__FILE__) . "assets/admin"); 15 15 define('fsc_VERSION', time()); 16 16 17 $fsc_disable_options = array( 18 __('Font Size Resizer', 'font-size-change'), 19 __('Post Reading Time', 'font-size-change'), 20 ); 17 21 18 22 class fontSizeChange … … 27 31 add_action('plugins_loaded', array($this, 'load_textdomain')); 28 32 add_action('wp_enqueue_scripts', array($this, 'load_front_assets')); 29 add_action( 'admin_enqueue_scripts', array( $this, 'load_admin_assets' ) ); 30 } 31 32 function load_admin_assets() { 33 wp_enqueue_style( 'fsc-admin-css', fsc_ASSETS_ADMIN_DIR . "/css/admin.css", null, $this->version ); 34 } 33 add_action('admin_enqueue_scripts', array($this, 'load_admin_assets')); 34 } 35 36 function load_admin_assets() 37 { 38 wp_enqueue_style('fsc-admin-css', fsc_ASSETS_ADMIN_DIR . "/css/admin.css", null, $this->version); 39 wp_enqueue_style('wp-color-picker'); 40 wp_enqueue_script('fsc-color-picker-js', plugins_url('fsc-color-picker-script.js', __FILE__), array('wp-color-picker'), false, true); 41 } 35 42 36 43 function load_front_assets() … … 40 47 wp_enqueue_style('fsc-min-fontawesome', fsc_ASSETS_PUBLIC_DIR . "/css/fontawesome.min.css", null, $this->version); 41 48 42 wp_enqueue_script('fsc-main-js', fsc_ASSETS_PUBLIC_DIR . "/js/fscmain.js", null, $this->version, true );49 wp_enqueue_script('fsc-main-js', fsc_ASSETS_PUBLIC_DIR . "/js/fscmain.js", null, $this->version, true); 43 50 } 44 51 … … 53 60 54 61 //Display Font Resizer on Frontend 55 function fsc_display_frontend($content){ 56 $fsc_font_size_resizer = esc_attr(get_option('fsc_font_size_resizer')); 57 $fsc_reading_time = esc_attr(get_option('fsc_reading_time')); 62 function fsc_display_frontend($content) 63 { 64 error_reporting(0); 65 $fsc_disable = get_option('fsc_disable_option'); 58 66 $fsc_reading_time_pre_text = esc_attr(get_option('fsc_reading_time_pre_text')); 59 $fsc_reading_time_pre_text = $fsc_reading_time_pre_text ? $fsc_reading_time_pre_text : __("Read in", "change-font-size");67 $fsc_reading_time_pre_text = $fsc_reading_time_pre_text ? $fsc_reading_time_pre_text : __("Read in", "change-font-size"); 60 68 $fsc_btn_bg = esc_attr(get_option('fsc_btn_bg')); 61 69 $fsc_btn_color = esc_attr(get_option('fsc_btn_color')); … … 67 75 $font_size_resizer_display = ''; 68 76 $min = ''; 69 $stripped_content = strip_tags( $content);70 $wordn = str_word_count( $stripped_content);71 $reading_minute = floor( $wordn / 200);72 $reading_seconds = floor( $wordn % 200 / ( 200 / 60 ));73 74 if (is_singular('post')){75 if ($reading_minute > 1){77 $stripped_content = strip_tags($content); 78 $wordn = str_word_count($stripped_content); 79 $reading_minute = floor($wordn / 200); 80 $reading_seconds = floor($wordn % 200 / (200 / 60)); 81 82 if (is_singular('post')) { 83 if ($reading_minute > 1) { 76 84 $min = "mintues"; 77 } else{85 } else { 78 86 $min = "mintue"; 79 87 } 80 if($fsc_reading_time != "disable"){ 81 $reading_time_display = "<div style='background-color: $fsc_reading_time_bg; color: $fsc_reading_time_color' class='fsc_reading_time'>". 82 $fsc_reading_time_pre_text. ' '. $reading_minute.'.'.$reading_seconds . ' '. $min. 88 if (!in_array('Post Reading Time', $fsc_disable)) { 89 $reading_time_display = "<div style='background-color: $fsc_reading_time_bg; color: $fsc_reading_time_color' class='fsc_reading_time'>" . 90 $fsc_reading_time_pre_text . ' ' . $reading_minute . '.' . $reading_seconds . ' ' . $min . 91 '</div>'; 92 } 93 if (!in_array('Font Size Resizer', $fsc_disable)) { 94 $font_size_resizer_display = "<div> 95 <button style='background-color:$fsc_btn_bg; border: $fsc_btn_border;' class='fsc_btn' title='Increase Font Size' id='fsc_plus'><i style='color: $fsc_btn_color;' class='fa fa-plus'></i></button> 96 <button style='background-color:$fsc_btn_bg; border: $fsc_btn_border;' class='fsc_btn' id='fsc_minus' title='Decrease Font Size'><i style='color: $fsc_btn_color;' class='fa fa-minus'></i></button> 97 </div>"; 98 } 99 $fsc_icon = '<div class="fsc_wrapper">' . 100 $reading_time_display . 101 $font_size_resizer_display . 102 83 103 '</div>'; 84 } 85 if($fsc_font_size_resizer != "disable"){ 86 $font_size_resizer_display = "<div> 87 <button style='background-color:$fsc_btn_bg; color: $fsc_btn_color; border: $fsc_btn_border;' class='fsc_btn' title='Increase Font Size' id='fsc_plus'><i class='fa fa-plus'></i></button> 88 <button style='background-color:$fsc_btn_bg; color: $fsc_btn_color; border: $fsc_btn_border;' class='fsc_btn' id='fsc_minus' title='Decrease Font Size'><i class='fa fa-minus'></i></button> 89 </div>"; 90 } 91 $fsc_icon = '<div class="fsc_wrapper">'. 92 $reading_time_display. 93 $font_size_resizer_display. 94 95 '</div>'; 96 97 } 104 } 98 105 $fsc_icon .= sprintf('%s', $content); 99 return '<div class="fsc_text">'. $fsc_icon. '</div>'; 100 106 return '<div class="fsc_text">' . $fsc_icon . '</div>'; 101 107 } 102 108 … … 158 164 $fields = array( 159 165 array( 160 'label' => __('Disable Font Size Resizer', 'font-size-change'), 161 'id' => 'fsc_font_size_resizer', 162 'type' => 'text', 163 'section' => 'fsc_section', 164 'placeholder' => __('Type disable to disable font size resizer', 'font-size-change'), 165 ), 166 167 array( 168 'label' => __('Disable Reading Time', 'font-size-change'), 169 'id' => 'fsc_reading_time', 170 'type' => 'text', 171 'section' => 'fsc_section', 172 'placeholder' => __('Type disable to disable reading time', 'font-size-change'), 166 'label' => __('Disable', 'font-size-change'), 167 'id' => 'fsc_disable_option', 168 'type' => 'checkbox', 169 'section' => 'fsc_section', 170 'placeholder' => __('Type disable to disable font size resizer', 'font-size-change'), 173 171 ), 174 172 … … 176 174 'label' => __('Change Reading Time Prefix Text', 'font-size-change'), 177 175 'id' => 'fsc_reading_time_pre_text', 178 'type' => 'text ',179 'section' => 'fsc_section', 180 'placeholder' => __('Default Value: Read in', 'font-size-change'),176 'type' => 'textarea', 177 'section' => 'fsc_section', 178 'placeholder' => __('Default Value: Read in', 'font-size-change'), 181 179 ), 182 180 … … 186 184 'type' => 'text', 187 185 'section' => 'fsc_section', 188 'placeholder' => __('Example: blueviolet or #8A2BE2'),186 'desc' => __('Default Plus Minus Button Background Color: transparent', 'font-size-change'), 189 187 ), 190 188 … … 194 192 'type' => 'text', 195 193 'section' => 'fsc_section', 196 'placeholder' => __('Example: blueviolet or #8A2BE2'), 194 'placeholder' => __('Example: blueviolet or #8A2BE2'), 195 'desc' => __('Default Plus Minus Button Color: #8A2BE2', 'font-size-change'), 197 196 ), 198 197 … … 200 199 'label' => __('Change Plus Minus Button Border', 'font-size-change'), 201 200 'id' => 'fsc_btn_border', 202 'type' => 'text', 203 'section' => 'fsc_section', 204 'placeholder' => __('Example: 1px solid blueviolet or #8A2BE2'), 201 'type' => 'textarea', 202 'section' => 'fsc_section', 203 'placeholder' => __('Example: 1px solid blueviolet or #8A2BE2'), 204 'desc' => __('Default Plus Minus Button Border: 1px solid #8A2BE2', 'font-size-change'), 205 205 ), 206 206 … … 210 210 'type' => 'text', 211 211 'section' => 'fsc_section', 212 'placeholder' => __('Example: blueviolet or #8A2BE2'), 212 'placeholder' => __('Example: blueviolet or #8A2BE2'), 213 'desc' => __('Default Reading Time Background Color: #8A2BE2', 'font-size-change'), 213 214 ), 214 215 … … 218 219 'type' => 'text', 219 220 'section' => 'fsc_section', 220 'placeholder' => __('Example: blueviolet or #8A2BE2'), 221 'placeholder' => __('Example: blueviolet or #8A2BE2'), 222 'desc' => __('Default Reading Time Color: #ffffff', 'font-size-change'), 221 223 ), 222 224 … … 232 234 public function fsc_field_callback($field) 233 235 { 236 global $fsc_disable_options; 234 237 $value = get_option($field['id']); 238 $option_d = get_option('fsc_disable_option'); 235 239 switch ($field['type']) { 240 case 'text': 241 printf( 242 '<input class="my-color-field" name="%1$s" id="%1$s" type="%2$s" placeholder="%3$s" value="%4$s"/>', 243 $field['id'], 244 $field['type'], 245 isset($field['placeholder']) ? $field['placeholder'] : '', 246 $value 247 ); 248 break; 249 case 'textarea': 250 printf( 251 '<textarea name="%1$s" id="%1$s" placeholder="%2$s" rows="1" cols="30">%3$s</textarea>', 252 $field['id'], 253 isset($field['placeholder']) ? $field['placeholder'] : '', 254 $value 255 ); 256 break; 257 case 'checkbox': 258 foreach ($fsc_disable_options as $fsc_disable_option) { 259 $selected_d = ''; 260 261 if (is_array($option_d) && in_array($fsc_disable_option, $option_d)) { 262 $selected_d = 'checked'; 263 } 264 printf('<input type="checkbox" name="fsc_disable_option[]" value="%s" %s /> %s <br/>', $fsc_disable_option, $selected_d, $fsc_disable_option); 265 } 266 break; 236 267 default: 237 268 printf( 238 '<input class="fsc_setting_form_field" name="%1$s" id="%1$s" type="%2$s" placeholder="%3$s" value="%4$s"/>',269 '<input class="fsc_setting_form_field" name="%1$s" id="%1$s" type="%2$s" placeholder="%3$s" value="%4$s"/>', 239 270 $field['id'], 240 271 $field['type'], … … 252 283 new fsc_Settings_Page(); 253 284 //Option Page End 254 255 256 257 -
font-resizer-with-post-reading-time/trunk/readme.txt
r2832099 r2834451 5 5 Requires at least: 4.7 6 6 Requires PHP: 7.0 7 Tested up to: 6. 08 Stable tag: 1.0. 27 Tested up to: 6.1.1 8 Stable tag: 1.0.3 9 9 License: GPLv2 or later 10 10 License URI: https://www.gnu.org/licenses/gpl-2.0.html
Note: See TracChangeset
for help on using the changeset viewer.