wp_mail is undefined

You may call the function too early. You have to wait until the action ‘plugins_loaded’ fires. wp_mail() is defined in wp-includes/pluggable.php. pluggable.php is loaded in wp-settings.php after the plugins are loaded but before ‘plugins_loaded’ is called. See this answer for an example.

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