Example #1
1
 /**
  *	Function called on plugin initialisation allowing to declare the new types needed by our plugin
  *	@see wpshop_products::create_wpshop_products_type();
  *	@see wpshop_categories::create_product_categories();
  */
 public static function add_new_wp_type()
 {
     $wpshop_shop_type = get_option('wpshop_shop_type', WPSHOP_DEFAULT_SHOP_TYPE);
     /*	Creation du type d'element Entité pour wpshop	*/
     wpshop_entities::create_wpshop_entities_type();
     add_action('add_meta_boxes', array('wpshop_entities', 'add_meta_boxes'));
     add_action('save_post', array('wpshop_entities', 'save_entity_type_custom_informations'));
     add_filter('manage_posts_columns', array('wpshop_entities', 'custom_columns_header'), 10, 2);
     add_filter('manage_posts_custom_column', array('wpshop_entities', 'custom_columns_content'), 10, 2);
     // 			add_action('quick_edit_custom_box', array('wpshop_attributes', 'quick_edit'), 10, 2);
     add_action('bulk_edit_custom_box', array('wpshop_attributes', 'bulk_edit'), 10, 2);
     /*	Creation des types personnalisé à partir des entités créées	*/
     wpshop_entities::create_wpshop_entities_custom_type();
     /*	Add wpshop product type and add a new meta_bow into product creation/edition interface for regrouping title and editor in order to sort interface	*/
     wpshop_products::create_wpshop_products_type();
     add_action('add_meta_boxes', array('wpshop_products', 'add_meta_boxes'));
     add_filter('post_link', array('wpshop_products', 'set_product_permalink'), 10, 3);
     add_filter('post_type_link', array('wpshop_products', 'set_product_permalink'), 10, 3);
     add_action('pre_get_posts', array('wpshop_products', 'set_product_request_by_name'));
     $product_class = new wpshop_products();
     add_action('save_post', array($product_class, 'save_product_custom_informations'));
     /*	Add wpshop product category term	*/
     wpshop_categories::create_product_categories();
     /*	Add wpshop message term	*/
     if ($wpshop_shop_type == 'sale') {
         /*	Add wpshop orders term	*/
         wpshop_orders::create_orders_type();
         add_action('add_meta_boxes', array('wpshop_orders', 'add_meta_boxes'));
         add_action('manage_' . WPSHOP_NEWTYPE_IDENTIFIER_ORDER . '_posts_custom_column', array('wpshop_orders', 'orders_custom_columns'), 10, 2);
         add_filter('manage_edit-' . WPSHOP_NEWTYPE_IDENTIFIER_ORDER . '_columns', array('wpshop_orders', 'orders_edit_columns'));
         add_action('restrict_manage_posts', array('wpshop_orders', 'list_table_filters'));
         add_filter('parse_query', array('wpshop_orders', 'list_table_filter_parse_query'));
     }
     $args = array('public' => true, '_builtin' => false);
     $output = 'objects';
     // names or objects, note names is the default
     $operator = 'or';
     // 'and' or 'or'
     $wp_types_original = get_post_types($args, $output, $operator);
     foreach ($wp_types_original as $type => $type_definition) {
         $wp_types[$type] = $type_definition->labels->name;
     }
     $to_exclude = unserialize(WPSHOP_INTERNAL_TYPES_TO_EXCLUDE);
     if (!empty($to_exclude)) {
         foreach ($to_exclude as $excluded_type) {
             if (isset($wp_types[$excluded_type])) {
                 unset($wp_types[$excluded_type]);
             }
         }
     }
     DEFINE('WPSHOP_INTERNAL_TYPES', serialize(array_merge($wp_types, array('users' => __('Users', 'wpshop')))));
 }