Pixelbart
Forum Replies Created
-
Forum: Plugins
In reply to: [Helpful] Start and Log PageOn the start page the individual votes for single posts are shown. The charts do not show the table, only always the selected time.
The logs under Logs, are the logs. So there the single votes are listed. On the start page the posts with the totals of the votes.
Forum: Plugins
In reply to: [Helpful] dashboard widget slows down the admin home pageI would start small first and see how it goes. You can always set it higher. The only important thing is that you only delete the votes in an emergency, so that you still know next month what performed well last month.
Personally, I am with a good hoster and have caching active for only one hour. So I can repeatedly call the dashboard within an hour without all the data being pulled each time.
Forum: Plugins
In reply to: [Helpful] dashboard widget slows down the admin home pageHello @mohammedays,
Thank you for your feedback!
Currently there is no automatic deletion, simply because it doesn’t make sense if you want to measure how well something is performing. Especially the history is important here.
If your dashboard is too slow, you can enable caching. This can be done directly in Helpful’s settings, under System. Helpful should display several 10,000 votes without any problems.
Otherwise you can build a solution yourself to delete ALL entries automatically after 7 days. Without cronjobs you can just do that with transients – directly in admin_init, if you are interested.
So this you can put in the functions.php and then it will be executed every 7 days. The important thing is that it is also run once at the beginning. After that then every 7 days.
// only in admin area (use init, template_redirect or something else, for every page in the fronted) add_action('admin_init', function() { // seven days in seconds $seven_days_in_seconds = DAY_IN_SECONDS * 7; // transients, deletes itself automatically after seven days $transient = get_transient('helpful_auto_delete'); // fires only, if the transients is not set if (false === $transient) { global $wpdb; // db table name $table_name = $wpdb->prefix . 'helpful'; // db query for truncate table $wpdb->query("TRUNCATE TABLE $table_name"); // stores a transient for seven days set_transient('helpful_auto_delete', time(), $seven_days_in_seconds); } });Forum: Plugins
In reply to: [Helpful] Custom Post Type IntegrationForum: Plugins
In reply to: [Helpful] Custom Post Type IntegrationHello @meir321
you can also extend the shortcode and set your own headings. Then what you are looking for should actually work. You can have a look at it.
Below you will also find a link to the other shortcode attributes of Helpful.
[helpful heading="My new heading!"]See: https://helpful-plugin.info/docs/getting-started/shortcodes/
Great. Thank you for the quick feedback!
Forum: Plugins
In reply to: [Helpful] Uncaught ReferenceError: jQuery is not definedAre you using caching plugins? The error says that jQuery is not defined for you, at least not when Helpful is loaded.
Forum: Plugins
In reply to: [Helpful] Uncaught ReferenceError: jQuery is not definedHello @taufik7000
thank you for your message. This error is not caused by Helpful, because Helpful does not use
$(...).transpose. Helpful also does not include anything in the index. Helpful uses a scripthelpful.js. The error must be somewhere else. Feel free to send me a link to your site and I’ll take a look. Maybe I can find the problem for you.Stay healthy and thanks for the feedback!
Greetings Kevin
Forum: Plugins
In reply to: [Helpful] Impossible to display name and email fields for votersNo problem and thank you for your answer! After all, you answered, so no problem regarding the noise!
Have you also a nice weekend and stay healthy!
Forum: Plugins
In reply to: [Helpful] Impossible to display name and email fields for votersManually you can delete the options in the database table wp_options.
You can see which options might be relevant for you here:
https://github.com/pixelbart/helpful/blob/master/core/services/class-options.php#L227
So in the database table the keys should always be the keys from the array. Currently there is no option here. I think the reset in the Helpful options only referred to the votes.
Maybe I will build something for this. Basically this should not be a problem. The problem must be something else. You can set WP_DEBUG to true and then install Query Monitor. Then in case of an error, the errors should be shown to you.
What is also useful is the following addition in the wp-config.php:
define(‘WP_DEBUG’, true);
define(‘WP_DEBUG_LOG’, true);After that, when you save the options in the wp-content folder on your webspace, there should be a debug.log. Errors that happen in the background will be stored there. Very useful for debugging.
Forum: Plugins
In reply to: [Helpful] Impossible to display name and email fields for votersHere with me I can not reproduce the error. It is important that you are not logged in when you try to vote.
If you are logged in, the fields are never shown to you, because they are filled automatically.
You can also send me an example. I have now checked this on 12 websites, all on different hosts. I could not see or reproduce the error.
Otherwise, also make sure that the template in your WordPress theme is kept up to date. Some people change Helpful’s templates and are surprised that newer versions cause errors.
Forum: Plugins
In reply to: [Helpful] Receiving multiple emailsThis is an annoying bug that I need to fix. I’ll make sure I get that done in a timely manner. Most importantly, I can also easily check here if someone has already clicked – I don’t know why I didn’t get that right in the first place. Sorry for the inconvenience!!!
Thanks for your feedback and please stay well!
Greetings Kevin
Forum: Plugins
In reply to: [Helpful] Can i access helpful plugin from WordPress Restfull APIIt is important that you generate a unique ID for the user here. This is necessary so that a user cannot vote more than once. You have to take care of this yourself, since this is not possible with the API.
The code for the REST endpoint should look something like this:
/** * @return void */ add_action('rest_api_init', function () { if (!function_exists('helpful_get_pro')) { return; } $options = [ 'methods' => 'POST', 'permission_callback' => '__return_empty_string', ]; $options['callback'] = function($data) { if (!isset($data['user_id']) || '' === $data['user_id']) { return 0; } if (!isset($data['post_id']) || ! is_numeric($data['post_id'])) { return 0; } $user_id = sanitize_text_field($data['user_id']); $post_id = intval(sanitize_text_field($data['post_id'])); Helpful\Core\Helpers::insert_vote($user_id, $post_id, 'pro', null); return 1; }; /** * domain.com/wp-json/helpful/pro/?post_id=1234&user_id=1234 */ register_rest_route('helpful', '/pro/', $options); $options['callback'] = function($data) { if (!isset($data['user_id']) || '' === $data['user_id']) { return 0; } if (!isset($data['post_id']) || ! is_numeric($data['post_id'])) { return 0; } $user_id = sanitize_text_field($data['user_id']); $post_id = intval(sanitize_text_field($data['post_id'])); Helpful\Core\Helpers::insert_vote($user_id, $post_id, 'contra', null); return 1; }; /** * domain.com/wp-json/helpful/contra/?post_id=1234&user_id=1234 */ register_rest_route('helpful', '/contra/', $options); });After that you can try the following things to execute your request:
/* Request URL */ $url = 'domain.com/wp-json/helpful/pro/'; $url = 'domain.com/wp-json/helpful/contra/'; /** * Here we now enter the user who should publish the post. * As password we use the generated password by applications passwords from admin user profile. */ $user = '<benutzername>'; $pass = '<applications passwords>'; /* Request header */ $headers = [ 'Authorization' => 'Basic ' . base64_encode($user . ':' . $pass), 'cache-control' => 'no-cache', ]; /* Request body */ $body = [ 'post_id' => 1234, // post_id for the vote 'user_id' => 1234, // unique user_id ]; /* Request arguments */ $args = [ 'headers' => $headers, 'body' => $body, 'method' => 'POST', 'timeout' => 45, 'redirection' => 5, 'httpversion' => '1.0', 'blocking' => true, 'cookies' => [], ]; /* Our request */ $response = wp_remote_post($url, $args); /* If the request returns an error, the error is output */ if (is_wp_error($response)) { print_r($response->get_error_message()); } $response = wp_remote_retrieve_body($response); $response = wp_json_decode($response); $response = intval($response); if (1 === $response) { echo 'Vote was saved'; } if (0 === $response) { echo 'Vote was not saved'; }How this works with the REST API and what you have to consider, you have to read yourself in the codex. But this is how it should work.
- This reply was modified 4 years, 6 months ago by Pixelbart.
Forum: Plugins
In reply to: [Helpful] Can i access helpful plugin from WordPress Restfull APIUnfortunately, this is currently not possible. However, you can generate your own endpoints for the REST api. Depends on what you need.
/** * @return void */ add_action('rest_api_init', function () { if (!function_exists('helpful_get_pro')) { return; } $options = [ 'methods' => 'GET', 'callback' => function() { if (isset($_GET['post_id']) && is_numeric($_GET['post_id'])) { $post_id = intval(sanitize_text_field($_GET['post_id'])); return [ 'pro' => helpful_get_pro($post_id), 'contra' => helpful_get_contra($post_id), ]; } return [ 'pro' => helpful_get_pro_all(), 'contra' => helpful_get_contra_all(), ]; }, 'permission_callback' => '__return_empty_string', ]; /** * domain.com/wp-json/helpful/votes/ * OR * domain.com/wp-json/helpful/votes/?post_id=12345 */ register_rest_route('helpful', '/votes/', $options); });If you put this in your
functions.phpyou can get the following URLs with the REST API:All votes: domain.com/wp-json/helpful/votes/
Single post: domain.com/wp-json/helpful/votes/?post_id=12345You can find more functions here:
https://github.com/pixelbart/helpful/blob/master/core/functions/values.php
Note that sometimes it is necessary to go to the permalinks page in your settings before the endpoint is available. So settings > call permalinks in your wp-admin.
I may include something similar in the future. Unfortunately, I haven’t gotten around to it yet.
Please stay healthy and have a nice day!
Greetings Kevin
Maybe you do not name the endpoint helpful, so that there are no conflicts in the future!
- This reply was modified 4 years, 6 months ago by Pixelbart.
Forum: Plugins
In reply to: [Helpful] Not savingAre you using PHP 8.0? I currently have the problem only with a site that uses PHP 8.0. However, I have not yet been able to find the cause.
I’ll take a look at it next week. Unfortunately I can’t do that at the moment.
Thanks for your feedback!