?> </h2> <?php echo JM_TC_Tabs::admin_tabs(); ?> <?php /** * Fields for admin page multi-options * @return array */ function jm_tc_multi_author_options() { $plugin_options = array('id' => 'jm_tc', 'show_on' => array('key' => 'options-page', 'value' => array('jm_tc_multi_author')), 'show_names' => true, 'fields' => array(array('name' => __('Add a field in profiles for author', JM_TC_TEXTDOMAIN), 'desc' => __('This would add a field in profiles if user can publish posts. In this case his Twitter username will be set as meta creator.', JM_TC_TEXTDOMAIN), 'id' => 'twitterProfile', 'type' => 'select', 'options' => array('no' => __('No', JM_TC_TEXTDOMAIN), 'yes' => __('Yes', JM_TC_TEXTDOMAIN))), array('name' => __('Meta key Twitter', JM_TC_TEXTDOMAIN), 'desc' => __('If the above option is set to "no", just modify user meta key associated with Twitter Account in profiles to get Twitter usernames from your own fields:', JM_TC_TEXTDOMAIN), 'id' => 'twitterUsernameKey', 'type' => 'text_medium'))); return $plugin_options; } ?> <?php cmb_metabox_form(jm_tc_multi_author_options(), JM_TC_Admin::key()); ?> <div class="doc-valid"> <?php echo JM_TC_Admin::docu_links(0); ?> </div> </div>
/** * Add fields to option page * @since 5.0 * @return $plugin_options */ public static function option_fields() { // Only need to initiate the array once per page-load if (!empty(self::$plugin_options)) { return self::$plugin_options; } self::$plugin_options = array('id' => self::$key, 'show_on' => array('key' => 'options-page', 'value' => array(self::$key)), 'show_names' => true, 'fields' => array(array('name' => __('Creator (twitter username)', JM_TC_TEXTDOMAIN), 'desc' => __('Who is the creator of content?', JM_TC_TEXTDOMAIN), 'id' => 'twitterCreator', 'type' => 'text_medium'), array('name' => __('Site (twitter username)', JM_TC_TEXTDOMAIN), 'desc' => __('Who is the Owner of the Website? (could be a trademark)', 'jm-tc'), 'id' => 'twitterSite', 'type' => 'text_medium'), array('name' => __('Card Types', JM_TC_TEXTDOMAIN), 'desc' => __('Choose what type of card you want to use', JM_TC_TEXTDOMAIN), 'id' => 'twitterCardType', 'type' => 'select', 'options' => array('summary' => __('Summary', JM_TC_TEXTDOMAIN), 'summary_large_image' => __('Summary below Large Image', JM_TC_TEXTDOMAIN), 'photo' => __('Photo', JM_TC_TEXTDOMAIN), 'app' => __('Application', JM_TC_TEXTDOMAIN))), array('name' => __('Open Graph', JM_TC_TEXTDOMAIN), 'desc' => __('Open Graph/SEO', JM_TC_TEXTDOMAIN), 'id' => 'twitterCardOg', 'type' => 'select', 'options' => array('no' => __('no', JM_TC_TEXTDOMAIN), 'yes' => __('yes', JM_TC_TEXTDOMAIN))), array('name' => __('Excerpt'), 'desc' => __('Excerpt as meta desc?', JM_TC_TEXTDOMAIN), 'id' => 'twitterCardExcerpt', 'type' => 'select', 'options' => array('no' => __('no', JM_TC_TEXTDOMAIN), 'yes' => __('yes', JM_TC_TEXTDOMAIN))))); return self::$plugin_options; }
/** * Meta box * @param array $meta_boxes * @return array|void */ function register_meta_boxes(array $meta_boxes) { if (!class_exists('cmb_Meta_Box')) { return; } $post_types = get_post_types(); // 1st meta box $meta_boxes['jm_tc_metabox'] = array('id' => 'jm_tc_metabox', 'title' => __('Twitter Cards', JM_TC_TEXTDOMAIN), 'pages' => $post_types, 'context' => 'advanced', 'priority' => 'high', 'show_on' => array('alt_value' => self::on_off('post'), 'alt_key' => 'exclude_post'), 'fields' => array(array('type' => 'title', 'name' => __('Documentation', JM_TC_TEXTDOMAIN), 'id' => 'documentation_title', 'desc' => JM_TC_Admin::docu_links(1)), array('type' => 'title', 'name' => __('Preview', JM_TC_TEXTDOMAIN), 'id' => 'preview_title'), array('type' => 'title', 'name' => __('Card type', JM_TC_TEXTDOMAIN), 'id' => 'type_title', 'desc' => ''), array('name' => __('Card Type', JM_TC_TEXTDOMAIN), 'id' => 'twitterCardType', 'type' => 'select', 'options' => array('summary' => __('Summary', JM_TC_TEXTDOMAIN), 'summary_large_image' => __('Summary below Large Image', JM_TC_TEXTDOMAIN), 'photo' => __('Photo', JM_TC_TEXTDOMAIN), 'product' => __('Product', JM_TC_TEXTDOMAIN), 'player' => __('Player', JM_TC_TEXTDOMAIN), 'gallery' => __('Gallery', JM_TC_TEXTDOMAIN), 'app' => __('Application', JM_TC_TEXTDOMAIN)), 'std' => $this->opts['twitterCardType']), array('type' => 'title', 'name' => __('Image', JM_TC_TEXTDOMAIN), 'id' => 'image_title'), array('id' => 'cardImage', 'name' => __('Set another source as twitter image (enter URL)', JM_TC_TEXTDOMAIN), 'type' => 'file'), array('type' => 'title', 'name' => __('Product Cards', JM_TC_TEXTDOMAIN), 'id' => 'product_title', 'desc' => ''), array('name' => __('Enter the first key data for product', JM_TC_TEXTDOMAIN), 'id' => "cardData1", 'type' => 'text_medium'), array('name' => __('Enter the first key label for product', JM_TC_TEXTDOMAIN), 'id' => "cardLabel1", 'type' => 'text_medium'), array('name' => __('Enter the second key data for product', JM_TC_TEXTDOMAIN), 'id' => "cardData2", 'type' => 'text_medium'), array('name' => __('Enter the second key label for product', JM_TC_TEXTDOMAIN), 'id' => "cardLabel2", 'type' => 'text_medium'), array('type' => 'title', 'name' => __('Gallery Cards', JM_TC_TEXTDOMAIN), 'id' => 'gallery_title', 'desc' => __('Just use shortcode <strong>[gallery]</strong> and include at least 4 images.', JM_TC_TEXTDOMAIN)), array('type' => 'title', 'name' => __('Player Cards', JM_TC_TEXTDOMAIN), 'id' => 'player_title'), array('id' => 'cardPlayer', 'name' => __('URL of iFrame player (MUST BE HTTPS)', JM_TC_TEXTDOMAIN), 'type' => 'text_url_https'), array('name' => __('Player width', JM_TC_TEXTDOMAIN), 'id' => "cardPlayerWidth", 'type' => 'text_number', 'desc' => __('When setting this, make sure player dimension and image dimensions are exactly the same! Image MUST BE greater than 68,600 pixels (a 262x262 square image, or a 350x196 16:9 image)', JM_TC_TEXTDOMAIN), 'min' => 262, 'max' => 1000), array('name' => __('Player height', JM_TC_TEXTDOMAIN), 'id' => "cardPlayerHeight", 'type' => 'text_number', 'min' => 196, 'max' => 1000), array('id' => 'cardPlayerStream', 'name' => __('URL of iFrame player (MUST BE HTTPS)', JM_TC_TEXTDOMAIN) . '[STREAM]', 'type' => 'text_url_https', 'desc' => __('If you do not understand what is the following field then it is probably a bad idea to fulfill it!', JM_TC_TEXTDOMAIN)))); $meta_boxes['twitter_creator'] = array('id' => 'twitter_creator', 'title' => __('Twitter Creator', JM_TC_TEXTDOMAIN), 'pages' => array('user'), 'show_names' => true, 'show_on' => array('alt_value' => self::on_off('profile'), 'alt_key' => 'exclude_profile'), 'fields' => array(array('name' => __('Twitter Creator', JM_TC_TEXTDOMAIN), 'desc' => __("Enter your Twitter Account (without @)", JM_TC_TEXTDOMAIN), 'id' => 'jm_tc_twitter', 'type' => 'text_medium', 'on_front' => true))); $meta_boxes['twitter_image_size'] = array('id' => 'twitter_image_size', 'title' => __('Twitter Image Size', JM_TC_TEXTDOMAIN), 'pages' => $post_types, 'context' => 'side', 'priority' => 'low', 'show_names' => true, 'show_on' => array('alt_value' => self::on_off('post'), 'alt_key' => 'exclude_post'), 'fields' => array(array('name' => __('Image width', JM_TC_TEXTDOMAIN), 'id' => "cardImageWidth", 'type' => 'text_number', 'min' => 280, 'max' => 1000, 'std' => $this->opts['twitterImageWidth']), array('name' => __('Image height', JM_TC_TEXTDOMAIN), 'id' => "cardImageHeight", 'type' => 'text_number', 'min' => 150, 'max' => 1000, 'std' => $this->opts['twitterImageHeight']), array('id' => 'twitter_featured_size', 'type' => 'title', 'name' => __('File size')))); return $meta_boxes; }