PluginProbe
Catch Web Tools / 0.1
Catch Web Tools v0.1
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 / inc / core.php

core.php in Catch Web Tools 0.1, at admin/inc/core.php

273 lines 9.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package Admin
4 * Main class: core.php
5 */
6
7 /**
8 * Core Classfor catchwebtools
9 */
10 class catchwebtools {
11
12 /**
13 * catchwebtools default constructor
14 * action hooks enabled to add Catch Web Tools to menu
15 */
16 function __construct() {
17 add_action( 'admin_menu', array( $this, 'add_plugin_settings_menu' ) );
18
19 add_action( 'admin_init', array( $this, 'register_settings' ) );
20 }
21
22 /**
23 * catchwebtools: add_plugin_settings_menu
24 * add Catch Web Tools to menu
25 */
26 function add_plugin_settings_menu() {
27 //add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $position );
28 add_menu_page( __('Dashboard', 'catchwebtools' ), __( 'Catch Web Tools', 'catchwebtools' ), 'manage_options', 'catch-web-tools', array( $this, 'catch_web_tools_settings_page' ), CATCHWEBTOOLS_URL . 'images/catch-themes-themes-option.png', '99.01564' );
29
30 //add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function);
31 add_submenu_page( 'catch-web-tools', __( 'Dashboard', 'catchwebtools' ), __( 'Dashboard', 'catchwebtools' ), 'manage_options', 'catch-web-tools', array( $this, 'catch_web_tools_settings_page' ) );
32
33 add_submenu_page( 'catch-web-tools', __( 'Webmasters', 'catchwebtools' ), __( 'Webmasters', 'catchwebtools' ), 'manage_options', 'catch-web-tools-webmasters', array( $this, 'catch_web_tools_webmaster_page' ) );
34
35 add_submenu_page( 'catch-web-tools', __( 'Custom CSS', 'catchwebtools' ), __( 'Custom CSS', 'catchwebtools' ), 'manage_options', 'catch-web-tools-custom-css', array( $this, 'catch_web_tools_custom_css_page' ) );
36
37 add_submenu_page( 'catch-web-tools', __( 'Social Icons', 'catchwebtools' ), __( 'Social Icons', 'catchwebtools' ), 'manage_options', 'catch-web-tools-social-icons', array( $this, 'catch_web_tools_social_icons_page' ) );
38
39 add_submenu_page( 'catch-web-tools', __( 'Open Graph', 'catchwebtools' ), __( 'Open Graph', 'catchwebtools' ), 'manage_options', 'catch-web-tools-opengraph', array( $this, 'catch_web_tools_opengraph_page' ) );
40
41 add_submenu_page( 'catch-web-tools', __( 'SEO', 'catchwebtools' ), __( 'SEO', 'catchwebtools' ), 'manage_options', 'catch-web-tools-seo', array( $this, 'catch_web_tools_seo_page' ) );
42 }
43
44 /**
45 * catchwebtools: catch_web_tools_settings_page
46 * Catch Web Tools Setting function
47 */
48 function catch_web_tools_settings_page() {
49 if ( !current_user_can( 'manage_options' ) ) {
50 wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
51 }
52
53 include( CATCHWEBTOOLS_PATH . '/admin/modules/dashboard.php' );
54 }
55
56 /**
57 * catchwebtools: catch_web_tools_webmaster_page
58 * Catch Web Tools Webmaster Display Function
59 */
60 function catch_web_tools_webmaster_page() {
61
62 if ( !current_user_can( 'manage_options' ) ) {
63 wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
64 }
65
66 include( CATCHWEBTOOLS_PATH . '/admin/modules/webmaster.php' );
67 }
68
69 /**
70 * catchwebtools: catch_web_tools_opengraph_page
71 * Catch Web Tools Webmaster Display Function
72 */
73 function catch_web_tools_opengraph_page() {
74
75 if ( !current_user_can( 'manage_options' ) ) {
76 wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
77 }
78
79 include( CATCHWEBTOOLS_PATH . '/admin/modules/opengraph.php' );
80 }
81
82 /**
83 * catchwebtools: catch_web_tools_seo_page
84 * Catch Web Tools SEO Display Function
85 */
86 function catch_web_tools_seo_page() {
87
88 if ( !current_user_can( 'manage_options' ) ) {
89 wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
90 }
91
92 include( CATCHWEBTOOLS_PATH . '/admin/modules/seo.php' );
93 }
94
95 /**
96 * catchwebtools: catch_web_tools_social_icons_page
97 * Catch Web Tools Social Icons Display Function
98 */
99 function catch_web_tools_social_icons_page() {
100
101 if ( !current_user_can( 'manage_options' ) ) {
102 wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
103 }
104
105 include( CATCHWEBTOOLS_PATH . '/admin/modules/social-icons.php' );
106 }
107
108 /**
109 * catchwebtools: catch_web_tools_custom_css_page
110 * Catch Web Tools Custom CSS Display Function
111 */
112 function catch_web_tools_custom_css_page() {
113
114 if ( !current_user_can( 'manage_options' ) ) {
115 wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
116 }
117
118 include( CATCHWEBTOOLS_PATH . '/admin/modules/custom-css.php' );
119 }
120
121 /**
122 * catchwebtools: register_settings
123 * Catch Web Tools Register Settings
124 */
125 function register_settings() {
126 // register_setting( $option_group, $option_name, $sanitize_callback )
127 register_setting(
128 'webmaster-tools-group',
129 'catchwebtools_webmaster',
130 array($this, 'catchwebtools_webmaster_sanitize_callback')
131 );
132
133 // register_setting( $option_group, $option_name, $sanitize_callback )
134 register_setting(
135 'opengraph-settings-group',
136 'catchwebtools_opengraph',
137 array($this, 'catchwebtools_opengraph_sanitize_callback')
138 );
139
140 // register_setting( $option_group, $option_name, $sanitize_callback )
141 register_setting(
142 'custom-css-settings-group',
143 'catchwebtools_custom_css',
144 array($this, 'catchwebtools_custom_css_sanitize_callback')
145 );
146
147 // register_setting( $option_group, $option_name, $sanitize_callback )
148 register_setting(
149 'seo-settings-group',
150 'catchwebtools_seo' ,
151 array($this, 'catchwebtools_seo_sanitize_callback')
152 );
153
154 // register_setting( $option_group, $option_name, $sanitize_callback )
155 register_setting(
156 'social-icons-group',
157 'catchwebtools_social',
158 array($this, 'catchwebtools_social_icons_sanitize_callback')
159 );
160
161 // register_setting( $option_group, $option_name, $sanitize_callback )
162 register_setting(
163 'catchids-settings-group',
164 'catchwebtools_catchids' ,
165 array($this, 'catchwebtools_catchids_sanitize_callback')
166 );
167 }
168
169 /**
170 * catchwebtools: catchwebtools_webmaster_sanitize_callback
171 * Webmaster Sanitization function callback
172 */
173 function catchwebtools_webmaster_sanitize_callback( $input ){
174
175 if( !empty( $input['header'] ) )
176 $input['header'] = $input['header'];
177
178 if( !empty( $input['footer'] ) )
179 $input['footer'] = wp_kses_stripslashes( $input['footer'] );
180
181 if( !empty( $input['google-site-verification'] ) )
182 $input['google-site-verification']= sanitize_text_field( $input['google-site-verification'] );
183
184 if( !empty( $input['msvalidate.01'] ) )
185 $input['msvalidate.01'] = sanitize_text_field( $input['msvalidate.01'] );
186
187 if( !empty( $input['alexaVerifyID'] ) )
188 $input['alexaVerifyID'] = sanitize_text_field( $input['alexaVerifyID'] );
189
190 delete_transient( 'catchwebtools_webmaster_transient' );
191
192 return $input;
193 }
194
195 /**
196 * catchwebtools: catchwebtools_opengraph_sanitize_callback
197 * Open Graph Sanitization function callback
198 */
199 function catchwebtools_opengraph_sanitize_callback( $input ){
200
201 if( !empty( $input['og:image'] ) )
202 $input['og:image'] = esc_url_raw ( $input['og:image'] );
203 if( !empty( $input['og:default_image'] ) )
204 $input['og:default_image'] = esc_url_raw ( $input['og:default_image'] );
205
206 foreach ( $input as $key => $value )
207 if( !empty( $input[ $key ] ) )
208 $input[ $key ] = wp_kses( sanitize_text_field( $value ) , '' );
209
210 delete_transient( 'catchwebtools_opengraph_transient' );
211
212 return $input;
213 }
214
215 /**
216 * catchwebtools: catchwebtools_custom_css_sanitize_callback
217 * Custom Css Sanitization function callback
218 */
219 function catchwebtools_custom_css_sanitize_callback( $input ){
220 if( !empty( $input ) )
221 $input = wp_filter_nohtml_kses( $input );
222
223 delete_transient( 'catchwebtools_custom_css_transient' );
224
225 return $input;
226 }
227
228 /**
229 * catchwebtools: catchwebtools_seo_sanitize_callback
230 * Seo Sanitization function callback
231 */
232 function catchwebtools_seo_sanitize_callback( $input ){
233 $input['title'] = ( $input['title'] != '' ) ? wp_filter_nohtml_kses( sanitize_text_field( $input['title'] ) ) : get_bloginfo ( 'name' );
234
235 $input['description'] = ( $input['description'] != '' ) ? wp_filter_nohtml_kses( sanitize_text_field($input['description'] ) ) : get_bloginfo ( 'description' );
236
237 delete_transient( 'catchwebtools_seo_transient' );
238
239 return $input;
240 }
241
242 /**
243 * catchwebtools: catchwebtools_social_icons_sanitize_callback
244 * Social Icons Sanitization function callback
245 */
246 function catchwebtools_social_icons_sanitize_callback( $input ){
247 if( !empty( $input['social_icon_size'] ) )
248 $input['social_icon_size'] = intval ( $input['social_icon_size'] );
249
250 if( !empty( $input['social_icon_color'] ) )
251 $input['social_icon_color'] = wp_filter_nohtml_kses ( $input['social_icon_color'] );
252
253 foreach ( $input as $key => $value )
254 if( $key != 'social_icon_size' && $key != 'social_icon_color' && $key != 'status' )
255 if( !empty( $input[ $key ] ) )
256 $input[ $key ] = esc_url_raw( sanitize_text_field( $value ) , '' );
257
258 delete_transient( 'catchwebtools_social_transient' );
259
260 return $input;
261 }
262
263 /**
264 * catchwebtools: catchwebtools_catchids_sanitize_callback
265 * Catch Ids Sanitization function callback
266 */
267 function catchwebtools_catchids_sanitize_callback( $input ){
268 delete_transient( 'catchwebtools_catchids_transient' );
269
270 return $input;
271 }
272 }
273 $catch_web_tools = new catchwebtools();