Wie Redux Framework-Wert in benutzerdefiniertem Visual Composer Content Element hinzugefügt wird

Ich habe dieses benutzerdefinierte Button Visual Composer-Inhaltselement mit dem folgenden Code erstellt.

 __('TP Buttons', THEMEPURPOSE_THEME_NAME), 'base' => 'tp_buttons', 'description' => __('Custom Button Styles by TP', THEMEPURPOSE_THEME_NAME), 'category' => __('ThemePurpose Elements', THEMEPURPOSE_THEME_NAME), 'icon' => get_template_directory_uri().'/assets/img/vc-icon.png', 'params' => array( // Text field for the heading array( 'type' => 'textfield', 'heading' => __( 'Button Text', THEMEPURPOSE_THEME_NAME ), 'param_name' => 'btn_title', 'value' => __( 'Learn More', THEMEPURPOSE_THEME_NAME ), 'admin_label' => false, 'weight' => 0, ), array( 'type' => 'dropdown', 'heading' => __( 'Button Style', THEMEPURPOSE_THEME_NAME ), 'param_name' => 'btn_style', 'value' => array( __( 'Link Button - Border on Hover', THEMEPURPOSE_THEME_NAME ) => 'tp_btn1', __( 'Link Button - Fill on Hover', THEMEPURPOSE_THEME_NAME ) => 'tp_btn2', ), 'admin_label' => false, 'weight' => 0, ), array( 'type' => 'dropdown', 'heading' => __( 'Button Block Position', THEMEPURPOSE_THEME_NAME ), 'param_name' => 'btn_position', 'value' => array( __( 'Left', THEMEPURPOSE_THEME_NAME ) => 'text-left', __( 'Center', THEMEPURPOSE_THEME_NAME ) => 'text-center', __( 'Right', THEMEPURPOSE_THEME_NAME ) => 'text-right', ), 'admin_label' => false, 'weight' => 0, ), array( 'type' => 'dropdown', 'heading' => __( 'Button Text Alignment', THEMEPURPOSE_THEME_NAME ), 'param_name' => 'btn_text_align', 'value' => array( __( 'Left', THEMEPURPOSE_THEME_NAME ) => 'text-left', __( 'Center', THEMEPURPOSE_THEME_NAME ) => 'text-center', __( 'Right', THEMEPURPOSE_THEME_NAME ) => 'text-right', ), 'admin_label' => false, 'weight' => 0, ), array( 'type' => 'vc_link', 'heading' => __( 'URL (Link)', THEMEPURPOSE_THEME_NAME ), 'param_name' => 'btn_link', 'description' => __( 'Add custom link.', THEMEPURPOSE_THEME_NAME ), ), array( 'type' => 'dropdown', 'heading' => __( 'Text and Border Color', THEMEPURPOSE_THEME_NAME ), 'param_name' => 'btn_color', 'value' => array( __( 'Accent Color 1', THEMEPURPOSE_THEME_NAME ) => 'accent_color_1', __( 'Accent Color 2', THEMEPURPOSE_THEME_NAME ) => 'accent_color2', __( 'Accent Color 3', THEMEPURPOSE_THEME_NAME ) => 'accent_color3', __( 'Accent Color 4', THEMEPURPOSE_THEME_NAME ) => 'accent_color4', __( 'Custom Color', THEMEPURPOSE_THEME_NAME ) => 'custom_color', ), 'admin_label' => false, 'weight' => 0, ), array( 'type' => 'colorpicker', 'heading' => __( 'Custom Color', THEMEPURPOSE_THEME_NAME ), 'param_name' => 'btn_custom_color', 'value' => '#fff', 'description' => __( 'Select custom button color.', THEMEPURPOSE_THEME_NAME ), 'dependency' => array( 'element' => 'btn_color', 'value' => 'custom_color', ), ), array( 'type' => 'css_editor', 'heading' => __( 'Css', THEMEPURPOSE_THEME_NAME ), 'param_name' => 'css', 'group' => __( 'Design options', THEMEPURPOSE_THEME_NAME ), ), ), ) ); } class WPBakeryShortCode_BannerSection extends WPBakeryShortCode {} /** * Visual Composer banner section shortcode */ function tp_buttons_shortcode( $attributes ) { // Get defaults of the Visual Composer new content element $defaults = vc_map_get_defaults('tp_buttons'); // Use defaults if values not provided if ( empty( $attributes['btn_style'] ) ) { $attributes['btn_style'] = $defaults['btn_style']; } if ( empty( $attributes['btn_position'] ) ) { $attributes['btn_position'] = $defaults['btn_position']; } // Attributes extract( shortcode_atts( array( ), $attributes ) ); // Code return render_cta_button_section( $attributes ); } add_shortcode( 'tp_buttons', 'tp_buttons_shortcode' ); /** * Render CTA button section * * @param array $attributes * @return string */ function render_cta_button_section( $attributes ) { // Prepare the URL options for the view https://wordpress.stackexchange.com/questions/276077/how-to-add-redux-framework-value-in-visual-composer-custom-content-element/$url_options_string = $attributes['btn_link']; https://wordpress.stackexchange.com/questions/276077/how-to-add-redux-framework-value-in-visual-composer-custom-content-element/$url_options_array = explode( '|', https://wordpress.stackexchange.com/questions/276077/how-to-add-redux-framework-value-in-visual-composer-custom-content-element/$url_options_string ); https://wordpress.stackexchange.com/questions/276077/how-to-add-redux-framework-value-in-visual-composer-custom-content-element/$url_options = array(); foreach ( https://wordpress.stackexchange.com/questions/276077/how-to-add-redux-framework-value-in-visual-composer-custom-content-element/$url_options_array as $entry ) { $temp_array = explode( ':', $entry ); https://wordpress.stackexchange.com/questions/276077/how-to-add-redux-framework-value-in-visual-composer-custom-content-element/$url_options[ $temp_array[0] ] = urldecode_deep( $temp_array[1] ); } // Prepare the variables for the view $btn_title_v = $attributes['btn_title']; $btn_text_align_v = $attributes['btn_text_align']; $btn_color_v = $attributes['btn_color']; $btn_custom_color_v = $attributes['btn_custom_color']; if ($btn_color_v != 'custom_color') { $btn_color_code = $tp_options['accent_color1']; } else { $btn_color_code = $btn_custom_color_v; } https://wordpress.stackexchange.com/questions/276077/how-to-add-redux-framework-value-in-visual-composer-custom-content-element/$url = https://wordpress.stackexchange.com/questions/276077/how-to-add-redux-framework-value-in-visual-composer-custom-content-element/$url_options['url']; $button_target = https://wordpress.stackexchange.com/questions/276077/how-to-add-redux-framework-value-in-visual-composer-custom-content-element/$url_options['target']; $button_extra_classes = $attributes['btn_style']; $section_extra_classes = $attributes['btn_position']; $button_extra_classes = $button_extra_classes . ' ' . $btn_text_align_v; $output = <<<MULTI  
$btn_title_v
MULTI; return $output; }

Mein Redux Global Code wurde oben auf dieser Codepage hinzugefügt, die in meiner functions.php enthalten ist

 global $tp_options; 

Jetzt scrollen Sie den obigen Code nach unten und Sie werden folgendes finden:

 if ($btn_color_v != 'custom_color') { $btn_color_code = $tp_options['accent_color1']; } else { $btn_color_code = $btn_custom_color_v; } 

Hier habe ich versucht, den accent_color1 Wert von meinem Redux-Framework zu holen. Diese $tp_options['accent_color1'] funktioniert gut in meiner footer.php und allen anderen Template-Seiten.

Offensichtlich habe ich viel in Google nach einer Lösung gesucht, aber nichts funktioniert. Bitte helfen Sie mir, neu in WordPress Theme-Entwicklung. Ich kenne sehr einfaches PHP, aber nicht so gut.

Bitte helfen !!!

Solutions Collecting From Web of "Wie Redux Framework-Wert in benutzerdefiniertem Visual Composer Content Element hinzugefügt wird"