• Resolved martin.krcho

    (@martinkrcho)


    Hi Hector,

    I was wondering if you could add some filters to your plugin. I would like to show “566 x” instead of “566.28 views per day” in the widget. I have to change couple of lines of code every time you release a new version. It would really help if I could just implement some filter in my theme.

    Have a look at lines 699-711 in includes/class-wordpress-popular-posts-output.php. I suggest changing them to the code snippet below. Would that be a problem? Thanks

    
    if ( $this->options['order_by'] == 'avg' ) {
    
    	$views_text = apply_filters('wpp_views_per_day_average_label', sprintf(
    		_n( '1 view per day', '%s views per day', $pageviews, 'wordpress-popular-posts' ),
    		number_format_i18n( $pageviews, 2 )
    	), $pageviews);
    }
    else {
    	$views_text = apply_filters('wpp_views_per_day_total_label',sprintf(
    		_n( '1 view', '%s views', $pageviews, 'wordpress-popular-posts' ),
    		number_format_i18n( $pageviews )
    	), pageviews);
    }
    
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Hector Cabrera

    (@hcabrera)

    Hi there!

    I have to change couple of lines of code every time you release a new version (…)

    There are already a few ways to customize the HTML output of the WPP widget without having to modify the code. Use either of them and you won’t have that problem.

    Thread Starter martin.krcho

    (@martinkrcho)

    Hi Hector,

    thanks for a quick reply. Sure, I could use filter “wpp_custom_html” or “wpp_post”, but that would leave me with a lot of unnecessary code and I would have to keep track of any changes to these bits of code in your plugin to keep it working going forward. It would be really neat if you could add the two filters I suggested. I understand if you don’t feel it’s important, but it would help a lot. And your plugin would be one bit more developer friendly ??

    Cheers

    Plugin Author Hector Cabrera

    (@hcabrera)

    (…) that would leave me with a lot of unnecessary code (…)

    The Custom Markup option built-in into the widget is quite minimal, and the filter hooks don’t take that much space either. I guess we’ll have to agree to disagree on this one.

    (…) I would have to keep track of any changes to these bits of code in your plugin to keep it working going forward.

    Not really, no. I avoid making changes that would break existing funcionality unless I have a very good reason to do so, so you don’t have to worry about that.

    It would be really neat if you could add the two filters I suggested.

    Since there are already a few ways in place to customize the HTML output of the widget, chances are it won’t happen to be honest. If you feel these are not developer friendly enough, then please keep doing what feels best for you.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Filters for “views per day” string’ is closed to new replies.