vendredi 4 décembre 2015

How to Integrate CMB2 WP Plugins to my custom developed plugins

I have a custom built plugins (http://ift.tt/1lAK9Xx) and its working fine .I want some advanced metabox types so i thought CMB2 Plugins will be the perfect one. But it has its own prefix suffix so kindly do let me know from where I can start Integrating? The CMB2 has an example file. http://ift.tt/1XEPPkF.

My current plugin file

    // Register Custom Post Type
        function CNSLounge() {
            register_post_type('CNSLounge', array(
            'labels' => array(
            'name'                  => _x( 'Authorz', 'Post Type General Name', 'text_domain' ),
            'singular_name'         => _x( 'Authorz', 'Post Type Singular Name', 'text_domain' ),
            'menu_name'             => __( 'Authorz', 'text_domain' ),
            'name_admin_bar'        => __( 'Authorz', 'text_domain' ),
            'parent_item_colon'     => __( 'Parent Item:', 'text_domain' ),
            'all_items'             => __( 'All Authors', 'text_domain' ),
            'add_new_item'          => __( 'Add New Authorz', 'text_domain' ),
            'add_new'               => __( 'Add Authorz', 'text_domain' ),
            'new_item'              => __( 'New Authorz', 'text_domain' ),
            'edit_item'             => __( 'Edit Authorz', 'text_domain' ),
            'update_item'           => __( 'Update Authorz', 'text_domain' ),
            'view_item'             => __( 'View Authorz', 'text_domain' ),
            'search_items'          => __( 'Search Authorz', 'text_domain' ),
            'not_found'             => __( 'Not found', 'text_domain' ),
            'not_found_in_trash'    => __( 'Not found in Trash', 'text_domain' ),
            'items_list'            => __( 'Authorz list', 'text_domain' ),
            'items_list_navigation' => __( 'Items list navigation', 'text_domain' ),
            'filter_items_list'     => __( 'Filter items list', 'text_domain' ),
                 ),
                'public' => true,
                'menu_position' => 1,
                'supports' => array('title','editor','revisions', 'page-attributes', 'post-formats'),
                'taxonomies'  => array( 'category', 'post_tag' ),
                'menu_icon' => plugins_url('images/image.png', __FILE__),
                'rewrite'   => array( 'slug' => 'CNSLounge' ),
                'has_archive' => true,
                'show_in_admin_bar'     => true,
                'show_in_nav_menus'     => true,
                'can_export'            => true,
                'has_archive'           => false,       
                'exclude_from_search'   => false,
                'publicly_queryable'    => true,
                'capability_type'       => 'post',
                ));

                register_post_type( 'post_type', $args );

            }
            add_action( 'init', 'CNSLounge', 0 );

        class Rational_Meta_Box {
            private $screens = array(
                'CNSLounge',
            );
            private $fields = array(
                array(
                    'id' => 'authorz-name',
                    'label' => 'Authorz Name',
                    'type' => 'text',
                    'required' => 1,
                    'placeholder' => 'Author Name',
                    'maxlength' => 120, 
                ),
            array(
                'id' => 'author-photo',
                'label' => 'Author Photo',
                'type' => 'media',
                'required' => 0,
                'return_format' => 'array',
                'preview_size' => 'thumbnail',
                'library' => 'all',
                'min_width' => '',
                'min_height' => '',
                'min_size' => '',
                'max_width' => '',
                'max_height' => '',
                'max_size' => '',
                'mime_types' => '',
            ),
  ),
        );


    public function __construct() {

        add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) );
        add_action( 'admin_footer', array( $this, 'admin_footer' ) );
        add_action( 'save_post', array( $this, 'save_post' ) );
    }



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire