Forum Replies Created

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter cgfx360

    (@cgfx360)

    @saurabhsaneja

    I still haven’t managed to make this work.

    The code you provided, at least for me, still presents the same problem I was having. When you access the customizer via the settings page, it still doesn’t hide any sections not in the array, it just shows them.

    If I move the control_filter() function outside of the ezt_plugin_settings_callback() function, it will fire and remove all the sections not in the array, but it fire’s all the time and removes the sections even when the customizer is accessed via the appearance menu, which I dont want.

    I made a video to better show what I mean:
    https://streamable.com/cqla3

    Not sure if it’s just me, or what, but I can’t seem to get it to work.

    Thanks your all your help so far by the way, I really appreciate it.

    • This reply was modified 8 years, 9 months ago by cgfx360.
    • This reply was modified 8 years, 9 months ago by cgfx360.
    Thread Starter cgfx360

    (@cgfx360)

    @saurabhsaneja

    The code to create a button in the woocommerce panel is:

    array(
       'title' => __('Customize!', 'woocommerce'),
       'desc'  => __('Some Text', 'woocommerce'),
       'type'  => 'wc_button',
       'link'  => $url
     )

    WooCommerce Settings API
    https://docs.woocommerce.com/document/settings-api/

    However, in my case, I’m not using WooCommerce. I’m creating a standalone plugin, so it’s slightly different (I use add_submenu_page() to create a settings page, and then the button is created in the callback function. which may be why it’s not working like the video. You can see what I mean with the code I posted in the original post.).

    But I basically create the button with:

    //Get customizer url
    $url = admin_url( 'customize.php' );
    
    $url = add_query_arg(
        'wc-email-customizer',
        'true',
        $url
    );
    
    ?>
        
                <a class="btn btn-default" href="<?php echo $url; ?>">Customize</a>
            
    
    <?php
    
    }

    P.S. As for the esc_url, I have a comment above some of the code to sanitize it, I just didn’t do so because I couldn’t get this to work in the first place. Not sure that’d make a difference in it working?

    • This reply was modified 8 years, 9 months ago by cgfx360.
    Thread Starter cgfx360

    (@cgfx360)

    @saurabhsaneja

    Sorry about that, let me try and clarify.

    If I understand it right, we add this query arg to the url:

    $url = add_query_arg(
        'wc-email-customizer',
        'true',
        $url
    );

    which I echo out here:

    <a class="btn btn-default" href="<?php echo $url; ?>">Customize</a>

    And This section of code:

    add_filter( 'customize_control_active', 'control_filter', 10, 2 );
    
    function control_filter( $active, $control ) {
        if ( in_array(
            $control->section,
            array(
                'wc_email_header',
                'wc_email_body',
                'wc_email_footer',
                'wc_email_send'
                )
            )
        ){
        return true;
    
    } 
    return false;
    
    }

    Is supposed to somehow be checking to see if the url contains the query arg we set here above. This one:

    $url = add_query_arg(
        'wc-email-customizer',
        'true',
        $url
    );

    Is present in the url (or rather, set to true ?). If it is, it will run the control_filter() function and remove any sections that are not in that array from the customizer. (Widgets, Colors, etc… the default customizer sections).

    So if we created a section like:

    $wp_customize->add_section( 'wc_email_header' , array(
        'title'      => __( 'Section Name', 'mytheme' ),
    ) );

    It’s my understanding this section would display because it is listed in that array inside the control_filter function. Whereas the default customizer sections/controls (Widgets, Colors, etc…) are not, so they wouldn’t be displayed.

    My problem is, I feel like I am missing something, because the function does in fact remove any sections not in that array, but it’s supposed to only do so for the customizer accessed via the button here:

    <a class="btn btn-default" href="<?php echo $url; ?>">Customize</a>

    and not the when the customizer is accessed via the appearance menu or any other method. But instead it’s running no matter how the customizer is accessed. Which makes me feel like I’m missing an if statement or something somewhere, but anything i’ve tried hasn’t worked.

    I hope that makes more sense?
    (Sorry for such a long reply, I wanted to try and clarify it as best I could)

    • This reply was modified 8 years, 9 months ago by cgfx360.
    • This reply was modified 8 years, 9 months ago by cgfx360.
    Thread Starter cgfx360

    (@cgfx360)

    Thanks for this! I had seen the core WordPress code for the settings before but they were much more helpful upon a second look.

    I sadly never was able to get the “Image Position” selector to really work, but otherwise everything has gone pretty well.

    Thanks!

    Forum: Fixing WordPress
    In reply to: Editable Image
    Thread Starter cgfx360

    (@cgfx360)

    Thank you 🙂

    Forum: Fixing WordPress
    In reply to: Editable Image
    Thread Starter cgfx360

    (@cgfx360)

    I thought that would be perfect if possible…

    But how do i set the featured image to display there? I haven’t been able to figure out the code to do that…

Viewing 6 replies - 1 through 6 (of 6 total)