New answers tagged

0 votes

Displaying an Uploaded Image as a Custom Avatar in Wordpress

// Função para adicionar upload de avatar no perfil do usuário para administradores e editores function custom_user_avatar_field( $profileuser ) { $user = wp_get_current_user(); if ( ! in_array( '...
Welson Elias's user avatar
1 vote
Accepted

How can I use the zip of my plugin in another website?

For some reason npm run plugin-zip only ZIP the build file and that's not enough for a plugin. I created my ZIP file manually by moving the build folder and index.php to a new folder and zip them. And ...
Moussa Saidi's user avatar
0 votes

Wordpress Global Var in Plugin but Outside Function

Tom made excellent points about scope and timing. Here's couple examples more demonstrating how to avoid global variable and add/execute action conditionally. I would also recommmend to have a look at ...
Antti Koskinen's user avatar
1 vote

Wordpress Global Var in Plugin but Outside Function

There are 2 problems here Problem 1: Scope The missing piece of the puzzle is scope. Scope isn't a WordPress thing, it's a fundamental programming feature, to use a global variable in a scope you have ...
Tom J Nowell's user avatar
  • 59.2k
0 votes

Is there a way to decide from init whether we are on a certain backend page?

I ended up checking the $_GET['page'] === $this->page->getId() and checking is_admin(). Not the perfect solution, but I did not have anything better for now.
inf3rno's user avatar
  • 133
1 vote

Is there a way to decide from init whether we are on a certain backend page?

There are few functions/global variable in WP to determine is_admin() - For checking if in admin panel global $pagename - to get the page name of admin
Aftab's user avatar
  • 1,321
1 vote

When to store store plugin options as a single database record?

If you are looking for performance and have 20 options so yes it is better to store in 1 option key in serialize() manner.
Aftab's user avatar
  • 1,321
0 votes

No Error Log File, no debug info

I also faced this error. What I did was to first create the debug.log file under the wp-content directory. I realized that errors were not logging in this file. Eventually, I decided to change the ...
Alalade Samuel's user avatar
0 votes
Accepted

Flash messages for not logged in users

What I did is combining cookies with transients just as others suggested. Be aware that the cookie must be sent with other HTTP headers, so init must be called in the plugin registration area while ...
inf3rno's user avatar
  • 133
1 vote

Custom post type template not loading from plugin

I think your first method isn't working because it's a theme method, not a plugin method. I could be entirely incorrect but I think the method of using single-custom_post_type.php only works for ...
Tony Djukic's user avatar
  • 2,044
0 votes
Accepted

Hide menu items from not logged in users

Turns out all of these work if I add a new menu to the theme. With the default menu none of them works. I'll report this as a bug to Kadence theme developers, I am curious about their opinion. For now ...
inf3rno's user avatar
  • 133
0 votes

Hide menu items from not logged in users

You could use something like this: // Function to hide menu items for non-logged-in users function hide_menu_items_for_non_logged_in($items, $args) { // Check if user is not logged in if (!...
Rick Hellewell's user avatar
0 votes

What are the differences between WPINC and ABSPATH?

It may also be good to note that there is no difference between die and exit. See: https://stackoverflow.com/questions/1795025/what-are-the-differences-in-die-and-exit-in-php
Harm op den Akker's user avatar
1 vote

Custom pages with plugin

A lot simpler solution is automagically adding the page if it does not exist. We can use a custom meta key to check its existence. We can do callback in the the_content filter if the current id is the ...
inf3rno's user avatar
  • 133
0 votes

how to send csv file to other server using wp_remote_post?

mirror issue in request body and headers ou can adjust your code to properly send the CSV file using wp_remote_post() The csv_file parameter is set to a CURLFile object, which represents the file to ...
vijay pancholi's user avatar
0 votes

How to dynamically add template in Innerblock?

To dynamically add or remove templates in the InnerBlocks component, you need to manage the template list state properly and ensure that changes to the template list trigger a re-render of the ...
vijay pancholi's user avatar

Top 50 recent answers are included