Example #1
0
/**
 * Load plugin
 *
 * Load the text domain and hook up the CPTs
 *
 * @since 1.0.0
 */
function appica_core_load()
{
    // Load text domain
    load_plugin_textdomain('appica', false, dirname(plugin_basename(__FILE__)) . '/languages');
    // Register the auto loader function
    spl_autoload_register('appica_loader');
    // Let's add some CPTs
    Appica_CPT_News::init();
    Appica_CPT_Team::init();
    Appica_CPT_Team_Alt::init();
    Appica_CPT_Gallery::init();
    Appica_CPT_Pricings::init();
    Appica_CPT_Timeline::init();
    Appica_CPT_Portfolio::init();
    Appica_CPT_App_Gallery::init();
    Appica_CPT_Testimonials::init();
    Appica_CPT_Gadget_Slideshow::init();
}
 /**
  * Save post metadata when a post of {@see $this->post_type} is saved.
  *
  * @since 1.0.0
  *
  * @param int     $post_id The ID of the post.
  * @param WP_Post $post    Post object
  *
  * @return void
  */
 public function save_meta_boxes($post_id, $post)
 {
     if ($this->post_type !== $post->post_type) {
         return;
     }
     // If something wrong with nonce
     if (!array_key_exists($this->nonce_field, $_POST) || !wp_verify_nonce($_POST[$this->nonce_field], $this->nonce)) {
         return;
     }
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return;
     }
     if (!current_user_can('edit_post', $post_id)) {
         return;
     }
     // Update price meta box
     if (array_key_exists($this->mb_price_name, $_POST)) {
         $meta_box_value = array_map(array('Appica_CPT_Pricings', 'sanitize_plans'), $_POST[$this->mb_price_name]);
         update_post_meta($post_id, $this->mb_price_name, $meta_box_value);
         unset($meta_box_value);
     }
     // Update button meta box
     if (array_key_exists($this->mb_button_name, $_POST)) {
         $meta_box_value = Appica_CPT_Pricings::sanitize_button($_POST[$this->mb_button_name]);
         update_post_meta($post_id, $this->mb_button_name, $meta_box_value);
         unset($meta_box_value);
     }
     // Update icon meta box
     if (array_key_exists($this->mb_icon_name, $_POST)) {
         $meta_box_value = sanitize_text_field($_POST[$this->mb_icon_name]);
         update_post_meta($post_id, $this->mb_icon_name, $meta_box_value);
         unset($meta_box_value);
     }
 }