/**
 * Adds grid item post type into the list of excluded post types for VC editors.
 *
 * @param array $list
 *
 * @since 4.4
 * @deprecated
 * @return array
 */
function vc_grid_item_vc_settings_exclude(array $list)
{
    require_once vc_path_dir('PARAMS_DIR', 'vc_grid_item/editor/class-vc-grid-item-editor.php');
    $vc_grid_item_editor = new Vc_Grid_Item_Editor();
    $list[] = $vc_grid_item_editor->postType();
    return $list;
}
Пример #2
0
 function om_wpb_remove_grid()
 {
     if (defined('VC_PAGE_MAIN_SLUG') && class_exists('Vc_Grid_Item_Editor')) {
         remove_submenu_page(VC_PAGE_MAIN_SLUG, 'edit.php?post_type=' . rawurlencode(Vc_Grid_Item_Editor::postType()));
         global $wp_post_types;
         if (isset($wp_post_types['vc_grid_item'])) {
             unset($wp_post_types['vc_grid_item']);
         }
     }
 }
 /**
  * Generates list of shortcodes only for Grid element.
  *
  * This method parses the list of mapped shortcodes and creates categories list for users.
  * Also it checks is 'is_grid_item_element' attribute true.
  *
  * @static
  *
  * @param bool $force - force data generation even data already generated.
  */
 protected static function generateGitemUserData($force = false)
 {
     if (!$force && self::$gitem_user_sc !== false && self::$gitem_user_categories !== false) {
         return;
     }
     // $settings = self::getSettings();
     self::$gitem_user_sc = self::$gitem_user_categories = self::$gitem_user_sorted_sc = array();
     $deprecated = 'deprecated';
     $add_deprecated = false;
     if (is_array(self::$sc) && !empty(self::$sc)) {
         foreach (self::$sc as $name => $values) {
             if (isset($values['post_type']) && Vc_Grid_Item_Editor::postType() === $values['post_type']) {
                 if (!isset($values['content_element']) || $values['content_element'] === true) {
                     $categories = isset($values['category']) ? $values['category'] : '_other_category_';
                     $values['_category_ids'] = array();
                     if (isset($values['deprecated']) && $values['deprecated'] !== false) {
                         $add_deprecated = true;
                         $values['_category_ids'][] = $deprecated;
                     } else {
                         if (is_array($categories) && !empty($categories)) {
                             foreach ($categories as $c) {
                                 if (array_search($c, self::$gitem_user_categories) === false) {
                                     self::$gitem_user_categories[] = $c;
                                 }
                                 $values['_category_ids'][] = md5($c);
                                 // array_search($category, self::$categories);
                             }
                         } else {
                             if (array_search($categories, self::$gitem_user_categories) === false) {
                                 self::$gitem_user_categories[] = $categories;
                             }
                             $values['_category_ids'][] = md5($categories);
                             // array_search($category, self::$categories);
                         }
                     }
                 }
                 self::$gitem_user_sc[$name] = $values;
                 self::$gitem_user_sorted_sc[] = $values;
             }
         }
     }
     if ($add_deprecated) {
         self::$gitem_user_categories[] = $deprecated;
     }
     $sort = new Vc_Sort(self::$gitem_user_sorted_sc);
     self::$gitem_user_sorted_sc = $sort->sortByKey();
 }
Пример #4
0
function vc_vc_grid_item_form_field($settings, $value)
{
    require_once vc_path_dir('PARAMS_DIR', 'vc_grid_item/editor/class-vc-grid-item-editor.php');
    require_once vc_path_dir('PARAMS_DIR', 'vc_grid_item/class-vc-grid-item.php');
    $output = '<div data-vc-grid-element="container">' . '<select data-vc-grid-element="value" type="hidden" name="' . $settings['param_name'] . '" class="wpb_vc_param_value wpb-select ' . $settings['param_name'] . ' ' . $settings['type'] . '_field" ' . '>';
    $vc_grid_item_templates = Vc_Grid_Item::predefinedTemplates();
    if (is_array($vc_grid_item_templates)) {
        foreach ($vc_grid_item_templates as $key => $data) {
            $output .= '<option data-vc-link="' . esc_url(admin_url('post-new.php?post_type=vc_grid_item&vc_gitem_template=' . $key)) . '" value="' . $key . '"' . ($key === $value ? ' selected="true"' : '') . '>' . esc_html($data['name']) . '</option>';
        }
    }
    $grid_item_posts = get_posts(array('posts_per_page' => '-1', 'orderby' => 'post_title', 'post_type' => Vc_Grid_Item_Editor::postType()));
    foreach ($grid_item_posts as $post) {
        $output .= '<option  data-vc-link="' . esc_url(get_edit_post_link($post->ID)) . '"value="' . $post->ID . '"' . ((string) $post->ID === $value ? ' selected="true"' : '') . '>' . esc_html($post->post_title) . '</option>';
    }
    $output .= '</select></div>';
    return $output;
}
Пример #5
0
 function vcex_gitem_post_video_add_grid_shortcodes($shortcodes)
 {
     $shortcodes['vcex_gitem_post_video'] = array('name' => esc_html__('Post Video', 'total'), 'base' => 'vcex_gitem_post_video', 'icon' => 'vcex-gitem-post-video vcex-icon fa fa-film', 'category' => WPEX_THEME_BRANDING, 'description' => esc_html__('Featured post video.', 'total'), 'post_type' => Vc_Grid_Item_Editor::postType(), 'params' => array(array('type' => 'textfield', 'heading' => esc_html__('Post ID', 'total'), 'param_name' => 'post_id', 'description' => esc_html__('Leave empty to use current post or post in loop.', 'total')), array('type' => 'css_editor', 'heading' => esc_html__('CSS', 'total'), 'param_name' => 'css')));
     return $shortcodes;
 }
/**
 * Highlight Vc submenu.
 * @since 4.5
 */
function vc_gitem_menu_highlight()
{
    global $parent_file, $submenu_file, $post_type;
    require_once vc_path_dir('PARAMS_DIR', 'vc_grid_item/editor/class-vc-grid-item-editor.php');
    if ($post_type === Vc_Grid_Item_Editor::postType()) {
        $parent_file = VC_PAGE_MAIN_SLUG;
        $submenu_file = 'edit.php?post_type=' . rawurlencode(Vc_Grid_Item_Editor::postType());
    }
}
Пример #7
0
<?php

return array('vc_gitem_wocommerce' => array('name' => __('WooCommerce field', 'js_composer'), 'base' => 'vc_gitem_wocommerce', 'icon' => 'icon-wpb-woocommerce', 'category' => __('Content', 'js_composer'), 'description' => __('Woocommerce', 'js_composer'), 'php_class_name' => 'Vc_Gitem_Woocommerce_Shortcode', 'params' => array(array('type' => 'dropdown', 'heading' => __('Content type', 'js_composer'), 'param_name' => 'post_type', 'value' => array(__('Product', 'js_composer') => 'product', __('Order', 'js_composer') => 'order'), 'description' => __('Select Woo Commerce post type.', 'js_composer')), array('type' => 'dropdown', 'heading' => __('Product field name', 'js_composer'), 'param_name' => 'product_field_key', 'value' => Vc_Vendor_Woocommerce::getProductsFieldsList(), 'dependency' => array('element' => 'post_type', 'value' => array('product')), 'description' => __('Select field from product.', 'js_composer')), array('type' => 'textfield', 'heading' => __('Product custom key', 'js_composer'), 'param_name' => 'product_custom_key', 'description' => __('Enter custom key.', 'js_composer'), 'dependency' => array('element' => 'product_field_key', 'value' => array('_custom_'))), array('type' => 'dropdown', 'heading' => __('Order fields', 'js_composer'), 'param_name' => 'order_field_key', 'value' => Vc_Vendor_Woocommerce::getOrderFieldsList(), 'dependency' => array('element' => 'post_type', 'value' => array('order')), 'description' => __('Select field from order.', 'js_composer')), array('type' => 'textfield', 'heading' => __('Order custom key', 'js_composer'), 'param_name' => 'order_custom_key', 'dependency' => array('element' => 'order_field_key', 'value' => array('_custom_')), 'description' => __('Enter custom key.', 'js_composer')), array('type' => 'checkbox', 'heading' => __('Show label', 'js_composer'), 'param_name' => 'show_label', 'value' => array(__('Yes', 'js_composer') => 'yes'), 'description' => __('Enter label to display before key value.', 'js_composer')), array('type' => 'dropdown', 'heading' => __('Align', 'js_composer'), 'param_name' => 'align', 'value' => array(__('left', 'js_composer') => 'left', __('right', 'js_composer') => 'right', __('center', 'js_composer') => 'center', __('justify', 'js_composer') => 'justify'), 'description' => __('Select alignment.', 'js_composer')), array('type' => 'textfield', 'heading' => __('Extra class name', 'js_composer'), 'param_name' => 'el_class', 'description' => __('Style particular content element differently - add a class name and refer to it in custom CSS.', 'js_composer'))), 'post_type' => Vc_Grid_Item_Editor::postType()));
Пример #8
0
$shortcode_vc_btn = WPBMap::getShortCode('vc_btn');
if (is_array($shortcode_vc_btn) && isset($shortcode_vc_btn['base'])) {
    $list['vc_btn'] = $shortcode_vc_btn;
    $list['vc_btn']['post_type'] = Vc_Grid_Item_Editor::postType();
    unset($list['vc_btn']['params'][1]);
}
$shortcode_vc_custom_heading = WPBMap::getShortCode('vc_custom_heading');
if (is_array($shortcode_vc_custom_heading) && isset($shortcode_vc_custom_heading['base'])) {
    $list['vc_custom_heading'] = $shortcode_vc_custom_heading;
    $list['vc_custom_heading']['post_type'] = Vc_Grid_Item_Editor::postType();
    unset($list['vc_custom_heading']['params'][1]);
}
$shortcode_vc_empty_space = WPBMap::getShortCode('vc_empty_space');
if (is_array($shortcode_vc_empty_space) && isset($shortcode_vc_empty_space['base'])) {
    $list['vc_empty_space'] = $shortcode_vc_empty_space;
    $list['vc_empty_space']['post_type'] = Vc_Grid_Item_Editor::postType();
}
foreach (array('vc_icon', 'vc_button2', 'vc_btn', 'vc_custom_heading', 'vc_single_image') as $key) {
    if (isset($list[$key])) {
        if (!isset($list[$key]['params'])) {
            $list[$key]['params'] = array();
        }
        if ('vc_button2' === $key) {
            // change settings for vc_link in dropdown. Add dependency.
            $list[$key]['params'][0] = array('type' => 'vc_link', 'heading' => __('URL (Link)', 'js_composer'), 'param_name' => 'url', 'dependency' => array('element' => 'link', 'value' => array('custom')), 'description' => __('Add custom link.', 'js_composer'));
        } else {
            array_unshift($list[$key]['params'], array('type' => 'vc_link', 'heading' => __('URL (Link)', 'js_composer'), 'param_name' => 'url', 'dependency' => array('element' => 'link', 'value' => array('custom')), 'description' => __('Add custom link.', 'js_composer')));
        }
        // Add link dropdown
        array_unshift($list[$key]['params'], $vc_gitem_add_link_param);
    }
<?php

if (!defined('ABSPATH')) {
    die('-1');
}
$groups = function_exists('acf_get_field_groups') ? acf_get_field_groups() : apply_filters('acf/get_field_groups', array());
$groups_param_values = $fields_params = array();
foreach ($groups as $group) {
    $id = isset($group['id']) ? 'id' : (isset($group['ID']) ? 'ID' : 'id');
    $groups_param_values[$group['title']] = $group[$id];
    $fields = function_exists('acf_get_fields') ? acf_get_fields($group[$id]) : apply_filters('acf/field_group/get_fields', array(), $group[$id]);
    $fields_param_value = array();
    foreach ($fields as $field) {
        $fields_param_value[$field['label']] = (string) $field['key'];
    }
    $fields_params[] = array('type' => 'dropdown', 'heading' => __('Field name', 'js_composer'), 'param_name' => 'field_from_' . $group[$id], 'value' => $fields_param_value, 'save_always' => true, 'description' => __('Select field from group.', 'js_composer'), 'dependency' => array('element' => 'field_group', 'value' => array((string) $group[$id])));
}
return array('vc_gitem_acf' => array('name' => __('Advanced Custom Field', 'js_composer'), 'base' => 'vc_gitem_acf', 'icon' => 'vc_icon-acf', 'category' => __('Content', 'js_composer'), 'description' => __('Advanced Custom Field', 'js_composer'), 'php_class_name' => 'Vc_Gitem_Acf_Shortcode', 'params' => array_merge(array(array('type' => 'dropdown', 'heading' => __('Field group', 'js_composer'), 'param_name' => 'field_group', 'value' => $groups_param_values, 'save_always' => true, 'description' => __('Select field group.', 'js_composer'))), $fields_params, array(array('type' => 'checkbox', 'heading' => __('Show label', 'js_composer'), 'param_name' => 'show_label', 'value' => array(__('Yes', 'js_composer') => 'yes'), 'description' => __('Enter label to display before key value.', 'js_composer')), array('type' => 'dropdown', 'heading' => __('Align', 'js_composer'), 'param_name' => 'align', 'value' => array(__('left', 'js_composer') => 'left', __('right', 'js_composer') => 'right', __('center', 'js_composer') => 'center', __('justify', 'js_composer') => 'justify'), 'description' => __('Select alignment.', 'js_composer')), array('type' => 'textfield', 'heading' => __('Extra class name', 'js_composer'), 'param_name' => 'el_class', 'description' => __('Style particular content element differently - add a class name and refer to it in custom CSS.', 'js_composer')))), 'post_type' => Vc_Grid_Item_Editor::postType()));
/**
 * Highlight Vc submenu.
 * @since 4.5
 */
function vc_gitem_menu_highlight()
{
    global $parent_file, $submenu_file, $post_type;
    if ($post_type === Vc_Grid_Item_Editor::postType()) {
        $parent_file = VC_PAGE_MAIN_SLUG;
        $submenu_file = 'edit.php?post_type=' . rawurlencode(Vc_Grid_Item_Editor::postType());
    }
}
Пример #11
0
function adjust_the_wp_menu()
{
    if (defined('VC_PAGE_MAIN_SLUG') && class_exists('Vc_Grid_Item_Editor')) {
        remove_submenu_page(VC_PAGE_MAIN_SLUG, 'edit.php?post_type=' . rawurlencode(Vc_Grid_Item_Editor::postType()));
    }
}
 protected function getCustomTemplateList()
 {
     $list = array();
     $templates = get_posts(array('post_type' => Vc_Grid_Item_Editor::postType(), 'numberposts' => -1));
     foreach ($templates as $template) {
         $id = $template->ID;
         $list[$template->post_title] = $id;
     }
     return $list;
 }
Пример #13
0
/**
 * @param $shortcodes
 *
 * @return mixed
 */
function nozhka_vc_grid_shortcodes($shortcodes)
{
    $shortcodes['ais_test'] = array('name' => __('Say Hello', 'nozhka'), 'base' => 'vc_say_hello', 'category' => __('Content', 'nozhka'), 'description' => __('Just outputs Hello World', 'nozhka'), 'post_type' => Vc_Grid_Item_Editor::postType());
    return $shortcodes;
}
Пример #14
0
function my_module_add_grid_shortcodes($shortcodes)
{
    $shortcodes['vc_post_author'] = array('name' => __('Post author', 'my-text-domain'), 'base' => 'vc_post_author', 'category' => __('Content', 'my-text-domain'), 'description' => __('Show current post author', 'my-text-domain'), 'post_type' => Vc_Grid_Item_Editor::postType());
    return $shortcodes;
}