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

Registering and using actions which return results in a Plugin class

Some actions hooks need to be fired on specific events. Try this code: class SpektrixPlugin { public function __construct(){ add_action(‘init’, array(&$this, ‘init’)); } public function spektrix_list_events($getPrices = FALSE) { $api = new SpektrixApiClient(); return $api->getAllEvents($getPrices); } public function init(){ add_action( ‘spektrix_list_events’, array ( $this, ‘spektrix_list_events’ )); } } $SpektrixEvents = new SpektrixPlugin(); I’ve tested this … Read more

Instantiate class to be available to all plugin functions

Ryan McCue had a nice idea for his plugin Hopper: add a callback for a custom filter to return the current instance. Sample code for the plugin: class Plugin_Class { public function __construct() { add_filter( ‘get_plugin_class’, array ( $this, ‘provide_instance’ ) ); } function provide_instance() { return $this; } } In a theme or a … Read more