/** * @package Remove_Customizer_Core_Sections * @version 1.0 */ /* Plugin Name: Remove Customizer Core Sections Plugin URI: https://jennyveens.com/ Description: Removes 'nav_menus' and 'widgets' sections from the Customizer Author: Jenny Veens Version: 1.0 Author URI: https://jennyveens.com/ Text Domain: jv-remove-customizer-core */ /** * Removes the core 'Widgets' panel from the Customizer. * * @param array $components Core Customizer components list. * @return array (Maybe) modified components list. */ function jv_remove_customizer_core_remove_widgets_panel( $components ) { $i = array_search( 'widgets', $components ); if ( false !== $i ) { unset( $components[ $i ] ); } return $components; } add_filter( 'customize_loaded_components', 'jv_remove_customizer_core_remove_widgets_panel' ); /** * Removes the core 'Menus' panel from the Customizer. * * @param array $components Core Customizer components list. * @return array (Maybe) modified components list. */ function jv_remove_customizer_core_remove_nav_menus_panel( $components ) { $i = array_search( 'nav_menus', $components ); if ( false !== $i ) { unset( $components[ $i ] ); } return $components; } add_filter( 'customize_loaded_components', 'jv_remove_customizer_core_remove_nav_menus_panel' ); // square image sizes add_image_size( '60x60', 60, 60, true ); add_image_size( '130x130', 130, 130, true ); add_image_size( '300x300', 300, 300, true ); add_image_size( '600x600', 600, 600, true ); // video aspect ration image sizes add_image_size( '1024x400', 1024, 400, array( 'center', 'center' ) ); add_image_size( '992x558', 992, 558, array( 'center', 'center' ) ); add_image_size( '768x432', 768, 432, array( 'center', 'center' ) ); add_image_size( '480x270', 480, 270, array( 'center', 'center' ) ); add_image_size( '320x180', 320, 180, array( 'center', 'center' ) ); add_image_size( '240x135', 240, 135, array( 'center', 'center' ) ); // 2:3 Images add_image_size( '450x300', 450, 300, array( 'center', 'center' ) ); // non-cropped brand logo size add_image_size( '300x200', 300, 200, false ); // image sizes in admin dropdown menus add_filter( 'image_size_names_choose', function( $sizes ){ return array_merge( $sizes, array( '60x60' => __( '60x60' ), '992x558' => __( '992x558' ), '450x300' => __( '450x300' ), '768x432' => __( '768x432' ), '480x270' => __( '480x270' ), '320x180' => __( '320x180' ), '240x135' => __( '240x135' ), '300x300' => __( '300x300' ), '600x600' => __( '600x600' ), ) ); }); /** * * Returns an array of restaurant locations * */ if ( ! function_exists( 'get_porchetta_locations' ) ) { function get_porchetta_locations(){ return array( 'dundas' => 'Dundas St West', 'king' => 'King St West', 'acc' => 'Scotiabank Arena', 'exchange_tower' => 'Exchange Tower', 'north_york' => 'North York', ); } } /** * * Returns an images for single location slider * Image Type should be 'location' or 'menu' * */ if ( ! function_exists( 'get_slide_images' ) ) { function get_slide_images( $location_slug, $image_type ){ $slide_number = array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9); $slides = NULL; foreach($slide_number as $number) { $image_id = get_theme_mod('porchetta_'. $location_slug . '_' . $image_type .'_image_'. ($number + 1)); if (!empty($image_id)) { $image = array(); $image_url = wp_get_attachment_image_src( $image_id, '992x558' )[ 0 ]; $image_alt = get_post_meta( $image_id, '_wp_attachment_image_alt', true); if (!empty($image_url)) { $image['url'] = $image_url; if (!empty($image_alt)) { $image['alt'] = $image_alt; } } $slides[] = $image; } } return $slides; } } /* Customizer: Integrations */ add_action( 'customize_register', function( $wp_customize ){ $wp_customize->add_panel( 'integrations', array( 'title' => 'Integrations' ) ); // Instagram access token can be generated here: http://instagram.pixelunion.net/ $services = array( 'instagram' => array( 'title' => 'Instagram', 'fields' => array( 'user_id' => 'User ID', 'access_token' => 'Access Token' ) ), 'google_analytics' => array( 'title' => 'Google Analytics ID', 'fields' => array( 'analytics_id' => 'Google Analytics ID' ) ) ); foreach($services as $key => $service) { $wp_customize->add_section( $key, array( 'title' => $service['title'], 'panel' => 'integrations' ) ); foreach($service['fields'] as $setting => $label) { $setting_name = 'integrations_'.$key.'_'.$setting; $wp_customize->add_setting( $setting_name, array( 'default' => NULL ) ); $wp_customize->add_control( new WP_Customize_Control( $wp_customize, $setting_name, array( 'settings' => $setting_name, 'section' => $key, 'label' => $label, 'type' => 'text' ) ) ); } } }); /* Customizer: Location Specific Settings */ add_action( 'customize_register', function( $wp_customize ){ $locations = get_porchetta_locations(); $sections = array( 'pages' => array( 'title' => 'Pages', 'fields' => array( 'menu_page' => array( 'type' => 'dropdown-pages', 'label' => 'Menu Page:' ), 'location_page' => array( 'type' => 'dropdown-pages', 'label' => 'Location Page:' ), 'delivery_page' => array( 'type' => 'dropdown-pages', 'label' => 'Delivery Page:' ), 'catering_page' => array( 'type' => 'dropdown-pages', 'label' => 'Catering Page:' ) ) ), 'menus' => array( 'title'=> 'Menus', 'fields' => array( 'sandwich_menu_image' => array( 'type' => 'file_upload', 'mime' => 'jpg', 'label' => 'Sandwich/Sides Menu (JPG/PNG):' ), 'sandwich_menu_pdf' => array( 'type' => 'file_upload', 'mime' => 'PDF', 'label' => 'Sandwich/Sides Menu (PDF):' ), 'beverage_menu_image' => array( 'type' => 'file_upload', 'mime' => 'jpg', 'label' => 'Beverage Menu (JPG/PNG):' ), 'beverage_menu_pdf' => array( 'type' => 'file_upload', 'mime' => 'PDF', 'label' => 'Beverage Menu (PDF):' ), 'breakfast_menu_image' => array( 'type' => 'file_upload', 'mime' => 'jpg', 'label' => 'Breakfast Menu (JPG/PNG):', ), 'breakfast_menu_pdf' => array( 'type' => 'file_upload', 'mime' => 'PDF', 'label' => 'Breakfast Menu (PDF):', ) ) ), 'contact_info' => array( 'title' => 'Contact Info', 'fields' => array( 'address' => array( 'type' => 'textarea', 'label' => 'Address:' ), 'phone' => array( 'type' => 'tel', 'label' => 'Phone' ), 'email' => array( 'type' => 'email', 'label' => 'Email:' ) ) ), 'delivery_links' => array( 'title' => 'Delievery Links', 'fields' => array( 'doordash' => array( 'type' => 'text', 'label' => 'Doordash:', 'sanitize_callback' => 'esc_url' ), 'uber_eats' => array( 'type' => 'text', 'label' => 'UberEats:', 'sanitize_callback' => 'esc_url' ), 'ritual' => array( 'type' => 'text', 'label' => 'Ritual:', 'sanitize_callback' => 'esc_url' ), 'delivery_available' => array( 'type' => 'select', 'label' => 'If no Ritual, is Pick-up available at this location?', 'choices' => array( 0 => 'No', 1 => 'Yes' ) ) ) ), 'hours' => array( 'title' => 'Hours', 'fields' => array( 'monday' => array( 'type' => 'text', 'label' => 'Monday' ), 'tuesday' => array( 'type' => 'text', 'label' => 'Tuesday' ), 'wednesday' => array( 'type' => 'text', 'label' => 'Wednesday' ), 'thursday' => array( 'type' => 'text', 'label' => 'Thursday' ), 'friday' => array( 'type' => 'text', 'label' => 'Friday' ), 'saturday' => array( 'type' => 'text', 'label' => 'Saturday' ), 'sunday' => array( 'type' => 'text', 'label' => 'Sunday' ), 'notes' => array( 'type' => 'textarea', 'label' => 'Additional Notes' ) ) ), 'map' => array( 'title' => 'Map', 'fields' => array( 'map_image' => array( 'type' => 'file_upload', 'mime' => 'JPG', 'label' => 'Upload the Map Image:' ), 'map_link' => array( 'type' => 'url', 'label' => 'Link to Google Map', 'sanitize_callback' => 'esc_url' ) ) ), 'location_slider_images' => array( 'title' => 'Location Slider Images', 'fields' => array( 'location_image_1' => array( 'type' => 'media_upload', 'mime' => 'JPG', 'label' => 'Image 1:' ), 'location_image_2' => array( 'type' => 'media_upload', 'mime' => 'JPG', 'label' => 'Image 2:' ), 'location_image_3' => array( 'type' => 'media_upload', 'mime' => 'JPG', 'label' => 'Image 3:' ), 'location_image_4' => array( 'type' => 'media_upload', 'mime' => 'JPG', 'label' => 'Image 4:' ), 'location_image_5' => array( 'type' => 'media_upload', 'mime' => 'JPG', 'label' => 'Image 5:' ), 'location_image_6' => array( 'type' => 'media_upload', 'mime' => 'JPG', 'label' => 'Image 6:' ), 'location_image_7' => array( 'type' => 'media_upload', 'mime' => 'JPG', 'label' => 'Image 7:' ), 'location_image_8' => array( 'type' => 'media_upload', 'mime' => 'JPG', 'label' => 'Image 8:' ), 'location_image_9' => array( 'type' => 'media_upload', 'mime' => 'JPG', 'label' => 'Image 9:' ), 'location_image_10' => array( 'type' => 'media_upload', 'mime' => 'JPG', 'label' => 'Image 10:' ) ) ), 'menu_slider_images' => array( 'title' => 'Menu Slider Images', 'fields' => array( 'menu_image_1' => array( 'type' => 'media_upload', 'mime' => 'JPG', 'label' => 'Image 1:' ), 'menu_image_2' => array( 'type' => 'media_upload', 'mime' => 'JPG', 'label' => 'Image 2:' ), 'menu_image_3' => array( 'type' => 'media_upload', 'mime' => 'JPG', 'label' => 'Image 3:' ), 'menu_image_4' => array( 'type' => 'media_upload', 'mime' => 'JPG', 'label' => 'Image 4:' ), 'menu_image_5' => array( 'type' => 'media_upload', 'mime' => 'JPG', 'label' => 'Image 5:' ), 'menu_image_6' => array( 'type' => 'media_upload', 'mime' => 'JPG', 'label' => 'Image 6:' ), 'menu_image_7' => array( 'type' => 'media_upload', 'mime' => 'JPG', 'label' => 'Image 7:' ), 'menu_image_8' => array( 'type' => 'media_upload', 'mime' => 'JPG', 'label' => 'Image 8:' ), 'menu_image_9' => array( 'type' => 'media_upload', 'mime' => 'JPG', 'label' => 'Image 9:' ), 'menu_image_10' => array( 'type' => 'media_upload', 'mime' => 'JPG', 'label' => 'Image 10:' ) ) ), 'delivery_map' => array( 'title' => 'Delivery Map', 'fields' => array( 'delivery_map_image' => array( 'type' => 'file_upload', 'mime' => 'JPG', 'label' => 'Upload the Map Image:' ), 'map_description' => array( 'type' => 'textarea', 'label' => 'Description of delivery zone for screen readers.' ) ) ) ); foreach($locations as $key => $location) { $panel = 'porchetta_' . $key; // ADD THE COMPANY CONTACT SECTION $wp_customize->add_panel( $panel, array( 'title' => $location ) ); foreach($sections as $section => $details) { $section = 'porchetta_' . $key . '_' . $section; $section_settings = array( 'title' => $details['title'], 'panel' => $panel ); if (!empty($details['description'])) { $section_settings['description'] = $details['description']; } // add panel to customizer menu $wp_customize->add_section( $section, $section_settings ); foreach($details['fields'] as $field => $options) { $setting = 'porchetta_' . $key . '_' . $field; // $default = ''; // if ($setting['default']) { // $default = $setting['default']; // } $setting_options = array( 'default' => '' ); if (!empty($options['sanitize_callback'])) { $setting_options['sanitize_callback'] = $options['sanitize_callback']; } $wp_customize->add_setting( $setting, $setting_options ); if ($options['type'] == 'file_upload') { $wp_customize->add_control( new WP_Customize_Upload_Control( $wp_customize, $setting, array( 'label' => $options['label'], 'section' => $section, 'settings' => $setting, ) ) ); } else if ($options['type'] == 'media_upload') { $wp_customize->add_control( new WP_Customize_Media_Control( $wp_customize, $setting, array( 'label' => $options['label'], 'section' => $section, 'settings' => $setting, ) ) ); } else { $settings = array( 'section' => $section, 'settings' => $setting, 'label' => $options['label'], 'type' => $options['type'], ); if (!empty($options['choices'])) { $settings['choices'] = $options['choices']; } $wp_customize->add_control( new WP_Customize_Control( $wp_customize, $setting, $settings ) ); } } // end $details } // end $sections } // end $locations }); /* Customizer: Social Media Links */ add_action( 'customize_register', function( $wp_customize ){ $socials = array( 'twitter' => 'Twitter', 'instagram' => 'Instagram', 'facebook' => 'Facebook' ); $wp_customize->add_panel( 'social_media', array( 'title' => 'Social Media' ) ); foreach($socials as $key => $social) { $setting = 'porchetta_customize_social_media_'.$key; $wp_customize->add_section( 'porchetta_customize_' . $key, array( 'title' => $social, 'panel' => 'social_media', 'description' => 'URLs should begin with http:// or https://' ) ); $wp_customize->add_setting( $setting, array( 'default' => '', 'sanitize_callback' => 'esc_url' ) ); $wp_customize->add_control( new WP_Customize_Control( $wp_customize, $setting, array( 'section' => 'porchetta_customize_' . $key, 'settings' => $setting, 'label' => $social.' URL', 'type' => 'url', ) ) ); } }); /* Customizer: Catering Emails */ add_action( 'customize_register', function( $wp_customize ){ $wp_customize->add_section( 'catering_emails', array( 'title' => 'Catering Emails', 'description' => 'Catering Orders will be sent to the \'To\' emails.' ) ); $recipients = array( 1, 2, 3, 4 ); foreach($recipients as $key) { $setting_name = 'catering_email_'.$key; $wp_customize->add_setting( $setting_name, array( 'default' => NULL ) ); $wp_customize->add_control( new WP_Customize_Control( $wp_customize, $setting_name, array( 'settings' => $setting_name, 'section' => 'catering_emails', 'label'=> 'To email ' . $key . ':', 'type' => 'text' ) ) ); } $wp_customize->add_setting( 'catering_email_from', array( 'default' => NULL ) ); $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'catering_email_from', array( 'settings' => 'catering_email_from', 'section' => 'catering_emails', 'label'=> 'From Email:', 'type' => 'text', 'description' => 'This is the account that the catering emails will be sent from.' ) ) ); }); /* Customizer: Contact Us Text */ add_action( 'customize_register', function( $wp_customize ){ $wp_customize->add_section( 'contact_us_message', array( 'title' => 'Contact Us Message' ) ); $setting_name = 'contact_us_message'; $wp_customize->add_setting( $setting_name, array( 'default' => NULL ) ); $wp_customize->add_control( new WP_Customize_Control( $wp_customize, $setting_name, array( 'settings' => $setting_name, 'section' => 'contact_us_message', 'type' => 'textarea' ) ) ); }); /* for more information on taxonomies, go here: http://codex.wordpress.org/Function_Reference/register_taxonomy */ // now let's add custom categories (these act like categories) register_taxonomy( 'item_type', array('catered_item'), /* if you change the name of register_post_type( 'custom_type', then you have to change this */ array('hierarchical' => true, /* if this is true, it acts like categories */ 'labels' => array( 'name' => __( 'Item Type Category', 'jointswp' ), /* name of the custom taxonomy */ 'singular_name' => __( 'Item Type Category', 'jointswp' ), /* single taxonomy name */ 'search_items' => __( 'Item Types', 'jointswp' ), /* search title for taxomony */ 'all_items' => __( 'All Item Types', 'jointswp' ), /* all title for taxonomies */ 'parent_item' => __( 'Parent Type', 'jointswp' ), /* parent title for taxonomy */ 'parent_item_colon' => __( 'Parent Type:', 'jointswp' ), /* parent taxonomy title */ 'edit_item' => __( 'Edit Item Type Category', 'jointswp' ), /* edit custom taxonomy title */ 'update_item' => __( 'Update Item Types', 'jointswp' ), /* update title for taxonomy */ 'add_new_item' => __( 'Add New Item Type Category', 'jointswp' ), /* add new title for taxonomy */ 'new_item_name' => __( 'New Item Type Category', 'jointswp' ) /* name title for taxonomy */ ), 'show_admin_column' => true, 'show_ui' => true, 'query_var' => true, 'rewrite' => false ) ); // https://www.smashingmagazine.com/2015/12/how-to-use-term-meta-data-in-wordpress/ // add catered item form add_action( 'item_type_add_form_fields', function( $term ){ ?>
Check this box if you want to hide this category from the catering meny pages.
Show on Menu page? |
---|