Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Using the WordPress Customizer to Build Beautif...

Using the WordPress Customizer to Build Beautiful Plugin Settings Pages

Using the Customizer at LoopConf

Patrick Rauland

May 08, 2015
Tweet

More Decks by Patrick Rauland

Other Decks in Technology

Transcript

  1. array( 'title' => __( 'Customize!', 'woocommerce' ), 'desc' => __(

    'Customize your product archive pages with the WordPress Customizer.', 'woocommerce' ), 'type' => 'wc_button', 'link' => $url ) WooCommerce Settings API: http://docs.woothemes.com/ document/settings-api/
  2. // get special page $shop_page_url = get_permalink( wc_get_page_id( 'shop' )

    ); // if we have a shop page go straight to it // the default will load the home page if ( $shop_page_url ) { $url = add_query_arg( 'url', urlencode( $shop_page_url ), $url ); }
  3. // get the return page $url = add_query_arg( 'return', urlencode(

    add_query_arg( array( 'page' => 'wc-settings', 'tab' => 'email' ), admin_url( 'admin.php' ) ) ), $url );
  4. 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; }
  5. $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'wc_email_header_image_control', array( 'label' => __( 'Upload

    a Header', 'woocommerce' ), 'priority' => 10, 'section' => 'wc_email_header', 'settings' => 'woocommerce_email_header_image', ) ) );