I Would like to use html codes in customizer API. But when I use it, WordPress removes the html tags.
In default area I used some html tags, But it does work on my actual page. Is there any way please ?
$wp_customize->add_setting('banner_title_display',array(
'default' => 'Largest <span> GiveAway</span> collections <small>Online</small>',
'sanitize_callback' => array($this, 'sanitize_custom_options')
));
$wp_customize->add_control(new WP_Customize_Control($wp_customize,'banner_title_display_control',array(
'label' => 'Main header text',
'section' => 'baner_header_section',
'settings' => 'banner_title_display',
'type' => 'textarea'
)));
Related
I have a child theme editing the main-structure-elements.php file from the Divi parent theme. I have tried to override this file by moving it into the child theme and making the changes there, as well as modifying the functions.php file to require that file, still no luck.
I just need to add a toggle to the Divi sections that adds a css filter. This is the code I have written in the main-structure-elements.php file which works great in the main divi file but is unrecognized if added just in the child theme file.
public function get_fields() {
$fields = array(
'fullpage_height' => array(
'label' => esc_html__( 'Enable Fullpage', 'et_builder' ),
'type' => 'yes_no_button',
'option_category' => 'configuration',
'options' => array(
'off' => et_builder_i18n( 'No' ),
'on' => et_builder_i18n( 'Yes' ),
),
'default' => 'off',
'description' => esc_html__( 'Here you can select whether or not your page should have Full Height enabled. This must be enabled on all sections to function', 'et_builder' ),
'tab_slug' => 'advanced',
'toggle_slug' => 'layout',
'default_on_front' => 'off',
),
this code then is triggering this code later in that same file.
if ( 'on' === $fullpage_height ) {
$this->add_classname( 'fullpage-vertical' );
}
I have been working on this for days, any insight would be a life saver
Did you try run this code as snippet using plugin "Code Snippets"? Maybe at this way the code will work fine.
I need to make a switch for the preloader. I created the corresponding item in the config.php:
array(
'id' => 'page_load_transition',
'type' => 'switch',
'title' => __( 'Page Load Transition', 'redux-framework-demo' ),
'desc' => __( 'Page load transition animation.', 'redux-framework-demo' ),
'default' => 1,
'on' => 'Enable',
'off' => 'Disable'
),
Also I have a div with a preloader html code:
<div id="preloader"><span id="spinner"></span></div>
and jQuery code:
var $preloader = $('#preloader').delay(700).fadeOut('slow').find('#spinner').fadeOut('slow'),
Now I need to make a switch, but all my attempts did not work.
I need to learn how to implement this correctly.
Thank you
Solved:
if(esc_html($varuna_option['page_load_transition'] == '1')) {
echo '<div id="preloader"><span id="spinner"></span></div>';
}
Everything turned out to be easier.
CMB2 has an option to use as an option page.
I'm looking in the example files, and on the wiki page but even copying and pasting the example on the files it not work.
I'm probably missing something, but I can't find what it is, I already spent two days trying to make this work.
Following the wiki and the example I modified to this code
add_action( 'cmb2_admin_init', 'yourprefix_register_theme_options_metabox' );
function yourprefix_register_theme_options_metabox() {
$option_key = 'wherever';
$cmb = new_cmb2_box( array(
'id'=> $option_key . '_theme_options-page',
'object_types' => array( 'options-page' ),
'hookup' => false,
'menu_title' => 'Site Options',
'parent_slug' => 'tools.php',
'capability' => 'manage_options'
) );
$cmb->add_field( array(
'name' => 'Site Background Color',
'desc' => 'field description',
'id' => 'bg_color',
'type' => 'colorpicker',
'default' => '#ffffff'
) );
}
Any leads on why it's not working?
Currently the documentation for CMB2's options page capabilities just takes you to their Snippet Library which isn't 100% straightforward, so hopefully I can help clarify how to use these functions properly.
First, the metaboxes you register in cmb2_admin_init can generate an entire admin page. Take this code example straight from the snippet library for instance:
add_action('cmb2_admin_init', 'register_my_admin_page');
function register_my_admin_page() {
/**
* Registers options page menu item and form.
*/
$cmb_options = new_cmb2_box( array(
'id' => 'myprefix_option_metabox',
'title' => esc_html__( 'Site Options', 'myprefix' ),
'object_types' => array( 'options-page' ),
/*
* The following parameters are specific to the options-page box
* Several of these parameters are passed along to add_menu_page()/add_submenu_page().
*/
'option_key' => 'myprefix_options', // The option key and admin menu page slug.
// 'icon_url' => 'dashicons-palmtree', // Menu icon. Only applicable if 'parent_slug' is left empty.
// 'menu_title' => esc_html__( 'Options', 'myprefix' ), // Falls back to 'title' (above).
// 'parent_slug' => 'themes.php', // Make options page a submenu item of the themes menu.
// 'capability' => 'manage_options', // Cap required to view options-page.
// 'position' => 1, // Menu position. Only applicable if 'parent_slug' is left empty.
// 'admin_menu_hook' => 'network_admin_menu', // 'network_admin_menu' to add network-level options page.
// 'display_cb' => false, // Override the options-page form output (CMB2_Hookup::options_page_output()).
// 'save_button' => esc_html__( 'Save Theme Options', 'myprefix' ), // The text for the options-page save button. Defaults to 'Save'.
) );
/*
* Options fields ids only need
* to be unique within this box.
* Prefix is not needed.
*/
$cmb_options->add_field( array(
'name' => __( 'Test Text', 'myprefix' ),
'desc' => __( 'field description (optional)', 'myprefix' ),
'id' => 'test_text',
'type' => 'text',
'default' => 'Default Text',
) );
$cmb_options->add_field( array(
'name' => __( 'Test Color Picker', 'myprefix' ),
'desc' => __( 'field description (optional)', 'myprefix' ),
'id' => 'test_colorpicker',
'type' => 'colorpicker',
'default' => '#bada55',
) );
}
This code snippet will generate a top-level admin page named "Site Options" with two fields: a text field and a color-picker field, complete with a title, form fields, submit button, etc. You can configure how the page is displayed to the user using the commented out settings on the new_cmb2_box function.
When the form is saved, it will save the meta box and its fields to the site option myprefix_options. So if you call the function get_option('myprefix_options'), it will return the following array:
array(
'myprefix_option_metabox' => array(
'test_text' => '' // value of the Test Text field,
'test_colorpicker' => '' // value of the Test Color Picker field
)
)
I hope that helps clarify things a bit.
I have some problem with rte in my extension. In tables I set field text area with rte. In BE TYPO3 generating rte view and when I formatting text everything is ok. The only problem is when I have some paragraphs - in BE I have <p> tag, but in frontend in HTML code the <p> tag didn't "exist".
My TCA code looks like this:
'description' => array(
'exclude' => 1,
'label' => 'LLL:EXT:fu_product_table/locallang_db.xml:tx_table_products.description',
'defaultExtras' => 'richtext[*]',
'config' => array(
'type' => 'text',
'cols' => '30',
'rows' => '5',
'wizards' => array(
'_PADDING' => 2,
'RTE' => array(
'notNewRecords' => 1,
'RTEonly' => 1,
'type' => 'script',
'title' => 'Full screen Rich Text Editing|Formatteret redigering i hele vinduet',
'icon' => 'wizard_rte2.gif',
'script' => 'wizard_rte.php',
),
),
)
),
And then trying to render the field in the class:
'<td class="td-1">' . $this->getFieldContent('description') . '</td>';
Any suggestion?
TYPO3 saves RTE's content little bit 'trimmed' (without full markup) so for 'reverting' it back to the valid HTML you need to wrap it with the dedicated method, ie:
$this->pi_RTEcssText($this->getFieldContent('description'))
Note: Adrian, next point for Extbase: it has special viewhelper for this, so you can do it easily directly in the template ;)
I have the following code below, but I can't figure out why it's not working. All I get from my template is a blank screen. Any ideas? I'm using the latest version of WordPress.
function twentyone_customizer_register($wp_customize)
{
$wp_customize->add_section('logo_changer', array(
'title' => __('Images', 'twentyone'),
'description' => 'Change index page background image.'
));
$wp_customize->add_setting('logo_image', array(
'default' => 'http://localhost/twentyone/wp-content/themes/twentyone/assets/img/showcase.jpg'
));
$wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'logo_image', array(
'label' => __('Edit Showcase Image', 'twentyone'),
'section' => 'logo_changer',
'settings' => 'logo_image'
)));
}
add_action('customize_register', 'twentyone_customizer_register');
I've solved my problem and I have edited the code to reflect the changes. I named the function starting with a number and that caused the theme customizer not to work.