New answers tagged

0 votes
Accepted

How to change the version of block.js and plugin to the same of Package.json?

WP Scripts provides no such feature for automating this, and if it did automate this it could cause problems. The version in block.json is not the version of your plugin, it's the version of the ...
Tom J Nowell's user avatar
  • 57.6k
0 votes

Check Plugins in Use by Mutli Site Network

Though the question is quite old I would like to share the small code snippet with you guys. So here is how to check whether a plugin is activated individually for some websites: $sites = get_sites(); ...
Misha Rudrastyh's user avatar
0 votes

How do I make my plugin load before the headers are output so I can redirect wordpress?

Hook into the headers hook add_action( 'wp_headers', [ $this, 'forward_to_login' ] ); /** * @return void */ function forward_to_login() { wp_redirect( 'www.example.com' ); } Simple an clean.
frizzant's user avatar
  • 123
3 votes
Accepted

What are the implications of having main plugin file name different to plugin slug?

It's only a good pratice to adopt this naming convention. As long as you have in the header of your main file the meta (at last Plugin name: Name of Your Plugin, WordPress will automatically recognize ...
PhpDoe's user avatar
  • 180
0 votes

Unable to download backup file created using All in One WP Migration WordPress plugin

I've got the same problem too. All my donwloads are cut at 512mb. The problem is probably (but not sure) linked to : • Cloudflare CDN and or Cloudflare routes (cloudflare VPN). • Litespeed server ...
Lionel's user avatar
  • 1
1 vote

WP Plugin: How to avoid db access for each comment?

As a follow up I'd like to share the complete solution (if everyone is interested). Thanks to @Antti Konskinen and @Rup again. /* Plugin Name: Vote on Comments Version: */ define('...
Abid's user avatar
  • 143
2 votes

WP Plugin: How to avoid db access for each comment?

In addition to the caching, you could get all of the comment scores in a single database query e.g. SELECT V.comment_id, V.vote_up, count(*) count FROM wp_comment_vote V JOIN wp_comments C ...
Rup's user avatar
  • 4,027
1 vote
Accepted

WP Plugin: How to avoid db access for each comment?

Yes, I would suspect that your current solution may cause performance issues, if the number of comments gets high. To make the calculations a little easier for your site, you could handle them before ...
Antti Koskinen's user avatar
-1 votes

How do I add an address type in woo commerce?

The quick/easy way to add this is through a plugin. There are a few WC checkout customization plugins available (just search for woocommerce checkout plugins). There is also generic data capturing ...
Adam's user avatar
  • 71
2 votes
Accepted

add_action() not working for admin

As noted in the documentation, the wp_enqueue_scripts hook (emphasis mine): ...is the proper hook to use when enqueuing scripts and styles that are meant to appear on the front end. If you want to ...
Jacob Peattie's user avatar
0 votes

Remove custom menu pages for admin users

Try to use the slug of the pages as parameter, e.g. remove_menu_page( 'dashboard' ); instead of remove_menu_page( 'admin.php?page=dashboard' );.
WanDal's user avatar
  • 1
0 votes

What is the best way to ignore wordpress administration using add_filter($title) also when Ajax request

There are a couple of things here that should always be kept in-mind when you're thinking of administrators and WordPress is_admin(). is_admin() tells you only whether or not the current WordPress ...
Paul G.'s user avatar
  • 1,164
0 votes

Hide plugin list

https://wordpress.org/plugins/hide-plugins/?ref=commonninja The Hide Plugins plugin does it all.
Avi Moyal's user avatar
1 vote
Accepted

show_admin_bar filter not called inside plugin class

As Jacob Peattie mentioned in the comments, the filter should return a value, if the condition is not met, as demonstrated below. Another thing to consider is the question of when are you ...
Antti Koskinen's user avatar
0 votes

CPU Overloading due to some hooks

This code is causing your replace_authors_name_attributes() function to run every time a page is visited on your site, so yes, your hooks are running: schedule_authors_consistency() { if (!...
Jacob Peattie's user avatar
0 votes
Accepted

correct way to enqueue js and css files for wordpress shortcode?

A better approach would be to only enqueue the scripts and styles when you know the shortcode is actually being used on the page. One way to do this is to use the wp_enqueue_scripts action to check if ...
ray-happyforms's user avatar
0 votes
Accepted

Iframe beeing removed when embeding a video through block in Sensei LMS (Vimeo)

Okay after three days of asking SENSEI LMS and Vimeo guys, it looks like everything was okay on their side. Vimeo oEmbeded block is not from sensei lms but directly inside of wordpress. That means I ...
smarcin22's user avatar
  • 101
0 votes

Is it possible to create a Post and change the author with Wordpress?

Are you trying to do this programmatically? It's certainly possible to be logged in and change the author of any post. It's even part of the "Quick Edit" menu, or you can go to the post, ...
Kevin's user avatar
  • 1
0 votes

Executing my function once on a specific time

With WordPress you can't trigger action at specific time. Better to use server side cron to perform action
Malay Solanki's user avatar
2 votes

I have created a custom plugin. After activation it creating page but i am not getting how to add another php file at page content?

I would approach this in different way. In this original index.php file, keep it simple, like this: if ( ! defined( 'ABSPATH' ) ) { exit; } if ( ! class_exists( 'My_Plugin' ) ) { require_once ...
mWin's user avatar
  • 71
0 votes

wp_enqueue_script doesn't load JS in plugin

I had the same problem... the thing is that you are using wp_enqueue_scripts, but if you want to load it in admin panel you have to use admin_enqueue_scripts instead... The function should be called ...
Oswaldo Cova's user avatar
1 vote

REST API - filters not working inside plugin class

This is a problem: public function __contruct() it should be __construct, the S is missing, meaning there is no constructor and the add_filter calls never happen The function that registers the ...
Tom J Nowell's user avatar
  • 57.6k

Top 50 recent answers are included