PluginProbe
CryptX / 3.3.1
CryptX v3.3.1
4.2.1 4.2.0 4.1.1 trunk 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.9 2.0 2.1 2.2 2.3 2.3.1 2.3.2 2.3.3 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 All 93 releases
cryptx / include / admin_option_page.php

admin_option_page.php in CryptX 3.3.1, at include/admin_option_page.php

192 lines 7.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Don't load this file direct!
4 */
5 if (!defined('ABSPATH')) {
6 return ;
7 }
8
9 /**
10 * load required code
11 */
12 require_once(CRYPTX_DIR_PATH . 'include/admin_general.php');
13 require_once(CRYPTX_DIR_PATH . 'include/admin_presentation.php');
14 require_once(CRYPTX_DIR_PATH . 'include/admin_howto.php');
15 require_once(CRYPTX_DIR_PATH . 'include/admin_changelog.php');
16
17 /**
18 * Add css to header
19 */
20 function rw_cryptx_admin_css_script($hook) {
21 // Load only on ?page=cryptx
22 if($hook != 'settings_page_cryptx') {
23 return;
24 }
25 wp_enqueue_style( 'cryptx-admin-css', CRYPTX_DIR_URL . '/css/admin.css' );
26 wp_enqueue_style( 'wp-color-picker' );
27 wp_enqueue_script( 'cryptx-admin-js', CRYPTX_DIR_URL . '/js/cryptx-admin.min.js', array( 'jquery', 'wp-color-picker' ), false, true );
28 wp_enqueue_media();
29
30 }
31 add_action( 'admin_enqueue_scripts', 'rw_cryptx_admin_css_script' );
32
33 /**
34 * add links to plugin site
35 */
36 function rw_cryptx_init_row_meta($links, $file) {
37 if (CRYPTX_BASENAME == $file) {
38 return array_merge(
39 $links,
40 array(
41 sprintf(
42 '<a href="options-general.php?page=%s">%s</a>',
43 CRYPTX_BASEFOLDER,
44 __('Settings')
45 )
46 ),
47 array(
48 sprintf(
49 '<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4026696">%s</a>',
50 __('Donate', 'cryptx')
51 )
52 )
53 );
54 }
55 return $links;
56 }
57
58 /**
59 * add CryptX to Option menu
60 */
61 function rw_cryptx_menu() {
62 add_submenu_page(
63 'options-general.php',
64 _x( 'CryptX', 'CryptX settings page', 'cryptx' ),
65 _x( 'CryptX', 'CryptX settings menu', 'cryptx' ),
66 'manage_options',
67 'cryptx',
68 'rw_cryptx_submenu'
69 );
70 }
71 if (is_admin()) add_action('admin_menu', 'rw_cryptx_menu');
72
73 /**
74 * save options
75 */
76 function rw_cryptx_saveOptions() {
77 global $cryptX_var, $data, $rw_cryptx_active_tab;
78
79 if (isset($_POST) && !empty($_POST)) {
80 if (function_exists('current_user_can') === true && current_user_can('manage_options') === false) {
81 wp_die("You don't have permission to access!");
82 }
83 $saveOptions = cryptx_sanitize_data($_POST['cryptX_var']);
84 check_admin_referer('cryptX');
85 if(isset($_POST['cryptX_var_reset'])) {
86 delete_option('cryptX');
87 $saveOptions = rw_loadDefaults();
88 }
89 if(isset($_POST['cryptX_save_general_settings'])) {
90 $checkboxes = array(
91 'the_content' => 0,
92 'the_meta_key' => 0,
93 'the_excerpt' => 0,
94 'comment_text' => 0,
95 'widget_text' => 0,
96 'autolink' => 0,
97 'metaBox' => 0,
98 );
99 $saveOptions = wp_parse_args( $saveOptions, $checkboxes );
100 }
101 $saveOptions = wp_parse_args( $saveOptions, rw_loadDefaults() );
102 update_option( 'cryptX', $saveOptions);
103 $cryptX_var = rw_loadDefaults();
104 ?>
105 <div id="message" class="updated fade">
106 <p><strong><?php _e('Settings saved.') ?></strong></p>
107 </div>
108 <?php
109 }
110 }
111
112 /**
113 * sanitize given options
114 */
115 function cryptx_sanitize_data($data) {
116 if( isset( $data['version']) ) $data['version'] = sanitize_text_field($data['version']);
117 if( isset( $data['at']) ) $data['at'] = sanitize_text_field($data['at']);
118 if( isset( $data['dot']) ) $data['dot'] = sanitize_text_field($data['dot']);
119 if( isset( $data['css_id']) ) $data['css_id'] = sanitize_text_field($data['css_id']);
120 if( isset( $data['css_class']) ) $data['css_class'] = sanitize_text_field($data['css_class']);
121 if( isset( $data['the_content']) ) $data['the_content'] = (int) $data['the_content'];
122 if( isset( $data['the_meta_key']) ) $data['the_meta_key'] = (int) $data['the_meta_key'];
123 if( isset( $data['the_excerpt']) ) $data['the_excerpt'] = (int) $data['the_excerpt'];
124 if( isset( $data['comment_text']) ) $data['comment_text'] = (int) $data['comment_text'];
125 if( isset( $data['java']) ) $data['java'] = (int) $data['java'];
126 if( isset( $data['load_java']) ) $data['load_java'] = (int) $data['load_java'];
127 if( isset( $data['opt_linktext']) ) $data['opt_linktext'] = (int) $data['opt_linktext'];
128 if( isset( $data['autolink']) ) $data['autolink'] = (int) $data['autolink'];
129 if( isset( $data['alt_linktext']) ) $data['alt_linktext'] = sanitize_text_field($data['alt_linktext']);
130 if( isset( $data['http_linkimage_title']) ) $data['http_linkimage_title'] = sanitize_text_field($data['http_linkimage_title']);
131 if( isset( $data['alt_linkimage_title']) ) $data['alt_linkimage_title'] = sanitize_text_field($data['alt_linkimage_title']);
132 if( isset( $data['excludedIDs']) ) $data['excludedIDs'] = sanitize_text_field($data['excludedIDs']);
133 if( isset( $data['metaBox']) ) $data['metaBox'] = (bool) $data['metaBox'];
134 if( isset( $data['excludedIDs']) ) $data['excludedIDs'] = sanitize_text_field($data['excludedIDs']);
135 if( isset( $data['alt_uploadedimage']) ) $data['alt_uploadedimage'] = sanitize_text_field($data['alt_uploadedimage']);
136 if( isset( $data['c2i_font']) ) $data['c2i_font'] = sanitize_text_field($data['c2i_font']);
137 if( isset( $data['c2i_fontSize']) ) $data['c2i_fontSize'] = (int) $data['c2i_fontSize'];
138 if( isset( $data['c2i_fontRGB']) ) $data['c2i_fontRGB'] = sanitize_text_field($data['c2i_fontRGB']);
139 if( isset( $data['echo']) ) $data['echo'] = (int) $data['echo'];
140 if( isset( $data['whiteList']) ) $data['whiteList'] = sanitize_text_field($data['whiteList']);
141 return $data;
142 }
143
144 /**
145 * print CryptX Option Page
146 */
147 function rw_cryptx_submenu() {
148 global $cryptX_var, $data, $rw_cryptx_active_tab;
149 rw_cryptx_saveOptions();
150 $rw_cryptx_active_tab = isset( $_GET['tab'] ) ? $_GET['tab'] : 'general';
151 ?>
152 <div class="cryptx-option-page">
153 <h1><?php _e("CryptX settings",'cryptx'); ?></h1>
154 <form method="post" action="">
155 <?php wp_nonce_field('cryptX') ?>
156
157 <h2 class="nav-tab-wrapper">
158 <?php
159 do_action( 'rw_cryptx_settings_tab' );
160 ?>
161 </h2>
162 <div class="cryptx-tab-content-wrapper">
163 <?php
164 do_action( 'rw_cryptx_settings_content' );
165 ?>
166 </div><!-- /.cryptx-tab-content-wrapper -->
167 </form>
168 </div><!-- /.cryptx-option-page -->
169 <?php
170 }
171
172 /**
173 * Option page navigation
174 */
175 function rw_cryptx_settings_tab_presentation(){
176 global $rw_cryptx_active_tab; ?>
177 <a class="nav-tab <?php echo $rw_cryptx_active_tab == 'general' || '' ? 'nav-tab-active' : ''; ?>" href="<?php echo admin_url( 'options-general.php?page=' . CRYPTX_BASEFOLDER . '&tab=general' ); ?>">
178 <?php _e("General",'cryptx'); ?>
179 </a>
180 <a class="nav-tab <?php echo $rw_cryptx_active_tab == 'presentation' ? 'nav-tab-active' : ''; ?>" href="<?php echo admin_url( 'options-general.php?page=' . CRYPTX_BASEFOLDER . '&tab=presentation' ); ?>">
181 <?php _e("Presentation",'cryptx'); ?>
182 </a>
183 <a class="nav-tab <?php echo $rw_cryptx_active_tab == 'howto' ? 'nav-tab-active' : ''; ?>" href="<?php echo admin_url( 'options-general.php?page=' . CRYPTX_BASEFOLDER . '&tab=howto' ); ?>">
184 <?php _e("How to&hellip;",'cryptx'); ?>
185 </a>
186 <a class="nav-tab <?php echo $rw_cryptx_active_tab == 'changelog' ? 'nav-tab-active' : ''; ?>" href="<?php echo admin_url( 'options-general.php?page=' . CRYPTX_BASEFOLDER . '&tab=changelog' ); ?>">
187 <?php _e("Changelog",'cryptx'); ?>
188 </a>
189 <?php
190 }
191 add_action( 'rw_cryptx_settings_tab', 'rw_cryptx_settings_tab_presentation' );
192