These are chat archives for WebDevStudios/CMB2

24th
Sep 2015
Ronald Huereca
@ronalfy
Sep 24 2015 13:07
Heya @sc0ttkclark you around?
Ronald Huereca
@ronalfy
Sep 24 2015 13:22
Well, whenver you see this, I need an extra push. Would like to use CMB2 to render rather than create a new control for each field type. Almost there, I just need a second brain. https://github.com/ronalfy/CMB2/blob/customizer/includes/customizer/CMB2_Customizer_Checkbox.php
Scott Kingsley Clark
@sc0ttkclark
Sep 24 2015 15:08
@ronalfy hey, just getting into the office
looks like you just need to tell CMB2 what $this->value() is, right?
Ronald Huereca
@ronalfy
Sep 24 2015 15:33
let me try it and get back to you
Scott Kingsley Clark
@sc0ttkclark
Sep 24 2015 15:33
sure
exciting times, that's exactly what i was thinking should happen, for the customizer control classes
Ronald Huereca
@ronalfy
Sep 24 2015 15:35
thanks. Without your support this would be impossible
Scott Kingsley Clark
@sc0ttkclark
Sep 24 2015 15:44
so far, you've proven it's very possible, you've done pretty much the whole thing, i've just nodded my head and reviewed the code :)
you should be more confident, you're doing awesome things :)
Ronald Huereca
@ronalfy
Sep 24 2015 15:46
thanks man.. I def have imposter syndrome
@sc0ttkclark here we go.. just now don't know how to save it as a theme option
<?php
/* Proof of concept of creating custom meta boxes for customizer */
class CMB_Customize_Checkbox extends WP_Customize_Control {
    public $type = 'checkbox';

    public function render_content() {
       /* Need help with this so we can use CMB2 native functions */
       $field = new CMB2_Field( array( 'object_id' => $this->id, 'object_type' => 'checkbox', 'field_args' => array( 'id' => $this->id, 'type' => 'checkbox', 'name' => $this->label, 'value' => $this->value(), 'desc' => $this->label, 'escaped_value' => esc_html( $this->value() ) ) ) );

       $type = new CMB2_Types( $field );

       echo $type->checkbox();   
    }
}
Scott Kingsley Clark
@sc0ttkclark
Sep 24 2015 15:47
CMB2 doesn't hook into the saving for customizer, does it need to?
that's all part of the Customizer itself
as long as you have the controls / fields / etc registered
it does that
you'd just want to be able to pass theme_mod vs option as a customizer_type argument
Ronald Huereca
@ronalfy
Sep 24 2015 15:59
negative.. let me do some more troubleshooting. At least I got it to show.
Scott Kingsley Clark
@sc0ttkclark
Sep 24 2015 15:59
ok cool
Ronald Huereca
@ronalfy
Sep 24 2015 15:59
I meant to type that to your first question
found the issue.. needs to have extra field..
Ronald Huereca
@ronalfy
Sep 24 2015 16:14
Okay, I am officially awesome
public function input( $args = array() ) {
        $a = $this->parse_args( $args, 'input', array(
            'type'  => 'text',
            'class' => 'regular-text',
            'name'  => $this->_name(),
            'id'    => $this->_id(),
            'value' => $this->field->escaped_value(),
            'desc'  => $this->_desc( true ),
            'data-customize-setting-link' => $this->_name()
        ) );

Had to add in that attribute so it will update changes in customizer.

and got it to update in real time

so I'll just start going down the fields and create objects for each
Plan is to get the base fields down... tackle groups later.
Scott Kingsley Clark
@sc0ttkclark
Sep 24 2015 16:18
exactly
Ronald Huereca
@ronalfy
Sep 24 2015 16:19
I can see why devs hate customizer. So will save them so much time.
Scott Kingsley Clark
@sc0ttkclark
Sep 24 2015 16:38
yeah, it's not fun
we're trying to fix some of those things in our Fields API implementation
Justin Sternberg
@jtsternberg
Sep 24 2015 16:39
fyi, i'm passively keeping up, just not ready to participate in the convo yet. :)
Ronald Huereca
@ronalfy
Sep 24 2015 16:44
no worries Justin. Let me get as many controls as I can.. then I'll submit an official merge request
Scott Kingsley Clark
@sc0ttkclark
Sep 24 2015 16:48
@ronalfy there are some tweaks we can suggest once you have the PR, which lets us comment on specific lines etc and follow up on things
Justin Sternberg
@jtsternberg
Sep 24 2015 16:48
Yah, for starters, I can already tell you we'll push back on WP coding standards (or anything that doesn't fit the code "style" of CMB2)
like inline function calls, etc
I know it's super annoying...
Scott Kingsley Clark
@sc0ttkclark
Sep 24 2015 16:49
i can help on those too
@ronalfy can you give me write access to your repo? once you get it to a place where it's working, i can swoop in and do some cleanup so you don't have to worry about anything but making it work :)
Justin Sternberg
@jtsternberg
Sep 24 2015 16:51
@sc0ttkclark's like a WP superhero
Ronald Huereca
@ronalfy
Sep 24 2015 18:28
@sc0ttkclark let me figure out the JS and it's all yours
what's your git username?
Scott Kingsley Clark
@sc0ttkclark
Sep 24 2015 18:28
sc0ttkclark
we're on gitter, usernames are the same as github
Ronald Huereca
@ronalfy
Sep 24 2015 18:35
okay
any ideas how to initialize JS for a time picker?
Ronald Huereca
@ronalfy
Sep 24 2015 18:50
nm, almost there
Ronald Huereca
@ronalfy
Sep 24 2015 20:32
@sc0ttkclark I had to givee up.. my brain is fried.. couldn't figure out text timer or radio.. I'll try again some other day :D
Scott Kingsley Clark
@sc0ttkclark
Sep 24 2015 20:41
sounds good, i'll take a look
everything you have is in git right? can you list out the field types you haven't confirmed as working yet?
@ronalfy ^^
Ronald Huereca
@ronalfy
Sep 24 2015 21:11
@sc0ttkclark sure..
let me do a push and
@sc0ttkclark I added you as a contributor
@sc0ttkclark here in the customizer branch tell you what I've tried. I stopped at radio.
Ronald Huereca
@ronalfy
Sep 24 2015 21:16
I was working on the radio last. Gave up for the time being.
Ronald Huereca
@ronalfy
Sep 24 2015 21:22
I'm at the point in my dev brain where it'll be easier creating custom customizer controls/outputs for some of these.