Displaying “One Time” Notification in Plugins

The idea is that you need to save_errors or update the option that has the errors/notices whenever you want. As soon as its output once by admin_notices it will be cleared. /** * Sample_Notice_Handling */ class Sample_Notice_Handling { public static $_notices = array(); /** * Constructor */ public function __construct() { add_action( ‘admin_notices’, array( $this, … Read more

Editing edit-tags.php page in wp-admin

You can use the dynamic {$taxonomy}_term_new_form_tag action, where you replace {$taxonomy} with your taxonomy slug. Example1) For the post_tag taxonomy: add_action( ‘post_tag_term_new_form_tag’, function() { printf( ‘><div class=”form-field”>%s</div’, esc_html__( ‘Some content’, ‘mydomain’ ) ); }, PHP_INT_MAX ); 1) Update: I didn’t noticed at first that this is inside the <form> tag, so this is a hack … Read more

Creating multiple wp_editer() text fields in for loop — the text/visual switch only works for first editor

https://codex.wordpress.org/Function_Reference/wp_editor The second argument for the wp_editor() function is editor ID In the above for loop – all of the editors had the same ID Changing <?php wp_editor( wp_kses_post( $benz_tab_content ), ‘benz_tab_content’, $settings ); ?> to <?php wp_editor( wp_kses_post( $benz_tab_content ), “benz_tab_content_$y”, $settings ); ?> allowed me to give each editor a unique ID — … Read more

$wpdb update query in plugin only updating one column

I had to use two separate queries. The $wpdb->update syntax cant deal with calculating based on the existing value. But for the other two fields it works. So like this: $table = $wpdb->prefix . ‘woocommerce_downloadable_product_permissions’; $expiry_date = date(“Y-m-d”, strtotime(“+ 30 days”)); $expiry_time = $expiry_date . ‘ 00:00:00’; $wpdb->query(“UPDATE $table SET download_count = (download_count + 1) … Read more

Custom plugin admin page issues

The last parameter of add_submenu_page expects a function callback, not a file include – hence the error as that is not a valid callback. (See add_submenu_page in the codex.) You can include the file in the function if you prefer: add_submenu_page( “???”, “Add / Edit Price Options in Kilometers”, “Add / Edit Price Options in … Read more

Admin side jquery is not loaded

If you want to load Jquery, wordpress already provides a handler for it (its also the one in /wp-includes/js/jquery/jquery.js): function load_admin_script(){ wp_enqueue_script(‘jquery’); } add_action(‘admin_enqueue_scripts’,’load_admin_script’); note that the jQuery in WordPress runs in noConflict mode.