Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add section to the existing panel #99

Closed
pavliukpetro opened this issue Apr 7, 2021 · 4 comments
Closed

Add section to the existing panel #99

pavliukpetro opened this issue Apr 7, 2021 · 4 comments

Comments

@pavliukpetro
Copy link

Hello,
is it possible to add section to the existing panel in the Customizer that was already defined by default in WP theme?
For example those sections come from the Woocommerce and I want to add my additional section there.

Снимок экрана 2021-04-07 в 23 52 36

Thank you.

@Codestar
Copy link
Owner

Codestar commented Apr 8, 2021

Hi,

Yes it's possible. for eg. Let's see this example:

// Control core classes for avoid errors
if( class_exists( 'CSF' ) ) {

  //
  // Set a unique slug-like ID
  $prefix = 'my_framework';

  //
  // Create customize options
  CSF::createCustomizeOptions( $prefix );

  //
  // Create a section
  CSF::createSection( $prefix, array(
    'assign' => 'title_tagline', // the exists panel id
    'fields' => array(

      //
      // A text field
      array(
        'id'    => 'opt-text-1',
        'type'  => 'text',
        'title' => 'Text 1',
      ),

    )
  ) );

  //
  // Create a section
  CSF::createSection( $prefix, array(
    'assign' => 'static_front_page', // the exists panel id
    'fields' => array(

      //
      // A text field
      array(
        'id'    => 'opt-text-2',
        'type'  => 'text',
        'title' => 'Text 2',
      ),

    )
  ) );

}

As you see there is a "assign" parameter. It's allow to add custom field to exists panels.

Btw, WooCommerce section id's:

'assign' => 'woocommerce_store_notice',
'assign' => 'woocommerce_product_catalog',
'assign' => 'woo-shop-single',
'assign' => 'woocommerce_product_images',
'assign' => 'woo-shop-cart',
'assign' => 'woocommerce_checkout',

Regards, Codestar

@pavliukpetro
Copy link
Author

Hello,
yes it works for adding the new field to the WooCommerce section. But how can I add new section next to existing WooCommerce's sections?
Thanks

@pavliukpetro
Copy link
Author

Ok, I added.
I simple create the new section in WP like

$wp_customize->add_section( 'woo_single_product_page', array( 'title' => __( 'Product Page', 'understrap' ), 'priority' => 10, 'panel' => 'woocommerce', ) );
and assign the fields to it.

But I am wonder is I can create the section and add it to the 'panel' => 'woocommerce' using Codestar Framework.

Thanks

@Codestar
Copy link
Owner

Codestar commented Apr 9, 2021

Unfortunately, that's not possible. maybe it can be possible in the next updates.

@Codestar Codestar closed this as completed Apr 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants