WordPress.org

Ready to get started?Download WordPress

Forums

I Recommend This
[resolved] Disable Ajax functionality (9 posts)

  1. teti86
    Member
    Posted 5 months ago #

    Hi, great plugin.

    I would like to know if it's possible to disable Ajax functionality and manage the vote update only server side (by refresh the page) because if an user has javascript disabled on his browser he can't vote.

    Thanks!

    http://wordpress.org/plugins/i-recommend-this/

  2. Harish Chouhan
    Member
    Plugin Author

    Posted 5 months ago #

    @teti86, that would be possible but you would need to edit lot of the plugin and some extra functionality (similar to comments) where on clicking some data with ID would be passed to another page which could process and return user back to the previous page where they clicked.
    I am afraid I would not be able to assist you with this, but if you do develop it, would appreciate if you could share.

  3. teti86
    Member
    Posted 5 months ago #

    Thanks Harish, I supposed it.
    Maybe there is possible to only refresh page when an user vote without modified lot of the plugin?

    Thanks again.

  4. Harish Chouhan
    Member
    Plugin Author

    Posted 5 months ago #

    @teti86, I think it would involve few steps. Right due to many in-built WP functions its easier to call a function inside a plugin using basic JavaScript & AJAX provided by WP. So to bypass it and use direct page refresh, first the ajax refresh would have to be disabled and some form with post method would have to be introduced.

  5. teti86
    Member
    Posted 5 months ago #

    I try this solution, it seems to work.

    1- commented file dot_irecommendthis.js
    2- replaced the <a> button (inside the dot-irecommendthis.php file) with a form with an hidden input field with the post_id value and a submit button. This form is set to method post.
    3- create a custom page template that process the vote request (check if the cookies or ip already exist, update post meta, insert the ip on database, set the cookies) and then redirect to the contest page.

  6. Harish Chouhan
    Member
    Plugin Author

    Posted 5 months ago #

    @teti86 Thanks for the update. If you could share the code, I can try testing it within the plugin to allow users this option.

  7. teti86
    Member
    Posted 5 months ago #

    Sorry for waiting. Sure, I can share the code but probably you can do it better.

    1- I create another text option (and its relative function) to "dot-irecommendthis.php"

    add_settings_field( 'contest_page', __( 'Insert page url to return after vote', 'dot' ), array(&$this, 'setting_contest_page'), 'dot-irecommendthis', 'dot-irecommendthis' );

    This option add a news text field on the setting panel of the plugin.

    2- comment the js file to remove the ajax call

    3- create a wordpress page template called "verify-template.php" and create a page with this template. This template contain the code that retrieve the post id with $_POST['recommend_id'], get and update the post meta, set cookie, and insert in the DB the ip. After that redirect to the page set in the option $options['contest_page'].

    4- remove the a link in the "dot-irecommendthis.php" file (row 654) and add a form:

    $dot_irt_html .= '<form action="http://www.mydomain.it/verify/" method="post">';
    $dot_irt_html .= '<input type="hidden" name="recommend_id" value="'. $post_ID .'">';
    $dot_irt_html .= '<button type="submit">Vota</button>';
    $dot_irt_html .= apply_filters( 'dot_irt_before_count', $output );
    $dot_irt_html .= '</form>';
  8. Harish Chouhan
    Member
    Plugin Author

    Posted 5 months ago #

    Thansks mate. This is helpful. I will try adding it on my site. let me know if there is any site links of yours to give credit ti.

  9. teti86
    Member
    Posted 5 months ago #

    Thanks to you for the plugin =)
    I forgot one thing. The form is outputted (I don't know if "outputted" is the correct word =D) only if cookies aren't set or ip isn't in database.
    So if a person has already voted can not see the form and the submit button.

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.