New answers tagged plugin-development
0
votes
Warning: Cannot update a component (`Unknown`) while rendering a different component
I saw a React.js post on useEffect and then looked for examples on Gutenberg source as follows:
...
import {
useEffect
} from '@wordpress/element';
...
function Test2Edit(props) {
...
...
0
votes
add_menu_page() with different name for first submenu item
function content_adder_menu() {
add_menu_page(
'Content', // Page title
'Content', // Menu title
'manage_options', // Capability required to access
'content-adder', // Menu slug
'...
0
votes
Reliable way to add nonce to HTTP Header in WordPress?
I have refered your questions discussion reagrding the adding of nonce csp in wordpress scripts.Please check my findings
I have created a function in functions.php of my theme
//creating random nonce ...
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 ...
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 ...
0
votes
How to assign to each output values from foreach loop to a meta_key?
Problem Solved but solution not reusable.
I'd like some advice or a solution to assign the same meta_key to each datetime generated.
Based from this answer : to assign variables to each datetime from ...
0
votes
Custom rest fields not loaded in rest api cpt response
I've ended up with a simple solution. after the query to the DB to get all the desired CPT I'm looping the posts object and inside my loop I get the postmeta I will need to add and append them to each ...
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 ...
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' );.
0
votes
Accepted
Does a wordpress custom plugin is fired by default on php theme ajax request?
This will never work:
add_action( 'admin_init', 'my_ajax_checker', 10, 2);
function my_ajax_checker() {
if( wp_doing_ajax() ) {
add_action('plugins_loaded', 'atv_convert_multilingual');
...
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 ...
4
votes
Accepted
Why does WordPress not make use of gettext directly?
When your .mo files are however put to use in your application under the hood, wordpress parses your translation files into an associative array and extracts the translations as such, instead of ...
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 ...
0
votes
Check for dependent plugin and if false dont activate plugin
To check for a dependent plugin before activating another plugin, you would typically need to do the following in your code:
Identify the dependent plugin: Determine which plugin your plugin depends ...
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 ...
Top 50 recent answers are included
Related Tags
plugin-development × 6593plugins × 1928
php × 754
theme-development × 412
custom-post-types × 392
hooks × 295
functions × 285
customization × 258
ajax × 252
woocommerce-offtopic × 216
javascript × 206
block-editor × 184
filters × 183
shortcode × 183
database × 173
jquery × 165
actions × 164
wp-admin × 162
options × 151
widgets × 131
settings-api × 114
wp-query × 113
posts × 107
custom-field × 104
wp-enqueue-script × 101