Changeset 2588325
- Timestamp:
- 08/25/2021 08:50:22 AM (4 years ago)
- Location:
- timify
- Files:
-
- 25 added
- 12 edited
-
assets/screenshot-1.png (modified) (previous)
-
assets/screenshot-2.png (modified) (previous)
-
assets/screenshot-3.png (modified) (previous)
-
tags/1.1.0 (added)
-
tags/1.1.0/assets (added)
-
tags/1.1.0/assets/js (added)
-
tags/1.1.0/assets/js/admin.js (added)
-
tags/1.1.0/includes (added)
-
tags/1.1.0/includes/admin (added)
-
tags/1.1.0/includes/admin/admin-init.php (added)
-
tags/1.1.0/includes/admin/class.metabox.php (added)
-
tags/1.1.0/includes/admin/settings (added)
-
tags/1.1.0/includes/admin/settings/class.settings-api.php (added)
-
tags/1.1.0/includes/admin/settings/class.settings.php (added)
-
tags/1.1.0/includes/db.php (added)
-
tags/1.1.0/includes/frontend (added)
-
tags/1.1.0/includes/frontend/class.frontend.php (added)
-
tags/1.1.0/includes/frontend/class.shortcode.php (added)
-
tags/1.1.0/includes/helpers (added)
-
tags/1.1.0/includes/helpers/class.helper-functions.php (added)
-
tags/1.1.0/includes/script-functions.php (added)
-
tags/1.1.0/languages (added)
-
tags/1.1.0/languages/timify-fr_FR.mo (added)
-
tags/1.1.0/languages/timify-fr_FR.po (added)
-
tags/1.1.0/languages/timify.pot (added)
-
tags/1.1.0/readme.txt (added)
-
tags/1.1.0/timify.php (added)
-
trunk/assets/js/admin.js (modified) (1 diff)
-
trunk/includes/admin/class.metabox.php (modified) (4 diffs)
-
trunk/includes/admin/settings/class.settings-api.php (modified) (9 diffs)
-
trunk/includes/admin/settings/class.settings.php (modified) (6 diffs)
-
trunk/includes/db.php (added)
-
trunk/includes/frontend/class.frontend.php (modified) (14 diffs)
-
trunk/includes/frontend/class.shortcode.php (modified) (5 diffs)
-
trunk/includes/helpers/class.helper-functions.php (modified) (3 diffs)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/timify.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
timify/trunk/assets/js/admin.js
r2572859 r2588325 3 3 $(document).ready(function() { 4 4 5 //shortcode show hide 6 var lmSelector='#timify_settings .lm_display_method .regular'; 7 var rtSelector='#timify_settings .rt_display_method .regular'; 8 var lmDSelected=$(lmSelector).val(); 9 var rtDSelected=$(rtSelector).val(); 5 //shortcode show hide 6 var lmSelector='#timify_settings .lm_display_method .regular'; 7 var rtSelector='#timify_reading_settings .rt_display_method .regular'; 8 var wcSelector='#timify_word_settings .wc_display_method .regular'; 9 var pvcSelector='#timify_view_settings .pvc_display_method .regular'; 10 11 var lmDSelected=$(lmSelector).val(); 12 var rtDSelected=$(rtSelector).val(); 13 var wcDSelected=$(wcSelector).val(); 14 var pvcDSelected=$(pvcSelector).val(); 15 16 $('#timify_reading_settings .rt_shortcode_content').hide(); 17 $('#timify_settings .lm_shortcode_content').hide(); 18 $('#timify_settings .lm_post_date_selector').hide(); 19 $('#timify_word_settings .wc_shortcode_content').hide(); 20 $('#timify_view_settings .pvc_shortcode_content').hide(); 21 22 if(rtDSelected=='shortcode_content'){ 23 $('#timify_reading_settings .rt_'+rtDSelected).show(); 24 } 25 if(lmDSelected=='shortcode_content'){ 26 $('#timify_settings .lm_'+lmDSelected).show(); 27 } 28 if(lmDSelected=='replace_original'){ 29 $('#timify_settings .lm_post_date_selector').show(); 30 } 31 if(wcDSelected=='shortcode_content'){ 32 $('#timify_word_settings .wc_'+wcDSelected).show(); 33 } 34 if(pvcDSelected=='shortcode_content'){ 35 $('#timify_view_settings .pvc_'+pvcDSelected).show(); 36 } 37 38 $(lmSelector).on('change', function() { 39 var lmSelectedVal=$(this).find('option:selected').val(); 40 if(lmSelectedVal=='shortcode_content'){ 41 $('#timify_settings .lm_'+lmSelectedVal).show(); 42 }else{ 43 $('#timify_settings .lm_shortcode_content').hide(); 44 } 45 if(lmSelectedVal=='replace_original'){ 46 $('#timify_settings .lm_post_date_selector').show(); 47 }else{ 48 $('#timify_settings .lm_post_date_selector').hide(); 49 } 50 51 }); 10 52 11 $('#timify_settings .rt_shortcode_content').hide(); 12 $('#timify_settings .lm_shortcode_content').hide(); 13 14 15 if(rtDSelected=='shortcode_content'){ 16 $('#timify_settings .rt_'+rtDSelected).show(); 17 } 18 if(lmDSelected=='shortcode_content'){ 19 $('#timify_settings .lm_'+lmDSelected).show(); 20 } 21 22 23 $(lmSelector).on('change', function() { 24 var lmSelectedVal=$(this).find('option:selected').val(); 25 if(lmSelectedVal=='shortcode_content'){ 26 $('#timify_settings .lm_'+lmSelectedVal).show(); 27 }else{ 28 $('#timify_settings .lm_shortcode_content').hide(); 29 } 30 }); 31 32 33 $(rtSelector).on('change', function() { 34 var rtSelectedVal=$(this).find('option:selected').val(); 35 if(rtSelectedVal=='shortcode_content'){ 36 $('#timify_settings .rt_'+rtSelectedVal).show(); 37 }else{ 38 $('#timify_settings .rt_shortcode_content').hide(); 39 } 40 }); 53 $(rtSelector).on('change', function() { 54 var rtSelectedVal=$(this).find('option:selected').val(); 55 if(rtSelectedVal=='shortcode_content'){ 56 $('#timify_reading_settings .rt_'+rtSelectedVal).show(); 57 }else{ 58 $('#timify_reading_settings .rt_shortcode_content').hide(); 59 } 60 }); 61 62 63 $(wcSelector).on('change', function() { 64 var wcSelectedVal=$(this).find('option:selected').val(); 65 if(wcSelectedVal=='shortcode_content'){ 66 $('#timify_word_settings .wc_'+wcSelectedVal).show(); 67 }else{ 68 $('#timify_word_settings .wc_shortcode_content').hide(); 69 } 70 }); 71 72 $(pvcSelector).on('change', function() { 73 var pvcSelectedVal=$(this).find('option:selected').val(); 74 if(pvcSelectedVal=='shortcode_content'){ 75 $('#timify_view_settings .pvc_'+pvcSelectedVal).show(); 76 }else{ 77 $('#timify_view_settings .pvc_shortcode_content').hide(); 78 } 79 }); 41 80 42 81 //ajax for admin dashboard top notice -
timify/trunk/includes/admin/class.metabox.php
r2572859 r2588325 42 42 } 43 43 44 $position = $this->get_data( 'lm_display_method', 'before_content' );45 if ( ! in_array( $position, [ 'before_content', 'replace_original' ] ) ) {46 return;47 }44 // $position = $this->get_data( 'lm_display_method', 'before_content' ); 45 // if ( ! in_array( $position, [ 'before_content', 'replace_original' ] ) ) { 46 // return; 47 // } 48 48 49 49 $post_types = $this->get_data( 'lm_rt_post_types' ); … … 66 66 $disabled = $this->get_meta( $post->ID, '_lm_disable' ); 67 67 $rtdisabled = $this->get_meta( $post->ID, '_rt_disable' ); 68 $wcdisabled = $this->get_meta( $post->ID, '_wc_disable' ); 69 $pvcdisabled = $this->get_meta( $post->ID, '_pvc_disable' ); 68 70 69 71 // buid nonce … … 79 81 <label for="rt-disable" class="selectit" title="<?php _e( 'You can disable auto insertation of reading time on this', 'timify' ); ?>"> 80 82 <input id="rt-disable" type="checkbox" name="rt_disable_insert" <?php if ( $rtdisabled == 'yes' ) { echo esc_attr('checked'); } ?> /> <?php _e( 'Disable reading time on this post', 'timify' ); ?> 83 </label> 84 </p> 85 <p> 86 <label for="wc-disable" class="selectit" title="<?php _e( 'You can disable auto insertation of word count on this', 'timify' ); ?>"> 87 <input id="wc-disable" type="checkbox" name="wc_disable_insert" <?php if ( $wcdisabled == 'yes' ) { echo esc_attr('checked'); } ?> /> <?php _e( 'Disable Word count on this post', 'timify' ); ?> 88 </label> 89 </p> 90 <p> 91 <label for="pvc-disable" class="selectit" title="<?php _e( 'You can disable auto insertation of Post View on this', 'timify' ); ?>"> 92 <input id="pvc-disable" type="checkbox" name="pvc_disable_insert" <?php if ( $pvcdisabled == 'yes' ) { echo esc_attr('checked'); } ?> /> <?php _e( 'Disable View Count on this post', 'timify' ); ?> 81 93 </label> 82 94 </p> … … 116 128 $this->update_meta( $post_id, '_rt_disable', 'no' ); 117 129 } 130 if ( isset( $_POST[ 'wc_disable_insert' ] ) ) { 131 $this->update_meta( $post_id, '_wc_disable', 'yes' ); 132 } else { 133 $this->update_meta( $post_id, '_wc_disable', 'no' ); 134 } 135 if ( isset( $_POST[ 'pvc_disable_insert' ] ) ) { 136 $this->update_meta( $post_id, '_pvc_disable', 'yes' ); 137 } else { 138 $this->update_meta( $post_id, '_pvc_disable', 'no' ); 139 } 118 140 } 119 141 -
timify/trunk/includes/admin/settings/class.settings-api.php
r2572859 r2588325 223 223 $max = ( $args['max'] == '' ) ? '' : ' max="' . $args['max'] . '"'; 224 224 $step = ( $args['step'] == '' ) ? '' : ' step="' . $args['step'] . '"'; 225 $html = sprintf( '<input type="%1$s" class=" %2$s-number" id="%3$s[%4$s]" name="%3$s[%4$s]" value="%5$s"%6$s%7$s%8$s%9$s/>', $type, $size, $args['section'], $args['id'], $value, $placeholder, $min, $max, $step );225 $html = sprintf( '<input type="%1$s" class="timify-%2$s-number" id="%3$s[%4$s]" name="%3$s[%4$s]" value="%5$s"%6$s%7$s%8$s%9$s/>', $type, $size, $args['section'], $args['id'], $value, $placeholder, $min, $max, $step ); 226 226 $html .= $this->get_field_description( $args ); 227 227 echo wp_kses( $html, $this->allowed_html_field ); … … 236 236 $value = esc_attr( $this->get_option( $args['id'], $args['section'], $args['std'] ) ); 237 237 $html = '<fieldset>'; 238 $html .= sprintf( '<label for=" wpuf-%1$s[%2$s]">', $args['section'], $args['id'] );238 $html .= sprintf( '<label for="timify-%1$s[%2$s]">', $args['section'], $args['id'] ); 239 239 $html .= sprintf( '<input type="hidden" name="%1$s[%2$s]" value="off" />', $args['section'], $args['id'] ); 240 $html .= sprintf( '<input type="checkbox" class="checkbox" id=" wpuf-%1$s[%2$s]" name="%1$s[%2$s]" value="on" %3$s />', $args['section'], $args['id'], checked( $value, 'on', false ) );240 $html .= sprintf( '<input type="checkbox" class="checkbox" id="timify-%1$s[%2$s]" name="%1$s[%2$s]" value="on" %3$s />', $args['section'], $args['id'], checked( $value, 'on', false ) ); 241 241 $html .= sprintf( '%1$s</label>', $args['desc'] ); 242 242 $html .= '</fieldset>'; … … 255 255 foreach ( $args['options'] as $key => $label ) { 256 256 $checked = isset( $value[ $key ] ) ? $value[ $key ] : '0'; 257 $html .= sprintf( '<label for=" wpuf-%1$s[%2$s][%3$s]">', $args['section'], $args['id'], $key );258 $html .= sprintf( '<input type="checkbox" class="checkbox" id=" wpuf-%1$s[%2$s][%3$s]" name="%1$s[%2$s][%3$s]" value="%3$s" %4$s />', $args['section'], $args['id'], $key, checked( $checked, $key, false ) );257 $html .= sprintf( '<label for="timify-%1$s[%2$s][%3$s]">', $args['section'], $args['id'], $key ); 258 $html .= sprintf( '<input type="checkbox" class="checkbox" id="timify-%1$s[%2$s][%3$s]" name="%1$s[%2$s][%3$s]" value="%3$s" %4$s />', $args['section'], $args['id'], $key, checked( $checked, $key, false ) ); 259 259 $html .= sprintf( '%1$s</label><br>', $label ); 260 260 } … … 270 270 */ 271 271 function callback_groupTextSelect( $args ) { 272 $value = $this->get_option( $args['id'], $args['section'], $args['std'] ); 273 $html = '<fieldset>'; 274 $html .= sprintf( '<input type="hidden" name="%1$s[%2$s]" value="" />', $args['section'], $args['id'] ); 275 $sn=1; 276 $size = isset( $args['size'] ) && ! is_null( $args['size'] ) ? $args['size'] : 'regular'; 277 foreach ( $args['group_fields'] as $key ) { 278 $checked = isset( $value[ $key ] ) ? $value[ $key ] : '0'; 279 if($sn==1){ 280 $html .= sprintf( '<label for="timify-%1$s[%2$s][%3$s]">', $args['section'], $args['id'], $key ); 281 $html .= sprintf( '<input type="number" class="timify-%5$s-number" id="timify-%1$s[%2$s][%3$s]" name="%1$s[%2$s][%3$s]" value="%4$s" />', $args['section'], $args['id'], $key,$checked,$size ); 282 }elseif($sn==2){ 283 $html .= sprintf( '<select class="time-type" name="%1$s[%2$s][%3$s]" id="%1$s[%2$s][%3$s]">',$args['section'], $args['id'], $key ); 284 foreach ( $args['options'] as $key => $label ) { 285 $html .= sprintf( '<option value="%s"%s>%s</option>', $key, selected( $checked, $key, false ), $label ); 286 } 287 $html .= sprintf( '</select>' ); 288 } 289 $sn++; 290 } 291 292 $html .= $this->get_field_description( $args ); 293 $html .= '</fieldset>'; 294 echo wp_kses($html,$this->allowed_html_field); 295 } 296 297 /** 298 * Displays a groupNumberSelect for a settings field 299 * 300 * @param array $args settings field args 301 */ 302 function callback_groupNumberSelect( $args ) { 272 303 $value = $this->get_option( $args['id'], $args['section'], $args['std'] ); 273 304 $html = '<fieldset>'; … … 276 307 foreach ( $args['group_fields'] as $key ) { 277 308 $checked = isset( $value[ $key ] ) ? $value[ $key ] : '0'; 278 if($sn==1){ 279 $html .= sprintf( '<label for="wpuf-%1$s[%2$s][%3$s]">', $args['section'], $args['id'], $key );280 $html .= sprintf( '<input type="number" class="time-number" id="wpuf-%1$s[%2$s][%3$s]" name="%1$s[%2$s][%3$s]" value="%4$s" />', $args['section'], $args['id'], $key,$checked );281 }elseif($sn==2){282 $size = isset( $args['size'] ) && ! is_null( $args['size'] ) ? $args['size'] : 'regular';283 $html .= sprintf( '<select class=" time-type" name="%1$s[%2$s][%3$s]" id="%1$s[%2$s][%3$s]">',$args['section'], $args['id'], $key);309 $size = isset( $args['size'] ) && ! is_null( $args['size'] ) ? $args['size'] : 'regular'; 310 $step = ( $args['step'] == '' ) ? '' : ' step="' . $args['step'] . '"'; 311 if($sn<=4){ 312 $html .= sprintf( '<input type="number" class="timify-%5$s-number" id="timify-%1$s[%2$s][%3$s]" name="%1$s[%2$s][%3$s]" value="%4$s" %6$s />', $args['section'], $args['id'], $key,$checked,$size, $step); 313 }elseif($sn==5){ 314 $html .= sprintf( '<select class="%4$s-type" name="%1$s[%2$s][%3$s]" id="%1$s[%2$s][%3$s]">',$args['section'], $args['id'], $key,$size ); 284 315 foreach ( $args['options'] as $key => $label ) { 285 316 $html .= sprintf( '<option value="%s"%s>%s</option>', $key, selected( $checked, $key, false ), $label ); … … 290 321 } 291 322 323 292 324 $html .= $this->get_field_description( $args ); 293 325 $html .= '</fieldset>'; … … 305 337 $html = '<fieldset>'; 306 338 foreach ( $args['options'] as $key => $label ) { 307 $html .= sprintf( '<label for=" wpuf-%1$s[%2$s][%3$s]">', $args['section'], $args['id'], $key );308 $html .= sprintf( '<input type="radio" class="radio" id=" wpuf-%1$s[%2$s][%3$s]" name="%1$s[%2$s]" value="%3$s" %4$s />', $args['section'], $args['id'], $key, checked( $value, $key, false ) );339 $html .= sprintf( '<label for="timify-%1$s[%2$s][%3$s]">', $args['section'], $args['id'], $key ); 340 $html .= sprintf( '<input type="radio" class="radio" id="timify-%1$s[%2$s][%3$s]" name="%1$s[%2$s]" value="%3$s" %4$s />', $args['section'], $args['id'], $key, checked( $value, $key, false ) ); 309 341 $html .= sprintf( '%1$s</label><br>', $label ); 310 342 } … … 675 707 box-sizing: border-box; 676 708 } 709 .timify-settings .bg_color { 710 box-sizing: inherit; 711 } 677 712 678 713 .timify-settings { … … 757 792 margin-top: -3px; 758 793 } 794 .timify-100-number{ 795 width: 100px; 796 } 797 .wp-picker-container .iris-picker { 798 box-sizing: content-box; 799 } 759 800 760 801 </style> -
timify/trunk/includes/admin/settings/class.settings.php
r2572859 r2588325 34 34 array( 35 35 'id' => 'timify_settings', 36 'title' => __( 'Timify Settings', 'timify' ), 37 ), 38 // array( 39 // 'id' => 'timify_section_two', 40 // 'title' => __( 'Timify Settings Section Two', 'timify' ) 41 // ) 36 'title' => __( 'General Settings', 'timify' ), 37 ), 38 array( 39 'id' => 'timify_reading_settings', 40 'title' => __( 'Reading Time', 'timify' ), 41 ), 42 array( 43 'id' => 'timify_word_settings', 44 'title' => __( 'Word', 'timify' ), 45 ), 46 array( 47 'id' => 'timify_view_settings', 48 'title' => __( 'View', 'timify' ), 49 ) 42 50 ); 43 51 … … 72 80 'name' => 'time', 73 81 'label' => __( 'Apply to Posts Time Ago Show Not Older Than', 'timify' ), 82 'size' => 100, 74 83 'type' => 'groupTextSelect', 75 84 'group_fields'=>array('number','type'), … … 127 136 128 137 array( 129 'name' => 'lm_alignment', 130 'label' => __( 'Last Modified Before Content Alignment:', 'timify' ), 138 'name' => 'lm_post_date_selector', 139 'label' => __( 'Enter CSS Selector of Post Date:', 'timify' ), 140 'type' => 'text', 141 'desc'=> __('This field for replace published date css selector. If you are using any caching plugin, please clear/remove your cache after any changes made to this field.','timify'), 142 'default'=>'.posted-on .entry-date' 143 ), 144 145 array( 146 'name' => 'lm_icon_class', 147 'label' => __( 'Icon Class', 'timify' ), 148 'type' => 'text', 149 'default'=> 'dashicons-calendar-alt', 150 'desc'=>'Enter the post views icon class. Any of the <a href="https://developer.wordpress.org/resource/dashicons/" target="_blank">Dashicons</a> classes are available.' 151 ), 152 153 array( 154 'name' => 'lm_rt_post_types', 155 'label' => __( 'Apply Post Type', 'timify' ), 156 'type' => 'postTypes', 157 'default'=> array('post') 158 ), 159 160 array( 161 'name' => 'show_on', 162 'label' => __( 'Show All On', 'timify' ), 163 'type' => 'multicheck', 164 'options'=>array( 165 'single_page' => __( 'Single Page', 'timify' ), 166 'home_blog_page' => __( 'Home/Blog Page', 'timify' ), 167 'archive_page' => __( 'Archive Page', 'timify' ), 168 ), 169 'default'=>array( 170 'single_page'=>'single_page', 171 ) 172 ), 173 174 array( 175 'name' => 'label_enable', 176 'label' => __( 'Label Enable', 'timify' ), 177 'type' => 'checkbox', 178 'default'=> 'off' 179 ), 180 181 array( 182 'name' => 'font_size', 183 'label' => __( 'Font Size', 'timify' ), 184 'size' => 100, 185 'type' => 'number', 186 'default'=> 15, 187 'desc' => 'px' 188 ), 189 190 array( 191 'name' => 'line_height', 192 'label' => __( 'Line Height', 'timify' ), 193 'size' => 100, 194 'type' => 'number', 195 'step' => 'any', 196 'default'=> 22, 197 'desc' => 'px' 198 ), 199 200 array( 201 'name' => 'margin', 202 'label' => __( 'Margin', 'timify' ), 203 'size' => 100, 204 'step' => 'any', 205 'type' => 'groupNumberSelect', 206 'group_fields'=>array('left','top','right','bottom','type'), 207 'options' =>array( 208 'px' => __( 'px', 'timify' ), 209 'em' => __( 'em', 'timify' ), 210 ), 211 'default'=>array( 212 'left'=>1, 213 'top'=>1, 214 'right'=>1, 215 'bottom'=>1, 216 'type' => 'px' 217 ) 218 219 ), 220 221 array( 222 'name' => 'padding', 223 'label' => __( 'Padding', 'timify' ), 224 'size' => 100, 225 'step' => 'any', 226 'type' => 'groupNumberSelect', 227 'group_fields'=>array('left','top','right','bottom','type'), 228 'options' =>array( 229 'px' => __( 'px', 'timify' ), 230 'em' => __( 'em', 'timify' ), 231 ), 232 'default'=>array( 233 'left'=>0.5, 234 'top'=>0.7, 235 'right'=>0.5, 236 'bottom'=>0.7, 237 'type' => 'em' 238 ) 239 240 ), 241 array( 242 'name' => 'bg_color', 243 'label' => __( 'Background Color', 'timify' ), 244 'type' => 'color', 245 'default'=> '#dddddd', 246 ), 247 array( 248 'name' => 'display_bg', 249 'label' => __( 'Display Background', 'timify' ), 250 'type' => 'select', 251 'options'=> array( 252 'block' => __( 'Full Wrap', 'timify' ), 253 'inline-block' => __( 'Inline Wrap', 'timify' ), 254 ), 255 ), 256 array( 257 'name' => 'text_color', 258 'label' => __( 'Text Color', 'timify' ), 259 'type' => 'color', 260 'default'=> '#000000', 261 ), 262 array( 263 'name' => 'sp_color', 264 'label' => __( 'Separator Color', 'timify' ), 265 'type' => 'color', 266 'default'=> '#212121', 267 ), 268 269 array( 270 'name' => 'alignment', 271 'label' => __( 'Before Content Alignment:', 'timify' ), 131 272 'type' => 'select', 132 273 'options'=> array( … … 135 276 'right'=>__('Right','timify') 136 277 ), 137 ), 138 139 array( 140 'name' => 'lm_post_date_selector', 141 'label' => __( 'Enter CSS Selector of Post Date:', 'timify' ), 142 'type' => 'text', 143 'desc'=> __('This field for replace published date css selector. If you are using any caching plugin, please clear/remove your cache after any changes made to this field.','timify'), 144 'default'=>'.posted-on .entry-date' 145 ), 146 278 'default'=> 'center' 279 ), 280 281 282 ), 283 284 'timify_reading_settings'=>array( 147 285 array( 148 286 'name' => 'rt_enable', … … 185 323 'type' => 'select', 186 324 'options'=> array( 187 'before_content' => __( 'Before Content', 'timify' ), 325 'before_content' => __( 'Before Content', 'timify' ), 188 326 'shortcode_content' => __( 'ShortCode', 'timify' ), 189 327 ) … … 198 336 199 337 array( 200 'name' => 'rt_alignment', 201 'label' => __( 'Reading Time Before Content Alignment:', 'timify' ), 202 'type' => 'select', 203 'options'=> array( 204 'left' => __( 'Left', 'timify' ), 205 'center'=>__('Center','timify'), 206 'right'=>__('Right','timify') 207 ), 208 ), 209 210 array( 211 'name' => 'lm_rt_post_types', 212 'label' => __( 'Apply Post Type', 'timify' ), 213 'type' => 'postTypes', 214 'default'=> array('post') 215 ), 216 217 218 219 220 ) 338 'name' => 'rt_icon_class', 339 'label' => __( 'Icon Class', 'timify' ), 340 'type' => 'text', 341 'default'=> 'dashicons-clock', 342 'desc'=>'Enter the post views icon class. Any of the <a href="https://developer.wordpress.org/resource/dashicons/" target="_blank">Dashicons</a> classes are available.' 343 ), 344 ), 345 346 'timify_word_settings'=>array( 347 array( 348 'name' => 'wc_enable', 349 'label' => __( 'Words Count Enable', 'timify' ), 350 'type' => 'checkbox', 351 'default'=> 'on' 352 ), 353 354 array( 355 'name' => 'wc_label', 356 'label' => __( 'Words Count Label', 'timify' ), 357 'type' => 'text', 358 'default'=>__('Words Count:','timify') 359 ), 360 361 array( 362 'name' => 'wc_postfix', 363 'label' => __( 'Words Count Postfix', 'timify' ), 364 'type' => 'text', 365 'default'=>__('Words','timify') 366 ), 367 368 array( 369 'name' => 'wc_display_method', 370 'label' => __( 'Words Count Display Method', 'timify' ), 371 'type' => 'select', 372 'options'=> array( 373 'before_content' => __( 'Before Content', 'timify' ), 374 'shortcode_content' => __( 'ShortCode', 'timify' ), 375 ) 376 ), 377 378 array( 379 'name' => 'wc_shortcode_content', 380 'label' => __( 'Copy Words Count Shortcode Enter the Post Content', 'timify' ), 381 'type' => 'html', 382 'desc' => '[timify-post-words-count]' 383 ), 384 385 array( 386 'name' => 'wc_icon_class', 387 'label' => __( 'Icon Class', 'timify' ), 388 'type' => 'text', 389 'default'=>'dashicons-editor-table', 390 'desc'=>'Enter the post views icon class. Any of the <a href="https://developer.wordpress.org/resource/dashicons/" target="_blank">Dashicons</a> classes are available.' 391 ), 392 ), 393 394 'timify_view_settings'=>array( 395 array( 396 'name' => 'pvc_enable', 397 'label' => __( 'PostView Count Enable', 'timify' ), 398 'type' => 'checkbox', 399 'default'=> 'on' 400 ), 401 array( 402 'name' => 'pvc_label', 403 'label' => __( 'PostView Count Label', 'timify' ), 404 'type' => 'text', 405 'default'=>__('PostView Count:','timify') 406 ), 407 408 array( 409 'name' => 'pvc_postfix', 410 'label' => __( 'PostView Count Postfix', 'timify' ), 411 'type' => 'text', 412 'default'=>__('Views','timify') 413 ), 414 415 array( 416 'name' => 'pvc_display_method', 417 'label' => __( 'PostView Count Display Method', 'timify' ), 418 'type' => 'select', 419 'options'=> array( 420 'before_content' => __( 'Before Content', 'timify' ), 421 'shortcode_content' => __( 'ShortCode', 'timify' ), 422 ) 423 ), 424 425 array( 426 'name' => 'pvc_shortcode_content', 427 'label' => __( 'Copy PostView Count Shortcode Enter the Post Content', 'timify' ), 428 'type' => 'html', 429 'desc' => '[timify-post-view-count]' 430 ), 431 432 array( 433 'name' => 'pvc_icon_class', 434 'label' => __( 'Icon Class', 'timify' ), 435 'type' => 'text', 436 'default'=>'dashicons-visibility', 437 'desc'=>'Enter the post views icon class. Any of the <a href="https://developer.wordpress.org/resource/dashicons/" target="_blank">Dashicons</a> classes are available.' 438 ), 439 440 441 ), 221 442 222 443 -
timify/trunk/includes/frontend/class.frontend.php
r2583330 r2588325 21 21 22 22 public $reading_time; 23 public $words_count; 23 24 24 25 public $allwoed_html_kses = array( … … 39 40 $default_sets = array( 40 41 'active' => array( 'date' => 'date', 'time' => 'time', 'modified_date' => '', 'modified_time' => '' ), 42 'show_on' => array( 'single_page' => 'single_page', 'home_blog_page' => '', 'archive_page' => '' ), 41 43 'time' => array( 'number' => '12', 'type' => 'months' ), 42 44 'ago_label' => 'ago', 45 'font_size' => '15', 46 'line_height' => '22', 47 'margin' => array('left' => '1', 'top' => '1','right'=>'1','bottom' => '1','type'=>'px'), 48 'padding' => array('left' => '0.5', 'top' => '0.7','right'=>'0.5','bottom' => '0.7','type'=>'em'), 49 'bg_color' => '#dddddd', 50 'display_bg' => 'block', 51 'text_color' => '#000000', 52 'sp_color' => '#212121', 53 'alignment' => 'center', 54 'label_enable' => 'off', 43 55 'lm_enable' => 'on', 44 56 'lm_label' => 'Last Update On:', 45 57 'lm_display_method' => 'before_content', 46 'lm_alignment' => 'left',47 58 'lm_post_date_selector'=>'.posted-on .entry-date', 59 'lm_icon_class' => 'dashicons-calendar-alt', 48 60 'rt_enable' => 'on', 49 61 'rt_label' => 'Reading Time:', … … 52 64 'rt_word_per_minute'=> '200', 53 65 'rt_display_method' => 'before_content', 54 'rt_ alignment' => 'left',66 'rt_icon_class' => 'dashicons-clock', 55 67 'lm_rt_post_types' => array('post'), 68 'wc_enable' => 'on', 69 'wc_label' => 'Post Words:', 70 'wc_postfix' => 'Words', 71 'wc_display_method' => 'before_content', 72 'wc_icon_class' => 'dashicons-editor-table', 73 'pvc_enable' => 'on', 74 'pvc_label' => 'PostView Count:', 75 'pvc_postfix' => 'Views', 76 'pvc_display_method' => 'before_content', 77 'pvc_icon_class' => 'dashicons-visibility' 78 56 79 57 80 ); … … 60 83 $this->settings = get_option( 'timify_settings', $default_sets ); 61 84 $this->settings = wp_parse_args( $this->settings, $default_sets); 85 $this->settings = wp_parse_args( get_option( 'timify_reading_settings', $default_sets ), $this->settings); 86 $this->settings = wp_parse_args( get_option( 'timify_word_settings', $default_sets ), $this->settings); 87 $this->settings = wp_parse_args( get_option( 'timify_view_settings', $default_sets ), $this->settings); 88 89 add_action('loop_start', array($this,'render_loop_start'), 50); 90 add_action( 'wp', array( $this, 'render_frontend' ) ); 91 add_action( 'wp_footer', array($this,'lm_published_date_replace'), 99 ); 92 add_action( 'wp_head', array($this,'pvc_insert_by_ip') ); 93 add_action( 'wp_enqueue_scripts', array(&$this,'render_frontend_styles') ); 94 95 } 96 97 /** 98 * date filter hook fire when loop start in post. 99 * @since 1.1.0 100 */ 101 public function render_loop_start() { 62 102 $list_filter_array = array(); 63 64 103 if ( isset($this->settings['active']['date']) ): 65 104 $list_filter_array = array_merge( $list_filter_array, array( 'the_date', 'get_the_date' ) ); … … 74 113 $list_filter_array = array_merge( $list_filter_array, array( 'get_the_modified_time', 'the_modified_time' ) ); 75 114 endif; 76 $filterlists = apply_filters( 'timify_ filters',$list_filter_array );115 $filterlists = apply_filters( 'timify_date_filters',$list_filter_array ); 77 116 78 117 foreach ( $filterlists as $filter ) : … … 80 119 endforeach; 81 120 82 //last modified and reading time insert post content 83 add_filter( 'the_content', array($this,'lm_rt_display_info'), apply_filters( 'timify_display_priority', 5 ) ); 84 add_action( 'wp_footer', array($this,'lm_published_date_replace'), 99 ); 85 86 121 } 122 123 /** 124 * the_content and get_the_excerpt filter hook fire in settings show on page. 125 * @since 1.1.0 126 */ 127 public function render_frontend(){ 128 129 $current_theme = $this->get_current_theme(); 130 $show_on = !empty($this->settings['show_on'])?$this->settings['show_on']:array(); 131 132 if ( in_array( 'single_page', $show_on ) && is_singular() && is_main_query() ) { 133 add_filter( 'the_content', array($this,'lm_rt_display_info'), 90 ); 134 } 135 136 if ( in_array( 'home_blog_page', $show_on ) && is_home() && ! is_archive() && is_main_query() ) { 137 add_filter( 'get_the_excerpt', array( $this, 'lm_rt_display_info' ), 1000 ); 138 if ( 'Twenty Twenty' === $current_theme || 'Twenty Fifteen' === $current_theme || 'Twenty Nineteen' === $current_theme || 'Twenty Thirteen' === $current_theme || 'Twenty Fourteen' === $current_theme || 'Twenty Sixteen' === $current_theme || 'Twenty Seventeen' === $current_theme || 'Twenty Twelve' === $current_theme ) { 139 add_filter( 'the_content', array( $this, 'lm_rt_display_info' ), 1000 ); 140 } 141 } 142 143 if ( in_array( 'archive_page', $show_on ) && ! is_home() && is_archive() && is_main_query() ) { 144 add_filter( 'get_the_excerpt', array( $this, 'lm_rt_display_info' ), 1000 ); 145 if ( 'Twenty Twenty' === $current_theme || 'Twenty Fifteen' === $current_theme || 'Twenty Nineteen' === $current_theme || 'Twenty Thirteen' === $current_theme || 'Twenty Fourteen' === $current_theme || 'Twenty Sixteen' === $current_theme || 'Twenty Seventeen' === $current_theme || 'Twenty Twelve' === $current_theme ) { 146 add_filter( 'the_content', array( $this, 'lm_rt_display_info' ), 1000 ); 147 } 148 } 149 87 150 } 88 151 … … 126 189 127 190 $ago_label = $this->settings['ago_label']; 128 $timestamp = human_time_diff( $modified_timestamp, $time ).' '.$ago_label;191 $timestamp = human_time_diff( $modified_timestamp, $time ).' '.$ago_label; 129 192 130 193 //time filter hook 131 194 $timestamp = apply_filters( 'timify_post_formatted_date', $timestamp, get_the_ID() ); 132 195 133 $template ='<span class="timify -lm-rlast-modified-info">'.$timestamp.'</span>';196 $template ='<span class="timify_lm_info">'.$timestamp.'</span>'; 134 197 $selectors = preg_replace( "/\r|\n/", '', wp_kses_post( $selectors ) ); ?> 135 198 … … 155 218 } 156 219 220 /** 221 * add post view count by ip address. 222 * @since 1.1.0 223 */ 224 public function pvc_insert_by_ip() { 225 global $post; 226 if ( ! wp_is_post_revision( $post ) && ! is_preview() ) { 227 if ( is_single() ) { 228 timify_insert_ip(); 229 } 230 } 231 } 157 232 158 233 /** … … 163 238 */ 164 239 public function lm_rt_display_info( $content ) { 165 $template='<div class="lm-rt-wrap">';166 $lm_display_position = $this->get_data( 'lm_display_method', 'before_content' );167 $ rt_display_position = $this->get_data( 'rt_display_method', 'before_content' );168 169 if ( ! is_singular() ) {170 return $content;171 }172 240 241 global $post; 242 $template_reading = $template_last_modified = $template_word = $template_view = ''; 243 $lm_display_position = $this->settings['lm_display_method']; 244 $rt_display_position = $this->settings['rt_display_method']; 245 $wc_display_position = $this->settings['wc_display_method']; 246 $pvc_display_position = $this->settings['pvc_display_method']; 247 173 248 $post_types = $this->get_data( 'lm_rt_post_types', [ 'post' ] ); 174 249 if ( ! in_array( get_post_type(), $post_types ) ) { … … 182 257 183 258 if ( $this->settings['lm_enable']==='on' && in_array( $lm_display_position, [ 'before_content' ]) ) { 184 $label = $this->settings['lm_label']; 185 $lm_alignment = $this->settings['lm_alignment']; 186 $lm_style = "style='display:block;text-align:$lm_alignment'"; 187 188 $modified_timestamp = get_post_modified_time( 'U' ); 189 $time = current_time( 'U' ); 190 $ago_label = $this->settings['ago_label']; 191 $timestamp = human_time_diff( $modified_timestamp, $time ).' '.$ago_label; 192 193 //time filter hook 194 $timestamp = apply_filters( 'timify_post_formatted_date', $timestamp, get_the_ID() ); 259 $modified_timestamp = get_post_modified_time( 'U'); 260 $time = current_time( 'U' ); 261 $ago_label = $this->settings['ago_label']; 262 $icon = $this->settings['lm_icon_class']; 263 $timestamp = human_time_diff( $modified_timestamp, $time ).' '.$ago_label; 195 264 $lmdisable = $this->get_meta( get_the_ID(), '_lm_disable' ); 196 265 $label = $this->settings['label_enable']==='on'?'<span class="label">'.$this->settings['lm_label'].'</span>':''; 197 266 if ( empty( $lmdisable ) || ! empty( $lmdisable ) && $lmdisable == 'no' ) { 198 $template .='<span class="timify_lm_info" ' .$lm_style. '><span class="lm-label">' . wp_kses( $label, $this->allwoed_html_kses ) . '</span><span class="lm-date">'.$timestamp.'</span></span>';199 } 200 } 201 202 if ( $this->settings['rt_enable']==='on' && in_array( $rt_display_position, [ 'before_content' ]) ) {203 $post_id = get_the_ID();267 $template_last_modified = '<li class="timify-meta-last-modified-wrap"><span class="icon dashicons '.esc_attr($icon).'"></span>' . wp_kses( $label, $this->allowed_html_field ) . '<span class="time">'.esc_html($timestamp).'</span></li>'; 268 } 269 } 270 271 if ( $this->settings['rt_enable']==='on' && in_array( $rt_display_position, [ 'before_content' ]) ) { 272 $post_id = $post->ID; 204 273 $this->rt_calculation( $post_id, $this->settings ); 205 $label = $this->settings['rt_label'];206 274 $postfix = $this->settings['rt_postfix']; 207 275 $postfixs = $this->settings['rt_postfixs']; 208 $rt_alignment = $this->settings['rt_alignment']; 209 $rt_style = "style='display:block;text-align:$rt_alignment'"; 276 $reading_time = $this->reading_time; 210 277 $cal_postfix = $this->add_postfix_reading_time( $this->reading_time, $postfixs, $postfix ); 278 $icon = $this->settings['rt_icon_class']; 211 279 $rtdisable = $this->get_meta( get_the_ID(), '_rt_disable' ); 280 $label = $this->settings['label_enable']==='on'?'<span class="label">'.$this->settings['rt_label'].'</span>':''; 212 281 if ( empty( $rtdisable ) || ! empty( $rtdisable ) && $rtdisable == 'no' ) { 213 $template .='<span class="timify_rt_info" '.$rt_style.'><span class="rt-label rt-prefix">' . wp_kses( $label, $this->allwoed_html_kses ) . '</span><span class="rt-time">' . esc_html( $this->reading_time ) . '</span><span class="rt-label rt-postfix">' . wp_kses( $cal_postfix, $this->allwoed_html_kses ) . '</span></span>'; 214 } 215 } 216 217 $template.='</div>'; 218 219 $content = $template . $content; 282 $template_reading = '<li class="timify-meta-reading-wrap"><span class="icon dashicons '.esc_attr($icon).'"></span>' . wp_kses( $label, $this->allowed_html_field ) . '<span class="reading">'.esc_html($reading_time).'</span><span class="postfix">'.esc_html($cal_postfix).'</span></li>'; 283 } 284 } 285 286 if ( $this->settings['wc_enable']==='on' && in_array( $wc_display_position, [ 'before_content' ]) ) { 287 $post_id = $post->ID; 288 $content_post = get_post($post_id); 289 $content_word = $content_post->post_content; 290 $post_words_count = '<span class="words">'.$this->wc_calculation($content_word).'</span>'; 291 $postfix = !empty($this->settings['wc_postfix'])?'<span class="postfix">'.esc_html($this->settings['wc_postfix']).'</span>':''; 292 $icon = $this->settings['wc_icon_class']; 293 $wcdisable = $this->get_meta( get_the_ID(), '_wc_disable' ); 294 $label = $this->settings['label_enable']==='on'?'<span class="label">'.$this->settings['wc_label'].'</span>':''; 295 if ( empty( $wcdisable ) || ! empty( $wcdisable ) && $wcdisable == 'no' ) { 296 $template_word = '<li class="timify-meta-word-wrap"><span class="icon dashicons '.esc_attr($icon).'"></span>'.wp_kses( $label, $this->allowed_html_field ). wp_kses( $post_words_count,$this->allowed_html_field ) . wp_kses( $postfix,$this->allowed_html_field ).'</li>'; 297 } 298 } 299 300 if ( $this->settings['pvc_enable']==='on' && in_array( $pvc_display_position, [ 'before_content' ]) ) { 301 $post_id = $post->ID; 302 $post_view_count = '<span class="views">'.timify_get_post_view_count().'</span>'; 303 $postfix = !empty($this->settings['pvc_postfix'])?'<span class="postfix">'.esc_html($this->settings['pvc_postfix']).'</span>':''; 304 $icon = $this->settings['pvc_icon_class']; 305 $pvcdisable = $this->get_meta( get_the_ID(), '_pvc_disable' ); 306 $label = $this->settings['label_enable']==='on'?'<span class="label">'.$this->settings['pvc_label'].'</span>':''; 307 if ( empty( $pvcdisable ) || ! empty( $pvcdisable ) && $pvcdisable == 'no' ) { 308 $template_view = '<li class="timify-meta-view-wrap"><span class="icon dashicons '.esc_attr($icon).'"></span>'. wp_kses( $label, $this->allowed_html_field ) . wp_kses( $post_view_count,$this->allowed_html_field ) . wp_kses( $postfix, $this->allowed_html_field ).'</li>'; 309 } 310 } 311 312 if( !empty($template_last_modified) || !empty($template_reading) || !empty($template_word) || !empty($template_view) && in_the_loop() ): 313 $html = '<div class="timify-meta-wrap"><ul class="timify-container">'.$template_last_modified.$template_reading.$template_word.$template_view.'</ul></div>'; 314 $content = $html . $content; 315 else: 316 $content = $content; 317 endif; 220 318 221 return apply_filters( 'timify_post_content_output', $content, $template, get_the_ID() ); 319 return apply_filters( 'timify_post_content_output', $content, get_the_ID() ); 320 } 321 322 /** 323 * add frontend style inline css in header 324 * @since 1.1.0 325 */ 326 public function render_frontend_styles() { 327 wp_register_style( 'timify-style', false ); 328 wp_enqueue_style( 'timify-style' ); 329 $css = array(); 330 $css[] = ".timify-meta-wrap { 331 font-size: {$this->settings['font_size']}px; 332 line-height: {$this->settings['line_height']}px; 333 text-align: {$this->settings['alignment']}; 334 margin-top: {$this->settings['margin']['top']}{$this->settings['margin']['type']}; 335 margin-right: {$this->settings['margin']['right']}{$this->settings['margin']['type']}; 336 margin-bottom: {$this->settings['margin']['bottom']}{$this->settings['margin']['type']}; 337 margin-left: {$this->settings['margin']['left']}{$this->settings['margin']['type']}; 338 }"; 339 340 $css[] = ".timify-container { 341 background:{$this->settings['bg_color']}; 342 color: {$this->settings['text_color']}; 343 padding-top: {$this->settings['padding']['top']}{$this->settings['padding']['type']}; 344 padding-right: {$this->settings['padding']['right']}{$this->settings['padding']['type']}; 345 padding-bottom: {$this->settings['padding']['bottom']}{$this->settings['padding']['type']}; 346 padding-left: {$this->settings['padding']['left']}{$this->settings['padding']['type']}; 347 display: {$this->settings['display_bg']}; 348 margin:0; 349 list-style:none; 350 }"; 351 352 $css[] =".timify-container .timify-meta-last-modified-wrap, 353 .timify-container .timify-meta-reading-wrap, 354 .timify-container .timify-meta-word-wrap, 355 .timify-container .timify-meta-view-wrap { 356 display:inline-block; 357 padding-right: 8px; 358 margin-right: 4px; 359 position: relative; 360 }"; 361 362 $css[] =".timify-container .timify-meta-last-modified-wrap:before, 363 .timify-container .timify-meta-reading-wrap:before, 364 .timify-container .timify-meta-word-wrap:before, 365 .timify-container .timify-meta-view-wrap:before { 366 position: absolute; 367 height: 22px; 368 width: 2px; 369 background: {$this->settings['sp_color']}; 370 content: ''; 371 right: 0; 372 opacity: 0.2; 373 }"; 374 375 $css[] =".timify-container li:last-child:before { 376 content:inherit; 377 }"; 378 379 $css[] =".timify-container li .words, 380 .timify-container li .reading, 381 .timify-container li .views, 382 .timify-container li .label { 383 display: inline-block; 384 padding: 0 4px; 385 }"; 386 387 $css[] =".timify-container li .time { 388 padding-left: 4px; 389 }"; 390 391 wp_add_inline_style( 'timify-style', preg_replace( '/\n|\t/i', '', implode( '', $css ) )); 222 392 } 223 393 … … 234 404 */ 235 405 public function convert_date_time_ago( $original_time, $date_format ) { 406 global $post; 407 $this->date_format = $date_format; 236 408 237 409 $timelist_array = array( … … 242 414 ); 243 415 244 global $post; 245 $this->date_format = $date_format; 416 $post_id = $post->ID; 417 $post_types = $this->get_data( 'lm_rt_post_types', [ 'post' ] ); 418 if ( ! in_array( get_post_type( $post_id ), $post_types ) ) { 419 return $original_time; 420 } 246 421 247 422 if( !$this->is_can_convert_date() ){ … … 259 434 if ( ( $curr_time - $post_time ) <= $limit ) { 260 435 $alabel = $this->settings['ago_label']; 261 return human_time_diff( $post_time, $curr_time ).' '.$alabel;436 return human_time_diff( $post_time, $curr_time ).' '.$alabel; 262 437 } 263 438 … … 292 467 293 468 /** 469 * post words count calculate 470 * @param $content 471 * @return string words 472 * @since 1.0.0 473 */ 474 public function wc_calculation($content){ 475 return $this->words_count=str_word_count((strip_tags($content))); 476 } 477 478 /** 294 479 * Check the conflict with our Timify functionality 295 480 * AMP WordPress plugin already has Timify functionality -
timify/trunk/includes/frontend/class.shortcode.php
r2583330 r2588325 23 23 add_shortcode( 'timify-last-modified-date', [ $this, 'lm_render' ] ); 24 24 add_shortcode( 'timify-post-reading-time', [ $this, 'rt_render' ] ); 25 add_shortcode( 'timify-post-words-count', [ $this, 'wc_render' ] ); 26 add_shortcode( 'timify-post-view-count', [ $this, 'pvc_render' ] ); 25 27 } 26 28 … … 34 36 global $post; 35 37 36 if ( ! $this->is_enabled( 'lm_enable' )) {37 return; 38 } 39 40 $lmposition = $this-> get_data( 'lm_display_method', 'before_content' );38 if ( $this->settings['lm_enable'] !== 'on' ) { 39 return; 40 } 41 42 $lmposition = $this->settings['lm_display_method']; 41 43 if ( $lmposition !== 'shortcode_content' ) { 42 44 return; 43 45 } 44 46 45 $post_id = $post->ID; 46 $atts = shortcode_atts( [ 47 $label = $this->settings['lm_label']; 48 $post_id = $post->ID; 49 $lmatts = shortcode_atts( [ 47 50 'id' => $post_id, 48 ], $atts, 'timify-post-modified-info' ); 49 50 $get_post = get_post( absint( $atts['id'] ) ); 51 if ( ! $get_post ) { 52 return; 53 } 54 55 $label = $this->settings['lm_label']; 56 $lm_alignment = $this->settings['lm_alignment']; 57 $lm_style = "style='display:block;text-align:$lm_alignment'"; 58 51 'label' => $label 52 ], $atts); 53 54 $get_post = get_post( absint( $lmatts['id'] ) ); 55 if ( ! $get_post ) { 56 return; 57 } 58 59 59 60 $modified_timestamp = get_post_modified_time( 'U' ); 60 61 $time = current_time( 'U' ); … … 67 68 68 69 if ( empty( $lmdisable ) || ! empty( $lmdisable ) && $lmdisable == 'no' ) { 69 $template ='< span class="timify_lm_info" ' .$lm_style. '><span class="lm-label">' . wp_kses( $label, $this->allwoed_html_kses ) . '</span><span class="lm-date">'.$timestamp.'</span></span>';70 $template ='<p class="timify-meta-last-modified-wrap"><span class="label">' . wp_kses( $lmatts['label'], $this->allwoed_html_kses ) . '</span> <span class="date">'.esc_html($timestamp).'</span></p>'; 70 71 } 71 72 … … 84 85 global $post; 85 86 86 if ( ! $this->is_enabled( 'rt_enable' )) {87 return; 88 } 89 90 $position = $this-> get_data( 'rt_display_method', 'before_content' );87 if ( $this->settings['rt_enable'] !== 'on' ) { 88 return; 89 } 90 91 $position = $this->settings['rt_display_method'];; 91 92 if ( $position !== 'shortcode_content' ) { 92 93 return; 93 94 } 94 95 95 $ post_id = $post->ID;96 $ atts = shortcode_atts( [97 96 $label = $this->settings['rt_label']; 97 $post_id = $post->ID; 98 $rtatts = shortcode_atts( [ 98 99 'id' => $post_id, 99 100 ], $atts , 'timify-post-modified-info');101 102 $get_post = get_post( absint( $ atts['id'] ) );100 'label' => $label 101 ], $atts); 102 103 $get_post = get_post( absint( $rtatts['id'] ) ); 103 104 if ( ! $get_post ) { 104 105 return; … … 106 107 107 108 $this->rt_calculation( $post_id, $this->settings ); 108 $label = $this->settings['rt_label'];109 109 $postfix = $this->settings['rt_postfix']; 110 110 $postfixs = $this->settings['rt_postfixs']; 111 $rt_alignment = $this->settings['rt_alignment'];112 $rt_style = "style='display:block;text-align:$rt_alignment'";113 111 $cal_postfix = $this->add_postfix_reading_time( $this->reading_time, $postfixs, $postfix ); 114 112 $rtdisable = $this->get_meta( get_the_ID(), '_rt_disable' ); 115 113 if ( empty( $rtdisable ) || ! empty( $rtdisable ) && $rtdisable == 'no' ) { 116 $template ='<span class="timify_rt_info" '.$rt_style.'><span class="rt-label rt-prefix">' . wp_kses( $label, $this->allwoed_html_kses ) . '</span> <span class="rt-time">' . esc_html( $this->reading_time ) . '</span><span class="rt-label rt-postfix">' . wp_kses( $cal_postfix, $this->allwoed_html_kses ) . '</span></span>'; 117 } 118 114 $template ='<p class="timify-meta-reading-wrap"><span class="label">' . wp_kses( $rtatts['label'], $this->allwoed_html_kses ) . '</span> <span class="time">' . esc_html( $this->reading_time ) . '</span><span class="postfix">' . wp_kses( $cal_postfix, $this->allwoed_html_kses ) . '</span></p>'; 115 } 116 117 return $template; 118 } 119 120 /** 121 * Callback to register shortcodes for word count. 122 * 123 * @param array $atts Shortcode attributes. 124 * @return string Shortcode output. 125 * @since 1.1.0 126 */ 127 128 public function wc_render($atts) { 129 130 global $post; 131 132 if ( $this->settings['wc_enable'] !== 'on' ) { 133 return; 134 } 135 136 $position = $this->settings['wc_display_method']; 137 if ( $position !== 'shortcode_content' ) { 138 return; 139 } 140 141 $label = $this->settings['wc_label']; 142 $post_id = $post->ID; 143 $wcatts = shortcode_atts( [ 144 'id' => $post_id, 145 'label' => $label 146 ], $atts); 147 148 $get_post = get_post( absint( $wcatts['id'] ) ); 149 if ( ! $get_post ) { 150 return; 151 } 152 153 $content_post = get_post($post_id); 154 $content_word = $content_post->post_content; 155 $post_words_count = '<span class="words"> '.$this->wc_calculation($content_word).'</span>'; 156 $postfix = !empty($this->settings['wc_postfix'])?'<span class="postfix">'.$this->settings['wc_postfix'].'</span>':''; 157 $icon = !empty($this->settings['wc_icon_class'])?'<span class="icon dashicons '.$this->settings['wc_icon_class'].'"></span>':''; 158 $wcdisable = $this->get_meta( get_the_ID(), '_wc_disable' ); 159 if ( empty( $wcdisable ) || ! empty( $wcdisable ) && $wcdisable == 'no' ) { 160 $template ='<p class="timify-meta-word-wrap">'.esc_html($wcatts['label']) . wp_kses($post_words_count,$this->allowed_html_field).' '.wp_kses($postfix,$this->allowed_html_field).'</p>'; 161 } 162 163 164 return $template; 165 } 166 167 /** 168 * Callback to register shortcodes for post view. 169 * 170 * @param array $atts Shortcode attributes. 171 * @return string Shortcode output. 172 * @since 1.1.0 173 */ 174 175 public function pvc_render($atts) { 176 177 global $post; 178 179 if ( $this->settings['pvc_enable'] !== 'on' ) { 180 return; 181 } 182 183 $position = $this->settings['pvc_display_method']; 184 if ( $position !== 'shortcode_content' ) { 185 return; 186 } 187 188 $label = $this->settings['pvc_label']; 189 $post_id = $post->ID; 190 $pvcatts = shortcode_atts( [ 191 'id' => $post_id, 192 'label' => $label 193 ], $atts); 194 195 $get_post = get_post( absint( $pvcatts['id'] ) ); 196 if ( ! $get_post ) { 197 return; 198 } 199 200 $post_view_count = '<span class="views"> '.timify_get_post_view_count().'</span>'; 201 $postfix = !empty($this->settings['pvc_postfix'])?'<span class="postfix">'.$this->settings['pvc_postfix'].'</span>':''; 202 $icon = !empty($this->settings['pvc_icon_class'])?'<span class="icon dashicons '.$this->settings['pvc_icon_class'].'"></span>':''; 203 $pvcdisable = $this->get_meta( get_the_ID(), '_pvc_disable' ); 204 if ( empty( $pvcdisable ) || ! empty( $pvcdisable ) && $pvcdisable == 'no' ) { 205 $template = '<p class="timify-meta-view-wrap">'. esc_html($pvcatts['label']). wp_kses($post_view_count,$this->allowed_html_field).' '.wp_kses($postfix,$this->allowed_html_field).'</p>'; 206 } 207 119 208 return $template; 120 209 } -
timify/trunk/includes/helpers/class.helper-functions.php
r2572859 r2588325 30 30 'p' => [ 31 31 'class'=>[], 32 'id'=>[] 32 'id'=>[], 33 'a'=>[], 34 'span'=>[] 33 35 ], 34 36 'label' => [ … … 57 59 'placeholder'=>[], 58 60 ], 61 'a'=>[ 62 'class' => [], 63 'id' => [], 64 'href'=>[], 65 'target'=>[] 66 ], 67 'span'=>[ 68 'class' => [], 69 'id' => [], 70 'span'=>[] 71 ], 59 72 'fieldset'=>[], 60 73 'br'=>[], 61 74 'strong'=>[], 75 62 76 63 77 ]; … … 132 146 } 133 147 134 148 /** 149 * get current theme name. 150 * @return string 151 * @since 1.1.0 152 */ 153 public function get_current_theme() { 154 $theme_name = ''; 155 $theme = wp_get_theme(); 156 if ( isset( $theme->parent_theme ) && '' != $theme->parent_theme || null != $theme->parent_theme ) { 157 $theme_name = $theme->parent_theme; 158 } else { 159 $theme_name = $theme->name; 160 } 161 return $theme_name; 162 } 163 164 135 165 136 166 } -
timify/trunk/readme.txt
r2583330 r2588325 1 1 === Timify === 2 Contributors: ThemeIM, golam robbani292 Contributors: ThemeIM, golam523 3 3 Tags: reading time, last-modified, modified time, word count, date 4 4 Requires at least: 4.0 5 5 Tested up to: 5.8 6 6 Requires PHP: 5.6.0 7 Stable tag: 1. 0.17 Stable tag: 1.1.0 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html 10 10 11 With Timify, let your audience know about publish date, publish time, and reading time of your articles. You can also customize each setting according to your requirements. Add a shortcode that works with postfix and label. And everything is plain and simple.11 With Timify, let your audience know about the last modified date, publish date, and reading time of your articles. You can also customize each setting according to your requirements. Add a shortcode that works with postfix and label. And everything is plain and simple. 12 12 13 13 == Description == 14 Timify is your one-stop solution for informing your readers about the publish date, publish time, and reading timeof an article.14 Timify is your one-stop solution for informing your readers about the last modified date, publish date, reading time, word count, post view count by IP address and date formate time ago of an article. 15 15 To maintain a proper engagement with your audience, it is important to add the last updated time of your post or page in WordPress. 16 16 Google prefers articles that include update dates rather than publish dates. Timify will automatically generate the last update time of your articles. … … 34 34 EX: Default: April 13, 2021 35 35 After Modification: 3 days ago. 36 2. Apply the “Time Ago” showing as your preferred recently published posts. Available time period: Minutes, hours,days, months.37 3. Change the “Ago” Word .38 4. You can change the “Last Modified Label”39 5. You can position the “Last Modified Time” in 3 different ways. Before content, Replace the default published date or you can use the shortcode anywhere in the post page.40 6. Advanced method for changing the “Last modified date” position with the published date you should enter the css selector field.41 7. You can change the “Reading Time Label”42 8. You can position the “Reading Time” in 2 different ways. Before content or you can use the shortcode anywhere in the post page.43 9. You can apply the settings for almost every post type including Custom post types (If there exist any in your system).36 2. Apply the “Time Ago” showing as your preferred recently published posts. Available time period: Minutes, hours,days, months. 37 3. Change the “Ago” Word . 38 4. You can change the “Last Modified Label” 39 5. You can position the “Last Modified Time” in 3 different ways. Before content, Replace the default published date or you can use the shortcode anywhere in the post page. 40 6. Advanced method for changing the “Last modified date” position with the published date you should enter the css selector field. 41 7. You can change the “Reading Time Label” 42 8. You can position the “Reading Time” in 2 different ways. Before content or you can use the shortcode anywhere in the post page. 43 9. You can apply the settings for almost every post type including Custom post types (If there exist any in your system). 44 44 10. You can align the “Last Modified Label” and “Reading Time Label” in the single post page. 45 45 11. You can disable or enable the plugin settings in individual posts in the post edit page. 46 12. You can word count enable or disable in timify settings. 47 13. You can post view enable or disable in timify stttings. 46 48 47 49 = ABOUT THE AUTHOR = … … 83 85 = 1.0.1 = 84 86 * Fix broken content issue. 87 = 1.1.0 = 88 * add word count, post view count and individual setting options -
timify/trunk/timify.php
r2583330 r2588325 4 4 * Plugin URI: https://www.themeim.com/ 5 5 * Description: Generate blogs following the latest trend with Timify. Apply post date, post time, and reading time on your blogs along with modifying them. And it is so easy to use 6 * Version: 1. 0.16 * Version: 1.1.0 7 7 * Author: ThemeIM 8 8 * Author URI: https://themeim.com/ … … 46 46 * @var string 47 47 */ 48 protected $version = '1. 0.1';48 protected $version = '1.1.0'; 49 49 50 50 /** … … 159 159 //require_once( TIMIFY_PATH . '/vendor/autoload.php' ); 160 160 require_once( TIMIFY_INCLUDES . '/script-functions.php' ); 161 require_once( TIMIFY_INCLUDES . '/db.php' ); 161 162 require_once( TIMIFY_INCLUDES . '/helpers/class.helper-functions.php' ); 162 163 … … 176 177 177 178 private function init_hooks() { 178 //register_activation_hook( __FILE__, array( $this, 'activate_plugin' ) );179 register_activation_hook( __FILE__, array( $this, 'activate_plugin' ) ); 179 180 add_action( 'admin_init', array( $this, 'check_environment' ) ); 180 181 add_action( 'plugins_loaded', array( $this, 'on_plugins_loaded' ), - 1 ); … … 247 248 */ 248 249 249 //public function activate_plugin() {250 251 //}250 public function activate_plugin() { 251 timify_create_table(); 252 } 252 253 253 254 /** … … 262 263 } 263 264 delete_option( 'timify_settings' ); 265 delete_option( 'timify_reading_settings' ); 266 delete_option( 'timify_word_settings' ); 267 delete_option( 'timify_view_settings' ); 264 268 } 265 269
Note: See TracChangeset
for help on using the changeset viewer.