PluginProbe
Catch Web Tools / 3.2
Catch Web Tools v3.2
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.2, at admin/admin-functions.php

181 lines 5.9 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'), '2013-10-05');
23
24 wp_enqueue_script('catch-ids-match-height', plugin_dir_url(__FILE__) . 'js/jquery.matchHeight.min.js', array('jquery'), '1.0', false);
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'), '2013-10-05');
33
34 wp_enqueue_style('catchwebtools-plugin-dashboard-css', CATCHWEBTOOLS_URL . 'admin/css/admin-dashboard.css', false, '2013-10-05');
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 <script>
47 (function(d, s, id) {
48 var js, fjs = d.getElementsByTagName(s)[0];
49 if (d.getElementById(id)) return;
50 js = d.createElement(s);
51 js.id = id;
52 js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=276203972392824";
53 fjs.parentNode.insertBefore(js, fjs);
54 }(document, 'script', 'facebook-jssdk'));
55 </script>
56 <script>
57 ! function(d, s, id) {
58 var js, fjs = d.getElementsByTagName(s)[0];
59 if (!d.getElementById(id)) {
60 js = d.createElement(s);
61 js.id = id;
62 js.src = "//platform.twitter.com/widgets.js";
63 fjs.parentNode.insertBefore(js, fjs);
64 }
65 }(document, "script", "twitter-wjs");
66 </script>
67 <!-- End Social scripts -->
68 <?php
69 }
70 }
71
72 //Catch Updater Scripts and Style
73 //Only add Catch Updater Scripts and Style to theme-install page and plugin-install page
74 if ('theme-install.php' == $hook_suffix || 'plugin-install.php' == $hook_suffix) {
75 wp_enqueue_script('catch-updater-admin-js', CATCHWEBTOOLS_URL . 'admin/js/catch-updater-admin.js');
76
77 wp_enqueue_style('catch-updater-admin-css', CATCHWEBTOOLS_URL . 'admin/css/catch-updater-admin.css');
78 }
79
80 //Catch Updater Scripts and Style
81 //Only add Catch Updater Scripts and Style to theme-install page and plugin-install page
82 if ('catch-web-tools_page_catch-web-tools-catch-ids' == $hook_suffix) {
83 wp_enqueue_script('catch-ids-js', CATCHWEBTOOLS_URL . 'admin/js/catch-ids.js');
84 wp_enqueue_style('catch-ids-css', CATCHWEBTOOLS_URL . 'admin/css/catch-ids.css');
85 }
86 }
87 add_action('admin_enqueue_scripts', 'catchwebtools_admin_enqueue_scripts');
88
89 require_once(CATCHWEBTOOLS_PATH . 'admin/inc/core.php');
90
91 require_once(CATCHWEBTOOLS_PATH . 'admin/inc/catch-ids.php');
92
93 require_once(CATCHWEBTOOLS_PATH . 'admin/inc/social-icons.php');
94
95 require_once(CATCHWEBTOOLS_PATH . 'to-top/to-top.php');
96
97 function cwt_updater()
98 {
99 global $wp_version;
100 // Disable Catch Updater module by default since version 5.5 and later
101 if (version_compare($wp_version, '5.5', '<')) {
102 // Get Catch Updater Status
103 $catchwebtools_catch_updater = catchwebtools_get_options('catchwebtools_catch_updater');
104
105 if ($catchwebtools_catch_updater['status']) {
106 if (is_admin()) {
107 require_once(CATCHWEBTOOLS_PATH . 'admin/catch-updater/inc/catch-updater-modify-installer.php');
108 require_once(CATCHWEBTOOLS_PATH . 'admin/catch-updater/inc/catch-updater-plugin-modify-installer.php');
109 } else {
110 require_once(CATCHWEBTOOLS_PATH . 'admin/catch-updater/inc/catch-updater-show-maintenance-message.php');
111 }
112 }
113 }
114 }
115
116 add_action('admin_init', 'cwt_updater');
117
118
119 //Get Catch Big Image Size Threshold Status
120 $catchwebtools_big_image_size_threshold = catchwebtools_get_options('catchwebtools_big_image_size_threshold');
121
122 if ($catchwebtools_big_image_size_threshold['status']) {
123 add_filter('big_image_size_threshold', '__return_false');
124 }
125
126 //Get SEO and OG status
127 $catchwebtools_seo = catchwebtools_get_options('catchwebtools_seo');
128 $catchwebtools_og = catchwebtools_get_options('catchwebtools_opengraph');
129
130 /* Include metabox only if SEO or OG modules are activated.
131 * Otherwise it produced an error due to WP nonce
132 */
133 if (($catchwebtools_seo['status'] || $catchwebtools_og['status']) && is_admin()) {
134 require_once(CATCHWEBTOOLS_PATH . 'admin/inc/metabox.php');
135 }
136
137 function catchwebtools_custom_css_migrate()
138 {
139 $ver = get_theme_mod('cwt_custom_css_version', false);
140
141 // Return if update has already been run
142 if (version_compare($ver, '4.7') >= 0) {
143 return;
144 }
145
146 if (function_exists('wp_update_custom_css_post')) {
147 // Migrate any existing theme CSS to the core option added in WordPress 4.7.
148
149 /**
150 * Get Theme Options Values
151 */
152 $custom_css = catchwebtools_get_options('catchwebtools_custom_css');
153
154 if ('' != $custom_css && ! is_array($custom_css)) {
155 $core_css = wp_get_custom_css(); // Preserve any CSS already added to the core option.
156 $return = wp_update_custom_css_post($core_css . $custom_css);
157 if (! is_wp_error($return)) {
158 // Remove the old theme_mod, so that the CSS is stored in only one place moving forward.
159 unset($custom_css);
160 delete_transient('catchwebtools_custom_css');
161 delete_option('catchwebtools_custom_css');
162
163 // Update to match custom_css_version so that script is not executed continously
164 set_theme_mod('cwt_custom_css_version', '4.7');
165 }
166 }
167 }
168 }
169 add_action('after_setup_theme', 'catchwebtools_custom_css_migrate');
170
171 // Display customizer options of Heaader Footer script only if WebMaster module is active.
172 function catchwebtools_is_active_webmaster_module($control)
173 {
174 $enabled = $control->manager->get_setting('catchwebtools_webmaster[status]')->value();
175 if (1 == $enabled) {
176 return true;
177 } else {
178 return false;
179 }
180 }
181