wp_specialchars and wp_specialchars_decode in a shortcode plugin

The Codex description of these two functions: wp_specialchars: Converts a number of special characters into their HTML entities. Specifically deals with: &, <, >, “, and ‘. wp_specialchars_decode: Converts a number of HTML entities into their special characters. According to http://codex.wordpress.org/Function_Reference/wp_specialchars This function is deprecated as of WordPress 2.8.0. Please use esc_html instead. You don’t … Read more

nonces in custom oop plugin

check_admin_referer is a pluggable function which means it is defined after plugins are loaded so call your constructor or instantiate the object after or using plugins_loaded action hook. ex: class MyClass{ function __construct(){ if( isset($_POST[‘my_nonce_field’]) && check_admin_referer(‘my_nonce_action’, ‘my_nonce_field’)) $this->update_item(); } } add_action(‘plugins_loaded’,’newobj’); function newobj(){ $myclass = new MyClass; }

Adding a custom line of text to php code

In the insert_posts function, before the line $post_id = wp_insert_post( $post ); add the following (and suit to your needs): Link to Twitter User Page $post[‘post_content’] .= ‘<a href=”http://twitter.com/__USERNAME__”>’ .’Follow me on Twitter’ .'</a>’; and/or Link to Twitter Status $post[‘post_content’] .= ‘<a href=”‘.$post[‘twitter_permalink’].'”>’ .’View this post on Twitter’ .'</a>’;

Do extra plugin files get deleted during an upgrade?

Yes, the entire old directory will be deleted. So store files in the upload directory and other data in the database to keep all changes. From class Plugin_Upgrader: //Hooked to upgrade_clear_destination function delete_old_plugin($removed, $local_destination, $remote_destination, $plugin) { global $wp_filesystem; if ( is_wp_error($removed) ) return $removed; //Pass errors through. $plugin = isset($plugin[‘plugin’]) ? $plugin[‘plugin’] : ”; … Read more

WordPress plugin installation

Add this code and replace yourpagename with the your page slug on which u want this filter to execute function my_name( $content ) { global $post; if ( $post->post_name == ‘yourpagename’ ) { return $content; } } add_filter( ‘the_content’, ‘my_name’ );

how to show database content in wordpress post

For the sake of the example, I’ll assume you to have copied the relevant Table to the WordPress DB, to have named it wp_my_xtra_table and it to contain 3 columns (id,num_val,str_val). function wpse106832_shortcode_demo( $atts ) { global $wpdb; extract( shortcode_atts( array( ‘id’ => 1 ), $atts ) ); $table_row = $wpdb->get_row( ‘SELECT * ‘ . … Read more