WordPress functions give fatal error in included php file

You’re POSTing the form to the validate.php file directly, so the WordPress code isn’t loaded. Instead you need to POST the form to the current URL or the home_url or something like that, and then have the plugin intercept the data and act accordingly, so that the WordPress code is loaded before you use its … Read more

Facebook plugin shows existing comments

I don’t use this plugin, but it looks like this comment template is loaded with add_filter( ‘comments_template’, array( ‘Facebook_Comments’, ‘comments_template’ ) ); The simplified structure of this comment template looks like: if ( have_comments() ) : // … wp_list_comments( $_comment_options ); // … endif; $_facebook_comments = Facebook_Comments::comments_box(); if ( $_facebook_comments ) { do_action( ‘facebook_comment_form_before’ ); … Read more

Serialize data for wp options

To store Data use this Code : save the serialize values $title=”Your Title Value”; $message=”Your message HTML..”; $image=”http://www.domain.com/yourimage.jpg”; $notice_data = array(‘title’ => $title, ‘message’ => $message, ‘image’ => $image ); if(get_option(‘notice_data’) === FALSE){ add_option(‘notice_data’, $notice_data ); }else{ update_option(‘notice_data’, $notice_data ); } Now you can get the serialize values and use in your code $notice_data = … Read more

Average Account Age

WordPress records when a user was registered in the $wpdb->users (usually wp_users) table in the column user_registered. So you can use that to calculate the average account age. There’s no internal function for this, so you’ll have to use $wpdb directly. This stackoverflow answer has some good info about calculating the average of a series … Read more

RW Meta Box ,Problem setting post title

Here’s a solution that take’s advantage of Rilwis’ action hook… so you can profit from his nonce checking without needing to add your own. add_action(‘rwmb_after_save_post’, ‘post_updated’); function post_updated($post_id) { // verify post is not a revision & not an autosave if (!wp_is_post_revision($post_id) && !(defined(‘DOING_AUTOSAVE’) && DOING_AUTOSAVE)) { global $prefix; $prefix . ‘name’; // check that … Read more

Disable multisite-wide plugins on specific sites

Multisite-wide active plugins are stored in the active_sitewide_plugins site option. We can hook into this option and return an empty array (no plugins are active). This snippet should be installed as a Must-Use Plugin. <?php /** * Plugin Name: Disable Sitewide Plugins * Author: Shea Bunge * Author URI: http://bungeshea.com * Version: 0.1 */ global … Read more