Plugin to display text before a post

smraj, try to use a filter. Use this code snippet. Place this in our theme’s functions.php file add_filter(‘the_content’, ‘adddata’); function adddata($content) { $pre_post_text=”Welcome to my post!……….”; // only display this on single post pages if(is_single() && !is_home()) { $content = $pre_post_text.$content; } return $content; }

WordPress check box unchecked on null value ternary operator [plugin development]

checked() only checks if the passed first and second parameters match. It doesn’t do any array key checking, so you need to do it yourself before using the function to avoid errors. <?php global $options; $enabled = ( isset( $options[‘enable’] ) ) ? $options[‘enable’]: ”; ?> <input name=”settings[‘enable’]” type=”checkbox” id=”” value=”1″ <?php checked( $enabled, 1 … Read more

WordPress Plugin Reviewer

You can use sanitization and escaping functions that WordPress provides for example, you might need to do this: $sanitize_value = sanitize_text_field( $_POST[$this->unique] ); Here are the detail that you needed. https://codex.wordpress.org/Validating_Sanitizing_and_Escaping_User_Data

Woocommerce: block user removing cart item

Maybe there is a way of doing this, but briefly scanning through the relevant functions suggests that I basically have no control over the item being removed, or the call to wc_add_notice to mark is as removed. As such I ended up with the following fairly simple, but slightly ugly method: add_action(‘woocommerce_cart_item_removed’, function($key, $cart){ // … Read more

How to design WooCommerce-like admin tabs for plugin settings page?

I’ve figured it out how to do it on my custom admin page. You can use default wordpress classes and get variable trickery like so: <?php if( isset( $_GET[ ‘tab’ ] ) ) { $active_tab = $_GET[ ‘tab’ ]; } // end if ?> <h2 class=”nav-tab-wrapper”> <a href=”https://wordpress.stackexchange.com/questions/350785/?page=sandbox_theme_options&tab=display_options” class=”nav-tab <?php echo $active_tab == ‘display_options’ ? … Read more