Last active
July 6, 2017 13:12
-
-
Save netdesignr/88bb1af13ba5805377cdaed0ae0c091f to your computer and use it in GitHub Desktop.
Check if short-code exists in page and echo something inside Wordpress dashboard
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Check if shortcode exists in page and echo something in Wordpress dashboard | |
*/ | |
function check_if_shortcode_exists_in_page_and_echo_something() | |
{ | |
global $post; | |
if (function_exists('get_current_screen') | |
&& function_exists('has_shortcode') | |
&& function_exists('is_admin') | |
) { | |
$screen = get_current_screen(); | |
if (isset($screen)) { | |
if (is_admin() && ($screen->id == 'page') && has_shortcode($post->post_content, 'shortcode-name')) { | |
echo "Do somethig" | |
} | |
if (is_admin()) { | |
echo "Something else" | |
} | |
} | |
} | |
} | |
/** | |
* The hook | |
*/ | |
add_action('admin_notices', 'check_if_shortcode_exists_in_page_and_echo_something'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment