New answers tagged

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) { ... ...
Phil Huhn's user avatar
  • 143
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 '...
sukhchain's user avatar
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 ...
athira's user avatar
  • 1
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
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

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 ...
imagIne's user avatar
  • 45
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 ...
ICTDEV's user avatar
  • 111
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
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'); ...
Tom J Nowell's user avatar
  • 57.6k
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
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 ...
Tom J Nowell's user avatar
  • 57.6k
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

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 ...
Eso's user avatar
  • 1
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

Top 50 recent answers are included