• Resolved WP-Henne

    (@wp-henne)


    Hey, just came across the plugin!

    I would like to use it for a classifieds page.

    If it would be made possible for a later release to choose from existing post types where the report link is used, that would be brilliant!

    For now, I’m looking to see if and how I can modify the template from WP-Adverts (https://ww.wp.xz.cn/plugins/wpadverts/).

    In the current state, the report button/link for adverts is not displayed, even if “Show the Report button not just on single posts, but on all blog pages” is active.

    What do I have to insert to get the link manually in the template?

    Thank you very much!

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Marcel Pol

    (@mpol)

    Hi,
    For some strange reason they don’t run the ‘the_content’ filter on their content. You can add a filter in PHP code. You can add this in functions.php of your theme, preferably a child theme, or to your own plugin.

    add_action( 'adverts_the_content', 'zeno_report_post_the_content_add_report_button' );

    Can you manage?
    Regards, Marcel

    Thread Starter WP-Henne

    (@wp-henne)

    Hello Marcel,

    this works, thank You.

    I had tried to code in the single.php of the plugin or to use ‘add_action’. ( https://ww.wp.xz.cn/support/topic/report-ads-and-like-button/ )
    However, both fail due to obvious errors in the plugin. I’ll report this to the developers there.

    Thanks to the snippet I have and ‘report ad’, but also in the overview pages.

    Can I filter so that pages are excluded?

    Thanks for your quick support!

    Plugin Author Marcel Pol

    (@mpol)

    Hi, the code might be more safe as:

    function add_zeno_report_post_the_content_add_report_button() {<br> if ( function_exists( 'zeno_report_post_the_content_add_report_button' ) ) {<br> add_filter( 'adverts_the_content', 'zeno_report_post_the_content_add_report_button' );<br> }<br>}<br>add_action( 'init', 'add_zeno_report_post_the_content_add_report_button' );

    In case you ever disable this plugin.

    Currently there is no way to select post type, I will add it to the todo list.

    Regards, Marcel

    Plugin Author Marcel Pol

    (@mpol)

    Hi, a third version that will only work on the adverts post_type:

    function add_zeno_report_post_the_content_add_report_button() {
    if ( function_exists( 'zeno_report_post_the_content_add_report_button' ) ) {
    $post = get_post();
    if ( 'advert' === get_post_type( $post ) ) {
    add_filter( 'adverts_the_content', 'zeno_report_post_the_content_add_report_button' );
    }
    }
    }
    add_action( 'wp', 'add_zeno_report_post_the_content_add_report_button' );

    Plugin Author Marcel Pol

    (@mpol)

    Sorry for being so incomplete 🙂
    This addition with remove_filter should remove the report button from posts and pages.

    function add_zeno_report_post_the_content_add_report_button() {
    if ( function_exists( 'zeno_report_post_the_content_add_report_button' ) ) {
    $post = get_post();
    if ( 'advert' === get_post_type( $post ) ) {
    add_filter( 'adverts_the_content', 'zeno_report_post_the_content_add_report_button' );
    }
    remove_filter( 'the_content', 'zeno_report_post_the_content_add_report_button' );
    }
    }
    add_action( 'wp', 'add_zeno_report_post_the_content_add_report_button' );

    Thread Starter WP-Henne

    (@wp-henne)

    Hello @mpol !

    Thank you very much! Both are quite good and help me. But the details are not perfect.

    With the last code snippet I cannot (yet) prevent the report hint from appearing on the page with the shortcode for the display overview.

    If I set the plugin to “nothing”, the snipet does not work. If it is set to “Link”, the insertion on the “advert” page works. In addition, the link is also set on the “page”.

    It would be ideal to leave the setting in the plugin options off and only set it to “advert” via Snipet. But I don’t know how to do that on my own.
    Conversely, querying “page” and then removing the link did not work with my on-board resources:

    		if ( 'page' === get_post_type( $post ) ) {
    remove_filter( 'adverts_the_content', 'zeno_report_post_the_content_add_report_button' );
    echo "!page!";
    }

    I see !page! like expected, but also the link :-/

    Plugin Author Marcel Pol

    (@mpol)

    Hi,
    The ‘remove_filter’ should be for the ‘the_content’ filter, as that is used in the plugin.
    Using add_filter should be done for the ‘adverts_the_content’ filter.

    I am not sure if I want to create an option for post types, I’m not sure how feasable it is and if it would work good. I do understand having a settings page is easier than using custom code.
    By the way, the last snippet of code is all you need.

    Thread Starter WP-Henne

    (@wp-henne)

    Hello Marcel!

    Thank You so much! Now with Your hint I’ve got the solution:

    function add_zeno_report_post_the_content_add_report_button() {
    if ( function_exists( 'zeno_report_post_the_content_add_report_button' ) ) {
    $post = get_post();
    if ( 'advert' === get_post_type( $post ) ) {
    add_filter( 'adverts_the_content', 'zeno_report_post_the_content_add_report_button' );
    // advert single page
    }
    if ( 'page' === get_post_type( $post ) ) {
    remove_filter( 'the_content', 'zeno_report_post_the_content_add_report_button' );
    // shortcode pages
    }
    }
    }
    add_action( 'wp', 'add_zeno_report_post_the_content_add_report_button' );

    This Snippet works for me.

    Your plugin is currently unique. There is no other “reporting” tool! When I play through the possibilities of what can be done with it… I would love to support it!

    I’m not a programmer, but a critical user of plugins. And a good beta tester 😉
    For example, if you see the options of “Admin Menu Post List” (I still have the plugin in use):

    So I could imagine that with the selection for Custom Post Types.

    Thank You again!

    Thread Starter WP-Henne

    (@wp-henne)

    Resolved, the code above is my solution.

    Great work Marcel!

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Use with custom Post Type?’ is closed to new replies.