gbonvehi
Forum Replies Created
-
@greg I think that load_plugin_textdomain should not be hooked into init but plugins_loaded according to https://codex.www.ads-software.com/Function_Reference/load_plugin_textdomain
Ken or karlharshman, try replacing in wp-statistics.php line 33 where it says
add_action('init', 'wp_statistics_init');
with
add_action('plugins_loaded', 'wp_statistics_init');
Cheers,
GuillermoPS: This is untested as I’m not having the problem neither.
You’re welcome Greg, I think it’s the easiest way to ensure the output is valid Javascript. I’ll mark this as resolved since it was just a suggestion.
Cheers,
GuillermoHi there,
Greg, the warning they’re receiving is because of the preg_replace_callback line in wps-install.php, line 223:
$final_report = preg_replace_callback('/%(.*?)%/ime', function($m) { return $template_vars[$m[1]]; }, $report_content);
you should remove the e modifier (/im instead of /ime) to prevent it.Cheers,
GuillermoNo need to apologize Greg, you’re doing an amazing job!
I just wanted to confirm to reapply the changes, I’ll update to 9 when it’s ready then.Cheers,
GuillermoNo need to be sorry, you’re doing a great work, thanks again!
Hi again Greg,
I first need to thank you for being so active in the support forum!
Now to the point, I’ve checked 8.8.1 update and the fixes are not included there, was this on purpose (maybe you’ve it scheduled for a newer version)?
Thanks again,
GuillermoNo, there was no reason, just saw it was deprecated in 5.5 but as you said, it’s been available since 5 so you can just replace the older version.
Cheers,
GuillermoForum: Plugins
In reply to: [EG-Attachments] won't remove from wp 4Hi nikosoff,
I’ve just experienced the same issue.
There’s a coding error inside uninstall.php which will prevent uninstalling it.
Just change near the bottom of the file, there’s a line that contains${wpdb->prefix}
change it to
{$wpdb->prefix}
Cheers,
GuillermoForum: Plugins
In reply to: [Post Views Counter] get views for a REST APIHi mkiisoft,
I’m not the author but I got a nice answer in this same forum so I’m glad if I can help him/her/them.
You can simply create a new WordPress AJAX call ( https://codex.www.ads-software.com/AJAX_in_Plugins ) in your theme and call it with the post ID to get the views count.
Here’s an example.
In your functions.php you register the AJAX callback, here it has the name ‘ajax_post_views_counter’.
function ajax_post_views_counter() { $post_id = intval( $_GET['post_id'] ); if ( empty( $post_id ) ) { echo json_encode( (object) array( 'views' => -1, 'error' => 'Empty post ID' ) ); die(); } if ( ! function_exists( 'pvc_get_post_views' ) ) { echo json_encode( (object) array( 'views' => -1, 'error' => 'Plugin not loaded' ) ); die(); } echo json_encode( (object) array( 'views' => pvc_get_post_views( $post_id ) ) ); die(); } add_action( 'wp_ajax_nopriv_ajax_post_views_counter', 'ajax_post_views_counter' ); // Enable also when outside admin add_action( 'wp_ajax_ajax_post_views_counter', 'ajax_post_views_counter' );
Then as explained in that link, you’ve to call admin-ajax.php with the name of the callback as the action parameter and then all the parameters you need, in this example we are using post_id.
The code below is ran from inside a WordPress loop where you can access the current post id and access to the admin_url helper, it will popup an alert with information on click.
The code will generate a link similar to
https://<YOUR_DOMAIN>/wp-admin/admin-ajax.php?action=ajax_post_views_counter&post_id=<POST_ID_HERE>
so if you’re not using WordPress to generate it, provided you’ve the post ID you can call it from anywhere.<button id="testAjaxCount">Test get count</button> <script> jQuery(function ( $ ) { $( '#testAjaxCount').on( 'click', function() { $.get( '<?php echo admin_url( 'admin-ajax.php' ) ?>?action=ajax_post_views_counter&post_id=<?php the_ID() ?>', function( result ) { if ( ! result.error ) alert( 'Views: ' + result.views ); else alert( 'Error: ' + result.error ); }, 'json' ); }); }); </script>
Hope it helps.
Cheers,
GuillermoForum: Plugins
In reply to: [Post Views Counter] Shortcode hyphen problemWell, after a quick review, I saw that inside *remove_post_views_count* method you’re besides removing the tag from the excerpt, also deregistering the shortcode, so if in a page you display an excerpt AND a content AFTER it it won’t have the shortcode available.
89 public function remove_post_views_count($excerpt) 90 { 91 remove_shortcode('post-views'); 92 $excerpt = preg_replace ('/\[post-views[^\]]*\]/', '', $excerpt); 93 return $excerpt; 94 }
I’ve removed the remove_shortcode call, I don’t know if that will affect other functionality of the plugin (I guess it shouldn’t), so far it seems to be working fine.
Check if it’s related to this bug (it has a solution there), https://www.ads-software.com/support/topic/plugin-qtranslate-slug-with-widget-error-after-upgrade
Otherwise I’d suggest you to turn on debugging and try to find out what is causing the problem.