diff --git a/bin/copy-images.js b/bin/copy-images.js index 5312ea4..5a82a96 100644 --- a/bin/copy-images.js +++ b/bin/copy-images.js @@ -1,10 +1,20 @@ -var ncp = require('ncp').ncp; +/** + * GTM Kit plugin file. + * + * @package GTM Kit + */ + +var ncp = require( 'ncp' ).ncp; ncp.limit = 16; -ncp('src/images', 'assets/images', function (err) { - if (err) { - return console.error(err); +ncp( + 'src/images', + 'assets/images', + function (err) { + if (err) { + return console.error( err ); + } + console.log( 'Images copied!' ); } - console.log('Images copied!'); -}); +); diff --git a/gtm-kit.php b/gtm-kit.php index c1f8a80..b436fc8 100644 --- a/gtm-kit.php +++ b/gtm-kit.php @@ -1,6 +1,6 @@ get( 'general', 'noscript_implementation' ); - if ( $noscript_implementation == 2 ) { + if ( $noscript_implementation === 2 ) { Frontend::get_body_script(); } } - diff --git a/inc/main.php b/inc/main.php index aa1f9ed..963aa35 100644 --- a/inc/main.php +++ b/inc/main.php @@ -1,4 +1,9 @@ %s', + ' + %s', esc_url( menu_page_url( 'gtmkit_general', false ) ), esc_attr__( 'Go to GTM Kit Settings page', 'gtm-kit' ), esc_html__( 'Settings', 'gtm-kit' ) @@ -78,9 +84,9 @@ function gtmkit_load_text_domain(): void { * Load frontend. */ function gtmkit_frontend_init(): void { - $options = new Options(); - $rest_API_server = new RestAPIServer(); - $util = new Util( $rest_API_server ); + $options = new Options(); + $rest_api_server = new RestAPIServer(); + $util = new Util( $rest_api_server ); ( new SetupWizard( $options, $util ) )->rest_init(); @@ -91,10 +97,10 @@ function gtmkit_frontend_init(): void { if ( $options->get( 'integrations', 'woocommerce_integration' ) && function_exists( 'WC' ) ) { WooCommerce::register( $options, $util ); } - if ( $options->get( 'integrations', 'cf7_integration' ) && class_exists('WPCF7') ) { + if ( $options->get( 'integrations', 'cf7_integration' ) && class_exists( 'WPCF7' ) ) { ContactForm7::register( $options, $util ); } - if ( $options->get( 'integrations', 'edd_integration' ) && class_exists('EDD_Requirements_Check') ) { + if ( $options->get( 'integrations', 'edd_integration' ) && class_exists( 'EDD_Requirements_Check' ) ) { EasyDigitalDownloads::register( $options, $util ); } } @@ -105,7 +111,6 @@ function gtmkit_frontend_init(): void { Frontend::register( $options ); require GTMKIT_PATH . 'inc/frontend-functions.php'; - } /** @@ -115,22 +120,22 @@ function gtmkit_admin_init(): void { if ( version_compare( get_option( 'gtmkit_version' ), GTMKIT_VERSION, '<' ) ) { if ( function_exists( 'opcache_reset' ) ) { - @opcache_reset(); + opcache_reset(); } new Upgrade(); } - $options = new Options(); - $rest_API_server = new RestAPIServer(); - $util = new Util( $rest_API_server ); + $options = new Options(); + $rest_api_server = new RestAPIServer(); + $util = new Util( $rest_api_server ); ( new SetupWizard( $options, $util ) )->hooks(); MetaBox::register( $options ); Analytics::register( $options, $util ); GeneralOptionsPage::register( $options, $util ); - IntegrationsOptionsPage::register( $options, $util); - HelpOptionsPage::register( $options, $util); + IntegrationsOptionsPage::register( $options, $util ); + HelpOptionsPage::register( $options, $util ); } /** @@ -138,11 +143,14 @@ function gtmkit_admin_init(): void { */ if ( ! wp_installing() ) { - add_action( 'before_woocommerce_init', function() { - if ( class_exists( FeaturesUtil::class ) ) { - FeaturesUtil::declare_compatibility( 'custom_order_tables', GTMKIT_FILE ); + add_action( + 'before_woocommerce_init', + function () { + if ( class_exists( FeaturesUtil::class ) ) { + FeaturesUtil::declare_compatibility( 'custom_order_tables', GTMKIT_FILE ); + } } - } ); + ); if ( is_admin() ) { add_action( 'plugins_loaded', 'TLA_Media\GTM_Kit\gtmkit_load_text_domain' ); diff --git a/postcss.config.js b/postcss.config.js index b004cf2..b5f1c16 100644 --- a/postcss.config.js +++ b/postcss.config.js @@ -1,6 +1,12 @@ +/** + * GTM Kit plugin file. + * + * @package GTM Kit + */ + module.exports = { plugins: [ - require('autoprefixer'), - require('cssnano') // This will minify the result CSS + require( 'autoprefixer' ), + require( 'cssnano' ) // This will minify the result CSS. ] } diff --git a/src/Admin/AbstractOptionsPage.php b/src/Admin/AbstractOptionsPage.php index df667b7..dfc49ca 100644 --- a/src/Admin/AbstractOptionsPage.php +++ b/src/Admin/AbstractOptionsPage.php @@ -1,10 +1,18 @@ options = $options; - $this->util = $util; + $this->util = $util; } /** * Register the options page. * - * @param Options $options - * @param Util $util + * @param Options $options An instance of Options. + * @param Util $util An instance of Util. */ - public static function register( Options $options, Util $util): void { + public static function register( Options $options, Util $util ): void { $page = new static( $options, $util ); add_action( 'admin_init', [ $page, 'configure' ] ); @@ -157,7 +167,6 @@ public function enqueue_assets( string $hook ) { ]; wp_localize_script( 'gtmkit-admin', 'gtmkit', $script_data ); - } /** @@ -177,5 +186,4 @@ function admin_body_class( string $classes ): string { return $classes; } - } diff --git a/src/Admin/Analytics.php b/src/Admin/Analytics.php index 3f1d627..46234f2 100644 --- a/src/Admin/Analytics.php +++ b/src/Admin/Analytics.php @@ -1,4 +1,9 @@ options = $options; - $this->util = $util; + $this->util = $util; } /** * Register analytics + * + * @param Options $options An instance of Options. + * @param Util $util An instance of Util. */ - public static function register( Options $options, Util $util): void { + public static function register( Options $options, Util $util ): void { self::$instance = $page = new Analytics( $options, $util ); if ( $options->get( 'general', 'analytics_active' ) ) { add_action( 'init', [ $page, 'schedule_daily_event' ] ); add_action( 'gtmkit_send_anonymous_data', [ $page, 'send_anonymous_data' ] ); } - } /** @@ -69,15 +81,13 @@ function schedule_daily_event(): void { $event = 'gtmkit_send_anonymous_data'; if ( class_exists( 'ActionScheduler' ) ) { - // Schedule event with ActionScheduler + // Schedule event with ActionScheduler. if ( ! as_next_scheduled_action( $event ) ) { as_schedule_single_action( strtotime( 'midnight +25 hours' ), $event, [], 'gtmkit' ); } - } else { - // Schedule event with WP-Cron - if ( ! wp_next_scheduled( $event ) ) { - wp_schedule_event( strtotime( 'midnight' ), 'daily', $event ); - } + } elseif ( ! wp_next_scheduled( $event ) ) { + // Schedule event with WP-Cron. + wp_schedule_event( strtotime( 'midnight' ), 'daily', $event ); } } @@ -87,9 +97,8 @@ function schedule_daily_event(): void { * @return void */ function send_anonymous_data(): void { - $mp = Mixpanel::getInstance( "a84d538948ddda17265f86785c80ca37" ); + $mp = Mixpanel::getInstance( 'a84d538948ddda17265f86785c80ca37' ); - $mp->track( "GTM Kit", $this->util->get_site_data( $this->options->get_all_raw() ) ); + $mp->track( 'GTM Kit', $this->util->get_site_data( $this->options->get_all_raw() ) ); } - } diff --git a/src/Admin/GeneralOptionsPage.php b/src/Admin/GeneralOptionsPage.php index de6aa9e..f4e87ee 100644 --- a/src/Admin/GeneralOptionsPage.php +++ b/src/Admin/GeneralOptionsPage.php @@ -1,9 +1,22 @@ ['site_data' => $site_data] + 'tab_data' => [ 'site_data' => $site_data ], ] ) ); @@ -97,8 +110,7 @@ public function render(): void { $dashboard_tabs->display( $form ); - $form->admin_footer( true, false); - + $form->admin_footer( true, false ); } /** @@ -141,13 +153,12 @@ protected function get_parent_slug(): string { * Get the tabs of the admin page. */ protected function get_tabs(): void { - $generalTabs = new OptionTabs( 'general' ); - $generalTabs->add_tab( new OptionTab( 'dashboard', __( 'Dashboard', 'gtm-kit' ) ) ); - $generalTabs->add_tab( new OptionTab( 'container', __( 'Container', 'gtm-kit' ) ) ); - $generalTabs->add_tab( new OptionTab( 'post_data', __( 'Post data', 'gtm-kit' ) ) ); - $generalTabs->add_tab( new OptionTab( 'user_data', __( 'User data', 'gtm-kit' ) ) ); - $generalTabs->add_tab( new OptionTab( 'misc', __( 'Misc.', 'gtm-kit' ) ) ); - $generalTabs->add_tab( new OptionTab( 'whats_new', __( "What's new", 'gtm-kit' ) ) ); + $general_tabs = new OptionTabs( 'general' ); + $general_tabs->add_tab( new OptionTab( 'dashboard', __( 'Dashboard', 'gtm-kit' ) ) ); + $general_tabs->add_tab( new OptionTab( 'container', __( 'Container', 'gtm-kit' ) ) ); + $general_tabs->add_tab( new OptionTab( 'post_data', __( 'Post data', 'gtm-kit' ) ) ); + $general_tabs->add_tab( new OptionTab( 'user_data', __( 'User data', 'gtm-kit' ) ) ); + $general_tabs->add_tab( new OptionTab( 'misc', __( 'Misc.', 'gtm-kit' ) ) ); + $general_tabs->add_tab( new OptionTab( 'whats_new', __( "What's new", 'gtm-kit' ) ) ); } - } diff --git a/src/Admin/HelpOptionsPage.php b/src/Admin/HelpOptionsPage.php index 39b71a0..01f0c70 100644 --- a/src/Admin/HelpOptionsPage.php +++ b/src/Admin/HelpOptionsPage.php @@ -1,9 +1,22 @@ display( $form ); $form->admin_footer( true, false ); - } /** @@ -85,9 +97,8 @@ protected function get_parent_slug(): string { * Get the tabs of the admin page. */ protected function get_tabs(): void { - $generalTabs = new OptionTabs( 'help' ); - $generalTabs->add_tab( new OptionTab( 'help', __( 'Overview', 'gtm-kit' ) ) ); - $generalTabs->add_tab( new OptionTab( 'support', __( 'Support', 'gtm-kit' ) ) ); + $general_tabs = new OptionTabs( 'help' ); + $general_tabs->add_tab( new OptionTab( 'help', __( 'Overview', 'gtm-kit' ) ) ); + $general_tabs->add_tab( new OptionTab( 'support', __( 'Support', 'gtm-kit' ) ) ); } - } diff --git a/src/Admin/IntegrationsOptionsPage.php b/src/Admin/IntegrationsOptionsPage.php index 9336324..7016596 100644 --- a/src/Admin/IntegrationsOptionsPage.php +++ b/src/Admin/IntegrationsOptionsPage.php @@ -1,9 +1,22 @@ display( $form ); $form->admin_footer( true, false ); - } /** @@ -104,11 +116,10 @@ protected function get_parent_slug(): string { * Get the tabs of the admin page. */ protected function get_tabs(): void { - $generalTabs = new OptionTabs( 'integrations' ); - $generalTabs->add_tab( new OptionTab( 'integrations', __( 'Overview', 'gtm-kit' ) ) ); - $generalTabs->add_tab( new OptionTab( 'woocommerce', 'WooCommerce' ) ); - $generalTabs->add_tab( new OptionTab( 'cf7', 'Contact Form 7' ) ); - $generalTabs->add_tab( new OptionTab( 'edd', 'Easy Digital Downloads' ) ); + $general_tabs = new OptionTabs( 'integrations' ); + $general_tabs->add_tab( new OptionTab( 'integrations', __( 'Overview', 'gtm-kit' ) ) ); + $general_tabs->add_tab( new OptionTab( 'woocommerce', 'WooCommerce' ) ); + $general_tabs->add_tab( new OptionTab( 'cf7', 'Contact Form 7' ) ); + $general_tabs->add_tab( new OptionTab( 'edd', 'Easy Digital Downloads' ) ); } - } diff --git a/src/Admin/MetaBox.php b/src/Admin/MetaBox.php index 3318dde..c13dc98 100644 --- a/src/Admin/MetaBox.php +++ b/src/Admin/MetaBox.php @@ -1,9 +1,17 @@ options = $options; } /** * Register meta box * - * @param Options $options + * @param Options $options The Options instance. */ public static function register( Options $options ): void { $page = new MetaBox( $options ); @@ -51,10 +59,17 @@ public function add_meta_boxes() { foreach ( $post_types as $post_type => $post_type_object ) { $label = $post_type_object->labels->singular_name; - add_meta_box( 'gtmkit_options', sprintf( __( 'GTM Kit', 'gtm-kit' ), $label ), [ - $this, - 'display_meta_boxes' - ], $post_type, 'side', 'core' ); + add_meta_box( + 'gtmkit_options', + sprintf( __( 'GTM Kit', 'gtm-kit' ), $label ), + [ + $this, + 'display_meta_boxes', + ], + $post_type, + 'side', + 'core' + ); } } } @@ -70,9 +85,9 @@ function display_meta_boxes() {
+ style="font-weight: bold;"> + title="" value="">

name = sanitize_title( $name ); $this->label = $label; $this->arguments = $arguments; @@ -86,7 +94,7 @@ public function get_tab_data(): array { /** * Retrieves the variable from the supplied arguments. * - * @param string $variable Variable to retrieve. + * @param string $variable Variable to retrieve. * @param string|mixed $default_value Default to use when variable not found. * * @return mixed|string The retrieved variable. diff --git a/src/Admin/OptionTabs.php b/src/Admin/OptionTabs.php index bba3fc4..d28d37e 100644 --- a/src/Admin/OptionTabs.php +++ b/src/Admin/OptionTabs.php @@ -1,7 +1,15 @@ base = sanitize_title( $base ); $tab = filter_input( INPUT_GET, 'tab' ); @@ -124,7 +132,7 @@ public function display( OptionsForm $form ): void {