PluginProbe
Catch Web Tools / 3.3
Catch Web Tools v3.3
trunk 0.1 0.2 0.3 0.4 1.0 1.1 1.2 1.3 1.4 1.4.1 1.5 1.5.1 1.5.2 1.6 1.7 1.8 1.8.1 1.9 1.9.1 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 All 58 releases
catch-web-tools / admin / admin-functions.php

admin-functions.php in Catch Web Tools 3.3, at admin/admin-functions.php

183 lines 6.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * @package Admin
5 */
6
7 // Exit if accessed directly
8 if (! defined('ABSPATH')) {
9 exit;
10 }
11
12 /**
13 * Enqueue admin scripts and styles
14 */
15 function catchwebtools_admin_enqueue_scripts($hook_suffix)
16 {
17 $allowed_admin_hook_suffix = catchwebtools_admin_hook_suffix();
18
19 if (in_array($hook_suffix, $allowed_admin_hook_suffix)) {
20 wp_enqueue_media();
21
22 wp_enqueue_script('catchwebtools-plugin-options', CATCHWEBTOOLS_URL . 'admin/js/admin.js', array('jquery', 'wp-color-picker'), CATCHWEBTOOLS_VERSION, true);
23
24 wp_enqueue_script('catch-ids-match-height', plugin_dir_url(__FILE__) . 'js/jquery.matchHeight.min.js', array('jquery'), CATCHWEBTOOLS_VERSION, true);
25
26 // Font Awesome
27 wp_enqueue_style('cwt-font-awesome', CATCHWEBTOOLS_URL . 'css/font-awesome/css/all.min.css', array(), '6.7.2', 'all');
28
29
30 //CSS Styles
31
32 wp_enqueue_style('catchwebtools-plugin-css', CATCHWEBTOOLS_URL . 'admin/css/admin.css', array('wp-color-picker', 'thickbox'), CATCHWEBTOOLS_VERSION);
33
34 wp_enqueue_style('catchwebtools-plugin-dashboard-css', CATCHWEBTOOLS_URL . 'admin/css/admin-dashboard.css', false, CATCHWEBTOOLS_VERSION);
35
36
37
38 /**
39 * Admin Social Links
40 * use facebook and twitter scripts only on dashboard
41 */
42 if ('toplevel_page_catch-web-tools' === $hook_suffix) {
43 ?>
44 <!-- Start Social scripts -->
45 <div id="fb-root"></div>
46 <?php // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedScript -- third-party social SDK loaders cannot be enqueued via wp_enqueue_script. ?>
47 <script>
48 (function(d, s, id) {
49 var js, fjs = d.getElementsByTagName(s)[0];
50 if (d.getElementById(id)) return;
51 js = d.createElement(s);
52 js.id = id;
53 js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=276203972392824";
54 fjs.parentNode.insertBefore(js, fjs);
55 }(document, 'script', 'facebook-jssdk'));
56 </script>
57 <?php // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedScript ?>
58 <script>
59 ! function(d, s, id) {
60 var js, fjs = d.getElementsByTagName(s)[0];
61 if (!d.getElementById(id)) {
62 js = d.createElement(s);
63 js.id = id;
64 js.src = "//platform.twitter.com/widgets.js";
65 fjs.parentNode.insertBefore(js, fjs);
66 }
67 }(document, "script", "twitter-wjs");
68 </script>
69 <!-- End Social scripts -->
70 <?php
71 }
72 }
73
74 //Catch Updater Scripts and Style
75 //Only add Catch Updater Scripts and Style to theme-install page and plugin-install page
76 if ('theme-install.php' === $hook_suffix || 'plugin-install.php' === $hook_suffix) {
77 wp_enqueue_script('catch-updater-admin-js', CATCHWEBTOOLS_URL . 'admin/js/catch-updater-admin.js', array('jquery'), CATCHWEBTOOLS_VERSION, true);
78
79 wp_enqueue_style('catch-updater-admin-css', CATCHWEBTOOLS_URL . 'admin/css/catch-updater-admin.css', array(), CATCHWEBTOOLS_VERSION);
80 }
81
82 //Catch Updater Scripts and Style
83 //Only add Catch Updater Scripts and Style to theme-install page and plugin-install page
84 if ('catch-web-tools_page_catch-web-tools-catch-ids' === $hook_suffix) {
85 wp_enqueue_script('catch-ids-js', CATCHWEBTOOLS_URL . 'admin/js/catch-ids.js', array('jquery'), CATCHWEBTOOLS_VERSION, true);
86 wp_enqueue_style('catch-ids-css', CATCHWEBTOOLS_URL . 'admin/css/catch-ids.css', array(), CATCHWEBTOOLS_VERSION);
87 }
88 }
89 add_action('admin_enqueue_scripts', 'catchwebtools_admin_enqueue_scripts');
90
91 require_once(CATCHWEBTOOLS_PATH . 'admin/inc/core.php');
92
93 require_once(CATCHWEBTOOLS_PATH . 'admin/inc/catch-ids.php');
94
95 require_once(CATCHWEBTOOLS_PATH . 'admin/inc/social-icons.php');
96
97 require_once(CATCHWEBTOOLS_PATH . 'to-top/to-top.php');
98
99 function catchwebtools_cwt_updater()
100 {
101 global $wp_version;
102 // Disable Catch Updater module by default since version 5.5 and later
103 if (version_compare($wp_version, '5.5', '<')) {
104 // Get Catch Updater Status
105 $catchwebtools_catch_updater = catchwebtools_get_options('catchwebtools_catch_updater');
106
107 if ($catchwebtools_catch_updater['status']) {
108 if (is_admin()) {
109 require_once(CATCHWEBTOOLS_PATH . 'admin/catch-updater/inc/catch-updater-modify-installer.php');
110 require_once(CATCHWEBTOOLS_PATH . 'admin/catch-updater/inc/catch-updater-plugin-modify-installer.php');
111 } else {
112 require_once(CATCHWEBTOOLS_PATH . 'admin/catch-updater/inc/catch-updater-show-maintenance-message.php');
113 }
114 }
115 }
116 }
117
118 add_action('admin_init', 'catchwebtools_cwt_updater');
119
120
121 //Get Catch Big Image Size Threshold Status
122 $catchwebtools_big_image_size_threshold = catchwebtools_get_options('catchwebtools_big_image_size_threshold');
123
124 if ($catchwebtools_big_image_size_threshold['status']) {
125 add_filter('big_image_size_threshold', '__return_false');
126 }
127
128 //Get SEO and OG status
129 $catchwebtools_seo = catchwebtools_get_options('catchwebtools_seo');
130 $catchwebtools_og = catchwebtools_get_options('catchwebtools_opengraph');
131
132 /* Include metabox only if SEO or OG modules are activated.
133 * Otherwise it produced an error due to WP nonce
134 */
135 if (($catchwebtools_seo['status'] || $catchwebtools_og['status']) && is_admin()) {
136 require_once(CATCHWEBTOOLS_PATH . 'admin/inc/metabox.php');
137 }
138
139 function catchwebtools_custom_css_migrate()
140 {
141 $ver = get_theme_mod('cwt_custom_css_version', false);
142
143 // Return if update has already been run
144 if (version_compare($ver, '4.7') >= 0) {
145 return;
146 }
147
148 if (function_exists('wp_update_custom_css_post')) {
149 // Migrate any existing theme CSS to the core option added in WordPress 4.7.
150
151 /**
152 * Get Theme Options Values
153 */
154 $custom_css = catchwebtools_get_options('catchwebtools_custom_css');
155
156 if ('' != $custom_css && ! is_array($custom_css)) {
157 $core_css = wp_get_custom_css(); // Preserve any CSS already added to the core option.
158 $return = wp_update_custom_css_post($core_css . $custom_css);
159 if (! is_wp_error($return)) {
160 // Remove the old theme_mod, so that the CSS is stored in only one place moving forward.
161 unset($custom_css);
162 delete_transient('catchwebtools_custom_css');
163 delete_option('catchwebtools_custom_css');
164
165 // Update to match custom_css_version so that script is not executed continously
166 set_theme_mod('cwt_custom_css_version', '4.7');
167 }
168 }
169 }
170 }
171 add_action('after_setup_theme', 'catchwebtools_custom_css_migrate');
172
173 // Display customizer options of Heaader Footer script only if WebMaster module is active.
174 function catchwebtools_is_active_webmaster_module($control)
175 {
176 $enabled = $control->manager->get_setting('catchwebtools_webmaster[status]')->value();
177 if (1 === (int) $enabled) {
178 return true;
179 } else {
180 return false;
181 }
182 }
183