Special ID attribute in shortcode
-
First of all, I want to express gratitude and appreciation for creating a pretty cool plugin. We recently used it in one of our projects and found one simple thing missing, namely, the ability to specify the post ID in the shortcode. So, we modified the code and are sending it to you to implement:
/** YCDEVS MODE - ADD ID ATTR * Function of the read_meter shortcode. * * @since 1.0.0 * @return shortcode display value. */ public function read_meter_shortcode($atts) { $atts = shortcode_atts( array( 'id' => '', ), $atts, 'read_meter' ); $bsf_rt_post = ''; if(isset($atts['id']) && !empty($atts['id'])){ $bsf_rt_post = get_post($atts['id'])->ID; } else { $bsf_rt_post = get_the_ID($atts['id']); } $this->bsf_rt_calculate_reading_time( $bsf_rt_post, $this->bsf_rt_options ); $label = $this->bsf_rt_options['bsf_rt_reading_time_label']; $postfix = $this->bsf_rt_options['bsf_rt_reading_time_postfix_label']; $shortcode_output = '<span class="bsf-rt-reading-time"><span class="bsf-rt-display-label" prefix="' . $label . '"> </span> <span class="bsf-rt-display-time" reading_time="' . $this->reading_time . '"></span> <span class="bsf-rt-display-postfix" postfix="' . $postfix . '"></span></span>'; return $shortcode_output; }
I believe this additional feature will be useful not only to us but also to a greater number of users ??
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Special ID attribute in shortcode’ is closed to new replies.