• Resolved ycdevs

    (@ycdevs)


    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 ??

    • This topic was modified 7 months, 2 weeks ago by ycdevs.
    • This topic was modified 7 months, 2 weeks ago by ycdevs.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi @ycdevs,

    Thanks for sharing the code!

    I’ll chat with our developer and see how we can work this into our plans. If it fits well and works smoothly, we’ll definitely consider including it in future updates.

    Kind regards,
    Avinash

    Thread Starter ycdevs

    (@ycdevs)

    Give a feedback, if you add this to plugin ??

    Plugin Support Herman Asrori (BSF)

    (@bsfherman)

    Hi @ycdevs,

    You can also consider raising a PR on our GitHub.

    And since this is actually not an issue, I will mark this thread as Resolved.

    Thank you for your support!

    Kind regards,
    Herman ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Special ID attribute in shortcode’ is closed to new replies.