How do I get the settings to the frontend? I need to add classes to vc_row.
/**
* Ken Burns Effect for Row.
*/
add_action( 'vc_after_init', 'ken_burns_effect_add_option_to_vc_row' );
function ken_burns_effect_add_option_to_vc_row() {
// Ken Burns Effect Attributes
$ken_burns_effect_attributes =
array(
array(
'type' => 'checkbox',
'heading' => __( 'Ken Burns for image background', 'ken_burns_effect' ),
'param_name' => 'enable_ken_burns_effect',
'value' => array(
__( 'Yes', 'ken_burns_effect' ) => 'yes',
),
'description' => 'Check this box if you want to enable ken burns effect for this row.',
),
array(
'type' => 'dropdown',
'heading' => __( 'Direction', 'ken_burns_effect' ),
'param_name' => 'direction_ken_burns_effect',
'value' => array(
'Zoom In' => 'zoom_in',
'Zoom Out' => 'zoom_out',
),
'description' => __( '', 'ken_burns_effect' ),
'dependency' => array(
'element' => 'enable_ken_burns_effect',
'value' => array( 'yes' ),
),
),
array(
'type' => 'textfield',
'heading' => __( 'Transition speed', 'ken_burns_effect' ),
'param_name' => 'transition_speed_ken_burns_effect',
'value' => '',
'description' => __( '', 'ken_burns_effect' ),
'dependency' => array(
'element' => 'enable_ken_burns_effect',
'value' => array( 'yes' ),
),
),
);
vc_add_params( 'vc_row', $ken_burns_effect_attributes);
}
You will have to override the vc_row.php by copying it to your theme or plugin.
You can check their documentation on how to set the override directory: https://kb.wpbakery.com/docs/inner-api/vc_set_shortcodes_templates_dir/
Then you can use your custom params inside vc_row.php using their param_name eg:
$enable_ken_burns_effect;
$direction_ken_burns_effect;
$transition_speed_ken_burns_effect;
Keep in mind that you have to override vc_row_inner.php too if you want to use options there. Same goes for section and columns.
Related
In my theme, I set up 2 options use Theme Customization API, the code snippet below.
I want to display the radio option when the checkbox is true, when the checkbox is false, the radio hidden. I try to use active_callbackļ¼but not working. So, How can achieve this function?
Thanks!
// Related Post.
$wp_customize->add_setting('_related_post', array(
'capability' => 'edit_theme_options',
'default' => 0,
'transport' => 'postMessage',
));
$wp_customize->add_control('_related_post', array(
'settings' => '_related_post',
'label' => __('Display Related Posts', 'typenow'),
'section' => '_theme_options',
'type' => 'checkbox',
'priority' => 30,
));
// Related Post Num.
$wp_customize->add_setting('_related_post_num', array(
'capability' => 'edit_theme_options',
'default' => '2',
'transport' => 'postMessage',
));
$wp_customize->add_control('_related_post_num', array(
'settings' => '_related_post_num',
'label' => __('Related Posts Number', 'typenow'),
'section' => '_theme_options',
'type' => 'radio',
'priority' => 35,
'choices' => array (
'2' => __('Two posts', 'typenow'),
'4' => __('Four posts', 'typenow'),
),
));
The solution:
$wp_customize->add_control('_related_post_num', array(
'settings' => '_related_post_num',
'label' => __('Related Posts Number', 'typenow'),
'section' => '_theme_options',
'type' => 'radio',
'priority' => 35,
'choices' => array (
'2' => __('Two posts', 'typenow'),
'4' => __('Four posts', 'typenow'),
),
'active_callback' => function(){
return get_theme_mod( '_related_post', false );
},
));
I am trying to use Redux inside the wordpress theme and not as a plugin. In functions.php I included both redux-framework.php and sample-config.php .
Now I need to create a repeater field.
From Redux doc, I got the following code to use in order to create a repeater field:
$this->sections[] = array(
'title' => __('Repeater Field', 'redux-framework-demo' ),
'icon' => 'el-icon-thumbs-up',
'fields' => array(
array(
'id' => 'repeater-field-id',
'type' => 'repeater',
'title' => __( 'Title', 'redux-framework-demo' ),
'subtitle' => __( '', 'redux-framework-demo' ),
'desc' => __( '', 'redux-framework-demo' ),
//'group_values' => true, // Group all fields below within the repeater ID
//'item_name' => '', // Add a repeater block name to the Add and Delete buttons
//'bind_title' => '', // Bind the repeater block title to this field ID
//'static' => 2, // Set the number of repeater blocks to be output
//'limit' => 2, // Limit the number of repeater blocks a user can create
//'sortable' => false, // Allow the users to sort the repeater blocks or not
'fields' => array(
array(
'id' => 'title_field',
'type' => 'text',
'placeholder' => __( 'Title', 'redux-framework-demo' ),
),
array(
'id' => 'text_field',
'type' => 'text',
'placeholder' => __( 'Text Field', 'redux-framework-demo' ),
),
array(
'id' => 'select_field',
'type' => 'select',
'title' => __( 'Select Field', 'redux-framework-demo' ),
'options' => array(
'1' => __( 'Option 1', 'redux-framework-demo' ),
'2' => __( 'Option 2', 'redux-framework-demo' ),
'3' => __( 'Option 3', 'redux-framework-demo' ),
),
'placeholder' => __( 'Listing Field', 'redux-framework-demo' ),
),
)
)
)
);
but if I place the code inside functions.php, what will the $this variable refer to? It'll produce errors. So how to use the snippet so that I can retrieve the values from template files as well?
You have to tried an old version system to create a section. You can try the new version system, I'm not sure if this works or not, but you can try this way:
Redux::setSection($opt_name, array(
'title' => __('Ads Sections', 'cbnews'),
'id' => 'ads-sections',
'desc' => __('You can manage your ads', 'cbnews'),
'icon' => 'dashicons dashicons-dashboard',
'fields' => array(
array(
'id' => 'repeater-field-id',
'type' => 'repeater',
'title' => __( 'Title', 'redux-framework-demo' ),
'subtitle' => __( '', 'redux-framework-demo' ),
'desc' => __( '', 'redux-framework-demo' ),
//'group_values' => true, // Group all fields below within the repeater ID
//'item_name' => '', // Add a repeater block name to the Add and Delete buttons
//'bind_title' => '', // Bind the repeater block title to this field ID
//'static' => 2, // Set the number of repeater blocks to be output
//'limit' => 2, // Limit the number of repeater blocks a user can create
//'sortable' => false, // Allow the users to sort the repeater blocks or not
'fields' => array(
array(
'id' => 'title_field',
'type' => 'text',
'placeholder' => __( 'Title', 'redux-framework-demo' ),
),
array(
'id' => 'text_field',
'type' => 'text',
'placeholder' => __( 'Text Field', 'redux-framework-demo' ),
),
array(
'id' => 'select_field',
'type' => 'select',
'title' => __( 'Select Field', 'redux-framework-demo' ),
'options' => array(
'1' => __( 'Option 1', 'redux-framework-demo' ),
'2' => __( 'Option 2', 'redux-framework-demo' ),
'3' => __( 'Option 3', 'redux-framework-demo' ),
),
'placeholder' => __( 'Listing Field', 'redux-framework-demo' ),
),
)
)
)
));
I've setup new fields below, there's two types for images and text how can I call it now on a php file I'm assuming there's a function for it.
I'm able to access the fields on the theme > customize and add data to it but now I want to paste on a template.
$wp_customize->add_section('travel_video', array(
'priority' => 16,
'capability' => 'edit_theme_options',
'title' => __(' - Featured Videos', 'travel-lite'),
'description' => ''
));
$wp_customize->add_setting('travel[fpvideo]', array(
'default' => __('Title 1', 'travel-lite'),
'capability' => 'edit_theme_options',
'sanitize_callback' => 'esc_textarea',
'type' => 'option'
));
$wp_customize->add_control('travel_fpvideo' , array(
'label' => __('Title 1', 'travel-lite'),
'section' => 'travel_video',
'settings' => 'travel[fpvideo]'
));
Try This code,you can look for reference customizer
function mytheme_customize_register($wp_customize) {
$wp_customize->add_section('travel_video', array(
'priority' => 16,
'capability' => 'edit_theme_options',
'title' => __(' - Featured Videos', 'travel-lite'),
'description' => ''
));
$wp_customize->add_setting('travel[fpvideo]', array(
'default' => __('Title 1', 'travel-lite'),
'capability' => 'edit_theme_options',
'sanitize_callback' => 'esc_textarea',
'type' => 'option'
));
$wp_customize->add_control('travel_fpvideo', array(
'label' => __('Title 1', 'travel-lite'),
'section' => 'travel_video',
'settings' => 'travel[fpvideo]'
));
}
add_action('customize_register', 'mytheme_customize_register');
I am creating visual composer plugin for price table. I want to add dynamic textfield so user become able to add multiple text fields for item list as want.
For now it's showing only one text field but user should able to add multiple fields.
array (
"type" => "textfield",
"heading" => __( 'List Items', 'pt-vc' ),
"param_name" => "price_list",
"description" => __( 'Write the list item that you offer', 'pt-vc' ),
"group" => 'List Item',
),
You can use param_group. Here is the code example.
'params'=> array (
array(
'type' => 'param_group',
'value' => '',
'heading' => __( 'List Items', 'pt-vc' ),
'param_name' => 'price_list',
// Note params is mapped inside param-group:
'params' => array(
array(
'type' => 'textfield',
'value' => '',
'heading' => __( 'List Items', 'pt-vc' ),
'param_name' => 'list_itmes',
)
)
)
);
I think answer may be late but help others.
You may use param_group for that. It's not mentioned in the documentation but you may find it "How To's"
https://kb.wpbakery.com/docs/developers-how-tos/use-param-group-in-elements/
Code snippet from link (in case link expires again):
vc_map(
array(
'base' => 'your_shortcode',
'params' => array(
array(
'type' => 'textfield',
'value' => '',
'heading' => 'Title',
'param_name' => 'simple_textfield',
),
// params group
array(
'type' => 'param_group',
'value' => '',
'param_name' => 'titles',
// Note params is mapped inside param-group:
'params' => array(
array(
'type' => 'textfield',
'value' => '',
'heading' => 'Enter your title(multiple field)',
'param_name' => 'title',
)
)
)
)
)
)
I need a Webinar in my wordpress site. So I'm registering an meta box for my custom post type. I can see my custom post in the wordpress admin panel, but inside the custom post meta box is missing. What is wrong here!
// Meta boxes
add_filter( 'rwmb_meta_boxes', 'navbig_webinars_register_meta_boxes' );
//Register meta boxes
function navbig_webinars_register_meta_boxes( $meta_boxes )
{
$prefix = 'navbig_webinars_';
$meta_boxes[] = array(
'id' => 'standard',
'title' => __( 'Webinar Data', 'rwmb' ),
'pages' => array( 'webinar' ),
'context' => 'normal',
'priority' => 'high',
'autosave' => true,
'fields' => array(
array(
'name' => __( 'Date of Webinar', 'rwmb' ),
'id' => "webinar_date",
'type' => 'date',
// jQuery date picker options. See here http://api.jqueryui.com/datepicker
'js_options' => array(
'dateFormat' => __( 'dd-MM-yy', 'rwmb' ),
'changeMonth' => true,
'changeYear' => true,
'showButtonPanel' => true,
),
),
array(
'name' => __( 'Location', 'rwmb' ),
'id' => "webinar-location",
'type' => 'text',
'std' => __( 'Default text value', 'rwmb' ),
),
array(
'name' => __( 'Time Of Webinar', 'rwmb' ),
'id' => 'webinar_time',
'type' => 'time',
'js_options' => array(
'stepMinute' => 5,
'showSecond' => true,
'stepSecond' => 10,
),
),
array(
'name' => __( 'Select Time Zone', 'rwmb' ),
'id' => "select-timezone",
'type' => 'select_advanced',
'options' => array(
'value1' => __( 'PST', 'rwmb' ),
'value2' => __( 'EST', 'rwmb' ),
),
'multiple' => false,
'placeholder' => __( 'Select an Coures Type', 'rwmb' ),
),
// URL
array(
'name' => __( 'Webinar URL', 'rwmb' ),
'id' => "webinar_url",
'type' => 'url',
'std' => 'http://google.com',
),
array(
'name' => __( 'Webinar Banner', 'rwmb' ),
'id' => "webinar_banner",
'type' => 'thickbox_image',
),
),
);
return $meta_boxes;
}
You can find more detail about meta boxes here.
Here is sample add_meta_box code:-
add_meta_box(
'some_meta_box_name'
,__( 'Some Meta Box Headline', 'plugin_textdomain' )
,'render_meta_box_content' //this is callback function.
,'post_type'
,'advanced'
,'high'
);