devinsays / customizer-library Goto Github PK
View Code? Open in Web Editor NEWCustomizer Library
Customizer Library
I'm trying to use:
'active_callback' => 'is_front_page',
It doesn't seem to work for image and upload options though. Would it just be a matter of adding active_callback to the options switch?
https://github.com/devinsays/customizer-library/blob/master/extensions/interface.php#L81-L109
Devin,
How do you handle option for ads? If I use textarea with default sanitization, it will strip the ads code, for example from adsense?
My solution for now is just create custom sanitization with 'unsafe' filter, using stripslashes
only. I need second opinion about this.
Thank you
Hi Devin,
I've strange experience with the choices control(select, radio), when saving it, it didn't worked
Here's my code
// Radio Button
$section = $prefix . 'radio';
$sections[] = array(
'id' => $section,
'title' => __( 'Radio Section', 'standard' ),
'priority' => 45,
'panel' => $test_panel,
);
$options['test-radio'] = array(
'id' => $prefix . 'test_radio',
'label' => __( 'This is title', 'standard' ),
'description' => __( 'This is description', 'standard' ),
'section' => $section,
'type' => 'radio',
'default' => 'options2',
'choices' => array(
'options1' => 'Option 1',
'options2' => 'Option 2',
'options3' => 'Option 3'
)
);
I tried to check the sanitization code customizer_library_sanitize_choices
and tried to remove whole code except return $value;
and the issue disappear(saving works). Do you know what is wrong?
Thank you.
I would like to know how to add "+ Add a Widget" in section.
Thank in advance
This is more a question, as I'm not understanding how to actually set initial default options. I have a default set in the customizer library file, and I see my checkbox for instance is set to default to checked.
But on theme install and activation it is not setting the default of that option to checked into the database. So any conditionals I've written in a template file for that option dont work. If I go in and deselect / reselect it works fine. So I'm somehow missing how to initialize my theme with the defaults set.
I'd appreciate any advice anyone could give me on this. I have a deadline, unfortunately, to finish this theme before xmas - so I'll probably have to just hack my template part a bit to make it work. But I'd love to figure this out and refactor.
Hi Devin,
I'm not having any trouble with any of the Google Fonts except for "Copse". I've had a look through the fonts.php extension but I'm not seeing why that one font would be singled out.
I'm sorry about title, I have no idea what is the best title for my question.
I'm trying to split the customizer option into seperated files, so I tried to added 'hook' in the middle of code, somethin like this
function standard_customizer_register() {
// Stores all the controls that will be added
$options = array();
// Stores all the sections to be added
$sections = array();
// Stores all the panels to be added
$panels = array();
// Adds the sections to the $options array
$options['sections'] = $sections;
// Hook to add the custom customizer.
do_action( 'standard_register_customizer', $options, $sections, $panels );
// Adds the sections to the $options array
$options['sections'] = $sections;
// Adds the panels to the $options array
$options['panels'] = $panels;
$customizer_library = Customizer_Library::Instance();
$customizer_library->add_options( $options );
}
add_action( 'init', 'standard_customizer_register' );
then I called the file and hook in to add the panels/sections.
$path = trailingslashit( get_template_directory() ) . 'admin/panels/';
require_once( $path . 'general.php' );
general.php
function standard_customizer_general_panel( $sections, $panels, $options) {
// Panel ID
$panel = 'panel';
$panels[] = array(
'id' => $panel,
'title' => __( 'General', 'Standard' ),
'priority' => 10
);
// Logo
$section = 'logo';
$sections[] = array(
'id' => $section,
'title' => __( 'Image Example', 'demo' ),
'priority' => '30',
'description' => __( 'Example section description.', 'demo' ),
'panel' => $panel
);
$options['logo'] = array(
'id' => 'logo',
'label' => __( 'Logo', 'demo' ),
'section' => $section,
'type' => 'image',
'default' => ''
);
}
add_action( 'standard_register_customizer', 'standard_customizer_general_panel', 10, 3 );
But it didn't worked. My question:
Thank you.
WP 4.0 added Panels to the customizer as a way to group sections. Would like to see this support added to the library.
Add an additional control that would allow for additional html - e.g. A heading or description, a line, etc.
An example would be something like this: http://coreymckrill.com/blog/2014/01/09/adding-arbitrary-html-to-a-wordpress-theme-customizer-section/
I believe this is the last piece keeping folks from embracing the customizer for all theme options - as currently we have no good way add additional help text and communicate to end users. Corey's article above is exactly the situation I just ran into. Panels might help, but those are not in the library either at this time.
Rather than using as a submodule, it would be great to include it via Composer.
I'm trying to figure out how to use images for my radio select options, like for instance when you are choosing layout options for a sidebar placement. Is this supported?
I'm having some trouble working out why the default helper function isn't returning my option defaults. Example usage:
$options['home-posts-section-title'] = array(
'id' => 'home-posts-section-title',
'label' => __( 'Section Title', 'themename' ),
'section' => $section,
'type' => 'textarea',
'default' => __( 'Latest News', 'themename' ),
'transport' => 'postMessage'
);
The setting is being called like this:
echo esc_attr( get_theme_mod( 'home-posts-section-title', customizer_library_get_default( 'home-posts-section-title' ) ) );
The default displays in the customizer screen but not on the live site.
Hello @devinsays, is there a way to choose files already uploaded? I am using a Logo setting in my client project. In case the logo image is removed, we have to upload a image again. Similar to Options framework is there no way to allow users to pick a image already uploaded?
If you have an optional color field and set a color value (hex number), the field can no longer be empty.
For exampleI set the field to white (#ffffff) and save. I then click "clear" and save. Value is still white. If I delete the value from the field manually and save the value will remain white. Once a value is set there is no way to allow the field to not have a value.
I am doing a theme review. How can I check that the settings are being sanitized?
Hello Devin,
Thanks for sharing this.
One thing I noticed was lack of tag to this project. I'm guessing this is because of you are still experimenting.
I am including this code within my plugin https://github.com/hchouhan/WordPress-for-My-Clients (also hosted at WordPress.org) to allow easier update for my client projects. My project already has submodule, and I don't want to add another submodule within a submodule.
Just wanted to know if you plan to tag this project soon, as it would be easier to compare and update in future.
Been trying for hours to add a second section to a custom panel. Can't figure out how to make it work.
I've tried:
$panel = 'panel';
$panels[] = array(
'id' => $panel,
'title' => __( 'Panel Examples', 'demo' ),
'priority' => '100'
);
$section = 'panel-section';
$sections[] = array(
'id' => $section,
'title' => __( 'Panel Section', 'demo' ),
'priority' => '10',
'panel' => $panel
);
$options['example-panel-text'] = array(
'id' => 'example-panel-text',
'label' => __( 'Example Text Input', 'demo' ),
'section' => $section,
'type' => 'text',
);
$section_two = 'panel-section-two';
$sections[] = array(
'id' => $section_two,
'title' => __( 'Panel Section Two', 'demo' ),
'priority' => '10',
'panel' => $panel
);
$options['example-panel-text'] = array(
'id' => 'example-panel-text',
'label' => __( 'Example Text Input', 'demo' ),
'section' => $section_two,
'type' => 'text',
);
and:
$panel = 'panel';
$panels[] = array(
'id' => $panel,
'title' => __( 'Panel Examples', 'demo' ),
'priority' => '100'
);
$section = 'panel-section';
$sections[] = array(
'id' => 'SectionOne',
'title' => __( 'Panel Section', 'demo' ),
'priority' => '10',
'panel' => $panel
);
$sections[] = array(
'id' => 'SectionTwo',
'title' => __( 'Panel Section Two', 'demo' ),
'priority' => '20',
'panel' => $panel
);
$options['example-panel-text'] = array(
'id' => 'example-panel-text',
'label' => __( 'Example Text Input', 'demo' ),
'section' => 'SectionOne',
'type' => 'text',
);
$options['example-panel-text'] = array(
'id' => 'example-panel-text',
'label' => __( 'Example Text Input', 'demo' ),
'section' => 'SectionTwo',
'type' => 'text',
);
In both cases, the second section overwrites the first one, and only the second one shows up. What am I doing wrong?
Can extra classes be added to each option. Wanting to create half and quarter width options to make a cleaner feel. I can so with by targeting the built in css now, but have to do each one by one. would to simplify make it more streamlined and add a single class for the shorter options.
Hi,
The css folder and css file is missing here.
Please update the version.
Hello Devin, I noticed you have tagged your versions but was not able to find it in https://github.com/devinsays/customizer-library/releases. Any reason for this? If none, I'd request you to please add the versions there whenever you get time. Makes it sometimes easier to pull it.
I'm getting the following required notice from the theme check plugin:
REQUIRED: Found a Customizer setting that did not have a sanitization callback function. Every call to the add_setting() method needs to have a sanitization callback function passed.
It doesn't give any more details other than that.
Hi Devin,
There is no editor in the theme customizer library. Is there any option to add there? I tried to add an option but is didn't worked. I found like that here https://github.com/paulund/wordpress-theme-customizer-custom-controls but not tried since I am comfortable with Options framework
This is not an issue but what I think if this could be added. As sometimes we may not work with plugin or theme options , for some projects we may think to just add some Theme customizer options.
Thanks in advance
Suggestion: add full examples to README.md that describe all possible arguments for the following functions/variables (args/values I noticed are missing are in parenthesis - there could be more as well):
$sections[]
$options[]
(priority)Customizer_Library_Styles()->add()
(media)Are there others you know of?
Awesome work, Devin! I'm loving this. Question: can I output media queries using Customizer_Library_Styles()->add()
? I'd love to be able to specify media query specific output for something like a retina and non-retina logo. Is this possible?
Thanks!
I know we talked on another issue about this, and you said it was best not to set the defaults in the database. However for my end users - they end up activating a theme where nothing is set and being completely overwhelmed and not knowing where to start. If the defaults were actually set upon activating the theme, this would not be a problem.
So, is there any workaround? A way to make take just the few options that really need to be set and put them in a function for after setup theme?
Hi Devin :)
Thanks for your library. Would you be keen to add another control for WP_Customize_Media_Control
so we could have an easy way of getting an attachment ID? Looks like it's ready to go in this PR.
My first thought was about multiple-images field useful for bacground sliders, etc. But maybe more general solution would be even nicer: repeatable fields.
Need to test with WordPress 4.0. @bradyvercher mentioned native Textarea Controls have been added.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.