@@ -1,21 +1,21 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | class FrmStylesController { |
| 4 | - public static $post_type = 'frm_styles'; |
|
| 5 | - public static $screen = 'formidable_page_formidable-styles'; |
|
| 6 | - |
|
| 7 | - public static function load_pro_hooks() { |
|
| 8 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
| 9 | - FrmProStylesController::load_pro_hooks(); |
|
| 10 | - } |
|
| 11 | - } |
|
| 12 | - |
|
| 13 | - public static function register_post_types() { |
|
| 14 | - register_post_type( self::$post_type, array( |
|
| 15 | - 'label' => __( 'Styles', 'formidable' ), |
|
| 16 | - 'public' => false, |
|
| 17 | - 'show_ui' => false, |
|
| 18 | - 'capability_type' => 'page', |
|
| 4 | + public static $post_type = 'frm_styles'; |
|
| 5 | + public static $screen = 'formidable_page_formidable-styles'; |
|
| 6 | + |
|
| 7 | + public static function load_pro_hooks() { |
|
| 8 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
| 9 | + FrmProStylesController::load_pro_hooks(); |
|
| 10 | + } |
|
| 11 | + } |
|
| 12 | + |
|
| 13 | + public static function register_post_types() { |
|
| 14 | + register_post_type( self::$post_type, array( |
|
| 15 | + 'label' => __( 'Styles', 'formidable' ), |
|
| 16 | + 'public' => false, |
|
| 17 | + 'show_ui' => false, |
|
| 18 | + 'capability_type' => 'page', |
|
| 19 | 19 | 'capabilities' => array( |
| 20 | 20 | 'edit_post' => 'frm_change_settings', |
| 21 | 21 | 'edit_posts' => 'frm_change_settings', |
@@ -25,11 +25,11 @@ discard block |
||
| 25 | 25 | 'delete_posts' => 'frm_change_settings', |
| 26 | 26 | 'read_private_posts' => 'read_private_posts', |
| 27 | 27 | ), |
| 28 | - 'supports' => array( |
|
| 28 | + 'supports' => array( |
|
| 29 | 29 | 'title', |
| 30 | - ), |
|
| 31 | - 'has_archive' => false, |
|
| 32 | - 'labels' => array( |
|
| 30 | + ), |
|
| 31 | + 'has_archive' => false, |
|
| 32 | + 'labels' => array( |
|
| 33 | 33 | 'name' => __( 'Styles', 'formidable' ), |
| 34 | 34 | 'singular_name' => __( 'Style', 'formidable' ), |
| 35 | 35 | 'menu_name' => __( 'Style', 'formidable' ), |
@@ -37,19 +37,19 @@ discard block |
||
| 37 | 37 | 'add_new_item' => __( 'Create a New Style', 'formidable' ), |
| 38 | 38 | 'edit_item' => __( 'Edit Style', 'formidable' ), |
| 39 | 39 | ), |
| 40 | - ) ); |
|
| 41 | - } |
|
| 40 | + ) ); |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - public static function menu() { |
|
| 43 | + public static function menu() { |
|
| 44 | 44 | add_submenu_page('formidable', 'Formidable | ' . __( 'Styles', 'formidable' ), __( 'Styles', 'formidable' ), 'frm_change_settings', 'formidable-styles', 'FrmStylesController::route' ); |
| 45 | - } |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - public static function admin_init() { |
|
| 48 | - if ( ! FrmAppHelper::is_admin_page('formidable-styles') ) { |
|
| 49 | - return; |
|
| 50 | - } |
|
| 47 | + public static function admin_init() { |
|
| 48 | + if ( ! FrmAppHelper::is_admin_page('formidable-styles') ) { |
|
| 49 | + return; |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - self::load_pro_hooks(); |
|
| 52 | + self::load_pro_hooks(); |
|
| 53 | 53 | |
| 54 | 54 | $style_tab = FrmAppHelper::get_param( 'frm_action', '', 'get', 'sanitize_title' ); |
| 55 | 55 | if ( $style_tab == 'manage' || $style_tab == 'custom_css' ) { |
@@ -57,18 +57,18 @@ discard block |
||
| 57 | 57 | return; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - wp_enqueue_script('jquery-ui-datepicker'); |
|
| 60 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
| 61 | 61 | |
| 62 | - $version = FrmAppHelper::plugin_version(); |
|
| 62 | + $version = FrmAppHelper::plugin_version(); |
|
| 63 | 63 | wp_enqueue_script( 'jquery-frm-themepicker', FrmAppHelper::plugin_url() . '/js/jquery/jquery-ui-themepicker.js', array( 'jquery' ), $version ); |
| 64 | 64 | |
| 65 | 65 | wp_enqueue_style( 'frm-custom-theme', admin_url('admin-ajax.php?action=frmpro_css' ) ); |
| 66 | 66 | |
| 67 | - $style = apply_filters('frm_style_head', false); |
|
| 68 | - if ( $style ) { |
|
| 67 | + $style = apply_filters('frm_style_head', false); |
|
| 68 | + if ( $style ) { |
|
| 69 | 69 | wp_enqueue_style( 'frm-single-custom-theme', admin_url( 'admin-ajax.php?action=frmpro_load_css&flat=1' ) . '&' . http_build_query( $style->post_content ) ); |
| 70 | - } |
|
| 71 | - } |
|
| 70 | + } |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | 73 | public static function enqueue_css( $register = 'enqueue' ) { |
| 74 | 74 | global $frm_vars; |
@@ -162,230 +162,230 @@ discard block |
||
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | public static function new_style( $return = '' ) { |
| 165 | - self::load_styler('default'); |
|
| 166 | - } |
|
| 165 | + self::load_styler('default'); |
|
| 166 | + } |
|
| 167 | 167 | |
| 168 | 168 | public static function duplicate() { |
| 169 | 169 | self::load_styler('default'); |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | public static function edit( $style_id = false, $message = '' ) { |
| 173 | - if ( ! $style_id ) { |
|
| 173 | + if ( ! $style_id ) { |
|
| 174 | 174 | $style_id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
| 175 | - if ( empty($style_id) ) { |
|
| 176 | - $style_id = 'default'; |
|
| 177 | - } |
|
| 178 | - } |
|
| 179 | - |
|
| 180 | - if ( 'default' == $style_id ) { |
|
| 181 | - $style = 'default'; |
|
| 182 | - } else { |
|
| 183 | - $frm_style = new FrmStyle($style_id); |
|
| 184 | - $style = $frm_style->get_one(); |
|
| 185 | - $style = $style->ID; |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - self::load_styler($style, $message); |
|
| 189 | - } |
|
| 190 | - |
|
| 191 | - public static function save() { |
|
| 192 | - $frm_style = new FrmStyle(); |
|
| 193 | - $message = ''; |
|
| 175 | + if ( empty($style_id) ) { |
|
| 176 | + $style_id = 'default'; |
|
| 177 | + } |
|
| 178 | + } |
|
| 179 | + |
|
| 180 | + if ( 'default' == $style_id ) { |
|
| 181 | + $style = 'default'; |
|
| 182 | + } else { |
|
| 183 | + $frm_style = new FrmStyle($style_id); |
|
| 184 | + $style = $frm_style->get_one(); |
|
| 185 | + $style = $style->ID; |
|
| 186 | + } |
|
| 187 | + |
|
| 188 | + self::load_styler($style, $message); |
|
| 189 | + } |
|
| 190 | + |
|
| 191 | + public static function save() { |
|
| 192 | + $frm_style = new FrmStyle(); |
|
| 193 | + $message = ''; |
|
| 194 | 194 | $post_id = FrmAppHelper::get_post_param( 'ID', false, 'sanitize_title' ); |
| 195 | 195 | $style_nonce = FrmAppHelper::get_post_param( 'frm_style', '', 'sanitize_text_field' ); |
| 196 | 196 | |
| 197 | 197 | if ( $post_id !== false && wp_verify_nonce( $style_nonce, 'frm_style_nonce' ) ) { |
| 198 | - $id = $frm_style->update($post_id); |
|
| 199 | - if ( empty($post_id) && ! empty($id) ) { |
|
| 200 | - // set the post id to the new style so it will be loaded for editing |
|
| 201 | - $post_id = reset($id); |
|
| 202 | - } |
|
| 203 | - // include the CSS that includes this style |
|
| 198 | + $id = $frm_style->update($post_id); |
|
| 199 | + if ( empty($post_id) && ! empty($id) ) { |
|
| 200 | + // set the post id to the new style so it will be loaded for editing |
|
| 201 | + $post_id = reset($id); |
|
| 202 | + } |
|
| 203 | + // include the CSS that includes this style |
|
| 204 | 204 | echo '<link href="' . esc_url( admin_url( 'admin-ajax.php?action=frmpro_css' ) ) . '" type="text/css" rel="Stylesheet" class="frm-custom-theme" />'; |
| 205 | - $message = __( 'Your styling settings have been saved.', 'formidable' ); |
|
| 206 | - } |
|
| 205 | + $message = __( 'Your styling settings have been saved.', 'formidable' ); |
|
| 206 | + } |
|
| 207 | 207 | |
| 208 | - return self::edit($post_id, $message); |
|
| 209 | - } |
|
| 208 | + return self::edit($post_id, $message); |
|
| 209 | + } |
|
| 210 | 210 | |
| 211 | 211 | public static function load_styler( $style, $message = '' ) { |
| 212 | - global $frm_settings; |
|
| 212 | + global $frm_settings; |
|
| 213 | 213 | |
| 214 | - $frm_style = new FrmStyle(); |
|
| 215 | - $styles = $frm_style->get_all(); |
|
| 214 | + $frm_style = new FrmStyle(); |
|
| 215 | + $styles = $frm_style->get_all(); |
|
| 216 | 216 | |
| 217 | - if ( is_numeric($style) ) { |
|
| 218 | - $style = $styles[ $style ]; |
|
| 219 | - } else if ( 'default' == $style ) { |
|
| 220 | - $style = $frm_style->get_default_style($styles); |
|
| 221 | - } |
|
| 217 | + if ( is_numeric($style) ) { |
|
| 218 | + $style = $styles[ $style ]; |
|
| 219 | + } else if ( 'default' == $style ) { |
|
| 220 | + $style = $frm_style->get_default_style($styles); |
|
| 221 | + } |
|
| 222 | 222 | |
| 223 | - self::add_meta_boxes(); |
|
| 223 | + self::add_meta_boxes(); |
|
| 224 | 224 | |
| 225 | 225 | include( FrmAppHelper::plugin_path() . '/classes/views/styles/show.php' ); |
| 226 | - } |
|
| 226 | + } |
|
| 227 | 227 | |
| 228 | 228 | /** |
| 229 | 229 | * @param string $message |
| 230 | 230 | * @param array|object $forms |
| 231 | 231 | */ |
| 232 | 232 | private static function manage( $message = '', $forms = array() ) { |
| 233 | - $frm_style = new FrmStyle(); |
|
| 234 | - $styles = $frm_style->get_all(); |
|
| 235 | - $default_style = $frm_style->get_default_style($styles); |
|
| 233 | + $frm_style = new FrmStyle(); |
|
| 234 | + $styles = $frm_style->get_all(); |
|
| 235 | + $default_style = $frm_style->get_default_style($styles); |
|
| 236 | 236 | |
| 237 | - if ( empty($forms) ) { |
|
| 238 | - $forms = FrmForm::get_published_forms(); |
|
| 239 | - } |
|
| 237 | + if ( empty($forms) ) { |
|
| 238 | + $forms = FrmForm::get_published_forms(); |
|
| 239 | + } |
|
| 240 | 240 | |
| 241 | 241 | include( FrmAppHelper::plugin_path() . '/classes/views/styles/manage.php' ); |
| 242 | - } |
|
| 242 | + } |
|
| 243 | 243 | |
| 244 | - private static function manage_styles() { |
|
| 244 | + private static function manage_styles() { |
|
| 245 | 245 | $style_nonce = FrmAppHelper::get_post_param( 'frm_manage_style', '', 'sanitize_text_field' ); |
| 246 | 246 | if ( ! $_POST || ! isset( $_POST['style'] ) || ! wp_verify_nonce( $style_nonce, 'frm_manage_style_nonce' ) ) { |
| 247 | - return self::manage(); |
|
| 248 | - } |
|
| 247 | + return self::manage(); |
|
| 248 | + } |
|
| 249 | 249 | |
| 250 | - global $wpdb; |
|
| 250 | + global $wpdb; |
|
| 251 | 251 | |
| 252 | 252 | $forms = FrmForm::get_published_forms(); |
| 253 | - foreach ( $forms as $form ) { |
|
| 254 | - if ( $_POST['style'][ $form->id ] == $_POST['prev_style'][ $form->id ] ) { |
|
| 255 | - continue; |
|
| 256 | - } |
|
| 253 | + foreach ( $forms as $form ) { |
|
| 254 | + if ( $_POST['style'][ $form->id ] == $_POST['prev_style'][ $form->id ] ) { |
|
| 255 | + continue; |
|
| 256 | + } |
|
| 257 | 257 | |
| 258 | - $form->options['custom_style'] = $_POST['style'][ $form->id ]; |
|
| 258 | + $form->options['custom_style'] = $_POST['style'][ $form->id ]; |
|
| 259 | 259 | |
| 260 | 260 | $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => maybe_serialize( $form->options ) ), array( 'id' => $form->id ) ); |
| 261 | - unset($form); |
|
| 262 | - } |
|
| 261 | + unset($form); |
|
| 262 | + } |
|
| 263 | 263 | |
| 264 | - $message = __( 'Your form styles have been saved.', 'formidable' ); |
|
| 265 | - return self::manage($message, $forms); |
|
| 266 | - } |
|
| 264 | + $message = __( 'Your form styles have been saved.', 'formidable' ); |
|
| 265 | + return self::manage($message, $forms); |
|
| 266 | + } |
|
| 267 | 267 | |
| 268 | - public static function custom_css( $message = '', $style = null ) { |
|
| 269 | - wp_enqueue_style('codemirror', FrmAppHelper::plugin_url() . '/css/codemirror.css'); |
|
| 270 | - wp_enqueue_script('codemirror', FrmAppHelper::plugin_url() . '/js/codemirror/codemirror.js', array(), '4.7'); |
|
| 271 | - wp_enqueue_script( 'codemirror-css', FrmAppHelper::plugin_url() . '/js/codemirror/css.js', array( 'codemirror' ), '4.7' ); |
|
| 268 | + public static function custom_css( $message = '', $style = null ) { |
|
| 269 | + wp_enqueue_style('codemirror', FrmAppHelper::plugin_url() . '/css/codemirror.css'); |
|
| 270 | + wp_enqueue_script('codemirror', FrmAppHelper::plugin_url() . '/js/codemirror/codemirror.js', array(), '4.7'); |
|
| 271 | + wp_enqueue_script( 'codemirror-css', FrmAppHelper::plugin_url() . '/js/codemirror/css.js', array( 'codemirror' ), '4.7' ); |
|
| 272 | 272 | |
| 273 | - if ( ! isset($style) ) { |
|
| 274 | - $frm_style = new FrmStyle(); |
|
| 275 | - $style = $frm_style->get_default_style(); |
|
| 276 | - } |
|
| 273 | + if ( ! isset($style) ) { |
|
| 274 | + $frm_style = new FrmStyle(); |
|
| 275 | + $style = $frm_style->get_default_style(); |
|
| 276 | + } |
|
| 277 | 277 | |
| 278 | 278 | include( FrmAppHelper::plugin_path() . '/classes/views/styles/custom_css.php' ); |
| 279 | - } |
|
| 279 | + } |
|
| 280 | 280 | |
| 281 | - public static function save_css() { |
|
| 282 | - $frm_style = new FrmStyle(); |
|
| 281 | + public static function save_css() { |
|
| 282 | + $frm_style = new FrmStyle(); |
|
| 283 | 283 | |
| 284 | - $message = ''; |
|
| 284 | + $message = ''; |
|
| 285 | 285 | $post_id = FrmAppHelper::get_post_param( 'ID', false, 'sanitize_text_field' ); |
| 286 | 286 | $nonce = FrmAppHelper::get_post_param( 'frm_custom_css', '', 'sanitize_text_field' ); |
| 287 | 287 | if ( wp_verify_nonce( $nonce, 'frm_custom_css_nonce' ) ) { |
| 288 | - $frm_style->update($post_id); |
|
| 289 | - $message = __( 'Your styling settings have been saved.', 'formidable' ); |
|
| 290 | - } |
|
| 288 | + $frm_style->update($post_id); |
|
| 289 | + $message = __( 'Your styling settings have been saved.', 'formidable' ); |
|
| 290 | + } |
|
| 291 | 291 | |
| 292 | - return self::custom_css($message); |
|
| 293 | - } |
|
| 292 | + return self::custom_css($message); |
|
| 293 | + } |
|
| 294 | 294 | |
| 295 | - public static function route() { |
|
| 295 | + public static function route() { |
|
| 296 | 296 | $action = FrmAppHelper::get_param( 'frm_action', '', 'get', 'sanitize_title' ); |
| 297 | 297 | |
| 298 | - switch ( $action ) { |
|
| 299 | - case 'edit': |
|
| 300 | - case 'save': |
|
| 301 | - case 'manage': |
|
| 302 | - case 'manage_styles': |
|
| 303 | - case 'custom_css': |
|
| 304 | - case 'save_css': |
|
| 298 | + switch ( $action ) { |
|
| 299 | + case 'edit': |
|
| 300 | + case 'save': |
|
| 301 | + case 'manage': |
|
| 302 | + case 'manage_styles': |
|
| 303 | + case 'custom_css': |
|
| 304 | + case 'save_css': |
|
| 305 | 305 | return self::$action(); |
| 306 | - default: |
|
| 307 | - do_action( 'frm_style_action_route', $action ); |
|
| 308 | - if ( apply_filters( 'frm_style_stop_action_route', false, $action ) ) { |
|
| 309 | - return; |
|
| 310 | - } |
|
| 306 | + default: |
|
| 307 | + do_action( 'frm_style_action_route', $action ); |
|
| 308 | + if ( apply_filters( 'frm_style_stop_action_route', false, $action ) ) { |
|
| 309 | + return; |
|
| 310 | + } |
|
| 311 | 311 | |
| 312 | - if ( 'new_style' == $action || 'duplicate' == $action ) { |
|
| 313 | - return self::$action(); |
|
| 314 | - } |
|
| 312 | + if ( 'new_style' == $action || 'duplicate' == $action ) { |
|
| 313 | + return self::$action(); |
|
| 314 | + } |
|
| 315 | 315 | |
| 316 | - return self::edit(); |
|
| 317 | - } |
|
| 318 | - } |
|
| 316 | + return self::edit(); |
|
| 317 | + } |
|
| 318 | + } |
|
| 319 | 319 | |
| 320 | - public static function reset_styling() { |
|
| 320 | + public static function reset_styling() { |
|
| 321 | 321 | FrmAppHelper::permission_check('frm_change_settings'); |
| 322 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 322 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 323 | 323 | |
| 324 | - $frm_style = new FrmStyle(); |
|
| 325 | - $defaults = $frm_style->get_defaults(); |
|
| 324 | + $frm_style = new FrmStyle(); |
|
| 325 | + $defaults = $frm_style->get_defaults(); |
|
| 326 | 326 | |
| 327 | - echo json_encode( $defaults ); |
|
| 328 | - wp_die(); |
|
| 329 | - } |
|
| 327 | + echo json_encode( $defaults ); |
|
| 328 | + wp_die(); |
|
| 329 | + } |
|
| 330 | 330 | |
| 331 | - public static function change_styling() { |
|
| 332 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 331 | + public static function change_styling() { |
|
| 332 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 333 | 333 | |
| 334 | - $frm_style = new FrmStyle(); |
|
| 335 | - $defaults = $frm_style->get_defaults(); |
|
| 334 | + $frm_style = new FrmStyle(); |
|
| 335 | + $defaults = $frm_style->get_defaults(); |
|
| 336 | 336 | |
| 337 | - // remove the # from the colors |
|
| 338 | - foreach ( $_GET['frm_style_setting']['post_content'] as $k => $v ) { |
|
| 339 | - if ( ! is_array($v) && strpos($v, '#') === 0 ) { |
|
| 340 | - $_GET['frm_style_setting']['post_content'][ $k ] = str_replace( '#', '', $v ); |
|
| 341 | - } |
|
| 342 | - } |
|
| 337 | + // remove the # from the colors |
|
| 338 | + foreach ( $_GET['frm_style_setting']['post_content'] as $k => $v ) { |
|
| 339 | + if ( ! is_array($v) && strpos($v, '#') === 0 ) { |
|
| 340 | + $_GET['frm_style_setting']['post_content'][ $k ] = str_replace( '#', '', $v ); |
|
| 341 | + } |
|
| 342 | + } |
|
| 343 | 343 | |
| 344 | - echo '<style type="text/css">'; |
|
| 344 | + echo '<style type="text/css">'; |
|
| 345 | 345 | include( FrmAppHelper::plugin_path() . '/css/_single_theme.css.php' ); |
| 346 | - echo '</style>'; |
|
| 347 | - wp_die(); |
|
| 348 | - } |
|
| 349 | - |
|
| 350 | - private static function add_meta_boxes() { |
|
| 351 | - |
|
| 352 | - // setup meta boxes |
|
| 353 | - $meta_boxes = array( |
|
| 354 | - 'general' => __( 'General', 'formidable' ), |
|
| 355 | - 'form-title' => __( 'Form Title', 'formidable' ), |
|
| 356 | - 'form-description' => __( 'Form Description', 'formidable' ), |
|
| 357 | - 'field-labels' => __( 'Field Labels', 'formidable' ), |
|
| 358 | - 'field-description' => __( 'Field Description', 'formidable' ), |
|
| 359 | - 'field-colors' => __( 'Field Colors', 'formidable' ), |
|
| 360 | - 'field-sizes' => __( 'Field Settings', 'formidable' ), |
|
| 361 | - 'check-box-radio-fields' => __( 'Check Box & Radio Fields', 'formidable' ), |
|
| 362 | - 'section-fields' => __( 'Section Fields', 'formidable' ), |
|
| 363 | - 'date-fields' => __( 'Date Fields', 'formidable' ), |
|
| 364 | - 'buttons' => __( 'Buttons', 'formidable' ), |
|
| 365 | - 'form-messages' => __( 'Form Messages', 'formidable' ), |
|
| 366 | - ); |
|
| 367 | - |
|
| 368 | - foreach ( $meta_boxes as $nicename => $name ) { |
|
| 346 | + echo '</style>'; |
|
| 347 | + wp_die(); |
|
| 348 | + } |
|
| 349 | + |
|
| 350 | + private static function add_meta_boxes() { |
|
| 351 | + |
|
| 352 | + // setup meta boxes |
|
| 353 | + $meta_boxes = array( |
|
| 354 | + 'general' => __( 'General', 'formidable' ), |
|
| 355 | + 'form-title' => __( 'Form Title', 'formidable' ), |
|
| 356 | + 'form-description' => __( 'Form Description', 'formidable' ), |
|
| 357 | + 'field-labels' => __( 'Field Labels', 'formidable' ), |
|
| 358 | + 'field-description' => __( 'Field Description', 'formidable' ), |
|
| 359 | + 'field-colors' => __( 'Field Colors', 'formidable' ), |
|
| 360 | + 'field-sizes' => __( 'Field Settings', 'formidable' ), |
|
| 361 | + 'check-box-radio-fields' => __( 'Check Box & Radio Fields', 'formidable' ), |
|
| 362 | + 'section-fields' => __( 'Section Fields', 'formidable' ), |
|
| 363 | + 'date-fields' => __( 'Date Fields', 'formidable' ), |
|
| 364 | + 'buttons' => __( 'Buttons', 'formidable' ), |
|
| 365 | + 'form-messages' => __( 'Form Messages', 'formidable' ), |
|
| 366 | + ); |
|
| 367 | + |
|
| 368 | + foreach ( $meta_boxes as $nicename => $name ) { |
|
| 369 | 369 | add_meta_box( $nicename . '-style', $name, 'FrmStylesController::include_style_section', self::$screen, 'side', 'default', $nicename ); |
| 370 | - unset($nicename, $name); |
|
| 371 | - } |
|
| 372 | - } |
|
| 370 | + unset($nicename, $name); |
|
| 371 | + } |
|
| 372 | + } |
|
| 373 | 373 | |
| 374 | 374 | public static function include_style_section( $atts, $sec ) { |
| 375 | - extract($atts); |
|
| 375 | + extract($atts); |
|
| 376 | 376 | $current_tab = FrmAppHelper::simple_get( 'page-tab', 'sanitize_title', 'default' ); |
| 377 | 377 | include( FrmAppHelper::plugin_path() . '/classes/views/styles/_' . $sec['args'] . '.php' ); |
| 378 | - } |
|
| 378 | + } |
|
| 379 | 379 | |
| 380 | - public static function load_css() { |
|
| 381 | - header('Content-type: text/css'); |
|
| 380 | + public static function load_css() { |
|
| 381 | + header('Content-type: text/css'); |
|
| 382 | 382 | |
| 383 | - $frm_style = new FrmStyle(); |
|
| 384 | - $defaults = $frm_style->get_defaults(); |
|
| 383 | + $frm_style = new FrmStyle(); |
|
| 384 | + $defaults = $frm_style->get_defaults(); |
|
| 385 | 385 | |
| 386 | 386 | include( FrmAppHelper::plugin_path() . '/css/_single_theme.css.php' ); |
| 387 | - wp_die(); |
|
| 388 | - } |
|
| 387 | + wp_die(); |
|
| 388 | + } |
|
| 389 | 389 | |
| 390 | 390 | public static function load_saved_css() { |
| 391 | 391 | $css = get_transient( 'frmpro_css' ); |
@@ -394,142 +394,142 @@ discard block |
||
| 394 | 394 | wp_die(); |
| 395 | 395 | } |
| 396 | 396 | |
| 397 | - /** |
|
| 398 | - * Check if the Formidable styling should be loaded, |
|
| 399 | - * then enqueue it for the footer |
|
| 400 | - * @since 2.0 |
|
| 401 | - */ |
|
| 402 | - public static function enqueue_style() { |
|
| 403 | - global $frm_vars; |
|
| 404 | - |
|
| 405 | - if ( isset( $frm_vars['css_loaded'] ) && $frm_vars['css_loaded'] ) { |
|
| 406 | - // the CSS has already been loaded |
|
| 407 | - return; |
|
| 408 | - } |
|
| 409 | - |
|
| 410 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 411 | - if ( $frm_settings->load_style != 'none' ) { |
|
| 412 | - wp_enqueue_style( 'formidable' ); |
|
| 413 | - $frm_vars['css_loaded'] = true; |
|
| 414 | - } |
|
| 415 | - } |
|
| 416 | - |
|
| 417 | - // Get the stylesheets for the form settings page |
|
| 418 | - public static function get_style_opts() { |
|
| 419 | - $frm_style = new FrmStyle(); |
|
| 420 | - $styles = $frm_style->get_all(); |
|
| 421 | - |
|
| 422 | - return $styles; |
|
| 423 | - } |
|
| 424 | - |
|
| 425 | - public static function get_form_style( $form = 'default' ) { |
|
| 426 | - $style = FrmFormsHelper::get_form_style( $form ); |
|
| 427 | - |
|
| 428 | - if ( empty( $style ) || 1 == $style ) { |
|
| 429 | - $style = 'default'; |
|
| 430 | - } |
|
| 431 | - |
|
| 432 | - $frm_style = new FrmStyle( $style ); |
|
| 433 | - return $frm_style->get_one(); |
|
| 434 | - } |
|
| 435 | - |
|
| 436 | - /** |
|
| 437 | - * @param string $class |
|
| 438 | - * @param string $style |
|
| 439 | - */ |
|
| 397 | + /** |
|
| 398 | + * Check if the Formidable styling should be loaded, |
|
| 399 | + * then enqueue it for the footer |
|
| 400 | + * @since 2.0 |
|
| 401 | + */ |
|
| 402 | + public static function enqueue_style() { |
|
| 403 | + global $frm_vars; |
|
| 404 | + |
|
| 405 | + if ( isset( $frm_vars['css_loaded'] ) && $frm_vars['css_loaded'] ) { |
|
| 406 | + // the CSS has already been loaded |
|
| 407 | + return; |
|
| 408 | + } |
|
| 409 | + |
|
| 410 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 411 | + if ( $frm_settings->load_style != 'none' ) { |
|
| 412 | + wp_enqueue_style( 'formidable' ); |
|
| 413 | + $frm_vars['css_loaded'] = true; |
|
| 414 | + } |
|
| 415 | + } |
|
| 416 | + |
|
| 417 | + // Get the stylesheets for the form settings page |
|
| 418 | + public static function get_style_opts() { |
|
| 419 | + $frm_style = new FrmStyle(); |
|
| 420 | + $styles = $frm_style->get_all(); |
|
| 421 | + |
|
| 422 | + return $styles; |
|
| 423 | + } |
|
| 424 | + |
|
| 425 | + public static function get_form_style( $form = 'default' ) { |
|
| 426 | + $style = FrmFormsHelper::get_form_style( $form ); |
|
| 427 | + |
|
| 428 | + if ( empty( $style ) || 1 == $style ) { |
|
| 429 | + $style = 'default'; |
|
| 430 | + } |
|
| 431 | + |
|
| 432 | + $frm_style = new FrmStyle( $style ); |
|
| 433 | + return $frm_style->get_one(); |
|
| 434 | + } |
|
| 435 | + |
|
| 436 | + /** |
|
| 437 | + * @param string $class |
|
| 438 | + * @param string $style |
|
| 439 | + */ |
|
| 440 | 440 | public static function get_form_style_class( $class, $style ) { |
| 441 | - if ( 1 == $style ) { |
|
| 442 | - $style = 'default'; |
|
| 443 | - } |
|
| 441 | + if ( 1 == $style ) { |
|
| 442 | + $style = 'default'; |
|
| 443 | + } |
|
| 444 | 444 | |
| 445 | - $frm_style = new FrmStyle($style); |
|
| 446 | - $style = $frm_style->get_one(); |
|
| 445 | + $frm_style = new FrmStyle($style); |
|
| 446 | + $style = $frm_style->get_one(); |
|
| 447 | 447 | |
| 448 | - if ( $style ) { |
|
| 448 | + if ( $style ) { |
|
| 449 | 449 | $class .= ' frm_style_' . $style->post_name; |
| 450 | - } |
|
| 450 | + } |
|
| 451 | 451 | |
| 452 | - return $class; |
|
| 453 | - } |
|
| 452 | + return $class; |
|
| 453 | + } |
|
| 454 | 454 | |
| 455 | - /** |
|
| 456 | - * @param string $val |
|
| 457 | - */ |
|
| 455 | + /** |
|
| 456 | + * @param string $val |
|
| 457 | + */ |
|
| 458 | 458 | public static function get_style_val( $val, $form = 'default' ) { |
| 459 | - $style = self::get_form_style($form); |
|
| 460 | - if ( $style && isset( $style->post_content[ $val ] ) ) { |
|
| 461 | - return $style->post_content[ $val ]; |
|
| 462 | - } |
|
| 463 | - } |
|
| 459 | + $style = self::get_form_style($form); |
|
| 460 | + if ( $style && isset( $style->post_content[ $val ] ) ) { |
|
| 461 | + return $style->post_content[ $val ]; |
|
| 462 | + } |
|
| 463 | + } |
|
| 464 | 464 | |
| 465 | 465 | public static function show_entry_styles( $default_styles ) { |
| 466 | - $frm_style = new FrmStyle('default'); |
|
| 467 | - $style = $frm_style->get_one(); |
|
| 468 | - |
|
| 469 | - if ( ! $style ) { |
|
| 470 | - return $default_styles; |
|
| 471 | - } |
|
| 472 | - |
|
| 473 | - foreach ( $default_styles as $name => $val ) { |
|
| 474 | - $setting = $name; |
|
| 475 | - if ( 'border_width' == $name ) { |
|
| 476 | - $setting = 'field_border_width'; |
|
| 477 | - } else if ( 'alt_bg_color' == $name ) { |
|
| 478 | - $setting = 'bg_color_active'; |
|
| 479 | - } |
|
| 480 | - $default_styles[ $name ] = $style->post_content[ $setting ]; |
|
| 481 | - unset($name, $val); |
|
| 482 | - } |
|
| 483 | - |
|
| 484 | - return $default_styles; |
|
| 485 | - } |
|
| 466 | + $frm_style = new FrmStyle('default'); |
|
| 467 | + $style = $frm_style->get_one(); |
|
| 468 | + |
|
| 469 | + if ( ! $style ) { |
|
| 470 | + return $default_styles; |
|
| 471 | + } |
|
| 472 | + |
|
| 473 | + foreach ( $default_styles as $name => $val ) { |
|
| 474 | + $setting = $name; |
|
| 475 | + if ( 'border_width' == $name ) { |
|
| 476 | + $setting = 'field_border_width'; |
|
| 477 | + } else if ( 'alt_bg_color' == $name ) { |
|
| 478 | + $setting = 'bg_color_active'; |
|
| 479 | + } |
|
| 480 | + $default_styles[ $name ] = $style->post_content[ $setting ]; |
|
| 481 | + unset($name, $val); |
|
| 482 | + } |
|
| 483 | + |
|
| 484 | + return $default_styles; |
|
| 485 | + } |
|
| 486 | 486 | |
| 487 | 487 | public static function &important_style( $important, $field ) { |
| 488 | - $important = self::get_style_val('important_style', $field['form_id']); |
|
| 489 | - return $important; |
|
| 490 | - } |
|
| 488 | + $important = self::get_style_val('important_style', $field['form_id']); |
|
| 489 | + return $important; |
|
| 490 | + } |
|
| 491 | 491 | |
| 492 | - /** |
|
| 493 | - * Fallback for WP < 3.6 |
|
| 494 | - */ |
|
| 495 | - public static function do_accordion_sections( $screen, $context, $object ) { |
|
| 496 | - if ( function_exists( 'do_accordion_sections' ) ) { |
|
| 497 | - return do_accordion_sections( $screen, $context, $object ); |
|
| 498 | - } |
|
| 492 | + /** |
|
| 493 | + * Fallback for WP < 3.6 |
|
| 494 | + */ |
|
| 495 | + public static function do_accordion_sections( $screen, $context, $object ) { |
|
| 496 | + if ( function_exists( 'do_accordion_sections' ) ) { |
|
| 497 | + return do_accordion_sections( $screen, $context, $object ); |
|
| 498 | + } |
|
| 499 | 499 | |
| 500 | - global $wp_meta_boxes; |
|
| 500 | + global $wp_meta_boxes; |
|
| 501 | 501 | |
| 502 | - $screen = 'formidable_page_formidable-styles'; |
|
| 503 | - $screen = convert_to_screen( $screen ); |
|
| 502 | + $screen = 'formidable_page_formidable-styles'; |
|
| 503 | + $screen = convert_to_screen( $screen ); |
|
| 504 | 504 | |
| 505 | - $page = $screen->id; |
|
| 505 | + $page = $screen->id; |
|
| 506 | 506 | |
| 507 | - $hidden = get_hidden_meta_boxes( $screen ); |
|
| 508 | - ?> |
|
| 507 | + $hidden = get_hidden_meta_boxes( $screen ); |
|
| 508 | + ?> |
|
| 509 | 509 | <div id="side-sortables" class="accordion-container"> |
| 510 | 510 | <?php |
| 511 | - $i = 0; |
|
| 512 | - $first_open = false; |
|
| 513 | - do { |
|
| 511 | + $i = 0; |
|
| 512 | + $first_open = false; |
|
| 513 | + do { |
|
| 514 | 514 | if ( ! isset( $wp_meta_boxes ) || ! isset( $wp_meta_boxes[ $page ] ) || ! isset( $wp_meta_boxes[ $page ][ $context ] ) ) { |
| 515 | 515 | break; |
| 516 | 516 | } |
| 517 | 517 | |
| 518 | - foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) { |
|
| 519 | - if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) { |
|
| 520 | - foreach ( $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) { |
|
| 521 | - if ( false == $box || ! $box['title'] ) { |
|
| 522 | - continue; |
|
| 518 | + foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) { |
|
| 519 | + if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) { |
|
| 520 | + foreach ( $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) { |
|
| 521 | + if ( false == $box || ! $box['title'] ) { |
|
| 522 | + continue; |
|
| 523 | 523 | } |
| 524 | 524 | |
| 525 | - $i++; |
|
| 526 | - $hidden_class = in_array( $box['id'], $hidden ) ? 'hide-if-js' : ''; |
|
| 525 | + $i++; |
|
| 526 | + $hidden_class = in_array( $box['id'], $hidden ) ? 'hide-if-js' : ''; |
|
| 527 | 527 | |
| 528 | - if ( ! $first_open && empty( $hidden_class ) ) { |
|
| 529 | - $first_open = true; |
|
| 530 | - } |
|
| 528 | + if ( ! $first_open && empty( $hidden_class ) ) { |
|
| 529 | + $first_open = true; |
|
| 530 | + } |
|
| 531 | 531 | |
| 532 | - ?> |
|
| 532 | + ?> |
|
| 533 | 533 | <div class="postbox <?php echo esc_attr( $box['id'] ); ?>"> |
| 534 | 534 | <div class="handlediv" title="<?php esc_attr_e( 'Click to toggle', 'formidable' ) ?>"><br/></div> |
| 535 | 535 | <h3 class='hndle'><span><?php echo esc_html( $box['title'] ); ?></span></h3> |
@@ -540,13 +540,13 @@ discard block |
||
| 540 | 540 | </div><!-- .accordion-section-content --> |
| 541 | 541 | </div><!-- .postbox --> |
| 542 | 542 | <?php |
| 543 | - } |
|
| 544 | - } |
|
| 545 | - } |
|
| 546 | - } while ( 0 ); |
|
| 547 | - ?> |
|
| 543 | + } |
|
| 544 | + } |
|
| 545 | + } |
|
| 546 | + } while ( 0 ); |
|
| 547 | + ?> |
|
| 548 | 548 | </div><!-- .accordion-container --> |
| 549 | 549 | <?php |
| 550 | - return $i; |
|
| 551 | - } |
|
| 550 | + return $i; |
|
| 551 | + } |
|
| 552 | 552 | } |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | */ |
| 139 | 139 | |
| 140 | 140 | private static function _is_ipv6( $ip ) { |
| 141 | - if ( function_exists('filter_var') ) { |
|
| 141 | + if ( function_exists( 'filter_var' ) ) { |
|
| 142 | 142 | return filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6 ) !== false; |
| 143 | 143 | } else { |
| 144 | 144 | return ! self::_is_ipv4( $ip ); |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | * @return integer TRUE if IPv4 |
| 153 | 153 | */ |
| 154 | 154 | private static function _is_ipv4( $ip ) { |
| 155 | - if ( function_exists('filter_var') ) { |
|
| 155 | + if ( function_exists( 'filter_var' ) ) { |
|
| 156 | 156 | return filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 ) !== false; |
| 157 | 157 | } else { |
| 158 | 158 | return preg_match( '/^\d{1,3}(\.\d{1,3}){3,3}$/', $ip ); |
@@ -220,15 +220,15 @@ discard block |
||
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | /* Ignore non utf-8 chars */ |
| 223 | - $comment[ $field ] = ( function_exists('iconv') ? iconv( 'utf-8', 'utf-8//TRANSLIT', $comment[ $field ] ) : $comment[ $field ] ); |
|
| 223 | + $comment[$field] = ( function_exists( 'iconv' ) ? iconv( 'utf-8', 'utf-8//TRANSLIT', $comment[$field] ) : $comment[$field] ); |
|
| 224 | 224 | |
| 225 | - if ( empty( $comment[ $field ] ) ) { |
|
| 225 | + if ( empty( $comment[$field] ) ) { |
|
| 226 | 226 | continue; |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | /* Perform regex */ |
| 230 | - if ( preg_match( '/' . $regexp . '/isu', $comment[ $field ] ) ) { |
|
| 231 | - $hits[ $field ] = true; |
|
| 230 | + if ( preg_match( '/' . $regexp . '/isu', $comment[$field] ) ) { |
|
| 231 | + $hits[$field] = true; |
|
| 232 | 232 | } |
| 233 | 233 | } |
| 234 | 234 | |