Are shortcodes case-sensitive?

Short Answer Yes, shortcodes are case sensitive Longer Answer It’s really easy to build a test case for this and see. <?php add_shortcode(‘sOme_ShOrTcOdE’, ‘wpse102375_shortcode’); function wpse102375_shortcode($args, $content=null) { return ‘yep’; } Longest Answer Read the source. The “magic” with shortcodes happens in do_shortcode, so let’s take a look at that. <?php // wp-includes/shortcode.php function do_shortcode($content) … Read more

Clarity needed on usage of multiple 403 forbidden header() functions at the beginning of the plugin files

The proper way to send a status (when WordPress is not available) is: http_response_code( 403 ); See the PHP Manual for its definition. But in Plugin files, this should never be the “default” code on top of a file header. See Worthwhile to restrict direct access of theme files? for a discussion. In WordPress, use … Read more

Loading custom page template via plugin

To add custom template in page attributes template section you have to first add your template to dropdown and load it in template_include hook when current page has selected it as current template. /** * Add “Custom” template to page attirbute template section. */ function wpse_288589_add_template_to_select( $post_templates, $wp_theme, $post, $post_type ) { // Add custom … Read more

Using require_once in a Plugin?

The first one is like saying… Include the file found in the inc directory, above the directory where this file is located. The second statement is saying… in the server root (/) look in the inc folder for canagan_admin_functions.php and include it. The first one will work, the second won’t. In the second you’re looking … Read more

How to get Post ID with the Add Filter Function

Nevermind, found out I can use get_the_ID();. This function will return the post id inside the the_content filter. The function simply declares the global $post object and returns its ID. add_filter(‘the_content’, ‘wpse51205_content’) wpse51205_content($content) { echo $content; // Echo out post content $PersonName = get_post_meta(get_the_ID(), ‘PersonName’, true); echo ‘Person: ‘ . $PersonName; } If you don’t … Read more

How can I track active users of my plugin? and why doesn’t WordPress.Org offer this?

You cannot get these data. There are several issues with plugin usage tracking: No clear definition of a user: Think multi-site, local installations, intranets … Privacy: You would have to ask the user before you can activate tracking. There are many good reasons not to send any data to an unknown entity without consent (traffic, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)