Plugin Directory

Changeset 2868895


Ignore:
Timestamp:
02/21/2023 04:50:10 PM (3 years ago)
Author:
jrobie23
Message:

updated banners and icons

Location:
mad-cow-customizer-for-woocommerce
Files:
8 edited
1 copied

Legend:

Unmodified
Added
Removed
  • mad-cow-customizer-for-woocommerce/tags/1.9.1/README.md

    r2844698 r2868895  
    66Requires at least: 5.2
    77Tested up to: 6.1
    8 Stable tag: 1.9
     8Stable tag: 1.9.1
    99Requires PHP: 7.0
    1010
     
    7979== Changelog ==
    8080
     81= 1.9.1 =
     82Added cool new banner images
     83
    8184= 1.8 =
    8285Add training video to ReadMe
  • mad-cow-customizer-for-woocommerce/tags/1.9.1/mad-cow-customizer-for-woocommerce.php

    r2844698 r2868895  
    11<?php
    2 if ( ! defined( 'ABSPATH' ) ) {
     2if (!defined('ABSPATH')) {
    33    exit; // Exit if accessed directly
    44}
     
    99 * Developer: Jason Robie
    1010 * Developer URI: https://madcowweb.com/
    11  * Version: 1.9
     11 * Version: 1.9.1
    1212 * Requires at least: 6.1
    1313 * Requires PHP:      7.2
     
    2626
    2727//Check if WooCommerce is active
    28 if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) :
    29 
    30     class MadCow_Customizer_Plugin {
    31 
    32         public function __construct() {
     28if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) :
     29
     30    class MadCow_Customizer_Plugin
     31    {
     32
     33        public function __construct()
     34        {
    3335            // Hook into the admin menu
    34             add_action( 'admin_menu', array( $this, 'create_plugin_settings_page' ) );
     36            add_action('admin_menu', array($this, 'create_plugin_settings_page'));
    3537
    3638            // Add Settings and Fields
    37             add_action( 'admin_init', array( $this, 'setup_sections' ) );
    38             add_action( 'admin_init', array( $this, 'setup_shop_page_fields' ) );
    39             add_action( 'admin_init', array( $this, 'setup_single_product_fields' ) );
    40             add_action( 'admin_init', array( $this, 'setup_cart_page_fields' ) );
    41             add_action( 'admin_init', array( $this, 'setup_checkout_page_fields' ) );
    42             add_action( 'admin_init', array( $this, 'setup_woo_email_fields' ) );
    43             add_action( 'admin_init', array( $this, 'setup_general_woo_fields' ) );
    44             add_action( 'admin_init', array( $this, 'setup_woo_tabs_fields' ) );
    45             add_action( 'admin_init', array( $this, 'setup_general_wp_fields' ) );
    46             add_action( 'admin_enqueue_scripts', 'madcow_customizer_styles' );
    47             add_action( 'wp_enqueue_scripts', 'madcow_customizer_styles' );
    48             function madcow_customizer_styles() {
    49                 wp_register_style( 'madcow_customizer_styles',  plugin_dir_url( __FILE__ ) . '/css/style.css' );
    50                 wp_enqueue_style( 'madcow_customizer_styles' );
     39            add_action('admin_init', array($this, 'setup_sections'));
     40            add_action('admin_init', array($this, 'setup_shop_page_fields'));
     41            add_action('admin_init', array($this, 'setup_single_product_fields'));
     42            add_action('admin_init', array($this, 'setup_cart_page_fields'));
     43            add_action('admin_init', array($this, 'setup_checkout_page_fields'));
     44            add_action('admin_init', array($this, 'setup_woo_email_fields'));
     45            add_action('admin_init', array($this, 'setup_general_woo_fields'));
     46            add_action('admin_init', array($this, 'setup_woo_tabs_fields'));
     47            add_action('admin_init', array($this, 'setup_general_wp_fields'));
     48            add_action('admin_enqueue_scripts', 'madcow_customizer_styles');
     49            add_action('wp_enqueue_scripts', 'madcow_customizer_styles');
     50            function madcow_customizer_styles()
     51            {
     52                wp_register_style('madcow_customizer_styles',  plugin_dir_url(__FILE__) . '/css/style.css');
     53                wp_enqueue_style('madcow_customizer_styles');
    5154            }
    5255
    53             include_once( plugin_dir_path( __FILE__ ) . 'includes/mcw-shop.php' );
    54             include_once( plugin_dir_path( __FILE__ ) . 'includes/mcw-single-product.php' );
    55             include_once( plugin_dir_path( __FILE__ ) . 'includes/mcw-cart.php' );
    56             include_once( plugin_dir_path( __FILE__ ) . 'includes/mcw-checkout.php' );
    57             include_once( plugin_dir_path( __FILE__ ) . 'includes/mcw-emails.php' );
    58             include_once( plugin_dir_path( __FILE__ ) . 'includes/mcw-general-woo.php' );
    59             include_once( plugin_dir_path( __FILE__ ) . 'includes/mcw-woo-tabs.php' );
    60             include_once( plugin_dir_path( __FILE__ ) . 'includes/mcw-general-wp.php' );
    61         }
    62 
    63         public function create_plugin_settings_page() {
     56            include_once(plugin_dir_path(__FILE__) . 'includes/mcw-shop.php');
     57            include_once(plugin_dir_path(__FILE__) . 'includes/mcw-single-product.php');
     58            include_once(plugin_dir_path(__FILE__) . 'includes/mcw-cart.php');
     59            include_once(plugin_dir_path(__FILE__) . 'includes/mcw-checkout.php');
     60            include_once(plugin_dir_path(__FILE__) . 'includes/mcw-emails.php');
     61            include_once(plugin_dir_path(__FILE__) . 'includes/mcw-general-woo.php');
     62            include_once(plugin_dir_path(__FILE__) . 'includes/mcw-woo-tabs.php');
     63            include_once(plugin_dir_path(__FILE__) . 'includes/mcw-general-wp.php');
     64        }
     65
     66        public function create_plugin_settings_page()
     67        {
    6468            // Add new admin menu item and page
    6569            $page_title = esc_html('MCW Settings Page');
     
    6771            $capability = esc_html('manage_options');
    6872            $slug = esc_html('mcw_settings_page');
    69             $callback = array( $this, 'mcw_settings_page' );
    70             add_submenu_page( 'woocommerce', $page_title, $menu_title, $capability, $slug, $callback );
    71         }
    72 
    73         public function mcw_settings_page( $active_tab = '' ) { ?>
    74             <div class="wrap">
    75             <h2>Mad Cow Customizer</h2>
    76             <?php if ( filter_input( INPUT_GET, 'settings-updated',FILTER_SANITIZE_STRING ) && filter_input(INPUT_GET, 'settings-updated' ,FILTER_SANITIZE_STRING) ) :
    77                 $this->admin_notice();
    78             endif;
    79             if ( filter_input( INPUT_GET, 'tab',FILTER_SANITIZE_STRING ) )  :
    80                 $active_tab = filter_input( INPUT_GET, 'tab',FILTER_SANITIZE_STRING );
    81             elseif ( $active_tab == filter_input( INPUT_GET, 'shop_page_options', FILTER_SANITIZE_STRING) ) :
    82                 $active_tab = filter_input( INPUT_GET, 'shop_page_options', FILTER_SANITIZE_STRING);
    83             elseif ( $active_tab == filter_input( INPUT_GET, 'single_product_options', FILTER_SANITIZE_STRING) ) :
    84                 $active_tab = filter_input( INPUT_GET, 'single_product_options', FILTER_SANITIZE_STRING);
    85             elseif ( $active_tab == filter_input( INPUT_GET, 'cart_page_options', FILTER_SANITIZE_STRING) ) :
    86                 $active_tab = filter_input( INPUT_GET, 'cart_page_options', FILTER_SANITIZE_STRING);
    87             elseif ( $active_tab == filter_input( INPUT_GET, 'checkout_page_options', FILTER_SANITIZE_STRING) ) :
    88                 $active_tab = filter_input( INPUT_GET, 'checkout_page_options', FILTER_SANITIZE_STRING);
    89             elseif ( $active_tab == filter_input( INPUT_GET, 'general_woo_options', FILTER_SANITIZE_STRING) ) :
    90                 $active_tab = filter_input( INPUT_GET, 'general_woo_options', FILTER_SANITIZE_STRING);
    91             elseif ( $active_tab == filter_input( INPUT_GET, 'woo_email_options', FILTER_SANITIZE_STRING) ) :
    92                 $active_tab = filter_input( INPUT_GET, 'woo_email_options', FILTER_SANITIZE_STRING);
    93             elseif ( $active_tab == filter_input( INPUT_GET, 'woo_tabs_options', FILTER_SANITIZE_STRING) ) :
    94                 $active_tab = filter_input( INPUT_GET, 'woo_tabs_options', FILTER_SANITIZE_STRING);
    95             elseif ( $active_tab == filter_input( INPUT_GET, 'general_wp_options', FILTER_SANITIZE_STRING) ) :
    96                 $active_tab = filter_input( INPUT_GET, 'general_wp_options', FILTER_SANITIZE_STRING);
    97             endif; ?>
    98 
    99             <h2 class="nav-tab-wrapper">
    100                 <a href="?page=mcw_settings_page&tab=shop_page_options" class="nav-tab <?php echo sanitize_text_field($active_tab == 'shop_page_options' ? 'nav-tab-active' : ''); ?>"><?php echo esc_html( 'Shop/Archive Page Options', 'madcowweb' ); ?></a>
    101                 <a href="?page=mcw_settings_page&tab=single_product_options" class="nav-tab <?php echo sanitize_text_field($active_tab == 'single_product_options' ? 'nav-tab-active' : ''); ?>"><?php echo esc_html( 'Single Product Page Options', 'madcowweb' ); ?></a>
    102                 <a href="?page=mcw_settings_page&tab=cart_page_options" class="nav-tab <?php echo sanitize_text_field($active_tab == 'cart_page_options' ? 'nav-tab-active' : ''); ?>"><?php echo esc_html( 'Cart Page Options', 'madcowweb' ); ?></a>
    103                 <a href="?page=mcw_settings_page&tab=checkout_page_options" class="nav-tab <?php echo sanitize_text_field($active_tab == 'checkout_page_options' ? 'nav-tab-active' : ''); ?>"><?php echo esc_html( 'Checkout Page Options', 'madcowweb' ); ?></a>
    104                 <a href="?page=mcw_settings_page&tab=woo_email_options" class="nav-tab <?php echo sanitize_text_field($active_tab == 'woo_email_options' ? 'nav-tab-active' : ''); ?>"><?php echo esc_html( 'Email Options', 'madcowweb' ); ?></a>
    105                 <a href="?page=mcw_settings_page&tab=general_woo_options" class="nav-tab <?php echo sanitize_text_field($active_tab == 'general_woo_options' ? 'nav-tab-active' : ''); ?>"><?php echo esc_html( 'General WooCommerce Options', 'madcowweb' ); ?></a>
    106                 <a href="?page=mcw_settings_page&tab=woo_tabs_options" class="nav-tab <?php echo sanitize_text_field($active_tab == 'woo_tabs_options' ? 'nav-tab-active' : ''); ?>"><?php echo esc_html( 'WooCommerce Custom Tabs', 'madcowweb' ); ?></a>
    107                 <a href="?page=mcw_settings_page&tab=general_wp_options" class="nav-tab <?php echo sanitize_text_field($active_tab == 'general_wp_options' ? 'nav-tab-active' : ''); ?>"><?php echo esc_html( 'General WordPress Options', 'madcowweb' ); ?></a>
    108             </h2>
    109 
    110             <form method="post" action="options.php">
    111                 <?php if ( $active_tab == 'shop_page_options' ) :
    112                     settings_fields( 'shop_archive_page_tab' );
    113                     do_settings_sections( 'shop_archive_page_tab' );
    114                 elseif ( $active_tab == 'single_product_options' ) :
    115                     settings_fields( 'single_product_page_tab' );
    116                     do_settings_sections( 'single_product_page_tab' );
    117                 elseif ( $active_tab == 'cart_page_options' ) :
    118                     settings_fields( 'cart_page_tab' );
    119                     do_settings_sections( 'cart_page_tab' );
    120                 elseif ( $active_tab == 'checkout_page_options' ) :
    121                     settings_fields( 'checkout_page_tab' );
    122                     do_settings_sections( 'checkout_page_tab' );
    123                 elseif ( $active_tab == 'woo_email_options' ) :
    124                     settings_fields( 'woo_email_tab' );
    125                     do_settings_sections( 'woo_email_tab' );
    126                 elseif ( $active_tab == 'general_woo_options' ) :
    127                     settings_fields( 'general_woo_tab' );
    128                     do_settings_sections( 'general_woo_tab' );
    129                 elseif ( $active_tab == 'woo_tabs_options' ) :
    130                     settings_fields( 'woo_product_tabs_tab' );
    131                     do_settings_sections( 'woo_product_tabs_tab' );
    132                 elseif ( $active_tab == 'general_wp_options' ) :
    133                     settings_fields( 'general_wp_tab' );
    134                     do_settings_sections( 'general_wp_tab' );
     73            $callback = array($this, 'mcw_settings_page');
     74            add_submenu_page('woocommerce', $page_title, $menu_title, $capability, $slug, $callback);
     75        }
     76
     77        public function mcw_settings_page($active_tab = '')
     78        { ?>
     79<div class="wrap">
     80    <h2>Mad Cow Customizer</h2>
     81    <?php if (filter_input(INPUT_GET, 'settings-updated', FILTER_SANITIZE_STRING) && filter_input(INPUT_GET, 'settings-updated', FILTER_SANITIZE_STRING)) :
     82                    $this->admin_notice();
    13583                endif;
    136                 submit_button(); ?>
    137             </form>
    138             </div>
    139         <?php }
    140 
    141         public function admin_notice() {
     84                if (filter_input(INPUT_GET, 'tab', FILTER_SANITIZE_STRING)) :
     85                    $active_tab = filter_input(INPUT_GET, 'tab', FILTER_SANITIZE_STRING);
     86                elseif ($active_tab == filter_input(INPUT_GET, 'shop_page_options', FILTER_SANITIZE_STRING)) :
     87                    $active_tab = filter_input(INPUT_GET, 'shop_page_options', FILTER_SANITIZE_STRING);
     88                elseif ($active_tab == filter_input(INPUT_GET, 'single_product_options', FILTER_SANITIZE_STRING)) :
     89                    $active_tab = filter_input(INPUT_GET, 'single_product_options', FILTER_SANITIZE_STRING);
     90                elseif ($active_tab == filter_input(INPUT_GET, 'cart_page_options', FILTER_SANITIZE_STRING)) :
     91                    $active_tab = filter_input(INPUT_GET, 'cart_page_options', FILTER_SANITIZE_STRING);
     92                elseif ($active_tab == filter_input(INPUT_GET, 'checkout_page_options', FILTER_SANITIZE_STRING)) :
     93                    $active_tab = filter_input(INPUT_GET, 'checkout_page_options', FILTER_SANITIZE_STRING);
     94                elseif ($active_tab == filter_input(INPUT_GET, 'general_woo_options', FILTER_SANITIZE_STRING)) :
     95                    $active_tab = filter_input(INPUT_GET, 'general_woo_options', FILTER_SANITIZE_STRING);
     96                elseif ($active_tab == filter_input(INPUT_GET, 'woo_email_options', FILTER_SANITIZE_STRING)) :
     97                    $active_tab = filter_input(INPUT_GET, 'woo_email_options', FILTER_SANITIZE_STRING);
     98                elseif ($active_tab == filter_input(INPUT_GET, 'woo_tabs_options', FILTER_SANITIZE_STRING)) :
     99                    $active_tab = filter_input(INPUT_GET, 'woo_tabs_options', FILTER_SANITIZE_STRING);
     100                elseif ($active_tab == filter_input(INPUT_GET, 'general_wp_options', FILTER_SANITIZE_STRING)) :
     101                    $active_tab = filter_input(INPUT_GET, 'general_wp_options', FILTER_SANITIZE_STRING);
     102                endif; ?>
     103
     104    <h2 class="nav-tab-wrapper">
     105        <a href="?page=mcw_settings_page&tab=shop_page_options" class="nav-tab <?php echo sanitize_text_field($active_tab == 'shop_page_options' ? 'nav-tab-active' : ''); ?>"><?php echo esc_html('Shop/Archive Page Options', 'madcowweb'); ?></a>
     106        <a href="?page=mcw_settings_page&tab=single_product_options" class="nav-tab <?php echo sanitize_text_field($active_tab == 'single_product_options' ? 'nav-tab-active' : ''); ?>"><?php echo esc_html('Single Product Page Options', 'madcowweb'); ?></a>
     107        <a href="?page=mcw_settings_page&tab=cart_page_options" class="nav-tab <?php echo sanitize_text_field($active_tab == 'cart_page_options' ? 'nav-tab-active' : ''); ?>"><?php echo esc_html('Cart Page Options', 'madcowweb'); ?></a>
     108        <a href="?page=mcw_settings_page&tab=checkout_page_options" class="nav-tab <?php echo sanitize_text_field($active_tab == 'checkout_page_options' ? 'nav-tab-active' : ''); ?>"><?php echo esc_html('Checkout Page Options', 'madcowweb'); ?></a>
     109        <a href="?page=mcw_settings_page&tab=woo_email_options" class="nav-tab <?php echo sanitize_text_field($active_tab == 'woo_email_options' ? 'nav-tab-active' : ''); ?>"><?php echo esc_html('Email Options', 'madcowweb'); ?></a>
     110        <a href="?page=mcw_settings_page&tab=general_woo_options" class="nav-tab <?php echo sanitize_text_field($active_tab == 'general_woo_options' ? 'nav-tab-active' : ''); ?>"><?php echo esc_html('General WooCommerce Options', 'madcowweb'); ?></a>
     111        <a href="?page=mcw_settings_page&tab=woo_tabs_options" class="nav-tab <?php echo sanitize_text_field($active_tab == 'woo_tabs_options' ? 'nav-tab-active' : ''); ?>"><?php echo esc_html('WooCommerce Custom Tabs', 'madcowweb'); ?></a>
     112        <a href="?page=mcw_settings_page&tab=general_wp_options" class="nav-tab <?php echo sanitize_text_field($active_tab == 'general_wp_options' ? 'nav-tab-active' : ''); ?>"><?php echo esc_html('General WordPress Options', 'madcowweb'); ?></a>
     113    </h2>
     114
     115    <form method="post" action="options.php">
     116        <?php if ($active_tab == 'shop_page_options') :
     117                        settings_fields('shop_archive_page_tab');
     118                        do_settings_sections('shop_archive_page_tab');
     119                    elseif ($active_tab == 'single_product_options') :
     120                        settings_fields('single_product_page_tab');
     121                        do_settings_sections('single_product_page_tab');
     122                    elseif ($active_tab == 'cart_page_options') :
     123                        settings_fields('cart_page_tab');
     124                        do_settings_sections('cart_page_tab');
     125                    elseif ($active_tab == 'checkout_page_options') :
     126                        settings_fields('checkout_page_tab');
     127                        do_settings_sections('checkout_page_tab');
     128                    elseif ($active_tab == 'woo_email_options') :
     129                        settings_fields('woo_email_tab');
     130                        do_settings_sections('woo_email_tab');
     131                    elseif ($active_tab == 'general_woo_options') :
     132                        settings_fields('general_woo_tab');
     133                        do_settings_sections('general_woo_tab');
     134                    elseif ($active_tab == 'woo_tabs_options') :
     135                        settings_fields('woo_product_tabs_tab');
     136                        do_settings_sections('woo_product_tabs_tab');
     137                    elseif ($active_tab == 'general_wp_options') :
     138                        settings_fields('general_wp_tab');
     139                        do_settings_sections('general_wp_tab');
     140                    endif;
     141                    submit_button(); ?>
     142    </form>
     143</div>
     144<?php }
     145
     146        public function admin_notice()
     147        {
    142148            echo wp_kses_post('<div class="notice notice-success is-dismissible"><p>Hooray! Your settings have been updated!</p></div>');
    143149        }
    144150
    145         public function setup_sections() {
    146             add_settings_section( 'shop_archive_page_tab', '', array( $this, 'shop_section_callback' ), 'shop_archive_page_tab' );
    147             add_settings_section( 'single_product_page_tab', '', array( $this, 'single_product_page_tab_callback' ) , 'single_product_page_tab' );
    148             add_settings_section( 'cart_page_tab', '', array( $this, 'cart_page_callback' ) , 'cart_page_tab' );
    149             add_settings_section( 'checkout_page_tab', '', array( $this, 'checkout_page_tab_callback' ), 'checkout_page_tab' );
    150             add_settings_section( 'woo_email_tab1', '', array( $this, 'woo_email_tab_callback1' ), 'woo_email_tab' );
    151             add_settings_section( 'woo_email_tab2', '', array( $this, 'woo_email_tab_callback2' ), 'woo_email_tab' );
    152             add_settings_section( 'general_woo_tab', '', array( $this, 'general_woo_tab_callback' ) , 'general_woo_tab' );
    153             add_settings_section( 'woo_product_tabs_tab1', '', array( $this, 'woo_product_tabs_tab_callback1' ) , 'woo_product_tabs_tab' );
    154             add_settings_section( 'woo_product_tabs_tab2', '', array( $this, 'woo_product_tabs_tab_callback2' ) , 'woo_product_tabs_tab' );
    155             add_settings_section( 'woo_product_tabs_tab3', '', array( $this, 'woo_product_tabs_tab_callback3' ) , 'woo_product_tabs_tab' );
    156             add_settings_section( 'general_wp_tab', '', array( $this, 'general_wp_tab_callback' ) , 'general_wp_tab' );
    157         }
    158         public function shop_section_callback() { ?>
    159                 <h1>Shop/Archive Page</h1>
    160                 <h2 class="mcw">Custom Hook locations are highlighted in bold, green, italic font</h2>
    161                 <h3 class="mcw">Use the editor titles to know where you want your content to appear</h3>
    162                 <p>Please use your browser's inspector to target these custom areas and add your own styling</p>
    163                 <?php echo wp_kses_post('<img src="' . plugins_url( 'images/mcw-customizer-shop.png', __FILE__ ) . '" > ');
    164         }
    165         public function single_product_page_tab_callback() { ?>
    166                 <h1>Single Product Page</h1>
    167                 <h2 class="mcw">Custom Hook locations are highlighted in bold, green, italic font</h2>
    168                 <h3 class="mcw">Use the editor titles to know where you want your content to appear</h3>
    169                 <p>Please use your browser's inspector to target these custom areas and add your own styling</p>
    170                 <?php echo wp_kses_post('<img src="' . plugins_url( 'images/mcw-customizer-product.png', __FILE__ ) . '" > ');
    171         }
    172         public function cart_page_callback() { ?>
    173                 <h1>Cart Page</h1>
    174                 <h2 class="mcw">Custom Hook locations are highlighted in bold, green, italic font</h2>
    175                 <h3 class="mcw">Use the editor titles to know where you want your content to appear</h3>
    176                 <p>Please use your browser's inspector to target these custom areas and add your own styling</p>
    177                 <?php echo wp_kses_post('<img src="' . plugins_url( 'images/mcw-customizer-cart.png', __FILE__ ) . '" > ');
    178         }
    179         public function checkout_page_tab_callback() { ?>
    180                 <h1>Checkout Page</h1>
    181                 <h2 class="mcw">Custom Hook locations are highlighted in bold, green, italic font</h2>
    182                 <h3 class="mcw">Use the editor titles to know where you want your content to appear</h3>
    183                 <p>Please use your browser's inspector to target these custom areas and add your own styling</p>
    184                 <?php echo wp_kses_post('<img style="max-width:550px;" src="' . plugins_url( 'images/mcw-customizer-checkout.png', __FILE__ ) . '" >');
    185         }
    186         public function woo_email_tab_callback1() { ?>
    187                 <h1>General WooCommerce Email Settings</h1>
    188                 <p>We recommend an Email Preview plugin such as <a href="https://wordpress.org/plugins/woo-preview-emails/" target="_blank">This one</a></p>
    189                 <h2 class="mcw">Email Header</h2>
    190                 <?php echo wp_kses_post('<img src="' . plugins_url( 'images/mcw-customizer-email.png', __FILE__ ) . '" >');
    191         }
    192         public function woo_email_tab_callback2() { ?>
    193                 <h2 class="mcw">Email Footer</h2>
    194                 <?php
    195         }
    196         public function general_woo_tab_callback() { ?>
    197                 <h1>General WooCommerce Settings</h1>
    198                 <p>Please use your browser's inspector to target these custom areas and add your own styling</p>
    199                 <?php
    200         }
    201         public function woo_product_tabs_tab_callback1() { ?>
    202                 <h1>WooCommerce Custom Product Tabs</h1>
    203                 <p>Please use your browser's inspector to target these custom areas and add your own styling</p>
    204                 <h2 class="mcw">Tab 1</h2>
    205                 <?php
    206         }
    207         public function woo_product_tabs_tab_callback2() { ?>
    208                 <h2 class="mcw">Tab 2</h2>
    209                 <?php
    210         }
    211         public function woo_product_tabs_tab_callback3() { ?>
    212                 <h2 class="mcw">Tab 3</h2>
    213                 <?php
    214         }
    215         public function general_wp_tab_callback() { ?>
    216             <h1>General WordPress Settings</h1>
    217             <?php
    218         }
    219 
    220         public function setup_shop_page_fields() {
    221             include ( plugin_dir_path( __FILE__ ) . 'includes/shop-page-fields.php' );
    222         }
    223         public function setup_single_product_fields() {
    224             include ( plugin_dir_path( __FILE__ ) . 'includes/single-product-fields.php' );
    225         }
    226         public function setup_cart_page_fields() {
    227             include ( plugin_dir_path( __FILE__ ) . 'includes/cart-page-fields.php' );
    228         }
    229         public function setup_checkout_page_fields() {
    230             include ( plugin_dir_path( __FILE__ ) . 'includes/checkout-page-fields.php' );
    231         }
    232         public function setup_woo_email_fields() {
    233             include ( plugin_dir_path( __FILE__ ) . 'includes/woo-email-fields.php' );
    234         }
    235         public function setup_general_woo_fields() {
    236             include ( plugin_dir_path( __FILE__ ) . 'includes/general-woo-fields.php' );
    237         }
    238         public function setup_woo_tabs_fields() {
    239             include ( plugin_dir_path( __FILE__ ) . 'includes/woo-tabs-fields.php' );
    240         }
    241         public function setup_general_wp_fields() {
    242             include ( plugin_dir_path( __FILE__ ) . 'includes/general-wp-fields.php' );
    243         }
    244 
    245         public function field_callback( $arguments ) {
    246             $value = get_option( $arguments['uid'] );
    247             $value = ! empty( $value ) ? $value : $arguments['default'];
    248 
    249             switch( $arguments['type'] ) {
     151        public function setup_sections()
     152        {
     153            add_settings_section('shop_archive_page_tab', '', array($this, 'shop_section_callback'), 'shop_archive_page_tab');
     154            add_settings_section('single_product_page_tab', '', array($this, 'single_product_page_tab_callback'), 'single_product_page_tab');
     155            add_settings_section('cart_page_tab', '', array($this, 'cart_page_callback'), 'cart_page_tab');
     156            add_settings_section('checkout_page_tab', '', array($this, 'checkout_page_tab_callback'), 'checkout_page_tab');
     157            add_settings_section('woo_email_tab1', '', array($this, 'woo_email_tab_callback1'), 'woo_email_tab');
     158            add_settings_section('woo_email_tab2', '', array($this, 'woo_email_tab_callback2'), 'woo_email_tab');
     159            add_settings_section('general_woo_tab', '', array($this, 'general_woo_tab_callback'), 'general_woo_tab');
     160            add_settings_section('woo_product_tabs_tab1', '', array($this, 'woo_product_tabs_tab_callback1'), 'woo_product_tabs_tab');
     161            add_settings_section('woo_product_tabs_tab2', '', array($this, 'woo_product_tabs_tab_callback2'), 'woo_product_tabs_tab');
     162            add_settings_section('woo_product_tabs_tab3', '', array($this, 'woo_product_tabs_tab_callback3'), 'woo_product_tabs_tab');
     163            add_settings_section('general_wp_tab', '', array($this, 'general_wp_tab_callback'), 'general_wp_tab');
     164        }
     165        public function shop_section_callback()
     166        { ?>
     167<h1>Shop/Archive Page</h1>
     168<h2 class="mcw">Custom Hook locations are highlighted in bold, green, italic font</h2>
     169<h3 class="mcw">Use the editor titles to know where you want your content to appear</h3>
     170<p>Please use your browser's inspector to target these custom areas and add your own styling</p>
     171<?php echo wp_kses_post('<img src="' . plugins_url('images/mcw-customizer-shop.png', __FILE__) . '" > ');
     172        }
     173        public function single_product_page_tab_callback()
     174        { ?>
     175<h1>Single Product Page</h1>
     176<h2 class="mcw">Custom Hook locations are highlighted in bold, green, italic font</h2>
     177<h3 class="mcw">Use the editor titles to know where you want your content to appear</h3>
     178<p>Please use your browser's inspector to target these custom areas and add your own styling</p>
     179<?php echo wp_kses_post('<img src="' . plugins_url('images/mcw-customizer-product.png', __FILE__) . '" > ');
     180        }
     181        public function cart_page_callback()
     182        { ?>
     183<h1>Cart Page</h1>
     184<h2 class="mcw">Custom Hook locations are highlighted in bold, green, italic font</h2>
     185<h3 class="mcw">Use the editor titles to know where you want your content to appear</h3>
     186<p>Please use your browser's inspector to target these custom areas and add your own styling</p>
     187<?php echo wp_kses_post('<img src="' . plugins_url('images/mcw-customizer-cart.png', __FILE__) . '" > ');
     188        }
     189        public function checkout_page_tab_callback()
     190        { ?>
     191<h1>Checkout Page</h1>
     192<h2 class="mcw">Custom Hook locations are highlighted in bold, green, italic font</h2>
     193<h3 class="mcw">Use the editor titles to know where you want your content to appear</h3>
     194<p>Please use your browser's inspector to target these custom areas and add your own styling</p>
     195<?php echo wp_kses_post('<img style="max-width:550px;" src="' . plugins_url('images/mcw-customizer-checkout.png', __FILE__) . '" >');
     196        }
     197        public function woo_email_tab_callback1()
     198        { ?>
     199<h1>General WooCommerce Email Settings</h1>
     200<p>We recommend an Email Preview plugin such as <a href="https://wordpress.org/plugins/woo-preview-emails/" target="_blank">This one</a></p>
     201<h2 class="mcw">Email Header</h2>
     202<?php echo wp_kses_post('<img src="' . plugins_url('images/mcw-customizer-email.png', __FILE__) . '" >');
     203        }
     204        public function woo_email_tab_callback2()
     205        { ?>
     206<h2 class="mcw">Email Footer</h2>
     207<?php
     208        }
     209        public function general_woo_tab_callback()
     210        { ?>
     211<h1>General WooCommerce Settings</h1>
     212<p>Please use your browser's inspector to target these custom areas and add your own styling</p>
     213<?php
     214        }
     215        public function woo_product_tabs_tab_callback1()
     216        { ?>
     217<h1>WooCommerce Custom Product Tabs</h1>
     218<p>Please use your browser's inspector to target these custom areas and add your own styling</p>
     219<h2 class="mcw">Tab 1</h2>
     220<?php
     221        }
     222        public function woo_product_tabs_tab_callback2()
     223        { ?>
     224<h2 class="mcw">Tab 2</h2>
     225<?php
     226        }
     227        public function woo_product_tabs_tab_callback3()
     228        { ?>
     229<h2 class="mcw">Tab 3</h2>
     230<?php
     231        }
     232        public function general_wp_tab_callback()
     233        { ?>
     234<h1>General WordPress Settings</h1>
     235<?php
     236        }
     237
     238        public function setup_shop_page_fields()
     239        {
     240            include(plugin_dir_path(__FILE__) . 'includes/shop-page-fields.php');
     241        }
     242        public function setup_single_product_fields()
     243        {
     244            include(plugin_dir_path(__FILE__) . 'includes/single-product-fields.php');
     245        }
     246        public function setup_cart_page_fields()
     247        {
     248            include(plugin_dir_path(__FILE__) . 'includes/cart-page-fields.php');
     249        }
     250        public function setup_checkout_page_fields()
     251        {
     252            include(plugin_dir_path(__FILE__) . 'includes/checkout-page-fields.php');
     253        }
     254        public function setup_woo_email_fields()
     255        {
     256            include(plugin_dir_path(__FILE__) . 'includes/woo-email-fields.php');
     257        }
     258        public function setup_general_woo_fields()
     259        {
     260            include(plugin_dir_path(__FILE__) . 'includes/general-woo-fields.php');
     261        }
     262        public function setup_woo_tabs_fields()
     263        {
     264            include(plugin_dir_path(__FILE__) . 'includes/woo-tabs-fields.php');
     265        }
     266        public function setup_general_wp_fields()
     267        {
     268            include(plugin_dir_path(__FILE__) . 'includes/general-wp-fields.php');
     269        }
     270
     271        public function field_callback($arguments)
     272        {
     273            $value = get_option($arguments['uid']);
     274            $value = !empty($value) ? $value : $arguments['default'];
     275
     276            switch ($arguments['type']) {
    250277                case 'radio':
    251278                case 'checkbox':
    252                     if( ! empty ( $arguments['options'] ) && is_array( $arguments['options'] ) ){
     279                    if (!empty($arguments['options']) && is_array($arguments['options'])) {
    253280                        $options_markup = '';
    254281                        $iterator = 0;
    255                         foreach( $arguments['options'] as $key => $label ){
     282                        foreach ($arguments['options'] as $key => $label) {
    256283                            $iterator++;
    257284                            $options_markup .= sprintf(
     
    260287                                $key,
    261288                                checked(
    262                                     $value[ array_search( $key, $value, true ) ],
     289                                    $value[array_search($key, $value, true)],
    263290                                    $key,
    264291                                    false
     
    268295                            );
    269296                        }
    270                         printf( '<fieldset>%s</fieldset>', $options_markup );
     297                        printf('<fieldset>%s</fieldset>', $options_markup);
    271298                    }
    272299                    break;
    273300                case 'text':
    274301                case 'textarea':
    275                     printf( '<textarea name="%1$s" id="%1$s" rows="%2$s" placeholder="%3$s">%4$s</textarea>',
    276                     sanitize_text_field($arguments['uid']),
    277                     sanitize_text_field($arguments['rows']),
    278                     sanitize_text_field($arguments['placeholder']),
    279                     wp_kses_post($value),
     302                    printf(
     303                        '<textarea name="%1$s" id="%1$s" rows="%2$s" placeholder="%3$s">%4$s</textarea>',
     304                        sanitize_text_field($arguments['uid']),
     305                        sanitize_text_field($arguments['rows']),
     306                        sanitize_text_field($arguments['placeholder']),
     307                        wp_kses_post($value),
    280308                    );
    281309                    break;
    282310            }
    283             if ( $helper = $arguments['helper'] ) :
    284                 printf( '<span class="mcw-helper"> %s</span>', sanitize_text_field( $helper ));
     311            if ($helper = $arguments['helper']) :
     312                printf('<span class="mcw-helper"> %s</span>', sanitize_text_field($helper));
    285313            endif;
    286             if ( $supplemental = $arguments['supplemental'] ) :
    287                 printf( '<p class="mcw-description">%s</p>', sanitize_text_field( $supplemental ));
     314            if ($supplemental = $arguments['supplemental']) :
     315                printf('<p class="mcw-description">%s</p>', sanitize_text_field($supplemental));
    288316            endif;
    289317        }
    290318    }
    291319    new MadCow_Customizer_Plugin();
    292     function mcw_add_settings_link( $links ) {
    293         $settings_link = '<a href="admin.php?page=mcw_settings_page">' . __( 'Mad Cow Settings' ) . '</a>';
    294         array_push( $links, $settings_link );
     320    function mcw_add_settings_link($links)
     321    {
     322        $settings_link = '<a href="admin.php?page=mcw_settings_page">' . __('Mad Cow Settings') . '</a>';
     323        array_push($links, $settings_link);
    295324        return $links;
    296325    }
    297     $plugin = plugin_basename( __FILE__ );
    298     add_filter( "plugin_action_links_$plugin", 'mcw_add_settings_link' );
     326    $plugin = plugin_basename(__FILE__);
     327    add_filter("plugin_action_links_$plugin", 'mcw_add_settings_link');
    299328endif;
  • mad-cow-customizer-for-woocommerce/trunk/README.md

    r2844698 r2868895  
    66Requires at least: 5.2
    77Tested up to: 6.1
    8 Stable tag: 1.9
     8Stable tag: 1.9.1
    99Requires PHP: 7.0
    1010
     
    7979== Changelog ==
    8080
     81= 1.9.1 =
     82Added cool new banner images
     83
    8184= 1.8 =
    8285Add training video to ReadMe
  • mad-cow-customizer-for-woocommerce/trunk/mad-cow-customizer-for-woocommerce.php

    r2844698 r2868895  
    11<?php
    2 if ( ! defined( 'ABSPATH' ) ) {
     2if (!defined('ABSPATH')) {
    33    exit; // Exit if accessed directly
    44}
     
    99 * Developer: Jason Robie
    1010 * Developer URI: https://madcowweb.com/
    11  * Version: 1.9
     11 * Version: 1.9.1
    1212 * Requires at least: 6.1
    1313 * Requires PHP:      7.2
     
    2626
    2727//Check if WooCommerce is active
    28 if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) :
    29 
    30     class MadCow_Customizer_Plugin {
    31 
    32         public function __construct() {
     28if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) :
     29
     30    class MadCow_Customizer_Plugin
     31    {
     32
     33        public function __construct()
     34        {
    3335            // Hook into the admin menu
    34             add_action( 'admin_menu', array( $this, 'create_plugin_settings_page' ) );
     36            add_action('admin_menu', array($this, 'create_plugin_settings_page'));
    3537
    3638            // Add Settings and Fields
    37             add_action( 'admin_init', array( $this, 'setup_sections' ) );
    38             add_action( 'admin_init', array( $this, 'setup_shop_page_fields' ) );
    39             add_action( 'admin_init', array( $this, 'setup_single_product_fields' ) );
    40             add_action( 'admin_init', array( $this, 'setup_cart_page_fields' ) );
    41             add_action( 'admin_init', array( $this, 'setup_checkout_page_fields' ) );
    42             add_action( 'admin_init', array( $this, 'setup_woo_email_fields' ) );
    43             add_action( 'admin_init', array( $this, 'setup_general_woo_fields' ) );
    44             add_action( 'admin_init', array( $this, 'setup_woo_tabs_fields' ) );
    45             add_action( 'admin_init', array( $this, 'setup_general_wp_fields' ) );
    46             add_action( 'admin_enqueue_scripts', 'madcow_customizer_styles' );
    47             add_action( 'wp_enqueue_scripts', 'madcow_customizer_styles' );
    48             function madcow_customizer_styles() {
    49                 wp_register_style( 'madcow_customizer_styles',  plugin_dir_url( __FILE__ ) . '/css/style.css' );
    50                 wp_enqueue_style( 'madcow_customizer_styles' );
     39            add_action('admin_init', array($this, 'setup_sections'));
     40            add_action('admin_init', array($this, 'setup_shop_page_fields'));
     41            add_action('admin_init', array($this, 'setup_single_product_fields'));
     42            add_action('admin_init', array($this, 'setup_cart_page_fields'));
     43            add_action('admin_init', array($this, 'setup_checkout_page_fields'));
     44            add_action('admin_init', array($this, 'setup_woo_email_fields'));
     45            add_action('admin_init', array($this, 'setup_general_woo_fields'));
     46            add_action('admin_init', array($this, 'setup_woo_tabs_fields'));
     47            add_action('admin_init', array($this, 'setup_general_wp_fields'));
     48            add_action('admin_enqueue_scripts', 'madcow_customizer_styles');
     49            add_action('wp_enqueue_scripts', 'madcow_customizer_styles');
     50            function madcow_customizer_styles()
     51            {
     52                wp_register_style('madcow_customizer_styles',  plugin_dir_url(__FILE__) . '/css/style.css');
     53                wp_enqueue_style('madcow_customizer_styles');
    5154            }
    5255
    53             include_once( plugin_dir_path( __FILE__ ) . 'includes/mcw-shop.php' );
    54             include_once( plugin_dir_path( __FILE__ ) . 'includes/mcw-single-product.php' );
    55             include_once( plugin_dir_path( __FILE__ ) . 'includes/mcw-cart.php' );
    56             include_once( plugin_dir_path( __FILE__ ) . 'includes/mcw-checkout.php' );
    57             include_once( plugin_dir_path( __FILE__ ) . 'includes/mcw-emails.php' );
    58             include_once( plugin_dir_path( __FILE__ ) . 'includes/mcw-general-woo.php' );
    59             include_once( plugin_dir_path( __FILE__ ) . 'includes/mcw-woo-tabs.php' );
    60             include_once( plugin_dir_path( __FILE__ ) . 'includes/mcw-general-wp.php' );
    61         }
    62 
    63         public function create_plugin_settings_page() {
     56            include_once(plugin_dir_path(__FILE__) . 'includes/mcw-shop.php');
     57            include_once(plugin_dir_path(__FILE__) . 'includes/mcw-single-product.php');
     58            include_once(plugin_dir_path(__FILE__) . 'includes/mcw-cart.php');
     59            include_once(plugin_dir_path(__FILE__) . 'includes/mcw-checkout.php');
     60            include_once(plugin_dir_path(__FILE__) . 'includes/mcw-emails.php');
     61            include_once(plugin_dir_path(__FILE__) . 'includes/mcw-general-woo.php');
     62            include_once(plugin_dir_path(__FILE__) . 'includes/mcw-woo-tabs.php');
     63            include_once(plugin_dir_path(__FILE__) . 'includes/mcw-general-wp.php');
     64        }
     65
     66        public function create_plugin_settings_page()
     67        {
    6468            // Add new admin menu item and page
    6569            $page_title = esc_html('MCW Settings Page');
     
    6771            $capability = esc_html('manage_options');
    6872            $slug = esc_html('mcw_settings_page');
    69             $callback = array( $this, 'mcw_settings_page' );
    70             add_submenu_page( 'woocommerce', $page_title, $menu_title, $capability, $slug, $callback );
    71         }
    72 
    73         public function mcw_settings_page( $active_tab = '' ) { ?>
    74             <div class="wrap">
    75             <h2>Mad Cow Customizer</h2>
    76             <?php if ( filter_input( INPUT_GET, 'settings-updated',FILTER_SANITIZE_STRING ) && filter_input(INPUT_GET, 'settings-updated' ,FILTER_SANITIZE_STRING) ) :
    77                 $this->admin_notice();
    78             endif;
    79             if ( filter_input( INPUT_GET, 'tab',FILTER_SANITIZE_STRING ) )  :
    80                 $active_tab = filter_input( INPUT_GET, 'tab',FILTER_SANITIZE_STRING );
    81             elseif ( $active_tab == filter_input( INPUT_GET, 'shop_page_options', FILTER_SANITIZE_STRING) ) :
    82                 $active_tab = filter_input( INPUT_GET, 'shop_page_options', FILTER_SANITIZE_STRING);
    83             elseif ( $active_tab == filter_input( INPUT_GET, 'single_product_options', FILTER_SANITIZE_STRING) ) :
    84                 $active_tab = filter_input( INPUT_GET, 'single_product_options', FILTER_SANITIZE_STRING);
    85             elseif ( $active_tab == filter_input( INPUT_GET, 'cart_page_options', FILTER_SANITIZE_STRING) ) :
    86                 $active_tab = filter_input( INPUT_GET, 'cart_page_options', FILTER_SANITIZE_STRING);
    87             elseif ( $active_tab == filter_input( INPUT_GET, 'checkout_page_options', FILTER_SANITIZE_STRING) ) :
    88                 $active_tab = filter_input( INPUT_GET, 'checkout_page_options', FILTER_SANITIZE_STRING);
    89             elseif ( $active_tab == filter_input( INPUT_GET, 'general_woo_options', FILTER_SANITIZE_STRING) ) :
    90                 $active_tab = filter_input( INPUT_GET, 'general_woo_options', FILTER_SANITIZE_STRING);
    91             elseif ( $active_tab == filter_input( INPUT_GET, 'woo_email_options', FILTER_SANITIZE_STRING) ) :
    92                 $active_tab = filter_input( INPUT_GET, 'woo_email_options', FILTER_SANITIZE_STRING);
    93             elseif ( $active_tab == filter_input( INPUT_GET, 'woo_tabs_options', FILTER_SANITIZE_STRING) ) :
    94                 $active_tab = filter_input( INPUT_GET, 'woo_tabs_options', FILTER_SANITIZE_STRING);
    95             elseif ( $active_tab == filter_input( INPUT_GET, 'general_wp_options', FILTER_SANITIZE_STRING) ) :
    96                 $active_tab = filter_input( INPUT_GET, 'general_wp_options', FILTER_SANITIZE_STRING);
    97             endif; ?>
    98 
    99             <h2 class="nav-tab-wrapper">
    100                 <a href="?page=mcw_settings_page&tab=shop_page_options" class="nav-tab <?php echo sanitize_text_field($active_tab == 'shop_page_options' ? 'nav-tab-active' : ''); ?>"><?php echo esc_html( 'Shop/Archive Page Options', 'madcowweb' ); ?></a>
    101                 <a href="?page=mcw_settings_page&tab=single_product_options" class="nav-tab <?php echo sanitize_text_field($active_tab == 'single_product_options' ? 'nav-tab-active' : ''); ?>"><?php echo esc_html( 'Single Product Page Options', 'madcowweb' ); ?></a>
    102                 <a href="?page=mcw_settings_page&tab=cart_page_options" class="nav-tab <?php echo sanitize_text_field($active_tab == 'cart_page_options' ? 'nav-tab-active' : ''); ?>"><?php echo esc_html( 'Cart Page Options', 'madcowweb' ); ?></a>
    103                 <a href="?page=mcw_settings_page&tab=checkout_page_options" class="nav-tab <?php echo sanitize_text_field($active_tab == 'checkout_page_options' ? 'nav-tab-active' : ''); ?>"><?php echo esc_html( 'Checkout Page Options', 'madcowweb' ); ?></a>
    104                 <a href="?page=mcw_settings_page&tab=woo_email_options" class="nav-tab <?php echo sanitize_text_field($active_tab == 'woo_email_options' ? 'nav-tab-active' : ''); ?>"><?php echo esc_html( 'Email Options', 'madcowweb' ); ?></a>
    105                 <a href="?page=mcw_settings_page&tab=general_woo_options" class="nav-tab <?php echo sanitize_text_field($active_tab == 'general_woo_options' ? 'nav-tab-active' : ''); ?>"><?php echo esc_html( 'General WooCommerce Options', 'madcowweb' ); ?></a>
    106                 <a href="?page=mcw_settings_page&tab=woo_tabs_options" class="nav-tab <?php echo sanitize_text_field($active_tab == 'woo_tabs_options' ? 'nav-tab-active' : ''); ?>"><?php echo esc_html( 'WooCommerce Custom Tabs', 'madcowweb' ); ?></a>
    107                 <a href="?page=mcw_settings_page&tab=general_wp_options" class="nav-tab <?php echo sanitize_text_field($active_tab == 'general_wp_options' ? 'nav-tab-active' : ''); ?>"><?php echo esc_html( 'General WordPress Options', 'madcowweb' ); ?></a>
    108             </h2>
    109 
    110             <form method="post" action="options.php">
    111                 <?php if ( $active_tab == 'shop_page_options' ) :
    112                     settings_fields( 'shop_archive_page_tab' );
    113                     do_settings_sections( 'shop_archive_page_tab' );
    114                 elseif ( $active_tab == 'single_product_options' ) :
    115                     settings_fields( 'single_product_page_tab' );
    116                     do_settings_sections( 'single_product_page_tab' );
    117                 elseif ( $active_tab == 'cart_page_options' ) :
    118                     settings_fields( 'cart_page_tab' );
    119                     do_settings_sections( 'cart_page_tab' );
    120                 elseif ( $active_tab == 'checkout_page_options' ) :
    121                     settings_fields( 'checkout_page_tab' );
    122                     do_settings_sections( 'checkout_page_tab' );
    123                 elseif ( $active_tab == 'woo_email_options' ) :
    124                     settings_fields( 'woo_email_tab' );
    125                     do_settings_sections( 'woo_email_tab' );
    126                 elseif ( $active_tab == 'general_woo_options' ) :
    127                     settings_fields( 'general_woo_tab' );
    128                     do_settings_sections( 'general_woo_tab' );
    129                 elseif ( $active_tab == 'woo_tabs_options' ) :
    130                     settings_fields( 'woo_product_tabs_tab' );
    131                     do_settings_sections( 'woo_product_tabs_tab' );
    132                 elseif ( $active_tab == 'general_wp_options' ) :
    133                     settings_fields( 'general_wp_tab' );
    134                     do_settings_sections( 'general_wp_tab' );
     73            $callback = array($this, 'mcw_settings_page');
     74            add_submenu_page('woocommerce', $page_title, $menu_title, $capability, $slug, $callback);
     75        }
     76
     77        public function mcw_settings_page($active_tab = '')
     78        { ?>
     79<div class="wrap">
     80    <h2>Mad Cow Customizer</h2>
     81    <?php if (filter_input(INPUT_GET, 'settings-updated', FILTER_SANITIZE_STRING) && filter_input(INPUT_GET, 'settings-updated', FILTER_SANITIZE_STRING)) :
     82                    $this->admin_notice();
    13583                endif;
    136                 submit_button(); ?>
    137             </form>
    138             </div>
    139         <?php }
    140 
    141         public function admin_notice() {
     84                if (filter_input(INPUT_GET, 'tab', FILTER_SANITIZE_STRING)) :
     85                    $active_tab = filter_input(INPUT_GET, 'tab', FILTER_SANITIZE_STRING);
     86                elseif ($active_tab == filter_input(INPUT_GET, 'shop_page_options', FILTER_SANITIZE_STRING)) :
     87                    $active_tab = filter_input(INPUT_GET, 'shop_page_options', FILTER_SANITIZE_STRING);
     88                elseif ($active_tab == filter_input(INPUT_GET, 'single_product_options', FILTER_SANITIZE_STRING)) :
     89                    $active_tab = filter_input(INPUT_GET, 'single_product_options', FILTER_SANITIZE_STRING);
     90                elseif ($active_tab == filter_input(INPUT_GET, 'cart_page_options', FILTER_SANITIZE_STRING)) :
     91                    $active_tab = filter_input(INPUT_GET, 'cart_page_options', FILTER_SANITIZE_STRING);
     92                elseif ($active_tab == filter_input(INPUT_GET, 'checkout_page_options', FILTER_SANITIZE_STRING)) :
     93                    $active_tab = filter_input(INPUT_GET, 'checkout_page_options', FILTER_SANITIZE_STRING);
     94                elseif ($active_tab == filter_input(INPUT_GET, 'general_woo_options', FILTER_SANITIZE_STRING)) :
     95                    $active_tab = filter_input(INPUT_GET, 'general_woo_options', FILTER_SANITIZE_STRING);
     96                elseif ($active_tab == filter_input(INPUT_GET, 'woo_email_options', FILTER_SANITIZE_STRING)) :
     97                    $active_tab = filter_input(INPUT_GET, 'woo_email_options', FILTER_SANITIZE_STRING);
     98                elseif ($active_tab == filter_input(INPUT_GET, 'woo_tabs_options', FILTER_SANITIZE_STRING)) :
     99                    $active_tab = filter_input(INPUT_GET, 'woo_tabs_options', FILTER_SANITIZE_STRING);
     100                elseif ($active_tab == filter_input(INPUT_GET, 'general_wp_options', FILTER_SANITIZE_STRING)) :
     101                    $active_tab = filter_input(INPUT_GET, 'general_wp_options', FILTER_SANITIZE_STRING);
     102                endif; ?>
     103
     104    <h2 class="nav-tab-wrapper">
     105        <a href="?page=mcw_settings_page&tab=shop_page_options" class="nav-tab <?php echo sanitize_text_field($active_tab == 'shop_page_options' ? 'nav-tab-active' : ''); ?>"><?php echo esc_html('Shop/Archive Page Options', 'madcowweb'); ?></a>
     106        <a href="?page=mcw_settings_page&tab=single_product_options" class="nav-tab <?php echo sanitize_text_field($active_tab == 'single_product_options' ? 'nav-tab-active' : ''); ?>"><?php echo esc_html('Single Product Page Options', 'madcowweb'); ?></a>
     107        <a href="?page=mcw_settings_page&tab=cart_page_options" class="nav-tab <?php echo sanitize_text_field($active_tab == 'cart_page_options' ? 'nav-tab-active' : ''); ?>"><?php echo esc_html('Cart Page Options', 'madcowweb'); ?></a>
     108        <a href="?page=mcw_settings_page&tab=checkout_page_options" class="nav-tab <?php echo sanitize_text_field($active_tab == 'checkout_page_options' ? 'nav-tab-active' : ''); ?>"><?php echo esc_html('Checkout Page Options', 'madcowweb'); ?></a>
     109        <a href="?page=mcw_settings_page&tab=woo_email_options" class="nav-tab <?php echo sanitize_text_field($active_tab == 'woo_email_options' ? 'nav-tab-active' : ''); ?>"><?php echo esc_html('Email Options', 'madcowweb'); ?></a>
     110        <a href="?page=mcw_settings_page&tab=general_woo_options" class="nav-tab <?php echo sanitize_text_field($active_tab == 'general_woo_options' ? 'nav-tab-active' : ''); ?>"><?php echo esc_html('General WooCommerce Options', 'madcowweb'); ?></a>
     111        <a href="?page=mcw_settings_page&tab=woo_tabs_options" class="nav-tab <?php echo sanitize_text_field($active_tab == 'woo_tabs_options' ? 'nav-tab-active' : ''); ?>"><?php echo esc_html('WooCommerce Custom Tabs', 'madcowweb'); ?></a>
     112        <a href="?page=mcw_settings_page&tab=general_wp_options" class="nav-tab <?php echo sanitize_text_field($active_tab == 'general_wp_options' ? 'nav-tab-active' : ''); ?>"><?php echo esc_html('General WordPress Options', 'madcowweb'); ?></a>
     113    </h2>
     114
     115    <form method="post" action="options.php">
     116        <?php if ($active_tab == 'shop_page_options') :
     117                        settings_fields('shop_archive_page_tab');
     118                        do_settings_sections('shop_archive_page_tab');
     119                    elseif ($active_tab == 'single_product_options') :
     120                        settings_fields('single_product_page_tab');
     121                        do_settings_sections('single_product_page_tab');
     122                    elseif ($active_tab == 'cart_page_options') :
     123                        settings_fields('cart_page_tab');
     124                        do_settings_sections('cart_page_tab');
     125                    elseif ($active_tab == 'checkout_page_options') :
     126                        settings_fields('checkout_page_tab');
     127                        do_settings_sections('checkout_page_tab');
     128                    elseif ($active_tab == 'woo_email_options') :
     129                        settings_fields('woo_email_tab');
     130                        do_settings_sections('woo_email_tab');
     131                    elseif ($active_tab == 'general_woo_options') :
     132                        settings_fields('general_woo_tab');
     133                        do_settings_sections('general_woo_tab');
     134                    elseif ($active_tab == 'woo_tabs_options') :
     135                        settings_fields('woo_product_tabs_tab');
     136                        do_settings_sections('woo_product_tabs_tab');
     137                    elseif ($active_tab == 'general_wp_options') :
     138                        settings_fields('general_wp_tab');
     139                        do_settings_sections('general_wp_tab');
     140                    endif;
     141                    submit_button(); ?>
     142    </form>
     143</div>
     144<?php }
     145
     146        public function admin_notice()
     147        {
    142148            echo wp_kses_post('<div class="notice notice-success is-dismissible"><p>Hooray! Your settings have been updated!</p></div>');
    143149        }
    144150
    145         public function setup_sections() {
    146             add_settings_section( 'shop_archive_page_tab', '', array( $this, 'shop_section_callback' ), 'shop_archive_page_tab' );
    147             add_settings_section( 'single_product_page_tab', '', array( $this, 'single_product_page_tab_callback' ) , 'single_product_page_tab' );
    148             add_settings_section( 'cart_page_tab', '', array( $this, 'cart_page_callback' ) , 'cart_page_tab' );
    149             add_settings_section( 'checkout_page_tab', '', array( $this, 'checkout_page_tab_callback' ), 'checkout_page_tab' );
    150             add_settings_section( 'woo_email_tab1', '', array( $this, 'woo_email_tab_callback1' ), 'woo_email_tab' );
    151             add_settings_section( 'woo_email_tab2', '', array( $this, 'woo_email_tab_callback2' ), 'woo_email_tab' );
    152             add_settings_section( 'general_woo_tab', '', array( $this, 'general_woo_tab_callback' ) , 'general_woo_tab' );
    153             add_settings_section( 'woo_product_tabs_tab1', '', array( $this, 'woo_product_tabs_tab_callback1' ) , 'woo_product_tabs_tab' );
    154             add_settings_section( 'woo_product_tabs_tab2', '', array( $this, 'woo_product_tabs_tab_callback2' ) , 'woo_product_tabs_tab' );
    155             add_settings_section( 'woo_product_tabs_tab3', '', array( $this, 'woo_product_tabs_tab_callback3' ) , 'woo_product_tabs_tab' );
    156             add_settings_section( 'general_wp_tab', '', array( $this, 'general_wp_tab_callback' ) , 'general_wp_tab' );
    157         }
    158         public function shop_section_callback() { ?>
    159                 <h1>Shop/Archive Page</h1>
    160                 <h2 class="mcw">Custom Hook locations are highlighted in bold, green, italic font</h2>
    161                 <h3 class="mcw">Use the editor titles to know where you want your content to appear</h3>
    162                 <p>Please use your browser's inspector to target these custom areas and add your own styling</p>
    163                 <?php echo wp_kses_post('<img src="' . plugins_url( 'images/mcw-customizer-shop.png', __FILE__ ) . '" > ');
    164         }
    165         public function single_product_page_tab_callback() { ?>
    166                 <h1>Single Product Page</h1>
    167                 <h2 class="mcw">Custom Hook locations are highlighted in bold, green, italic font</h2>
    168                 <h3 class="mcw">Use the editor titles to know where you want your content to appear</h3>
    169                 <p>Please use your browser's inspector to target these custom areas and add your own styling</p>
    170                 <?php echo wp_kses_post('<img src="' . plugins_url( 'images/mcw-customizer-product.png', __FILE__ ) . '" > ');
    171         }
    172         public function cart_page_callback() { ?>
    173                 <h1>Cart Page</h1>
    174                 <h2 class="mcw">Custom Hook locations are highlighted in bold, green, italic font</h2>
    175                 <h3 class="mcw">Use the editor titles to know where you want your content to appear</h3>
    176                 <p>Please use your browser's inspector to target these custom areas and add your own styling</p>
    177                 <?php echo wp_kses_post('<img src="' . plugins_url( 'images/mcw-customizer-cart.png', __FILE__ ) . '" > ');
    178         }
    179         public function checkout_page_tab_callback() { ?>
    180                 <h1>Checkout Page</h1>
    181                 <h2 class="mcw">Custom Hook locations are highlighted in bold, green, italic font</h2>
    182                 <h3 class="mcw">Use the editor titles to know where you want your content to appear</h3>
    183                 <p>Please use your browser's inspector to target these custom areas and add your own styling</p>
    184                 <?php echo wp_kses_post('<img style="max-width:550px;" src="' . plugins_url( 'images/mcw-customizer-checkout.png', __FILE__ ) . '" >');
    185         }
    186         public function woo_email_tab_callback1() { ?>
    187                 <h1>General WooCommerce Email Settings</h1>
    188                 <p>We recommend an Email Preview plugin such as <a href="https://wordpress.org/plugins/woo-preview-emails/" target="_blank">This one</a></p>
    189                 <h2 class="mcw">Email Header</h2>
    190                 <?php echo wp_kses_post('<img src="' . plugins_url( 'images/mcw-customizer-email.png', __FILE__ ) . '" >');
    191         }
    192         public function woo_email_tab_callback2() { ?>
    193                 <h2 class="mcw">Email Footer</h2>
    194                 <?php
    195         }
    196         public function general_woo_tab_callback() { ?>
    197                 <h1>General WooCommerce Settings</h1>
    198                 <p>Please use your browser's inspector to target these custom areas and add your own styling</p>
    199                 <?php
    200         }
    201         public function woo_product_tabs_tab_callback1() { ?>
    202                 <h1>WooCommerce Custom Product Tabs</h1>
    203                 <p>Please use your browser's inspector to target these custom areas and add your own styling</p>
    204                 <h2 class="mcw">Tab 1</h2>
    205                 <?php
    206         }
    207         public function woo_product_tabs_tab_callback2() { ?>
    208                 <h2 class="mcw">Tab 2</h2>
    209                 <?php
    210         }
    211         public function woo_product_tabs_tab_callback3() { ?>
    212                 <h2 class="mcw">Tab 3</h2>
    213                 <?php
    214         }
    215         public function general_wp_tab_callback() { ?>
    216             <h1>General WordPress Settings</h1>
    217             <?php
    218         }
    219 
    220         public function setup_shop_page_fields() {
    221             include ( plugin_dir_path( __FILE__ ) . 'includes/shop-page-fields.php' );
    222         }
    223         public function setup_single_product_fields() {
    224             include ( plugin_dir_path( __FILE__ ) . 'includes/single-product-fields.php' );
    225         }
    226         public function setup_cart_page_fields() {
    227             include ( plugin_dir_path( __FILE__ ) . 'includes/cart-page-fields.php' );
    228         }
    229         public function setup_checkout_page_fields() {
    230             include ( plugin_dir_path( __FILE__ ) . 'includes/checkout-page-fields.php' );
    231         }
    232         public function setup_woo_email_fields() {
    233             include ( plugin_dir_path( __FILE__ ) . 'includes/woo-email-fields.php' );
    234         }
    235         public function setup_general_woo_fields() {
    236             include ( plugin_dir_path( __FILE__ ) . 'includes/general-woo-fields.php' );
    237         }
    238         public function setup_woo_tabs_fields() {
    239             include ( plugin_dir_path( __FILE__ ) . 'includes/woo-tabs-fields.php' );
    240         }
    241         public function setup_general_wp_fields() {
    242             include ( plugin_dir_path( __FILE__ ) . 'includes/general-wp-fields.php' );
    243         }
    244 
    245         public function field_callback( $arguments ) {
    246             $value = get_option( $arguments['uid'] );
    247             $value = ! empty( $value ) ? $value : $arguments['default'];
    248 
    249             switch( $arguments['type'] ) {
     151        public function setup_sections()
     152        {
     153            add_settings_section('shop_archive_page_tab', '', array($this, 'shop_section_callback'), 'shop_archive_page_tab');
     154            add_settings_section('single_product_page_tab', '', array($this, 'single_product_page_tab_callback'), 'single_product_page_tab');
     155            add_settings_section('cart_page_tab', '', array($this, 'cart_page_callback'), 'cart_page_tab');
     156            add_settings_section('checkout_page_tab', '', array($this, 'checkout_page_tab_callback'), 'checkout_page_tab');
     157            add_settings_section('woo_email_tab1', '', array($this, 'woo_email_tab_callback1'), 'woo_email_tab');
     158            add_settings_section('woo_email_tab2', '', array($this, 'woo_email_tab_callback2'), 'woo_email_tab');
     159            add_settings_section('general_woo_tab', '', array($this, 'general_woo_tab_callback'), 'general_woo_tab');
     160            add_settings_section('woo_product_tabs_tab1', '', array($this, 'woo_product_tabs_tab_callback1'), 'woo_product_tabs_tab');
     161            add_settings_section('woo_product_tabs_tab2', '', array($this, 'woo_product_tabs_tab_callback2'), 'woo_product_tabs_tab');
     162            add_settings_section('woo_product_tabs_tab3', '', array($this, 'woo_product_tabs_tab_callback3'), 'woo_product_tabs_tab');
     163            add_settings_section('general_wp_tab', '', array($this, 'general_wp_tab_callback'), 'general_wp_tab');
     164        }
     165        public function shop_section_callback()
     166        { ?>
     167<h1>Shop/Archive Page</h1>
     168<h2 class="mcw">Custom Hook locations are highlighted in bold, green, italic font</h2>
     169<h3 class="mcw">Use the editor titles to know where you want your content to appear</h3>
     170<p>Please use your browser's inspector to target these custom areas and add your own styling</p>
     171<?php echo wp_kses_post('<img src="' . plugins_url('images/mcw-customizer-shop.png', __FILE__) . '" > ');
     172        }
     173        public function single_product_page_tab_callback()
     174        { ?>
     175<h1>Single Product Page</h1>
     176<h2 class="mcw">Custom Hook locations are highlighted in bold, green, italic font</h2>
     177<h3 class="mcw">Use the editor titles to know where you want your content to appear</h3>
     178<p>Please use your browser's inspector to target these custom areas and add your own styling</p>
     179<?php echo wp_kses_post('<img src="' . plugins_url('images/mcw-customizer-product.png', __FILE__) . '" > ');
     180        }
     181        public function cart_page_callback()
     182        { ?>
     183<h1>Cart Page</h1>
     184<h2 class="mcw">Custom Hook locations are highlighted in bold, green, italic font</h2>
     185<h3 class="mcw">Use the editor titles to know where you want your content to appear</h3>
     186<p>Please use your browser's inspector to target these custom areas and add your own styling</p>
     187<?php echo wp_kses_post('<img src="' . plugins_url('images/mcw-customizer-cart.png', __FILE__) . '" > ');
     188        }
     189        public function checkout_page_tab_callback()
     190        { ?>
     191<h1>Checkout Page</h1>
     192<h2 class="mcw">Custom Hook locations are highlighted in bold, green, italic font</h2>
     193<h3 class="mcw">Use the editor titles to know where you want your content to appear</h3>
     194<p>Please use your browser's inspector to target these custom areas and add your own styling</p>
     195<?php echo wp_kses_post('<img style="max-width:550px;" src="' . plugins_url('images/mcw-customizer-checkout.png', __FILE__) . '" >');
     196        }
     197        public function woo_email_tab_callback1()
     198        { ?>
     199<h1>General WooCommerce Email Settings</h1>
     200<p>We recommend an Email Preview plugin such as <a href="https://wordpress.org/plugins/woo-preview-emails/" target="_blank">This one</a></p>
     201<h2 class="mcw">Email Header</h2>
     202<?php echo wp_kses_post('<img src="' . plugins_url('images/mcw-customizer-email.png', __FILE__) . '" >');
     203        }
     204        public function woo_email_tab_callback2()
     205        { ?>
     206<h2 class="mcw">Email Footer</h2>
     207<?php
     208        }
     209        public function general_woo_tab_callback()
     210        { ?>
     211<h1>General WooCommerce Settings</h1>
     212<p>Please use your browser's inspector to target these custom areas and add your own styling</p>
     213<?php
     214        }
     215        public function woo_product_tabs_tab_callback1()
     216        { ?>
     217<h1>WooCommerce Custom Product Tabs</h1>
     218<p>Please use your browser's inspector to target these custom areas and add your own styling</p>
     219<h2 class="mcw">Tab 1</h2>
     220<?php
     221        }
     222        public function woo_product_tabs_tab_callback2()
     223        { ?>
     224<h2 class="mcw">Tab 2</h2>
     225<?php
     226        }
     227        public function woo_product_tabs_tab_callback3()
     228        { ?>
     229<h2 class="mcw">Tab 3</h2>
     230<?php
     231        }
     232        public function general_wp_tab_callback()
     233        { ?>
     234<h1>General WordPress Settings</h1>
     235<?php
     236        }
     237
     238        public function setup_shop_page_fields()
     239        {
     240            include(plugin_dir_path(__FILE__) . 'includes/shop-page-fields.php');
     241        }
     242        public function setup_single_product_fields()
     243        {
     244            include(plugin_dir_path(__FILE__) . 'includes/single-product-fields.php');
     245        }
     246        public function setup_cart_page_fields()
     247        {
     248            include(plugin_dir_path(__FILE__) . 'includes/cart-page-fields.php');
     249        }
     250        public function setup_checkout_page_fields()
     251        {
     252            include(plugin_dir_path(__FILE__) . 'includes/checkout-page-fields.php');
     253        }
     254        public function setup_woo_email_fields()
     255        {
     256            include(plugin_dir_path(__FILE__) . 'includes/woo-email-fields.php');
     257        }
     258        public function setup_general_woo_fields()
     259        {
     260            include(plugin_dir_path(__FILE__) . 'includes/general-woo-fields.php');
     261        }
     262        public function setup_woo_tabs_fields()
     263        {
     264            include(plugin_dir_path(__FILE__) . 'includes/woo-tabs-fields.php');
     265        }
     266        public function setup_general_wp_fields()
     267        {
     268            include(plugin_dir_path(__FILE__) . 'includes/general-wp-fields.php');
     269        }
     270
     271        public function field_callback($arguments)
     272        {
     273            $value = get_option($arguments['uid']);
     274            $value = !empty($value) ? $value : $arguments['default'];
     275
     276            switch ($arguments['type']) {
    250277                case 'radio':
    251278                case 'checkbox':
    252                     if( ! empty ( $arguments['options'] ) && is_array( $arguments['options'] ) ){
     279                    if (!empty($arguments['options']) && is_array($arguments['options'])) {
    253280                        $options_markup = '';
    254281                        $iterator = 0;
    255                         foreach( $arguments['options'] as $key => $label ){
     282                        foreach ($arguments['options'] as $key => $label) {
    256283                            $iterator++;
    257284                            $options_markup .= sprintf(
     
    260287                                $key,
    261288                                checked(
    262                                     $value[ array_search( $key, $value, true ) ],
     289                                    $value[array_search($key, $value, true)],
    263290                                    $key,
    264291                                    false
     
    268295                            );
    269296                        }
    270                         printf( '<fieldset>%s</fieldset>', $options_markup );
     297                        printf('<fieldset>%s</fieldset>', $options_markup);
    271298                    }
    272299                    break;
    273300                case 'text':
    274301                case 'textarea':
    275                     printf( '<textarea name="%1$s" id="%1$s" rows="%2$s" placeholder="%3$s">%4$s</textarea>',
    276                     sanitize_text_field($arguments['uid']),
    277                     sanitize_text_field($arguments['rows']),
    278                     sanitize_text_field($arguments['placeholder']),
    279                     wp_kses_post($value),
     302                    printf(
     303                        '<textarea name="%1$s" id="%1$s" rows="%2$s" placeholder="%3$s">%4$s</textarea>',
     304                        sanitize_text_field($arguments['uid']),
     305                        sanitize_text_field($arguments['rows']),
     306                        sanitize_text_field($arguments['placeholder']),
     307                        wp_kses_post($value),
    280308                    );
    281309                    break;
    282310            }
    283             if ( $helper = $arguments['helper'] ) :
    284                 printf( '<span class="mcw-helper"> %s</span>', sanitize_text_field( $helper ));
     311            if ($helper = $arguments['helper']) :
     312                printf('<span class="mcw-helper"> %s</span>', sanitize_text_field($helper));
    285313            endif;
    286             if ( $supplemental = $arguments['supplemental'] ) :
    287                 printf( '<p class="mcw-description">%s</p>', sanitize_text_field( $supplemental ));
     314            if ($supplemental = $arguments['supplemental']) :
     315                printf('<p class="mcw-description">%s</p>', sanitize_text_field($supplemental));
    288316            endif;
    289317        }
    290318    }
    291319    new MadCow_Customizer_Plugin();
    292     function mcw_add_settings_link( $links ) {
    293         $settings_link = '<a href="admin.php?page=mcw_settings_page">' . __( 'Mad Cow Settings' ) . '</a>';
    294         array_push( $links, $settings_link );
     320    function mcw_add_settings_link($links)
     321    {
     322        $settings_link = '<a href="admin.php?page=mcw_settings_page">' . __('Mad Cow Settings') . '</a>';
     323        array_push($links, $settings_link);
    295324        return $links;
    296325    }
    297     $plugin = plugin_basename( __FILE__ );
    298     add_filter( "plugin_action_links_$plugin", 'mcw_add_settings_link' );
     326    $plugin = plugin_basename(__FILE__);
     327    add_filter("plugin_action_links_$plugin", 'mcw_add_settings_link');
    299328endif;
Note: See TracChangeset for help on using the changeset viewer.