Advertisement
Guest User

grid-item-shortcodes.php

a guest
Oct 26th, 2016
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.81 KB | None | 0 0
  1. <?php
  2. if ( ! defined( 'ABSPATH' ) ) {
  3.     die( '-1' );
  4. }
  5.  
  6. $groups = function_exists( 'acf_get_field_groups' ) ? acf_get_field_groups() : apply_filters( 'acf/get_field_groups', array() );
  7. $groups_param_values = $fields_params = array();
  8. foreach ( $groups as $group ) {
  9.     $id = isset( $group['id'] ) ? 'id' : ( isset( $group['ID'] ) ? 'ID' : 'id' );
  10.     $groups_param_values[ $group['title'] ] = $group[ $id ];
  11.     $fields = function_exists( 'acf_get_fields' ) ? acf_get_fields( $group[ $id ] ) : apply_filters( 'acf/field_group/get_fields', array(), $group[ $id ] );
  12.  
  13.     $fields_param_value = array();
  14.     if(is_array($fields))
  15.     foreach ( $fields as $field ) {
  16.         $fields_param_value[ $field['label'] ] = (string) $field['key'];
  17.     }
  18.     $fields_params[] = array(
  19.         'type' => 'dropdown',
  20.         'heading' => __( 'Field name', 'js_composer' ),
  21.         'param_name' => 'field_from_' . $group[ $id ],
  22.         'value' => $fields_param_value,
  23.         'save_always' => true,
  24.         'description' => __( 'Select field from group.', 'js_composer' ),
  25.         'dependency' => array(
  26.             'element' => 'field_group',
  27.             'value' => array( (string) $group[ $id ] ),
  28.         ),
  29.     );
  30. }
  31.  
  32. return array(
  33.     'vc_gitem_acf' => array(
  34.         'name' => __( 'Advanced Custom Field', 'js_composer' ),
  35.         'base' => 'vc_gitem_acf',
  36.         'icon' => 'vc_icon-acf',
  37.         'category' => __( 'Content', 'js_composer' ),
  38.         'description' => __( 'Advanced Custom Field', 'js_composer' ),
  39.         'php_class_name' => 'Vc_Gitem_Acf_Shortcode',
  40.         'params' => array_merge(
  41.             array(
  42.                 array(
  43.                     'type' => 'dropdown',
  44.                     'heading' => __( 'Field group', 'js_composer' ),
  45.                     'param_name' => 'field_group',
  46.                     'value' => $groups_param_values,
  47.                     'save_always' => true,
  48.                     'description' => __( 'Select field group.', 'js_composer' ),
  49.                 ),
  50.             ), $fields_params,
  51.             array(
  52.                 array(
  53.                     'type' => 'checkbox',
  54.                     'heading' => __( 'Show label', 'js_composer' ),
  55.                     'param_name' => 'show_label',
  56.                     'value' => array( __( 'Yes', 'js_composer' ) => 'yes' ),
  57.                     'description' => __( 'Enter label to display before key value.', 'js_composer' ),
  58.                 ),
  59.                 array(
  60.                     'type' => 'dropdown',
  61.                     'heading' => __( 'Align', 'js_composer' ),
  62.                     'param_name' => 'align',
  63.                     'value' => array(
  64.                         __( 'left', 'js_composer' ) => 'left',
  65.                         __( 'right', 'js_composer' ) => 'right',
  66.                         __( 'center', 'js_composer' ) => 'center',
  67.                         __( 'justify', 'js_composer' ) => 'justify',
  68.                     ),
  69.                     'description' => __( 'Select alignment.', 'js_composer' ),
  70.                 ),
  71.                 array(
  72.                     'type' => 'textfield',
  73.                     'heading' => __( 'Extra class name', 'js_composer' ),
  74.                     'param_name' => 'el_class',
  75.                     'description' => __( 'Style particular content element differently - add a class name and refer to it in custom CSS.', 'js_composer' ),
  76.                 ),
  77.             )
  78.         ),
  79.         'post_type' => Vc_Grid_Item_Editor::postType(),
  80.     ),
  81. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement