PluginProbe
Header Enhancement / 2.0
Header Enhancement v2.0
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.0, at header-enhancement.php

175 lines 7.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.0
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__, 'check_pro_active');
32 function check_pro_active()
33 {
34 $required = 'header-enhancement-pro/header-enhancement-pro.php';
35 if (is_plugin_active($required)) {
36 // Translators: %1$s and %2$s wrap the "Return to Plugins" link. The message informs the user that the Pro version is active.
37 $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');
38
39 $message = sprintf(
40 $message,
41 '<br><a href="' . esc_url(admin_url('plugins.php')) . '">',
42 '</a>'
43 );
44
45 // Escape all HTML output before printing
46 wp_die(wp_kses_post($message));
47 }
48 }
49
50 // Define Version
51 if ( ! defined( 'HEADER_ENHANCEMENT_VERSION' ) ) {
52 define( 'HEADER_ENHANCEMENT_VERSION', '2.0' );
53 }
54
55 // The URL of the directory that contains the plugin
56 if (! defined('HEADER_ENHANCEMENT_URL')) {
57 define('HEADER_ENHANCEMENT_URL', plugin_dir_url(__FILE__));
58 }
59
60
61 // The absolute path of the directory that contains the file
62 if (! defined('HEADER_ENHANCEMENT_PATH')) {
63 define('HEADER_ENHANCEMENT_PATH', plugin_dir_path(__FILE__));
64 }
65
66 class HeaderEnhancement
67 {
68 private $plugin_name;
69 public function __construct()
70 {
71 $this->plugin_name = 'header-enhancement';
72 add_action('admin_menu', array($this, 'add_plugin_settings_menu'));
73 add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts'));
74 add_action('admin_enqueue_scripts', array($this, 'enqueue_styles'));
75 add_action('wp_print_scripts', array($this, 'dequeue_custom_header_video_js'), 100);
76
77 add_filter('plugin_row_meta', array($this, 'add_plugin_meta_links'), 10, 2);
78 add_action('wp_enqueue_scripts', array($this, 'frontend_enqueue_styles'));
79 }
80
81 function enqueue_scripts()
82 {
83 if (isset($_GET['page']) && 'header-enhancement' == $_GET['page']) {
84 wp_register_script('match-height', HEADER_ENHANCEMENT_URL . 'js/jquery.matchHeight.min.js', array('jquery'), HEADER_ENHANCEMENT_VERSION, false);
85 wp_register_script('header-enhancement-dashboard', HEADER_ENHANCEMENT_URL . 'js/dashboard-main.js', array('jquery', 'match-height'), HEADER_ENHANCEMENT_VERSION, false);
86 wp_enqueue_script('header-enhancement-dashboard');
87 }
88 }
89
90 function enqueue_styles()
91 {
92 if (isset($_GET['page']) && 'header-enhancement' == $_GET['page']) {
93 wp_enqueue_style('header-enhancement-style', HEADER_ENHANCEMENT_URL . 'css/header-enhancement.css', array(), HEADER_ENHANCEMENT_VERSION, 'all');
94 wp_enqueue_style('header-enhancement-dashboard', HEADER_ENHANCEMENT_URL . 'css/admin-dashboard.css', array(), HEADER_ENHANCEMENT_VERSION, 'all');
95 }
96 }
97
98 function frontend_enqueue_styles()
99 {
100 wp_enqueue_style('header-enhancement-style', HEADER_ENHANCEMENT_URL . 'css/frontend.css', array(), HEADER_ENHANCEMENT_VERSION, 'all');
101 }
102
103 function dequeue_custom_header_video_js()
104 {
105 wp_dequeue_script('wp-custom-header');
106 wp_deregister_script('wp-custom-header');
107 wp_register_script('wp-custom-header', HEADER_ENHANCEMENT_URL . 'js/header-enhancement.js', array(), HEADER_ENHANCEMENT_VERSION, true);
108 wp_enqueue_script('wp-custom-header');
109 }
110
111 function add_plugin_settings_menu()
112 {
113 add_menu_page(
114 esc_html__('Header Enhancement', 'header-enhancement'), //page title
115 esc_html__('Header Enhancement', 'header-enhancement'), //menu title
116 'edit_posts', //capability needed
117 'header-enhancement', //menu slug (and page query url)
118 array($this, 'settings'),
119 'dashicons-video-alt3',
120 '99.01564'
121 );
122 }
123
124 function settings()
125 {
126 $child_theme = false;
127 if (! current_user_can('edit_posts')) {
128 wp_die(esc_html__('You do not have sufficient permissions to access this page.', 'header-enhancement'));
129 }
130
131 require_once plugin_dir_path(__FILE__) . 'partials/header-enhancement-display.php';
132 }
133
134 function add_plugin_meta_links($meta_fields, $file)
135 {
136
137 if ($file == plugin_basename(__FILE__)) {
138
139 $meta_fields[] = "<a href='https://catchplugins.com/support-forum/forum/header-enhancement/' target='_blank'>Support Forum</a>";
140 $meta_fields[] = "<a href='https://wordpress.org/support/plugin/header-enhancement/reviews#new-post' target='_blank' title='Rate'>
141 <i class='ct-rate-stars'>"
142 . "<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>"
143 . "<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>"
144 . "<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>"
145 . "<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>"
146 . "<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>"
147 . '</i></a>';
148
149 $stars_color = '#ffb900';
150
151 echo '<style>'
152 . '.ct-rate-stars{display:inline-block;color:' . esc_html($stars_color) . ';position:relative;top:3px;}'
153 . '.ct-rate-stars svg{fill:' . esc_html($stars_color) . ';}'
154 . '.ct-rate-stars svg:hover{fill:' . esc_html($stars_color) . '}'
155 . '.ct-rate-stars svg:hover ~ svg{fill:none;}'
156 . '</style>';
157 }
158
159 return $meta_fields;
160 }
161 }
162
163 $class = new HeaderEnhancement();
164
165 /* CTP tabs removal options */
166 require HEADER_ENHANCEMENT_PATH . 'partials/ctp-tabs-removal.php';
167
168 $ctp_options = ctp_get_options();
169 if (1 == $ctp_options['theme_plugin_tabs']) {
170 /* Adds Catch Themes tab in Add theme page and Themes by Catch Themes in Customizer's change theme option. */
171 if (! class_exists('CatchThemesThemePlugin') && ! function_exists('add_our_plugins_tab')) {
172 require HEADER_ENHANCEMENT_PATH . 'partials/CatchThemesThemePlugin.php';
173 }
174 }
175