/** * Setup registered custom meta boxes. * * @return void */ public static function add_meta_boxes() { // Filter custom meta boxes to be registered self::$boxes = apply_filters('wr_meta_box_register', self::$boxes); foreach (self::$boxes as $id => $box) { // Build required arguments $args = array($id, $box['title'], array(__CLASS__, "print_html_{$id}"), $box['post_type']); // Build optional arguments foreach (array('context', 'priority', 'callback_args') as $arg) { if (isset($box[$arg])) { $args[] = $box[$arg]; } } // Register meta box if (is_array($box['post_type'])) { foreach ($box['post_type'] as $post_type) { // Set post type $args[3] = $post_type; call_user_func_array('add_meta_box', $args); } } else { call_user_func_array('add_meta_box', $args); } } }
/** * Constructor. * * @return void */ public function __construct() { // Initialize necessary WR Library classes //Hook Meta Box WR_CF_Init_Meta_Box::hook(); //Hook Post Type WR_CF_Init_Post_Type::hook(); //Hook Assets WR_CF_Init_Assets::hook(); //register post type wordpress WR_Contactform_Helpers_Hook::register_post_type(); // Prepare admin pages if (defined('WP_ADMIN')) { add_action('admin_init', array('WR_CF_Gadget_Base', 'hook'), 100); // add languages add_action('admin_init', array(&$this, 'wr_contactform_languages')); // Register admin menu for IT Contactform Plugin WR_CF_Init_Admin_Menu::hook(); add_action('admin_menu', array('WR_Contactform_Helpers_Hook', 'wr_contactform_register_menus')); // add Filter apply assets add_filter('wr_cf_register_assets', array('WR_Contactform_Helpers_Contactform', 'apply_assets')); // add filter customize the messages add_filter('post_updated_messages', array('WR_Contactform_Helpers_Contactform', 'set_messages')); //Adding "embed form" button add_action('media_buttons', array('WR_Contactform_Helpers_Hook', 'add_form_button'), 20); add_action('restrict_manage_posts', array('WR_Contactform_Helpers_Hook', 'wr_contactform_submissions_filters')); // Load sample forms WR_Contactform_Helpers_Sample_Form::hook(); // Load necessary assets WR_Contactform_Helpers_Hook::load_assets(); } else { global $pagenow; //Hook WR Gadget Base WR_CF_Gadget_Base::hook(); //get short code add_filter('the_content', 'do_shortcode'); // add Filter apply assets add_filter('wr_cf_register_assets', array('WR_Contactform_Helpers_Contactform', 'apply_assets')); //render contactform in frontend add_shortcode('wr_contactform', array(&$this, 'contactform_to_frontend')); //get language contactform in frontend $this->wr_contactform_frontend_languages(); //set content preview add_filter('the_content', array(&$this, 'wr_contactform_front_end_preview')); } }
public static function wp_loaded() { // Filter custom post types to be registered self::$types = apply_filters('wr_post_type_register', self::$types); foreach (self::$types as $slug => $type) { // Register custom meta boxes with WordPress if (isset($type['meta_boxes'])) { foreach ($type['meta_boxes'] as $meta_box) { if (!isset($meta_box['id'])) { continue; } // Set post type if (!isset($meta_box['post_type'])) { $meta_box['post_type'] = $slug; } // Register custom meta box WR_CF_Init_Meta_Box::add($meta_box); } } // Register custom post type with WordPress register_post_type($slug, $type['options']); // Setup columns to show in the listing page if (isset($type['list_columns'])) { add_filter("manage_{$slug}_posts_columns", array(__CLASS__, "list_columns_{$slug}")); } // Setup content retrieval for custom columns add_action('manage_posts_custom_column', array(__CLASS__, "render_column_{$slug}"), 10, 2); // Setup sortable for custom post type columns if (isset($type['sortable_columns']) && $type['sortable_columns']) { add_filter("manage_edit-{$slug}_sortable_columns", array(__CLASS__, "sortable_columns_{$slug}")); } // Add custom post type to website's main feed if (isset($type['main_feed']) && $type['main_feed']) { add_filter('request', array(__CLASS__, "main_feed_{$slug}")); } } }