• Resolved Alex Stine

    (@alexstine)


    Hello @takahashi_fumiki

    Firstly, awesome plugin, I really like how it even cleans up after itself after uninstall.

    My problem. I added the feedback links direct to template. However, the Feedback Statistic menu did not show up under Posts like it should of. I tried to create a menu link going to it, but I got an error.
    “You don’t have sufficient permissions to access this page.”
    As soon as checking the Posts checkbox under Settings, the Feedback Statistic menu appeared but the links were showing up twice because I added them direct to template.

    Could you please explain how I can add my links direct to template and have the Feedback Statistic menu item show up?

    Thanks.

Viewing 15 replies - 1 through 15 (of 16 total)
  • Thread Starter Alex Stine

    (@alexstine)

    Just a bit more detail, I have no post types selected, added the links direct to my theme template, if I try to visit this URL, I get an error message. As soon as I check Posts, it works great again.
    https://domain.com/wp-admin/edit.php?page=anyway-feedback-static-post

    I need to be able to access this URL without having Posts checked or else it will show up twice on my Posts which I don’t want.

    Thanks again.

    Thread Starter Alex Stine

    (@alexstine)

    Don’t know if this helps any, but I placed this in my post template. Twenty Sixteen content-single.php.
    https://github.com/WordPress/twentysixteen/blob/master/template-parts/content-single.php

    <?php
    if( function_exists('afb_display') ){
    afb_display();
    } ?>

    Sorry for the many replies, editing time is really limited now for some reason.

    Thanks.

    Plugin Author Takahashi Fumiki

    (@takahashi_fumiki)

    Hi, @alextine

    The admin URL of statistic page is generated with admin page API if check box is on at Setting > Anyway Feedback.
    Every setting page will be under the post list(/wp-admin/edit.php?post_type=xxx). If post is the post type(means default post), no query argument.
    So, the URL would become like this.

    For default post:
    https://example.com/wp-admin/edit.php?page=anyway-feedback-static-post
    For custom post type xxx:
    https://example.com/wp-admin/edit.php?post_type=xxx&page=anyway-feedback-static-xxx
    For custom post type e.g. add-on:
    https://example.com/wp-admin/edit.php?post_type=add-on&page=anyway-feedback-static-add-on

    If you want to the link to statistic page on “template”(does this mean front page, right?), just write like below

    echo admin_url(sprintf('edit.php?post_type=%1$s&page=anyway-feedback-static-%1$s', get_post_type()));
    

    I hope this helps.

    By the way, you have to check permission of current user. If no-perm user clicks this link, he/she will see the wp_die screen.

    if ( current_user_can( 'edit_post', get_the_ID() ) ) {
        // This user can edit this post.
    }
    
    Thread Starter Alex Stine

    (@alexstine)

    Hello @takahashi_fumiki

    I tried going directly to this URL and I got this error.
    Sorry, you are not allowed to access this page.
    https://example.com/wp-admin/edit.php?page=anyway-feedback-static-post

    I’m an Administrator user, why am I seeing this just from visiting the direct URL?

    Thanks.

    Thread Starter Alex Stine

    (@alexstine)

    This is for the “post” post type. ??

    Plugin Author Takahashi Fumiki

    (@takahashi_fumiki)

    @alexstine

    If you check for post, you will see this link. If not, you have no statistic screen. See the image below:

    https://dl.dropboxusercontent.com/u/569741/tmp/afb.png

    Thread Starter Alex Stine

    (@alexstine)

    @takahashi_fumiki

    I don’t understand, I already have posts. No one has voted yet, is this why the screen isn’t showing? I have one post named “Testing”, I just need this page to be accessible instead of this error.

    I am visually impaired, I cannot see pictures.

    Thanks.

    Plugin Author Takahashi Fumiki

    (@takahashi_fumiki)

    @alexstine

    > I am visually impaired, I cannot see pictures.

    Oh, sorry for that. I thought captured image is more intuitive, but that’s lack of my imagination.

    First of all, statistic screen is available only for post types which are checked “on” at “Post type setting” section of setting screen “Anyway Feedback” under “General Setting”.

    Your URL https://example.com/wp-admin/edit.php?page=anyway-feedback-static-post is O.K.

    As you mentioned above, you have written a code afb_display() directly in the template. I guess it’s because you don’t want feedback buttons to be inside the_content(), isn’t it? If so, you can select in which post type the buttons are hidden at “Hide default feedback controller” section of setting screen.

    Anyway, repeat again. The statistic page for post type “post” is only available if you check it at setting screen.

    I hope this comment helps.

    Thread Starter Alex Stine

    (@alexstine)

    @takahashi_fumiki

    Firstly, sorry for my slowness in understanding.

    So could you please explain how I can keep the Posts checkbox checked with hiding the links inside the content? It should only be displaying for the custom code. Do I need to hide it with CSS? Or is there another option I’m missing?

    Thanks.

    Plugin Author Takahashi Fumiki

    (@takahashi_fumiki)

    @alexstine

    > Firstly, sorry for my slowness in understanding.

    It’s Okay ??

    STEP1

    Go to setting page “Anyway Feedback” under “General Setting”. URL is ‘https://example.com/wp-admin/options-general.php?page=anyway-feedback&#8217;

    STEP2

    Turn “posts” on at the section “Post type setting”. Now statistic page for posts is available. URL should be ‘https://example.com/wp-admin/edit.php?page=anyway-feedback-static-post&#8217;.

    STEP3

    Now, you have 2 control areas because you wrote afb_display() directly to templates. You have to hide automatically generated buttons.

    Go to setting page and turn “posts” on at the section “Hide default feedback controller”. I don’t use screen reader but you can access it with tab key. Second “posts” is the one. Checked will be hidden.

    I believe now you can get what you want.

    Thread Starter Alex Stine

    (@alexstine)

    Hello @takahashi_fumiki

    Alright, almost. The only issue I’m having is I cannot see this section on either of my test site or live site. It simply isn’t in the settings page. Even tried fresh install.

    Go to setting page and turn “posts” on at the section “Hide default feedback controller”.

    I did save first, refreshed, still not there.

    Suggestions?

    Thread Starter Alex Stine

    (@alexstine)

    @takahashi_fumiki

    Now home, I was able to grab this screenshot for you. Hopefully I captured the settings correctly, you can clearly see that the option you are referring to is not there. It is also the only plugin activated, using the Twenty Sixteen theme.
    https://drive.google.com/file/d/0B_h6oU4LzDtlSTdibjd0TWk0NVk/view?usp=sharing

    Thanks.

    Plugin Author Takahashi Fumiki

    (@takahashi_fumiki)

    Oh, @alexstine, That’s my fault.
    The plugin repo’s latest version is different from Github.
    I thought changes were merged.
    I will fix it soon but quick fix is below.

    In your theme’s function.php, write this code block.

    remove_filter( 'the_content', array( AFB\Main::get_instance(), 'the_content' ), 10 );
    

    If you want some post type shows buttons and the other doesn’t, wait for next release.

    Thread Starter Alex Stine

    (@alexstine)

    Hello @takahashi_fumiki

    Thanks that worked for the time being. Could you please give me some code to do the same for comments? I am displaying the links conditionally for staff users only and do not want the links displaying automatically, just by the added code to the comments template.

    Thanks for your help. ??

    Plugin Author Takahashi Fumiki

    (@takahashi_fumiki)

    @alexstine

    To remove comment, this may work.

    remove_filter( 'comment_text', array( AFB\Main::get_instance(), 'comment_text' ), 10 );
    

    Don’t forget marking these code blocks with comment like below.

    // TODO: Remove this hooks when AFB updated!
    
Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘Feedback Statistics Not Showing When Add Direct To Template’ is closed to new replies.