PluginProbe
Header Enhancement / 2.1
Header Enhancement v2.1
trunk 1.0 1.1 1.2 1.3 1.4 1.4.1 1.4.2 1.4.3 1.5 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 2.0 2.1
header-enhancement / header-enhancement.php

header-enhancement.php in Header Enhancement 2.1, at header-enhancement.php

181 lines 8.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The plugin bootstrap file
4 *
5 * This file is read by WordPress to generate the plugin information in the plugin
6 * admin area. This file also includes all of the dependencies used by the plugin,
7 * registers the activation and deactivation functions, and defines a function
8 * that starts the plugin.
9 *
10 * @link catchplugins.com
11 * @since 1.0
12 * @package Header_Enhancement
13 *
14 * Plugin Name: Header Enhancement
15 * Plugin URI: https://catchplugins.com/plugins/header-enhancement/
16 * Description: Header Enhancement allows you to add an expressive custom header video on your website with features like mobile compatibility and sound effects.
17 * Version: 2.1
18 * Author: Catch Plugins
19 * Author URI: https://catchplugins.com
20 * License: GPL-2.0+
21 * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
22 * Text Domain: header-enhancement
23 * Domain Path: /languages
24 */
25
26 // If this file is called directly, abort.
27 if (! defined('WPINC')) {
28 die;
29 }
30
31 register_activation_hook(__FILE__, 'header_enhancement_check_pro_active');
32 if (! function_exists('header_enhancement_check_pro_active')) {
33 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- function_exists() guard above; established activation hook name.
34 function header_enhancement_check_pro_active()
35 {
36 $required = 'header-enhancement-pro/header-enhancement-pro.php';
37 if (is_plugin_active($required)) {
38 /* translators: %1$s and %2$s wrap the "Return to Plugins" link. The message informs the user that the Pro version is active. */
39 $message = __('Sorry, Pro version is already active. No need to activate Free version. If you still want to activate the Free version, please deactivate the Pro version first. %1$s&laquo; Return to Plugins%2$s.', 'header-enhancement');
40
41 $message = sprintf(
42 $message,
43 '<br><a href="' . esc_url(admin_url('plugins.php')) . '">',
44 '</a>'
45 );
46
47 // Escape all HTML output before printing
48 wp_die(wp_kses_post($message));
49 }
50 }
51 }
52
53 // Define Version
54 if ( ! defined( 'HEADER_ENHANCEMENT_VERSION' ) ) {
55 define( 'HEADER_ENHANCEMENT_VERSION', '2.1' );
56 }
57
58 // The URL of the directory that contains the plugin
59 if (! defined('HEADER_ENHANCEMENT_URL')) {
60 define('HEADER_ENHANCEMENT_URL', plugin_dir_url(__FILE__));
61 }
62
63
64 // The absolute path of the directory that contains the file
65 if (! defined('HEADER_ENHANCEMENT_PATH')) {
66 define('HEADER_ENHANCEMENT_PATH', plugin_dir_path(__FILE__));
67 }
68
69 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound -- HeaderEnhancement is the established class name for this plugin.
70 class HeaderEnhancement
71 {
72 private $plugin_name;
73 public function __construct()
74 {
75 $this->plugin_name = 'header-enhancement';
76 add_action('admin_menu', array($this, 'add_plugin_settings_menu'));
77 add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts'));
78 add_action('admin_enqueue_scripts', array($this, 'enqueue_styles'));
79 add_action('wp_print_scripts', array($this, 'dequeue_custom_header_video_js'), 100);
80
81 add_filter('plugin_row_meta', array($this, 'add_plugin_meta_links'), 10, 2);
82 add_action('wp_enqueue_scripts', array($this, 'frontend_enqueue_styles'));
83 }
84
85 function enqueue_scripts()
86 {
87 $he_page = isset($_GET['page']) ? sanitize_text_field(wp_unslash($_GET['page'])) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read-only page check for admin script loading.
88 if ('header-enhancement' === $he_page) {
89 wp_register_script('match-height', HEADER_ENHANCEMENT_URL . 'js/jquery.matchHeight.min.js', array('jquery'), HEADER_ENHANCEMENT_VERSION, true);
90 wp_register_script('header-enhancement-dashboard', HEADER_ENHANCEMENT_URL . 'js/dashboard-main.js', array('jquery', 'match-height'), HEADER_ENHANCEMENT_VERSION, true);
91 wp_enqueue_script('header-enhancement-dashboard');
92 }
93 }
94
95 function enqueue_styles()
96 {
97 $he_page = isset($_GET['page']) ? sanitize_text_field(wp_unslash($_GET['page'])) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read-only page check for admin style loading.
98 if ('header-enhancement' === $he_page) {
99 wp_enqueue_style('header-enhancement-style', HEADER_ENHANCEMENT_URL . 'css/header-enhancement.css', array(), HEADER_ENHANCEMENT_VERSION, 'all');
100 wp_enqueue_style('header-enhancement-dashboard', HEADER_ENHANCEMENT_URL . 'css/admin-dashboard.css', array(), HEADER_ENHANCEMENT_VERSION, 'all');
101 }
102 }
103
104 function frontend_enqueue_styles()
105 {
106 wp_enqueue_style('header-enhancement-style', HEADER_ENHANCEMENT_URL . 'css/frontend.css', array(), HEADER_ENHANCEMENT_VERSION, 'all');
107 }
108
109 function dequeue_custom_header_video_js()
110 {
111 wp_dequeue_script('wp-custom-header');
112 wp_deregister_script('wp-custom-header');
113 wp_register_script('wp-custom-header', HEADER_ENHANCEMENT_URL . 'js/header-enhancement.js', array(), HEADER_ENHANCEMENT_VERSION, true);
114 wp_enqueue_script('wp-custom-header');
115 }
116
117 function add_plugin_settings_menu()
118 {
119 add_menu_page(
120 esc_html__('Header Enhancement', 'header-enhancement'), //page title
121 esc_html__('Header Enhancement', 'header-enhancement'), //menu title
122 'manage_options', //capability needed
123 'header-enhancement', //menu slug (and page query url)
124 array($this, 'settings'),
125 'dashicons-video-alt3',
126 '99.01564'
127 );
128 }
129
130 function settings()
131 {
132 $child_theme = false;
133 if (! current_user_can('manage_options')) {
134 wp_die(esc_html__('You do not have sufficient permissions to access this page.', 'header-enhancement'));
135 }
136
137 require_once plugin_dir_path(__FILE__) . 'partials/header-enhancement-display.php';
138 }
139
140 function add_plugin_meta_links($meta_fields, $file)
141 {
142
143 if ($file === plugin_basename(__FILE__)) {
144
145 $meta_fields[] = "<a href='https://catchplugins.com/support-forum/forum/header-enhancement/' target='_blank'>Support Forum</a>";
146 $meta_fields[] = "<a href='https://wordpress.org/support/plugin/header-enhancement/reviews#new-post' target='_blank' title='Rate'>
147 <i class='ct-rate-stars'>"
148 . "<svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-star'><polygon points='12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2'/></svg>"
149 . "<svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-star'><polygon points='12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2'/></svg>"
150 . "<svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-star'><polygon points='12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2'/></svg>"
151 . "<svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-star'><polygon points='12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2'/></svg>"
152 . "<svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-star'><polygon points='12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2'/></svg>"
153 . '</i></a>';
154
155 $stars_color = '#ffb900';
156
157 echo '<style>'
158 . '.ct-rate-stars{display:inline-block;color:' . esc_html($stars_color) . ';position:relative;top:3px;}'
159 . '.ct-rate-stars svg{fill:' . esc_html($stars_color) . ';}'
160 . '.ct-rate-stars svg:hover{fill:' . esc_html($stars_color) . '}'
161 . '.ct-rate-stars svg:hover ~ svg{fill:none;}'
162 . '</style>';
163 }
164
165 return $meta_fields;
166 }
167 }
168
169 $header_enhancement = new HeaderEnhancement(); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- file-scope plugin instance.
170
171 /* CTP tabs removal options */
172 require HEADER_ENHANCEMENT_PATH . 'partials/ctp-tabs-removal.php';
173
174 $ctp_options = ctp_get_options(); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- shared ctp_ variable maintained for cross-plugin compatibility.
175 if (1 === $ctp_options['theme_plugin_tabs']) {
176 /* Adds Catch Themes tab in Add theme page and Themes by Catch Themes in Customizer's change theme option. */
177 if (! class_exists('CatchThemesThemePlugin') && ! function_exists('add_our_plugins_tab')) {
178 require HEADER_ENHANCEMENT_PATH . 'partials/CatchThemesThemePlugin.php';
179 }
180 }
181