/** * Visual Composer component. * * We're firing a bit late because we want to come after all * custom post types and taxonomies have been registered. * * @since 1.0.0 */ function mm_vc_posts() { // Only proceed if we're in the admin and Visual Composer is active. if (!is_admin()) { return; } if (!function_exists('vc_map')) { return; } $query_types = mm_get_query_types_for_vc('mm-posts'); $titles = mm_get_post_titles_for_vc('mm-posts'); $post_types = mm_get_post_types_for_vc('mm-posts'); $taxonomies = mm_get_taxonomies_for_vc('mm-posts'); $heading_levels = mm_get_heading_levels_for_vc('mm-posts'); $image_sizes = mm_get_image_sizes_for_vc('mm-posts'); $templates = mm_get_mm_posts_templates_for_vc('mm-posts'); // Grab post type values with capital letters for description and title fields. $post_types_formatted = mm_get_post_types('mm-posts '); // Modify the array of post titles for better formatting. $last = array_slice($post_types_formatted, -1); $first = join(', ', array_slice($post_types_formatted, 0, -1)); $both = array_filter(array_merge(array($first), $last), 'strlen'); $formatted_titles = join(' or ', $both); $fomatted_plural_titles = str_replace(array(',', ' or'), array('s,', 's or'), trim($formatted_titles)) . 's'; $title_heading = sprintf(__('Enter the Title(s) of Specific %s to Display', 'mm-components'), esc_html($fomatted_plural_titles)); $title_description = sprintf(__('Enter a specific %s to display', 'mm-components'), esc_html($formatted_titles)); vc_map(array('name' => __('Posts', 'mm-components'), 'base' => 'mm_posts', 'class' => '', 'icon' => MM_COMPONENTS_ASSETS_URL . 'component-icon.png', 'category' => __('Content', 'mm-components'), 'admin_enqueue_css' => MM_COMPONENTS_URL . '/css/post-titles-autocomplete.css', 'params' => array(array('type' => 'dropdown', 'heading' => __('Selection Type', 'mm-components'), 'param_name' => 'query_type', 'description' => __('Select posts by title or select posts of a specific type, taxonomy or term', 'mm-components'), 'value' => $query_types), array('type' => 'autocomplete', 'heading' => $title_heading, 'param_name' => 'post_ids', 'description' => $title_description, 'settings' => array('values' => $titles), 'dependency' => array('element' => 'query_type', 'value' => array('specific'))), array('type' => 'dropdown', 'heading' => __('Post Type', 'mm-components'), 'param_name' => 'post_type', 'description' => __('Select a post type to display multiple posts', 'mm-components'), 'value' => $post_types, 'dependency' => array('element' => 'query_type', 'value' => array('collection'))), array('type' => 'dropdown', 'heading' => __('Taxonomy', 'mm-components'), 'param_name' => 'taxonomy', 'description' => __('Select a taxonomy and term to only include posts that have the term', 'mm-components'), 'value' => $taxonomies, 'dependency' => array('element' => 'query_type', 'value' => array('collection'))), array('type' => 'textfield', 'heading' => __('Term', 'mm-components'), 'param_name' => 'term', 'description' => __('Specify a term in the selected taxonomy to only include posts that have the term', 'mm-components'), 'value' => '', 'dependency' => array('element' => 'query_type', 'value' => array('collection'))), array('type' => 'dropdown', 'heading' => __('Heading Level', 'mm-components'), 'param_name' => 'heading_level', 'description' => __('Select the post title heading level', 'mm-components'), 'value' => $heading_levels), array('type' => 'textfield', 'heading' => __('Posts Per Page', 'mm-components'), 'param_name' => 'per_page', 'description' => __('Specify the maximum number of posts to show at once', 'mm-components'), 'value' => '10'), array('type' => 'dropdown', 'heading' => __('Pagination', 'mm-components'), 'param_name' => 'pagination', 'value' => array(__('None', 'mm-components') => '', __('Next/Prev', 'mm-components') => 'next-prev', __('Page Numbers', 'mm-components') => 'page-numbers')), array('type' => 'checkbox', 'heading' => __('Show the Featured Image?', 'mm-components'), 'param_name' => 'show_featured_image', 'value' => array(__('Yes', 'mm-components') => 1)), array('type' => 'dropdown', 'heading' => __('Featured Image Size', 'mm-components'), 'param_name' => 'featured_image_size', 'value' => $image_sizes, 'dependency' => array('element' => 'show_featured_image', 'not_empty' => true)), array('type' => 'dropdown', 'heading' => __('Template', 'mm-components'), 'param_name' => 'template', 'description' => __('Select a custom template for custom output', 'mm-components'), 'value' => $templates), array('type' => 'checkbox', 'heading' => __('Use Masonry?', 'mm-components'), 'param_name' => 'masonry', 'value' => array(__('Yes', 'mm-components') => 1)), array('type' => 'checkbox', 'heading' => __('Link Title?', 'mm-components'), 'param_name' => 'link_title', 'std' => 1, 'value' => array(__('Yes', 'mm-components') => 1)), array('type' => 'checkbox', 'heading' => __('Show post info?', 'mm-components'), 'param_name' => 'show_post_info', 'description' => __('Default post info output includes post date and author.', 'mm-components'), 'value' => array(__('Yes', 'mm-components') => 1)), array('type' => 'checkbox', 'heading' => __('Show post meta?', 'mm-components'), 'param_name' => 'show_post_meta', 'description' => __('Default post meta output includes category and tag links.', 'mm-components'), 'value' => array(__('Yes', 'mm-components') => 1)), array('type' => 'checkbox', 'heading' => __('Use full post content?', 'mm-components'), 'param_name' => 'use_post_content', 'description' => __('By default the excerpt will be used. Check this to output the full post content.', 'mm-components'), 'value' => array(__('Yes', 'mm-components') => 1))))); // Because this component is registered on init we will call a custom action here // so that any templates adding extra params have a better hook to add them on. do_action('mm_posts_register_extra_vc_params'); }
/** * Visual Composer component. * * We're firing a bit late because we want to come after all * custom post types and taxonomies have been registered. * * @since 1.0.0 */ function mm_vc_posts() { // Only proceed if we're in the admin and Visual Composer is active. if (!is_admin()) { return; } if (!function_exists('vc_map')) { return; } $post_types = mm_get_post_types_for_vc('mm-posts'); $taxonomies = mm_get_taxonomies_for_vc('mm-posts'); $heading_levels = mm_get_heading_levels_for_vc('mm-posts'); $image_sizes = mm_get_image_sizes_for_vc('mm-posts'); $templates = mm_get_mm_posts_templates_for_vc('mm-posts'); vc_map(array('name' => __('Posts', 'mm-components'), 'base' => 'mm_posts', 'class' => '', 'icon' => MM_COMPONENTS_ASSETS_URL . 'component-icon.png', 'category' => __('Content', 'mm-components'), 'params' => array(array('type' => 'textfield', 'heading' => __('Post IDs', 'mm-components'), 'param_name' => 'post_ids', 'description' => __('Enter post IDs to display (separated by commas)', 'mm-components'), 'value' => ''), array('type' => 'dropdown', 'heading' => __('Post Type', 'mm-components'), 'param_name' => 'post_type', 'description' => __('Select a post type to display multiple posts', 'mm-components'), 'value' => $post_types), array('type' => 'dropdown', 'heading' => __('Taxonomy', 'mm-components'), 'param_name' => 'taxonomy', 'description' => __('Select a taxonomy and term to only include posts that have the term', 'mm-components'), 'value' => $taxonomies), array('type' => 'textfield', 'heading' => __('Term', 'mm-components'), 'param_name' => 'term', 'description' => __('Specify a term in the selected taxonomy to only include posts that have the term', 'mm-components'), 'value' => ''), array('type' => 'dropdown', 'heading' => __('Heading Level', 'mm-components'), 'param_name' => 'heading_level', 'description' => __('Select the post title heading level', 'mm-components'), 'value' => $heading_levels), array('type' => 'textfield', 'heading' => __('Posts Per Page', 'mm-components'), 'param_name' => 'per_page', 'description' => __('Specify the maximum number of posts to show at once', 'mm-components'), 'value' => '10'), array('type' => 'dropdown', 'heading' => __('Pagination', 'mm-components'), 'param_name' => 'pagination', 'value' => array(__('None', 'mm-components') => '', __('Next/Prev', 'mm-components') => 'next-prev', __('Page Numbers', 'mm-components') => 'page-numbers')), array('type' => 'checkbox', 'heading' => __('Show the Featured Image?', 'mm-components'), 'param_name' => 'show_featured_image', 'value' => array(__('Yes', 'mm-components') => 1)), array('type' => 'dropdown', 'heading' => __('Featured Image Size', 'mm-components'), 'param_name' => 'featured_image_size', 'value' => $image_sizes, 'dependency' => array('element' => 'show_featured_image', 'not_empty' => true)), array('type' => 'dropdown', 'heading' => __('Template', 'mm-components'), 'param_name' => 'template', 'description' => __('Select a custom template for custom output', 'mm-components'), 'value' => $templates), array('type' => 'checkbox', 'heading' => __('Use Masonry?', 'mm-components'), 'param_name' => 'masonry', 'value' => array(__('Yes', 'mm-components') => 1)), array('type' => 'checkbox', 'heading' => __('Link Title?', 'mm-components'), 'param_name' => 'link_title', 'std' => 1, 'value' => array(__('Yes', 'mm-components') => 1)), array('type' => 'checkbox', 'heading' => __('Show post info?', 'mm-components'), 'param_name' => 'show_post_info', 'description' => __('Default post info output includes post date and author.', 'mm-components'), 'value' => array(__('Yes', 'mm-components') => 1)), array('type' => 'checkbox', 'heading' => __('Show post meta?', 'mm-components'), 'param_name' => 'show_post_meta', 'description' => __('Default post meta output includes category and tag links.', 'mm-components'), 'value' => array(__('Yes', 'mm-components') => 1)), array('type' => 'checkbox', 'heading' => __('Use full post content?', 'mm-components'), 'param_name' => 'use_post_content', 'description' => __('By default the excerpt will be used. Check this to output the full post content.', 'mm-components'), 'value' => array(__('Yes', 'mm-components') => 1))))); // Because this component is registered on init we will call a custom action here // so that any templates adding extra params have a better hook to add them on. do_action('mm_posts_register_extra_vc_params'); }