Friday 10 November 2017

Find Unused Shortcodes in WordPress with Code


When going through various themes and plugins, you might use various shortcodes on your site or on a client site. When making the transition from one theme to another or from one plugin to another something might happen. You could forget a page or post where you have used a shortcode. Such unused shortcode could break your site. Let’s see how to find those pages and posts. How to find Unusued Shortcode
You can go to each post, page or any other custom post type and see which shortcode was not parsed into a styled text, form or something else. We are not doing that!
But we will do that through our code. We will have to parse all the content so that every possible shortcode that is registered gets parsed. With that approach, we will be left only with the shortcodes that once were registered (by a deactivated plugin or theme).
Coding our Search Engine
Our seach engine for unused shortcodes will be done on the admin side. You can add this code as a separate plugin or in your own existing plugin or theme. That is up to you. Let’s begin:
<?php
add_action( ‘admin_init’, ‘ibenic_get_all_posts_shortcodes’ );
function ibenic_get_all_posts_shortcodes() {
if( isset( $_REQUEST[‘get_shortcodes’]
Source: https://managewp.org/articles/16542/find-unused-shortcodes-in-wordpress-with-code




source https://williechiu40.wordpress.com/2017/11/10/find-unused-shortcodes-in-wordpress-with-code/

No comments:

Post a Comment