Hot answers tagged

3

Here's one way: You can look at has_shortcode() and find the parsing there: preg_match_all( '/' . get_shortcode_regex() . '/', $content, $matches, PREG_SET_ORDER ); using the get_shortcode_regex() function for the regex pattern. For non empty matches, you can then loop through them and collect the full shortcode matches with: $...


2

If you only need the Shortcodes without the attributes, you can use this function: function get_used_shortcodes( $content) { global $shortcode_tags; if ( false === strpos( $content, '[' ) ) { return array(); } if ( empty( $shortcode_tags ) || ! is_array( $shortcode_tags ) ) { return array(); } // Find all registered ...


2

If it's just a list of numbers, I'd suggest just saving them in a text file, with a number on each line. 110019 111222 112233 Then when you need the file, read its contents with PHP, and use preg_split() to turn it into an array: $file_path = plugin_dir_path( 'postcodes.txt', __FILE__ ); // Or wherever you've placed it. $file_contents = ...


2

You want to use $wp_admin_bar->add_node( $args ). Below is a tested working example. function wpse_add_toolbar_edit($wp_admin_bar) { $wp_admin_bar->add_node( array( 'id' => 'mylink', 'title' => 'My New Link', 'href' => 'mailto:support@domain.com', 'parent' => 'user-actions' ) ); } add_action(...


1

You must have to include wp_head() in header.php and wp_footer(); in your footer.php header.php <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <?php wp_head(); ?> <body> footer.php <?php wp_footer();?> </body> </html> if ...


1

WordPress redirects you back to the user-edit.php page upon successful user update, so while the admin_notices has yet been fired in your sulock_save_profile_fields(), the message (your custom admin notice) is never displayed because of the redirection. And one way to fix it, is by filtering the redirect URL via the wp_redirect filter: // In ...


Only top voted, non community-wiki answers of a minimum length are eligible