@@ -80,6 +80,9 @@ |
||
| 80 | 80 | wp_die(); |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | + /** |
|
| 84 | + * @param SimpleXMLElement $xml |
|
| 85 | + */ |
|
| 83 | 86 | private static function set_new_form_name( &$xml ) { |
| 84 | 87 | if ( isset( $xml->form ) ) { |
| 85 | 88 | $form_name = FrmAppHelper::get_param( 'name', '', 'post', 'sanitize_text_field' ); |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | $form->description = $description; |
| 96 | 96 | $name_set = true; |
| 97 | 97 | } |
| 98 | - $xml->form[ $k ] = $form; |
|
| 98 | + $xml->form[$k] = $form; |
|
| 99 | 99 | } |
| 100 | 100 | } |
| 101 | 101 | } |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | $export_format = apply_filters( 'frm_export_formats', $export_format ); |
| 180 | 180 | |
| 181 | 181 | $file_type = strtolower( pathinfo( $_FILES['frm_import_file']['name'], PATHINFO_EXTENSION ) ); |
| 182 | - if ( 'xml' !== $file_type && isset( $export_format[ $file_type ] ) ) { |
|
| 182 | + if ( 'xml' !== $file_type && isset( $export_format[$file_type] ) ) { |
|
| 183 | 183 | // allow other file types to be imported |
| 184 | 184 | do_action( 'frm_before_import_' . $file_type ); |
| 185 | 185 | return; |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | foreach ( $type as $tb_type ) { |
| 261 | 261 | $where = array(); |
| 262 | 262 | $join = ''; |
| 263 | - $table = $tables[ $tb_type ]; |
|
| 263 | + $table = $tables[$tb_type]; |
|
| 264 | 264 | |
| 265 | 265 | $select = $table . '.id'; |
| 266 | 266 | $query_vars = array(); |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | $table . '.parent_form_id' => $args['ids'], |
| 276 | 276 | ); |
| 277 | 277 | } else { |
| 278 | - $where[ $table . '.status !' ] = 'draft'; |
|
| 278 | + $where[$table . '.status !'] = 'draft'; |
|
| 279 | 279 | } |
| 280 | 280 | break; |
| 281 | 281 | case 'actions': |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | case 'items': |
| 289 | 289 | //$join = "INNER JOIN {$wpdb->prefix}frm_item_metas im ON ($table.id = im.item_id)"; |
| 290 | 290 | if ( $args['ids'] ) { |
| 291 | - $where[ $table . '.form_id' ] = $args['ids']; |
|
| 291 | + $where[$table . '.form_id'] = $args['ids']; |
|
| 292 | 292 | } |
| 293 | 293 | break; |
| 294 | 294 | case 'styles': |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | } |
| 330 | 330 | } |
| 331 | 331 | |
| 332 | - $records[ $tb_type ] = FrmDb::get_col( $table . $join, $where, $select ); |
|
| 332 | + $records[$tb_type] = FrmDb::get_col( $table . $join, $where, $select ); |
|
| 333 | 333 | unset( $tb_type ); |
| 334 | 334 | } |
| 335 | 335 | |
@@ -470,7 +470,7 @@ discard block |
||
| 470 | 470 | $no_export_fields = FrmField::no_save_fields(); |
| 471 | 471 | foreach ( $csv_fields as $k => $f ) { |
| 472 | 472 | if ( in_array( $f->type, $no_export_fields ) ) { |
| 473 | - unset( $csv_fields[ $k ] ); |
|
| 473 | + unset( $csv_fields[$k] ); |
|
| 474 | 474 | } |
| 475 | 475 | } |
| 476 | 476 | |
@@ -67,12 +67,16 @@ discard block |
||
| 67 | 67 | return $url; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | + /** |
|
| 71 | + * @return string |
|
| 72 | + */ |
|
| 70 | 73 | public static function get_affiliate() { |
| 71 | 74 | return absint( apply_filters( 'frm_affiliate_id', 0 ) ); |
| 72 | 75 | } |
| 73 | 76 | |
| 74 | 77 | /** |
| 75 | 78 | * @since 3.04.02 |
| 79 | + * @param string $medium |
|
| 76 | 80 | */ |
| 77 | 81 | public static function admin_upgrade_link( $medium, $page = '' ) { |
| 78 | 82 | if ( empty( $page ) ) { |
@@ -104,6 +108,9 @@ discard block |
||
| 104 | 108 | return $frm_settings; |
| 105 | 109 | } |
| 106 | 110 | |
| 111 | + /** |
|
| 112 | + * @return string |
|
| 113 | + */ |
|
| 107 | 114 | public static function get_menu_name() { |
| 108 | 115 | $frm_settings = self::get_settings(); |
| 109 | 116 | return $frm_settings->menu; |
@@ -622,6 +629,8 @@ discard block |
||
| 622 | 629 | |
| 623 | 630 | /** |
| 624 | 631 | * @since 3.06 |
| 632 | + * @param string $text |
|
| 633 | + * @param string $input_id |
|
| 625 | 634 | */ |
| 626 | 635 | public static function show_search_box( $text, $input_id, $placeholder = '' ) { |
| 627 | 636 | $tosearch = ''; |
@@ -895,6 +904,9 @@ discard block |
||
| 895 | 904 | return ( is_array( $values ) && in_array( $current, $values ) ) || ( ! is_array( $values ) && $values == $current ); |
| 896 | 905 | } |
| 897 | 906 | |
| 907 | + /** |
|
| 908 | + * @param string $function |
|
| 909 | + */ |
|
| 898 | 910 | public static function recursive_function_map( $value, $function ) { |
| 899 | 911 | if ( is_array( $value ) ) { |
| 900 | 912 | $original_function = $function; |
@@ -942,6 +954,9 @@ discard block |
||
| 942 | 954 | return $return; |
| 943 | 955 | } |
| 944 | 956 | |
| 957 | + /** |
|
| 958 | + * @return string |
|
| 959 | + */ |
|
| 945 | 960 | public static function esc_textarea( $text, $is_rich_text = false ) { |
| 946 | 961 | $safe_text = str_replace( '"', '"', $text ); |
| 947 | 962 | if ( ! $is_rich_text ) { |
@@ -1136,6 +1151,9 @@ discard block |
||
| 1136 | 1151 | return $values; |
| 1137 | 1152 | } |
| 1138 | 1153 | |
| 1154 | + /** |
|
| 1155 | + * @param string $fields |
|
| 1156 | + */ |
|
| 1139 | 1157 | private static function prepare_field_arrays( $fields, $record, array &$values, $args ) { |
| 1140 | 1158 | if ( ! empty( $fields ) ) { |
| 1141 | 1159 | foreach ( (array) $fields as $field ) { |
@@ -1338,6 +1356,9 @@ discard block |
||
| 1338 | 1356 | return $sub . ( ( $len < $original_len ) ? $continue : '' ); |
| 1339 | 1357 | } |
| 1340 | 1358 | |
| 1359 | + /** |
|
| 1360 | + * @param string[] $function_names |
|
| 1361 | + */ |
|
| 1341 | 1362 | public static function mb_function( $function_names, $args ) { |
| 1342 | 1363 | $mb_function_name = $function_names[0]; |
| 1343 | 1364 | $function_name = $function_names[1]; |
@@ -1371,6 +1392,9 @@ discard block |
||
| 1371 | 1392 | return $formatted; |
| 1372 | 1393 | } |
| 1373 | 1394 | |
| 1395 | + /** |
|
| 1396 | + * @param string $time_format |
|
| 1397 | + */ |
|
| 1374 | 1398 | private static function add_time_to_date( $time_format, $date ) { |
| 1375 | 1399 | if ( empty( $time_format ) ) { |
| 1376 | 1400 | $time_format = get_option( 'time_format' ); |
@@ -13,15 +13,15 @@ discard block |
||
| 13 | 13 | */ |
| 14 | 14 | public static $plug_version = '3.05'; |
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * @since 1.07.02 |
|
| 18 | - * |
|
| 19 | - * @param none |
|
| 20 | - * @return string The version of this plugin |
|
| 21 | - */ |
|
| 22 | - public static function plugin_version() { |
|
| 23 | - return self::$plug_version; |
|
| 24 | - } |
|
| 16 | + /** |
|
| 17 | + * @since 1.07.02 |
|
| 18 | + * |
|
| 19 | + * @param none |
|
| 20 | + * @return string The version of this plugin |
|
| 21 | + */ |
|
| 22 | + public static function plugin_version() { |
|
| 23 | + return self::$plug_version; |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | 26 | public static function plugin_folder() { |
| 27 | 27 | return basename( self::plugin_path() ); |
@@ -31,29 +31,29 @@ discard block |
||
| 31 | 31 | return dirname( dirname( dirname( __FILE__ ) ) ); |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - public static function plugin_url() { |
|
| 35 | - //prevously FRM_URL constant |
|
| 34 | + public static function plugin_url() { |
|
| 35 | + //prevously FRM_URL constant |
|
| 36 | 36 | return plugins_url( '', self::plugin_path() . '/formidable.php' ); |
| 37 | - } |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | 39 | public static function relative_plugin_url() { |
| 40 | 40 | return str_replace( array( 'https:', 'http:' ), '', self::plugin_url() ); |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * @return string Site URL |
|
| 45 | - */ |
|
| 46 | - public static function site_url() { |
|
| 47 | - return site_url(); |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - /** |
|
| 51 | - * Get the name of this site |
|
| 52 | - * Used for [sitename] shortcode |
|
| 53 | - * |
|
| 54 | - * @since 2.0 |
|
| 55 | - * @return string |
|
| 56 | - */ |
|
| 43 | + /** |
|
| 44 | + * @return string Site URL |
|
| 45 | + */ |
|
| 46 | + public static function site_url() { |
|
| 47 | + return site_url(); |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + /** |
|
| 51 | + * Get the name of this site |
|
| 52 | + * Used for [sitename] shortcode |
|
| 53 | + * |
|
| 54 | + * @since 2.0 |
|
| 55 | + * @return string |
|
| 56 | + */ |
|
| 57 | 57 | public static function site_name() { |
| 58 | 58 | return get_option( 'blogname' ); |
| 59 | 59 | } |
@@ -88,14 +88,14 @@ discard block |
||
| 88 | 88 | return add_query_arg( $query_args, $page ); |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - /** |
|
| 92 | - * Get the Formidable settings |
|
| 93 | - * |
|
| 94 | - * @since 2.0 |
|
| 95 | - * |
|
| 96 | - * @param None |
|
| 97 | - * @return FrmSettings $frm_setings |
|
| 98 | - */ |
|
| 91 | + /** |
|
| 92 | + * Get the Formidable settings |
|
| 93 | + * |
|
| 94 | + * @since 2.0 |
|
| 95 | + * |
|
| 96 | + * @param None |
|
| 97 | + * @return FrmSettings $frm_setings |
|
| 98 | + */ |
|
| 99 | 99 | public static function get_settings() { |
| 100 | 100 | global $frm_settings; |
| 101 | 101 | if ( empty( $frm_settings ) ) { |
@@ -156,50 +156,50 @@ discard block |
||
| 156 | 156 | return $is_formidable; |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - /** |
|
| 160 | - * Check for certain page in Formidable settings |
|
| 161 | - * |
|
| 162 | - * @since 2.0 |
|
| 163 | - * |
|
| 164 | - * @param string $page The name of the page to check |
|
| 165 | - * @return boolean |
|
| 166 | - */ |
|
| 159 | + /** |
|
| 160 | + * Check for certain page in Formidable settings |
|
| 161 | + * |
|
| 162 | + * @since 2.0 |
|
| 163 | + * |
|
| 164 | + * @param string $page The name of the page to check |
|
| 165 | + * @return boolean |
|
| 166 | + */ |
|
| 167 | 167 | public static function is_admin_page( $page = 'formidable' ) { |
| 168 | - global $pagenow; |
|
| 168 | + global $pagenow; |
|
| 169 | 169 | $get_page = self::simple_get( 'page', 'sanitize_title' ); |
| 170 | - if ( $pagenow ) { |
|
| 170 | + if ( $pagenow ) { |
|
| 171 | 171 | // allow this to be true during ajax load i.e. ajax form builder loading |
| 172 | 172 | return ( $pagenow == 'admin.php' || $pagenow == 'admin-ajax.php' ) && $get_page == $page; |
| 173 | - } |
|
| 173 | + } |
|
| 174 | 174 | |
| 175 | 175 | return is_admin() && $get_page == $page; |
| 176 | - } |
|
| 177 | - |
|
| 178 | - /** |
|
| 179 | - * Check for the form preview page |
|
| 180 | - * |
|
| 181 | - * @since 2.0 |
|
| 182 | - * |
|
| 183 | - * @param None |
|
| 184 | - * @return boolean |
|
| 185 | - */ |
|
| 186 | - public static function is_preview_page() { |
|
| 187 | - global $pagenow; |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + /** |
|
| 179 | + * Check for the form preview page |
|
| 180 | + * |
|
| 181 | + * @since 2.0 |
|
| 182 | + * |
|
| 183 | + * @param None |
|
| 184 | + * @return boolean |
|
| 185 | + */ |
|
| 186 | + public static function is_preview_page() { |
|
| 187 | + global $pagenow; |
|
| 188 | 188 | $action = self::simple_get( 'action', 'sanitize_title' ); |
| 189 | 189 | return $pagenow && $pagenow == 'admin-ajax.php' && $action == 'frm_forms_preview'; |
| 190 | - } |
|
| 191 | - |
|
| 192 | - /** |
|
| 193 | - * Check for ajax except the form preview page |
|
| 194 | - * |
|
| 195 | - * @since 2.0 |
|
| 196 | - * |
|
| 197 | - * @param None |
|
| 198 | - * @return boolean |
|
| 199 | - */ |
|
| 200 | - public static function doing_ajax() { |
|
| 201 | - return self::wp_doing_ajax() && ! self::is_preview_page(); |
|
| 202 | - } |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + /** |
|
| 193 | + * Check for ajax except the form preview page |
|
| 194 | + * |
|
| 195 | + * @since 2.0 |
|
| 196 | + * |
|
| 197 | + * @param None |
|
| 198 | + * @return boolean |
|
| 199 | + */ |
|
| 200 | + public static function doing_ajax() { |
|
| 201 | + return self::wp_doing_ajax() && ! self::is_preview_page(); |
|
| 202 | + } |
|
| 203 | 203 | |
| 204 | 204 | public static function js_suffix() { |
| 205 | 205 | return defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
@@ -227,81 +227,81 @@ discard block |
||
| 227 | 227 | return isset( $frm_vars['prevent_caching'] ) && $frm_vars['prevent_caching']; |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | - /** |
|
| 231 | - * Check if on an admin page |
|
| 232 | - * |
|
| 233 | - * @since 2.0 |
|
| 234 | - * |
|
| 235 | - * @param None |
|
| 236 | - * @return boolean |
|
| 237 | - */ |
|
| 238 | - public static function is_admin() { |
|
| 239 | - return is_admin() && ! self::wp_doing_ajax(); |
|
| 240 | - } |
|
| 241 | - |
|
| 242 | - /** |
|
| 243 | - * Check if value contains blank value or empty array |
|
| 244 | - * |
|
| 245 | - * @since 2.0 |
|
| 246 | - * @param mixed $value - value to check |
|
| 230 | + /** |
|
| 231 | + * Check if on an admin page |
|
| 232 | + * |
|
| 233 | + * @since 2.0 |
|
| 234 | + * |
|
| 235 | + * @param None |
|
| 236 | + * @return boolean |
|
| 237 | + */ |
|
| 238 | + public static function is_admin() { |
|
| 239 | + return is_admin() && ! self::wp_doing_ajax(); |
|
| 240 | + } |
|
| 241 | + |
|
| 242 | + /** |
|
| 243 | + * Check if value contains blank value or empty array |
|
| 244 | + * |
|
| 245 | + * @since 2.0 |
|
| 246 | + * @param mixed $value - value to check |
|
| 247 | 247 | * @param string |
| 248 | - * @return boolean |
|
| 249 | - */ |
|
| 250 | - public static function is_empty_value( $value, $empty = '' ) { |
|
| 251 | - return ( is_array( $value ) && empty( $value ) ) || $value === $empty; |
|
| 252 | - } |
|
| 253 | - |
|
| 254 | - public static function is_not_empty_value( $value, $empty = '' ) { |
|
| 255 | - return ! self::is_empty_value( $value, $empty ); |
|
| 256 | - } |
|
| 257 | - |
|
| 258 | - /** |
|
| 259 | - * Get any value from the $_SERVER |
|
| 260 | - * |
|
| 261 | - * @since 2.0 |
|
| 262 | - * @param string $value |
|
| 263 | - * @return string |
|
| 264 | - */ |
|
| 248 | + * @return boolean |
|
| 249 | + */ |
|
| 250 | + public static function is_empty_value( $value, $empty = '' ) { |
|
| 251 | + return ( is_array( $value ) && empty( $value ) ) || $value === $empty; |
|
| 252 | + } |
|
| 253 | + |
|
| 254 | + public static function is_not_empty_value( $value, $empty = '' ) { |
|
| 255 | + return ! self::is_empty_value( $value, $empty ); |
|
| 256 | + } |
|
| 257 | + |
|
| 258 | + /** |
|
| 259 | + * Get any value from the $_SERVER |
|
| 260 | + * |
|
| 261 | + * @since 2.0 |
|
| 262 | + * @param string $value |
|
| 263 | + * @return string |
|
| 264 | + */ |
|
| 265 | 265 | public static function get_server_value( $value ) { |
| 266 | - return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; |
|
| 267 | - } |
|
| 268 | - |
|
| 269 | - /** |
|
| 270 | - * Check for the IP address in several places |
|
| 271 | - * Used by [ip] shortcode |
|
| 272 | - * |
|
| 273 | - * @return string The IP address of the current user |
|
| 274 | - */ |
|
| 275 | - public static function get_ip_address() { |
|
| 266 | + return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; |
|
| 267 | + } |
|
| 268 | + |
|
| 269 | + /** |
|
| 270 | + * Check for the IP address in several places |
|
| 271 | + * Used by [ip] shortcode |
|
| 272 | + * |
|
| 273 | + * @return string The IP address of the current user |
|
| 274 | + */ |
|
| 275 | + public static function get_ip_address() { |
|
| 276 | 276 | $ip = ''; |
| 277 | 277 | foreach ( array( 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR' ) as $key ) { |
| 278 | - if ( ! isset( $_SERVER[ $key ] ) ) { |
|
| 279 | - continue; |
|
| 280 | - } |
|
| 278 | + if ( ! isset( $_SERVER[ $key ] ) ) { |
|
| 279 | + continue; |
|
| 280 | + } |
|
| 281 | 281 | |
| 282 | - foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { |
|
| 282 | + foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { |
|
| 283 | 283 | $ip = trim( $ip ); // just to be safe |
| 284 | 284 | |
| 285 | 285 | if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) !== false ) { |
| 286 | - return sanitize_text_field( $ip ); |
|
| 287 | - } |
|
| 288 | - } |
|
| 289 | - } |
|
| 286 | + return sanitize_text_field( $ip ); |
|
| 287 | + } |
|
| 288 | + } |
|
| 289 | + } |
|
| 290 | 290 | |
| 291 | 291 | return sanitize_text_field( $ip ); |
| 292 | - } |
|
| 292 | + } |
|
| 293 | 293 | |
| 294 | - public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
|
| 294 | + public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
|
| 295 | 295 | if ( strpos( $param, '[' ) ) { |
| 296 | 296 | $params = explode( '[', $param ); |
| 297 | - $param = $params[0]; |
|
| 298 | - } |
|
| 297 | + $param = $params[0]; |
|
| 298 | + } |
|
| 299 | 299 | |
| 300 | 300 | if ( $src == 'get' ) { |
| 301 | - $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); |
|
| 302 | - if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { |
|
| 303 | - $value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) ); |
|
| 304 | - } |
|
| 301 | + $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); |
|
| 302 | + if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { |
|
| 303 | + $value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) ); |
|
| 304 | + } |
|
| 305 | 305 | self::sanitize_value( $sanitize, $value ); |
| 306 | 306 | } else { |
| 307 | 307 | $value = self::get_simple_request( |
@@ -325,8 +325,8 @@ discard block |
||
| 325 | 325 | } |
| 326 | 326 | } |
| 327 | 327 | |
| 328 | - return $value; |
|
| 329 | - } |
|
| 328 | + return $value; |
|
| 329 | + } |
|
| 330 | 330 | |
| 331 | 331 | public static function get_post_param( $param, $default = '', $sanitize = '' ) { |
| 332 | 332 | return self::get_simple_request( |
@@ -394,12 +394,12 @@ discard block |
||
| 394 | 394 | } |
| 395 | 395 | |
| 396 | 396 | /** |
| 397 | - * Preserve backslashes in a value, but make sure value doesn't get compounding slashes |
|
| 398 | - * |
|
| 399 | - * @since 2.0.8 |
|
| 400 | - * @param string $value |
|
| 401 | - * @return string $value |
|
| 402 | - */ |
|
| 397 | + * Preserve backslashes in a value, but make sure value doesn't get compounding slashes |
|
| 398 | + * |
|
| 399 | + * @since 2.0.8 |
|
| 400 | + * @param string $value |
|
| 401 | + * @return string $value |
|
| 402 | + */ |
|
| 403 | 403 | public static function preserve_backslashes( $value ) { |
| 404 | 404 | // If backslashes have already been added, don't add them again |
| 405 | 405 | if ( strpos( $value, '\\\\' ) === false ) { |
@@ -421,14 +421,14 @@ discard block |
||
| 421 | 421 | } |
| 422 | 422 | } |
| 423 | 423 | |
| 424 | - public static function sanitize_request( $sanitize_method, &$values ) { |
|
| 425 | - $temp_values = $values; |
|
| 426 | - foreach ( $temp_values as $k => $val ) { |
|
| 427 | - if ( isset( $sanitize_method[ $k ] ) ) { |
|
| 424 | + public static function sanitize_request( $sanitize_method, &$values ) { |
|
| 425 | + $temp_values = $values; |
|
| 426 | + foreach ( $temp_values as $k => $val ) { |
|
| 427 | + if ( isset( $sanitize_method[ $k ] ) ) { |
|
| 428 | 428 | $values[ $k ] = call_user_func( $sanitize_method[ $k ], $val ); |
| 429 | - } |
|
| 430 | - } |
|
| 431 | - } |
|
| 429 | + } |
|
| 430 | + } |
|
| 431 | + } |
|
| 432 | 432 | |
| 433 | 433 | /** |
| 434 | 434 | * Sanitize the value, and allow some HTML |
@@ -565,40 +565,40 @@ discard block |
||
| 565 | 565 | ); |
| 566 | 566 | } |
| 567 | 567 | |
| 568 | - /** |
|
| 569 | - * Used when switching the action for a bulk action |
|
| 568 | + /** |
|
| 569 | + * Used when switching the action for a bulk action |
|
| 570 | 570 | * |
| 571 | - * @since 2.0 |
|
| 572 | - */ |
|
| 571 | + * @since 2.0 |
|
| 572 | + */ |
|
| 573 | 573 | public static function remove_get_action() { |
| 574 | 574 | if ( ! isset( $_GET ) ) { |
| 575 | 575 | return; |
| 576 | 576 | } |
| 577 | 577 | |
| 578 | - $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' ); |
|
| 579 | - if ( ! empty( $new_action ) ) { |
|
| 578 | + $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' ); |
|
| 579 | + if ( ! empty( $new_action ) ) { |
|
| 580 | 580 | $_SERVER['REQUEST_URI'] = str_replace( '&action=' . $new_action, '', self::get_server_value( 'REQUEST_URI' ) ); |
| 581 | - } |
|
| 582 | - } |
|
| 581 | + } |
|
| 582 | + } |
|
| 583 | 583 | |
| 584 | - /** |
|
| 585 | - * Check the WP query for a parameter |
|
| 586 | - * |
|
| 587 | - * @since 2.0 |
|
| 588 | - * @return string|array |
|
| 589 | - */ |
|
| 590 | - public static function get_query_var( $value, $param ) { |
|
| 591 | - if ( $value != '' ) { |
|
| 592 | - return $value; |
|
| 593 | - } |
|
| 584 | + /** |
|
| 585 | + * Check the WP query for a parameter |
|
| 586 | + * |
|
| 587 | + * @since 2.0 |
|
| 588 | + * @return string|array |
|
| 589 | + */ |
|
| 590 | + public static function get_query_var( $value, $param ) { |
|
| 591 | + if ( $value != '' ) { |
|
| 592 | + return $value; |
|
| 593 | + } |
|
| 594 | 594 | |
| 595 | - global $wp_query; |
|
| 596 | - if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
| 597 | - $value = $wp_query->query_vars[ $param ]; |
|
| 598 | - } |
|
| 595 | + global $wp_query; |
|
| 596 | + if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
| 597 | + $value = $wp_query->query_vars[ $param ]; |
|
| 598 | + } |
|
| 599 | 599 | |
| 600 | - return $value; |
|
| 601 | - } |
|
| 600 | + return $value; |
|
| 601 | + } |
|
| 602 | 602 | |
| 603 | 603 | /** |
| 604 | 604 | * @since 3.0 |
@@ -650,16 +650,16 @@ discard block |
||
| 650 | 650 | <?php |
| 651 | 651 | } |
| 652 | 652 | |
| 653 | - /** |
|
| 654 | - * @param string $type |
|
| 655 | - */ |
|
| 656 | - public static function trigger_hook_load( $type, $object = null ) { |
|
| 657 | - // only load the form hooks once |
|
| 653 | + /** |
|
| 654 | + * @param string $type |
|
| 655 | + */ |
|
| 656 | + public static function trigger_hook_load( $type, $object = null ) { |
|
| 657 | + // only load the form hooks once |
|
| 658 | 658 | $hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object ); |
| 659 | - if ( ! $hooks_loaded ) { |
|
| 659 | + if ( ! $hooks_loaded ) { |
|
| 660 | 660 | do_action( 'frm_load_' . $type . '_hooks' ); |
| 661 | - } |
|
| 662 | - } |
|
| 661 | + } |
|
| 662 | + } |
|
| 663 | 663 | |
| 664 | 664 | /** |
| 665 | 665 | * Save all front-end js scripts into a single file |
@@ -684,18 +684,18 @@ discard block |
||
| 684 | 684 | $new_file->combine_files( $files ); |
| 685 | 685 | } |
| 686 | 686 | |
| 687 | - /** |
|
| 688 | - * Check a value from a shortcode to see if true or false. |
|
| 689 | - * True when value is 1, true, 'true', 'yes' |
|
| 690 | - * |
|
| 691 | - * @since 1.07.10 |
|
| 692 | - * |
|
| 693 | - * @param string $value The value to compare |
|
| 694 | - * @return boolean True or False |
|
| 695 | - */ |
|
| 687 | + /** |
|
| 688 | + * Check a value from a shortcode to see if true or false. |
|
| 689 | + * True when value is 1, true, 'true', 'yes' |
|
| 690 | + * |
|
| 691 | + * @since 1.07.10 |
|
| 692 | + * |
|
| 693 | + * @param string $value The value to compare |
|
| 694 | + * @return boolean True or False |
|
| 695 | + */ |
|
| 696 | 696 | public static function is_true( $value ) { |
| 697 | - return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value ); |
|
| 698 | - } |
|
| 697 | + return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value ); |
|
| 698 | + } |
|
| 699 | 699 | |
| 700 | 700 | public static function get_pages() { |
| 701 | 701 | $query = array( |
@@ -708,10 +708,10 @@ discard block |
||
| 708 | 708 | return get_posts( $query ); |
| 709 | 709 | } |
| 710 | 710 | |
| 711 | - public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
|
| 712 | - $pages = self::get_pages(); |
|
| 711 | + public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
|
| 712 | + $pages = self::get_pages(); |
|
| 713 | 713 | $selected = self::get_post_param( $field_name, $page_id, 'absint' ); |
| 714 | - ?> |
|
| 714 | + ?> |
|
| 715 | 715 | <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" class="frm-pages-dropdown"> |
| 716 | 716 | <option value=""> </option> |
| 717 | 717 | <?php foreach ( $pages as $page ) { ?> |
@@ -721,16 +721,16 @@ discard block |
||
| 721 | 721 | <?php } ?> |
| 722 | 722 | </select> |
| 723 | 723 | <?php |
| 724 | - } |
|
| 724 | + } |
|
| 725 | 725 | |
| 726 | 726 | public static function post_edit_link( $post_id ) { |
| 727 | 727 | $post = get_post( $post_id ); |
| 728 | - if ( $post ) { |
|
| 728 | + if ( $post ) { |
|
| 729 | 729 | $post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' ); |
| 730 | 730 | return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>'; |
| 731 | - } |
|
| 732 | - return ''; |
|
| 733 | - } |
|
| 731 | + } |
|
| 732 | + return ''; |
|
| 733 | + } |
|
| 734 | 734 | |
| 735 | 735 | public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) { |
| 736 | 736 | ?> |
@@ -741,73 +741,73 @@ discard block |
||
| 741 | 741 | } |
| 742 | 742 | |
| 743 | 743 | public static function roles_options( $capability ) { |
| 744 | - global $frm_vars; |
|
| 744 | + global $frm_vars; |
|
| 745 | 745 | if ( isset( $frm_vars['editable_roles'] ) ) { |
| 746 | - $editable_roles = $frm_vars['editable_roles']; |
|
| 747 | - } else { |
|
| 748 | - $editable_roles = get_editable_roles(); |
|
| 749 | - $frm_vars['editable_roles'] = $editable_roles; |
|
| 750 | - } |
|
| 746 | + $editable_roles = $frm_vars['editable_roles']; |
|
| 747 | + } else { |
|
| 748 | + $editable_roles = get_editable_roles(); |
|
| 749 | + $frm_vars['editable_roles'] = $editable_roles; |
|
| 750 | + } |
|
| 751 | 751 | |
| 752 | - foreach ( $editable_roles as $role => $details ) { |
|
| 752 | + foreach ( $editable_roles as $role => $details ) { |
|
| 753 | 753 | $name = translate_user_role( $details['name'] ); |
| 754 | 754 | ?> |
| 755 | 755 | <option value="<?php echo esc_attr( $role ); ?>" <?php echo in_array( $role, (array) $capability ) ? ' selected="selected"' : ''; ?>><?php echo esc_attr( $name ); ?> </option> |
| 756 | 756 | <?php |
| 757 | 757 | unset( $role, $details ); |
| 758 | - } |
|
| 759 | - } |
|
| 758 | + } |
|
| 759 | + } |
|
| 760 | 760 | |
| 761 | 761 | public static function frm_capabilities( $type = 'auto' ) { |
| 762 | - $cap = array( |
|
| 763 | - 'frm_view_forms' => __( 'View Forms and Templates', 'formidable' ), |
|
| 764 | - 'frm_edit_forms' => __( 'Add/Edit Forms and Templates', 'formidable' ), |
|
| 765 | - 'frm_delete_forms' => __( 'Delete Forms and Templates', 'formidable' ), |
|
| 766 | - 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ), |
|
| 767 | - 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ), |
|
| 768 | - 'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ), |
|
| 769 | - ); |
|
| 762 | + $cap = array( |
|
| 763 | + 'frm_view_forms' => __( 'View Forms and Templates', 'formidable' ), |
|
| 764 | + 'frm_edit_forms' => __( 'Add/Edit Forms and Templates', 'formidable' ), |
|
| 765 | + 'frm_delete_forms' => __( 'Delete Forms and Templates', 'formidable' ), |
|
| 766 | + 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ), |
|
| 767 | + 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ), |
|
| 768 | + 'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ), |
|
| 769 | + ); |
|
| 770 | 770 | |
| 771 | 771 | if ( ! self::pro_is_installed() && 'pro' != $type ) { |
| 772 | - return $cap; |
|
| 773 | - } |
|
| 772 | + return $cap; |
|
| 773 | + } |
|
| 774 | 774 | |
| 775 | - $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' ); |
|
| 776 | - $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' ); |
|
| 777 | - $cap['frm_view_reports'] = __( 'View Reports', 'formidable' ); |
|
| 778 | - $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' ); |
|
| 775 | + $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' ); |
|
| 776 | + $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' ); |
|
| 777 | + $cap['frm_view_reports'] = __( 'View Reports', 'formidable' ); |
|
| 778 | + $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' ); |
|
| 779 | 779 | |
| 780 | - return $cap; |
|
| 781 | - } |
|
| 780 | + return $cap; |
|
| 781 | + } |
|
| 782 | 782 | |
| 783 | 783 | public static function user_has_permission( $needed_role ) { |
| 784 | - if ( $needed_role == '-1' ) { |
|
| 785 | - return false; |
|
| 784 | + if ( $needed_role == '-1' ) { |
|
| 785 | + return false; |
|
| 786 | 786 | } |
| 787 | 787 | |
| 788 | - // $needed_role will be equal to blank if "Logged-in users" is selected |
|
| 789 | - if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) { |
|
| 790 | - return true; |
|
| 791 | - } |
|
| 788 | + // $needed_role will be equal to blank if "Logged-in users" is selected |
|
| 789 | + if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) { |
|
| 790 | + return true; |
|
| 791 | + } |
|
| 792 | 792 | |
| 793 | - $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ); |
|
| 794 | - foreach ( $roles as $role ) { |
|
| 793 | + $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ); |
|
| 794 | + foreach ( $roles as $role ) { |
|
| 795 | 795 | if ( current_user_can( $role ) ) { |
| 796 | - return true; |
|
| 796 | + return true; |
|
| 797 | 797 | } |
| 798 | - if ( $role == $needed_role ) { |
|
| 799 | - break; |
|
| 798 | + if ( $role == $needed_role ) { |
|
| 799 | + break; |
|
| 800 | 800 | } |
| 801 | - } |
|
| 802 | - return false; |
|
| 803 | - } |
|
| 804 | - |
|
| 805 | - /** |
|
| 806 | - * Make sure administrators can see Formidable menu |
|
| 807 | - * |
|
| 808 | - * @since 2.0 |
|
| 809 | - */ |
|
| 810 | - public static function maybe_add_permissions() { |
|
| 801 | + } |
|
| 802 | + return false; |
|
| 803 | + } |
|
| 804 | + |
|
| 805 | + /** |
|
| 806 | + * Make sure administrators can see Formidable menu |
|
| 807 | + * |
|
| 808 | + * @since 2.0 |
|
| 809 | + */ |
|
| 810 | + public static function maybe_add_permissions() { |
|
| 811 | 811 | self::force_capability( 'frm_view_entries' ); |
| 812 | 812 | |
| 813 | 813 | if ( ! current_user_can( 'administrator' ) || current_user_can( 'frm_view_forms' ) ) { |
@@ -816,12 +816,12 @@ discard block |
||
| 816 | 816 | |
| 817 | 817 | $user_id = get_current_user_id(); |
| 818 | 818 | $user = new WP_User( $user_id ); |
| 819 | - $frm_roles = self::frm_capabilities(); |
|
| 820 | - foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 819 | + $frm_roles = self::frm_capabilities(); |
|
| 820 | + foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 821 | 821 | $user->add_cap( $frm_role ); |
| 822 | 822 | unset( $frm_role, $frm_role_description ); |
| 823 | - } |
|
| 824 | - } |
|
| 823 | + } |
|
| 824 | + } |
|
| 825 | 825 | |
| 826 | 826 | /** |
| 827 | 827 | * Make sure admins have permission to see the menu items |
@@ -838,30 +838,30 @@ discard block |
||
| 838 | 838 | } |
| 839 | 839 | } |
| 840 | 840 | |
| 841 | - /** |
|
| 842 | - * Check if the user has permision for action. |
|
| 843 | - * Return permission message and stop the action if no permission |
|
| 841 | + /** |
|
| 842 | + * Check if the user has permision for action. |
|
| 843 | + * Return permission message and stop the action if no permission |
|
| 844 | 844 | * |
| 845 | - * @since 2.0 |
|
| 846 | - * @param string $permission |
|
| 847 | - */ |
|
| 845 | + * @since 2.0 |
|
| 846 | + * @param string $permission |
|
| 847 | + */ |
|
| 848 | 848 | public static function permission_check( $permission, $show_message = 'show' ) { |
| 849 | 849 | $permission_error = self::permission_nonce_error( $permission ); |
| 850 | - if ( $permission_error !== false ) { |
|
| 851 | - if ( 'hide' == $show_message ) { |
|
| 852 | - $permission_error = ''; |
|
| 853 | - } |
|
| 850 | + if ( $permission_error !== false ) { |
|
| 851 | + if ( 'hide' == $show_message ) { |
|
| 852 | + $permission_error = ''; |
|
| 853 | + } |
|
| 854 | 854 | wp_die( esc_html( $permission_error ) ); |
| 855 | - } |
|
| 856 | - } |
|
| 855 | + } |
|
| 856 | + } |
|
| 857 | 857 | |
| 858 | - /** |
|
| 859 | - * Check user permission and nonce |
|
| 858 | + /** |
|
| 859 | + * Check user permission and nonce |
|
| 860 | 860 | * |
| 861 | - * @since 2.0 |
|
| 862 | - * @param string $permission |
|
| 863 | - * @return false|string The permission message or false if allowed |
|
| 864 | - */ |
|
| 861 | + * @since 2.0 |
|
| 862 | + * @param string $permission |
|
| 863 | + * @return false|string The permission message or false if allowed |
|
| 864 | + */ |
|
| 865 | 865 | public static function permission_nonce_error( $permission, $nonce_name = '', $nonce = '' ) { |
| 866 | 866 | if ( ! empty( $permission ) && ! current_user_can( $permission ) && ! current_user_can( 'administrator' ) ) { |
| 867 | 867 | $frm_settings = self::get_settings(); |
@@ -870,22 +870,22 @@ discard block |
||
| 870 | 870 | |
| 871 | 871 | $error = false; |
| 872 | 872 | if ( empty( $nonce_name ) ) { |
| 873 | - return $error; |
|
| 874 | - } |
|
| 873 | + return $error; |
|
| 874 | + } |
|
| 875 | 875 | |
| 876 | - if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
| 877 | - $frm_settings = self::get_settings(); |
|
| 878 | - $error = $frm_settings->admin_permission; |
|
| 879 | - } |
|
| 876 | + if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
| 877 | + $frm_settings = self::get_settings(); |
|
| 878 | + $error = $frm_settings->admin_permission; |
|
| 879 | + } |
|
| 880 | 880 | |
| 881 | - return $error; |
|
| 882 | - } |
|
| 881 | + return $error; |
|
| 882 | + } |
|
| 883 | 883 | |
| 884 | - public static function checked( $values, $current ) { |
|
| 884 | + public static function checked( $values, $current ) { |
|
| 885 | 885 | if ( self::check_selected( $values, $current ) ) { |
| 886 | - echo ' checked="checked"'; |
|
| 886 | + echo ' checked="checked"'; |
|
| 887 | 887 | } |
| 888 | - } |
|
| 888 | + } |
|
| 889 | 889 | |
| 890 | 890 | public static function check_selected( $values, $current ) { |
| 891 | 891 | $values = self::recursive_function_map( $values, 'trim' ); |
@@ -923,24 +923,24 @@ discard block |
||
| 923 | 923 | return (bool) count( array_filter( array_keys( $array ), 'is_string' ) ); |
| 924 | 924 | } |
| 925 | 925 | |
| 926 | - /** |
|
| 927 | - * Flatten a multi-dimensional array |
|
| 928 | - */ |
|
| 926 | + /** |
|
| 927 | + * Flatten a multi-dimensional array |
|
| 928 | + */ |
|
| 929 | 929 | public static function array_flatten( $array, $keys = 'keep' ) { |
| 930 | - $return = array(); |
|
| 931 | - foreach ( $array as $key => $value ) { |
|
| 930 | + $return = array(); |
|
| 931 | + foreach ( $array as $key => $value ) { |
|
| 932 | 932 | if ( is_array( $value ) ) { |
| 933 | 933 | $return = array_merge( $return, self::array_flatten( $value, $keys ) ); |
| 934 | - } else { |
|
| 934 | + } else { |
|
| 935 | 935 | if ( $keys == 'keep' ) { |
| 936 | 936 | $return[ $key ] = $value; |
| 937 | 937 | } else { |
| 938 | 938 | $return[] = $value; |
| 939 | 939 | } |
| 940 | - } |
|
| 941 | - } |
|
| 942 | - return $return; |
|
| 943 | - } |
|
| 940 | + } |
|
| 941 | + } |
|
| 942 | + return $return; |
|
| 943 | + } |
|
| 944 | 944 | |
| 945 | 945 | public static function esc_textarea( $text, $is_rich_text = false ) { |
| 946 | 946 | $safe_text = str_replace( '"', '"', $text ); |
@@ -951,11 +951,11 @@ discard block |
||
| 951 | 951 | return apply_filters( 'esc_textarea', $safe_text, $text ); |
| 952 | 952 | } |
| 953 | 953 | |
| 954 | - /** |
|
| 955 | - * Add auto paragraphs to text areas |
|
| 954 | + /** |
|
| 955 | + * Add auto paragraphs to text areas |
|
| 956 | 956 | * |
| 957 | - * @since 2.0 |
|
| 958 | - */ |
|
| 957 | + * @since 2.0 |
|
| 958 | + */ |
|
| 959 | 959 | public static function use_wpautop( $content ) { |
| 960 | 960 | if ( apply_filters( 'frm_use_wpautop', true ) ) { |
| 961 | 961 | $content = wpautop( str_replace( '<br>', '<br />', $content ) ); |
@@ -964,26 +964,26 @@ discard block |
||
| 964 | 964 | } |
| 965 | 965 | |
| 966 | 966 | public static function replace_quotes( $val ) { |
| 967 | - //Replace double quotes |
|
| 967 | + //Replace double quotes |
|
| 968 | 968 | $val = str_replace( array( '“', '”', '″' ), '"', $val ); |
| 969 | - //Replace single quotes |
|
| 970 | - $val = str_replace( array( '‘', '’', '′', '′', '’', '‘' ), "'", $val ); |
|
| 971 | - return $val; |
|
| 972 | - } |
|
| 973 | - |
|
| 974 | - /** |
|
| 975 | - * @since 2.0 |
|
| 976 | - * @return string The base Google APIS url for the current version of jQuery UI |
|
| 977 | - */ |
|
| 978 | - public static function jquery_ui_base_url() { |
|
| 969 | + //Replace single quotes |
|
| 970 | + $val = str_replace( array( '‘', '’', '′', '′', '’', '‘' ), "'", $val ); |
|
| 971 | + return $val; |
|
| 972 | + } |
|
| 973 | + |
|
| 974 | + /** |
|
| 975 | + * @since 2.0 |
|
| 976 | + * @return string The base Google APIS url for the current version of jQuery UI |
|
| 977 | + */ |
|
| 978 | + public static function jquery_ui_base_url() { |
|
| 979 | 979 | $url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core', '1.11.4' ); |
| 980 | 980 | $url = apply_filters( 'frm_jquery_ui_base_url', $url ); |
| 981 | - return $url; |
|
| 982 | - } |
|
| 981 | + return $url; |
|
| 982 | + } |
|
| 983 | 983 | |
| 984 | - /** |
|
| 985 | - * @param string $handle |
|
| 986 | - */ |
|
| 984 | + /** |
|
| 985 | + * @param string $handle |
|
| 986 | + */ |
|
| 987 | 987 | public static function script_version( $handle, $default = 0 ) { |
| 988 | 988 | global $wp_scripts; |
| 989 | 989 | if ( ! $wp_scripts ) { |
@@ -1005,12 +1005,12 @@ discard block |
||
| 1005 | 1005 | |
| 1006 | 1006 | public static function js_redirect( $url ) { |
| 1007 | 1007 | return '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>'; |
| 1008 | - } |
|
| 1008 | + } |
|
| 1009 | 1009 | |
| 1010 | 1010 | public static function get_user_id_param( $user_id ) { |
| 1011 | 1011 | if ( ! $user_id || empty( $user_id ) || is_numeric( $user_id ) ) { |
| 1012 | - return $user_id; |
|
| 1013 | - } |
|
| 1012 | + return $user_id; |
|
| 1013 | + } |
|
| 1014 | 1014 | |
| 1015 | 1015 | $user_id = sanitize_text_field( $user_id ); |
| 1016 | 1016 | if ( $user_id == 'current' ) { |
@@ -1022,14 +1022,14 @@ discard block |
||
| 1022 | 1022 | $user = get_user_by( 'login', $user_id ); |
| 1023 | 1023 | } |
| 1024 | 1024 | |
| 1025 | - if ( $user ) { |
|
| 1026 | - $user_id = $user->ID; |
|
| 1027 | - } |
|
| 1025 | + if ( $user ) { |
|
| 1026 | + $user_id = $user->ID; |
|
| 1027 | + } |
|
| 1028 | 1028 | unset( $user ); |
| 1029 | - } |
|
| 1029 | + } |
|
| 1030 | 1030 | |
| 1031 | - return $user_id; |
|
| 1032 | - } |
|
| 1031 | + return $user_id; |
|
| 1032 | + } |
|
| 1033 | 1033 | |
| 1034 | 1034 | public static function get_file_contents( $filename, $atts = array() ) { |
| 1035 | 1035 | if ( ! is_file( $filename ) ) { |
@@ -1044,28 +1044,28 @@ discard block |
||
| 1044 | 1044 | return $contents; |
| 1045 | 1045 | } |
| 1046 | 1046 | |
| 1047 | - /** |
|
| 1048 | - * @param string $table_name |
|
| 1049 | - * @param string $column |
|
| 1047 | + /** |
|
| 1048 | + * @param string $table_name |
|
| 1049 | + * @param string $column |
|
| 1050 | 1050 | * @param int $id |
| 1051 | 1051 | * @param int $num_chars |
| 1052 | - */ |
|
| 1053 | - public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) { |
|
| 1054 | - $key = ''; |
|
| 1052 | + */ |
|
| 1053 | + public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) { |
|
| 1054 | + $key = ''; |
|
| 1055 | 1055 | |
| 1056 | - if ( ! empty( $name ) ) { |
|
| 1056 | + if ( ! empty( $name ) ) { |
|
| 1057 | 1057 | $key = sanitize_key( $name ); |
| 1058 | - } |
|
| 1058 | + } |
|
| 1059 | 1059 | |
| 1060 | 1060 | if ( empty( $key ) ) { |
| 1061 | 1061 | $max_slug_value = pow( 36, $num_chars ); |
| 1062 | - $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
| 1062 | + $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
| 1063 | 1063 | $key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 ); |
| 1064 | - } |
|
| 1064 | + } |
|
| 1065 | 1065 | |
| 1066 | 1066 | if ( is_numeric( $key ) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) { |
| 1067 | 1067 | $key = $key . 'a'; |
| 1068 | - } |
|
| 1068 | + } |
|
| 1069 | 1069 | |
| 1070 | 1070 | $key_check = FrmDb::get_var( |
| 1071 | 1071 | $table_name, |
@@ -1077,7 +1077,7 @@ discard block |
||
| 1077 | 1077 | ); |
| 1078 | 1078 | |
| 1079 | 1079 | if ( $key_check || is_numeric( $key_check ) ) { |
| 1080 | - $suffix = 2; |
|
| 1080 | + $suffix = 2; |
|
| 1081 | 1081 | do { |
| 1082 | 1082 | $alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix; |
| 1083 | 1083 | $key_check = FrmDb::get_var( |
@@ -1091,20 +1091,20 @@ discard block |
||
| 1091 | 1091 | $suffix++; |
| 1092 | 1092 | } while ( $key_check || is_numeric( $key_check ) ); |
| 1093 | 1093 | $key = $alt_post_name; |
| 1094 | - } |
|
| 1095 | - return $key; |
|
| 1096 | - } |
|
| 1094 | + } |
|
| 1095 | + return $key; |
|
| 1096 | + } |
|
| 1097 | 1097 | |
| 1098 | - /** |
|
| 1099 | - * Editing a Form or Entry |
|
| 1098 | + /** |
|
| 1099 | + * Editing a Form or Entry |
|
| 1100 | 1100 | * |
| 1101 | - * @param string $table |
|
| 1102 | - * @return bool|array |
|
| 1103 | - */ |
|
| 1104 | - public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) { |
|
| 1105 | - if ( ! $record ) { |
|
| 1106 | - return false; |
|
| 1107 | - } |
|
| 1101 | + * @param string $table |
|
| 1102 | + * @return bool|array |
|
| 1103 | + */ |
|
| 1104 | + public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) { |
|
| 1105 | + if ( ! $record ) { |
|
| 1106 | + return false; |
|
| 1107 | + } |
|
| 1108 | 1108 | |
| 1109 | 1109 | if ( empty( $post_values ) ) { |
| 1110 | 1110 | $post_values = stripslashes_deep( $_POST ); |
@@ -1127,14 +1127,14 @@ discard block |
||
| 1127 | 1127 | |
| 1128 | 1128 | self::prepare_field_arrays( $fields, $record, $values, array_merge( $args, compact( 'default', 'post_values' ) ) ); |
| 1129 | 1129 | |
| 1130 | - if ( $table == 'entries' ) { |
|
| 1131 | - $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
|
| 1132 | - } else if ( $table == 'forms' ) { |
|
| 1133 | - $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values ); |
|
| 1134 | - } |
|
| 1130 | + if ( $table == 'entries' ) { |
|
| 1131 | + $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
|
| 1132 | + } else if ( $table == 'forms' ) { |
|
| 1133 | + $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values ); |
|
| 1134 | + } |
|
| 1135 | 1135 | |
| 1136 | - return $values; |
|
| 1137 | - } |
|
| 1136 | + return $values; |
|
| 1137 | + } |
|
| 1138 | 1138 | |
| 1139 | 1139 | private static function prepare_field_arrays( $fields, $record, array &$values, $args ) { |
| 1140 | 1140 | if ( ! empty( $fields ) ) { |
@@ -1147,15 +1147,15 @@ discard block |
||
| 1147 | 1147 | } |
| 1148 | 1148 | |
| 1149 | 1149 | private static function fill_field_defaults( $field, $record, array &$values, $args ) { |
| 1150 | - $post_values = $args['post_values']; |
|
| 1150 | + $post_values = $args['post_values']; |
|
| 1151 | 1151 | |
| 1152 | - if ( $args['default'] ) { |
|
| 1153 | - $meta_value = $field->default_value; |
|
| 1154 | - } else { |
|
| 1152 | + if ( $args['default'] ) { |
|
| 1153 | + $meta_value = $field->default_value; |
|
| 1154 | + } else { |
|
| 1155 | 1155 | if ( $record->post_id && self::pro_is_installed() && isset( $field->field_options['post_field'] ) && $field->field_options['post_field'] ) { |
| 1156 | 1156 | if ( ! isset( $field->field_options['custom_field'] ) ) { |
| 1157 | - $field->field_options['custom_field'] = ''; |
|
| 1158 | - } |
|
| 1157 | + $field->field_options['custom_field'] = ''; |
|
| 1158 | + } |
|
| 1159 | 1159 | $meta_value = FrmProEntryMetaHelper::get_post_value( |
| 1160 | 1160 | $record->post_id, |
| 1161 | 1161 | $field->field_options['post_field'], |
@@ -1167,31 +1167,31 @@ discard block |
||
| 1167 | 1167 | 'field' => $field, |
| 1168 | 1168 | ) |
| 1169 | 1169 | ); |
| 1170 | - } else { |
|
| 1170 | + } else { |
|
| 1171 | 1171 | $meta_value = FrmEntryMeta::get_meta_value( $record, $field->id ); |
| 1172 | - } |
|
| 1173 | - } |
|
| 1172 | + } |
|
| 1173 | + } |
|
| 1174 | 1174 | |
| 1175 | 1175 | $field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type; |
| 1176 | - $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
| 1176 | + $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
| 1177 | 1177 | |
| 1178 | 1178 | $field_array = self::start_field_array( $field ); |
| 1179 | 1179 | $field_array['value'] = $new_value; |
| 1180 | 1180 | $field_array['type'] = apply_filters( 'frm_field_type', $field_type, $field, $new_value ); |
| 1181 | 1181 | $field_array['parent_form_id'] = $args['parent_form_id']; |
| 1182 | 1182 | |
| 1183 | - $args['field_type'] = $field_type; |
|
| 1183 | + $args['field_type'] = $field_type; |
|
| 1184 | 1184 | |
| 1185 | 1185 | FrmFieldsHelper::prepare_edit_front_field( $field_array, $field, $values['id'], $args ); |
| 1186 | 1186 | |
| 1187 | 1187 | if ( ! isset( $field_array['unique'] ) || ! $field_array['unique'] ) { |
| 1188 | - $field_array['unique_msg'] = ''; |
|
| 1189 | - } |
|
| 1188 | + $field_array['unique_msg'] = ''; |
|
| 1189 | + } |
|
| 1190 | 1190 | |
| 1191 | - $field_array = array_merge( $field->field_options, $field_array ); |
|
| 1191 | + $field_array = array_merge( $field->field_options, $field_array ); |
|
| 1192 | 1192 | |
| 1193 | - $values['fields'][ $field->id ] = $field_array; |
|
| 1194 | - } |
|
| 1193 | + $values['fields'][ $field->id ] = $field_array; |
|
| 1194 | + } |
|
| 1195 | 1195 | |
| 1196 | 1196 | /** |
| 1197 | 1197 | * @since 3.0 |
@@ -1212,20 +1212,20 @@ discard block |
||
| 1212 | 1212 | ); |
| 1213 | 1213 | } |
| 1214 | 1214 | |
| 1215 | - /** |
|
| 1216 | - * @param string $table |
|
| 1217 | - */ |
|
| 1215 | + /** |
|
| 1216 | + * @param string $table |
|
| 1217 | + */ |
|
| 1218 | 1218 | private static function fill_form_opts( $record, $table, $post_values, array &$values ) { |
| 1219 | - if ( $table == 'entries' ) { |
|
| 1220 | - $form = $record->form_id; |
|
| 1219 | + if ( $table == 'entries' ) { |
|
| 1220 | + $form = $record->form_id; |
|
| 1221 | 1221 | FrmForm::maybe_get_form( $form ); |
| 1222 | - } else { |
|
| 1223 | - $form = $record; |
|
| 1224 | - } |
|
| 1222 | + } else { |
|
| 1223 | + $form = $record; |
|
| 1224 | + } |
|
| 1225 | 1225 | |
| 1226 | - if ( ! $form ) { |
|
| 1227 | - return; |
|
| 1228 | - } |
|
| 1226 | + if ( ! $form ) { |
|
| 1227 | + return; |
|
| 1228 | + } |
|
| 1229 | 1229 | |
| 1230 | 1230 | $values['form_name'] = isset( $record->form_id ) ? $form->name : ''; |
| 1231 | 1231 | $values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0; |
@@ -1234,26 +1234,26 @@ discard block |
||
| 1234 | 1234 | return; |
| 1235 | 1235 | } |
| 1236 | 1236 | |
| 1237 | - foreach ( $form->options as $opt => $value ) { |
|
| 1238 | - $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
| 1239 | - } |
|
| 1237 | + foreach ( $form->options as $opt => $value ) { |
|
| 1238 | + $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
| 1239 | + } |
|
| 1240 | 1240 | |
| 1241 | 1241 | self::fill_form_defaults( $post_values, $values ); |
| 1242 | - } |
|
| 1242 | + } |
|
| 1243 | 1243 | |
| 1244 | - /** |
|
| 1245 | - * Set to POST value or default |
|
| 1246 | - */ |
|
| 1244 | + /** |
|
| 1245 | + * Set to POST value or default |
|
| 1246 | + */ |
|
| 1247 | 1247 | private static function fill_form_defaults( $post_values, array &$values ) { |
| 1248 | - $form_defaults = FrmFormsHelper::get_default_opts(); |
|
| 1248 | + $form_defaults = FrmFormsHelper::get_default_opts(); |
|
| 1249 | 1249 | |
| 1250 | - foreach ( $form_defaults as $opt => $default ) { |
|
| 1251 | - if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
| 1250 | + foreach ( $form_defaults as $opt => $default ) { |
|
| 1251 | + if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
| 1252 | 1252 | $values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default; |
| 1253 | - } |
|
| 1253 | + } |
|
| 1254 | 1254 | |
| 1255 | 1255 | unset( $opt, $default ); |
| 1256 | - } |
|
| 1256 | + } |
|
| 1257 | 1257 | |
| 1258 | 1258 | if ( ! isset( $values['custom_style'] ) ) { |
| 1259 | 1259 | $values['custom_style'] = self::custom_style_value( $post_values ); |
@@ -1262,10 +1262,10 @@ discard block |
||
| 1262 | 1262 | foreach ( array( 'before', 'after', 'submit' ) as $h ) { |
| 1263 | 1263 | if ( ! isset( $values[ $h . '_html' ] ) ) { |
| 1264 | 1264 | $values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) ); |
| 1265 | - } |
|
| 1265 | + } |
|
| 1266 | 1266 | unset( $h ); |
| 1267 | - } |
|
| 1268 | - } |
|
| 1267 | + } |
|
| 1268 | + } |
|
| 1269 | 1269 | |
| 1270 | 1270 | /** |
| 1271 | 1271 | * @since 2.2.10 |
@@ -1288,33 +1288,33 @@ discard block |
||
| 1288 | 1288 | if ( $possible_email_field ) { |
| 1289 | 1289 | $class .= 'show_frm_not_email_to'; |
| 1290 | 1290 | } |
| 1291 | - ?> |
|
| 1291 | + ?> |
|
| 1292 | 1292 | <li> |
| 1293 | 1293 | <a href="javascript:void(0)" class="frmids frm_insert_code alignright <?php echo esc_attr( $class ); ?>" data-code="<?php echo esc_attr( $args['id'] ); ?>" >[<?php echo esc_attr( $args['id'] ); ?>]</a> |
| 1294 | 1294 | <a href="javascript:void(0)" class="frmkeys frm_insert_code alignright <?php echo esc_attr( $class ); ?>" data-code="<?php echo esc_attr( $args['key'] ); ?>" >[<?php echo esc_attr( self::truncate( $args['key'], 10 ) ); ?>]</a> |
| 1295 | 1295 | <a href="javascript:void(0)" class="frm_insert_code <?php echo esc_attr( $class ); ?>" data-code="<?php echo esc_attr( $args['id'] ); ?>" ><?php echo esc_attr( self::truncate( $args['name'], 60 ) ); ?></a> |
| 1296 | 1296 | </li> |
| 1297 | 1297 | <?php |
| 1298 | - } |
|
| 1298 | + } |
|
| 1299 | 1299 | |
| 1300 | 1300 | public static function truncate( $str, $length, $minword = 3, $continue = '...' ) { |
| 1301 | - if ( is_array( $str ) ) { |
|
| 1302 | - return ''; |
|
| 1301 | + if ( is_array( $str ) ) { |
|
| 1302 | + return ''; |
|
| 1303 | 1303 | } |
| 1304 | 1304 | |
| 1305 | - $length = (int) $length; |
|
| 1305 | + $length = (int) $length; |
|
| 1306 | 1306 | $str = wp_strip_all_tags( $str ); |
| 1307 | 1307 | $original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) ); |
| 1308 | 1308 | |
| 1309 | 1309 | if ( $length == 0 ) { |
| 1310 | - return ''; |
|
| 1311 | - } else if ( $length <= 10 ) { |
|
| 1310 | + return ''; |
|
| 1311 | + } else if ( $length <= 10 ) { |
|
| 1312 | 1312 | $sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) ); |
| 1313 | 1313 | return $sub . ( ( $length < $original_len ) ? $continue : '' ); |
| 1314 | - } |
|
| 1314 | + } |
|
| 1315 | 1315 | |
| 1316 | - $sub = ''; |
|
| 1317 | - $len = 0; |
|
| 1316 | + $sub = ''; |
|
| 1317 | + $len = 0; |
|
| 1318 | 1318 | |
| 1319 | 1319 | $words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) ); |
| 1320 | 1320 | |
@@ -1322,21 +1322,21 @@ discard block |
||
| 1322 | 1322 | $part = ( ( $sub != '' ) ? ' ' : '' ) . $word; |
| 1323 | 1323 | $total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) ); |
| 1324 | 1324 | if ( $total_len > $length && substr_count( $sub, ' ' ) ) { |
| 1325 | - break; |
|
| 1326 | - } |
|
| 1325 | + break; |
|
| 1326 | + } |
|
| 1327 | 1327 | |
| 1328 | - $sub .= $part; |
|
| 1328 | + $sub .= $part; |
|
| 1329 | 1329 | $len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) ); |
| 1330 | 1330 | |
| 1331 | 1331 | if ( substr_count( $sub, ' ' ) > $minword && $total_len >= $length ) { |
| 1332 | - break; |
|
| 1333 | - } |
|
| 1332 | + break; |
|
| 1333 | + } |
|
| 1334 | 1334 | |
| 1335 | 1335 | unset( $total_len, $word ); |
| 1336 | - } |
|
| 1336 | + } |
|
| 1337 | 1337 | |
| 1338 | 1338 | return $sub . ( ( $len < $original_len ) ? $continue : '' ); |
| 1339 | - } |
|
| 1339 | + } |
|
| 1340 | 1340 | |
| 1341 | 1341 | public static function mb_function( $function_names, $args ) { |
| 1342 | 1342 | $mb_function_name = $function_names[0]; |
@@ -1349,17 +1349,17 @@ discard block |
||
| 1349 | 1349 | |
| 1350 | 1350 | public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) { |
| 1351 | 1351 | if ( empty( $date ) ) { |
| 1352 | - return $date; |
|
| 1353 | - } |
|
| 1352 | + return $date; |
|
| 1353 | + } |
|
| 1354 | 1354 | |
| 1355 | 1355 | if ( empty( $date_format ) ) { |
| 1356 | 1356 | $date_format = get_option( 'date_format' ); |
| 1357 | 1357 | } |
| 1358 | 1358 | |
| 1359 | 1359 | if ( preg_match( '/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date ) && self::pro_is_installed() ) { |
| 1360 | - $frmpro_settings = new FrmProSettings(); |
|
| 1360 | + $frmpro_settings = new FrmProSettings(); |
|
| 1361 | 1361 | $date = FrmProAppHelper::convert_date( $date, $frmpro_settings->date_format, 'Y-m-d' ); |
| 1362 | - } |
|
| 1362 | + } |
|
| 1363 | 1363 | |
| 1364 | 1364 | $formatted = self::get_localized_date( $date_format, $date ); |
| 1365 | 1365 | |
@@ -1368,8 +1368,8 @@ discard block |
||
| 1368 | 1368 | $formatted .= self::add_time_to_date( $time_format, $date ); |
| 1369 | 1369 | } |
| 1370 | 1370 | |
| 1371 | - return $formatted; |
|
| 1372 | - } |
|
| 1371 | + return $formatted; |
|
| 1372 | + } |
|
| 1373 | 1373 | |
| 1374 | 1374 | private static function add_time_to_date( $time_format, $date ) { |
| 1375 | 1375 | if ( empty( $time_format ) ) { |
@@ -1451,32 +1451,32 @@ discard block |
||
| 1451 | 1451 | ); |
| 1452 | 1452 | } |
| 1453 | 1453 | |
| 1454 | - // Pagination Methods |
|
| 1454 | + // Pagination Methods |
|
| 1455 | 1455 | |
| 1456 | - /** |
|
| 1457 | - * @param integer $current_p |
|
| 1458 | - */ |
|
| 1456 | + /** |
|
| 1457 | + * @param integer $current_p |
|
| 1458 | + */ |
|
| 1459 | 1459 | public static function get_last_record_num( $r_count, $current_p, $p_size ) { |
| 1460 | 1460 | return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) ); |
| 1461 | 1461 | } |
| 1462 | 1462 | |
| 1463 | - /** |
|
| 1464 | - * @param integer $current_p |
|
| 1465 | - */ |
|
| 1466 | - public static function get_first_record_num( $r_count, $current_p, $p_size ) { |
|
| 1467 | - if ( $current_p == 1 ) { |
|
| 1468 | - return 1; |
|
| 1469 | - } else { |
|
| 1470 | - return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 ); |
|
| 1471 | - } |
|
| 1472 | - } |
|
| 1463 | + /** |
|
| 1464 | + * @param integer $current_p |
|
| 1465 | + */ |
|
| 1466 | + public static function get_first_record_num( $r_count, $current_p, $p_size ) { |
|
| 1467 | + if ( $current_p == 1 ) { |
|
| 1468 | + return 1; |
|
| 1469 | + } else { |
|
| 1470 | + return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 ); |
|
| 1471 | + } |
|
| 1472 | + } |
|
| 1473 | 1473 | |
| 1474 | 1474 | /** |
| 1475 | 1475 | * @return array |
| 1476 | 1476 | */ |
| 1477 | 1477 | public static function json_to_array( $json_vars ) { |
| 1478 | - $vars = array(); |
|
| 1479 | - foreach ( $json_vars as $jv ) { |
|
| 1478 | + $vars = array(); |
|
| 1479 | + foreach ( $json_vars as $jv ) { |
|
| 1480 | 1480 | $jv_name = explode( '[', $jv['name'] ); |
| 1481 | 1481 | $last = count( $jv_name ) - 1; |
| 1482 | 1482 | foreach ( $jv_name as $p => $n ) { |
@@ -1493,77 +1493,77 @@ discard block |
||
| 1493 | 1493 | $l3 = $name; |
| 1494 | 1494 | } |
| 1495 | 1495 | |
| 1496 | - $this_val = ( $p == $last ) ? $jv['value'] : array(); |
|
| 1496 | + $this_val = ( $p == $last ) ? $jv['value'] : array(); |
|
| 1497 | 1497 | |
| 1498 | - switch ( $p ) { |
|
| 1499 | - case 0: |
|
| 1500 | - $l1 = $name; |
|
| 1501 | - self::add_value_to_array( $name, $l1, $this_val, $vars ); |
|
| 1498 | + switch ( $p ) { |
|
| 1499 | + case 0: |
|
| 1500 | + $l1 = $name; |
|
| 1501 | + self::add_value_to_array( $name, $l1, $this_val, $vars ); |
|
| 1502 | 1502 | break; |
| 1503 | 1503 | |
| 1504 | - case 1: |
|
| 1505 | - $l2 = $name; |
|
| 1506 | - self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
| 1504 | + case 1: |
|
| 1505 | + $l2 = $name; |
|
| 1506 | + self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
| 1507 | 1507 | break; |
| 1508 | 1508 | |
| 1509 | - case 2: |
|
| 1510 | - $l3 = $name; |
|
| 1511 | - self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
| 1509 | + case 2: |
|
| 1510 | + $l3 = $name; |
|
| 1511 | + self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
| 1512 | 1512 | break; |
| 1513 | 1513 | |
| 1514 | - case 3: |
|
| 1515 | - $l4 = $name; |
|
| 1516 | - self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
| 1517 | - } |
|
| 1514 | + case 3: |
|
| 1515 | + $l4 = $name; |
|
| 1516 | + self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
| 1517 | + } |
|
| 1518 | 1518 | |
| 1519 | 1519 | unset( $this_val, $n ); |
| 1520 | - } |
|
| 1520 | + } |
|
| 1521 | 1521 | |
| 1522 | 1522 | unset( $last, $jv ); |
| 1523 | - } |
|
| 1524 | - |
|
| 1525 | - return $vars; |
|
| 1526 | - } |
|
| 1527 | - |
|
| 1528 | - /** |
|
| 1529 | - * @param string $name |
|
| 1530 | - * @param string $l1 |
|
| 1531 | - */ |
|
| 1532 | - public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
|
| 1533 | - if ( $name == '' ) { |
|
| 1534 | - $vars[] = $val; |
|
| 1535 | - } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
| 1536 | - $vars[ $l1 ] = $val; |
|
| 1537 | - } |
|
| 1538 | - } |
|
| 1523 | + } |
|
| 1524 | + |
|
| 1525 | + return $vars; |
|
| 1526 | + } |
|
| 1527 | + |
|
| 1528 | + /** |
|
| 1529 | + * @param string $name |
|
| 1530 | + * @param string $l1 |
|
| 1531 | + */ |
|
| 1532 | + public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
|
| 1533 | + if ( $name == '' ) { |
|
| 1534 | + $vars[] = $val; |
|
| 1535 | + } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
| 1536 | + $vars[ $l1 ] = $val; |
|
| 1537 | + } |
|
| 1538 | + } |
|
| 1539 | 1539 | |
| 1540 | 1540 | public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) { |
| 1541 | - $tooltips = array( |
|
| 1542 | - 'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ), |
|
| 1543 | - 'email_to' => __( 'Add one or more recipient addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected]. [admin_email] is the address set in WP General Settings.', 'formidable' ), |
|
| 1544 | - 'cc' => __( 'Add CC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1545 | - 'bcc' => __( 'Add BCC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1546 | - 'reply_to' => __( 'If you would like a different reply to address than the "from" address, add a single address here. FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1547 | - 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ), |
|
| 1548 | - 'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ), |
|
| 1549 | - ); |
|
| 1550 | - |
|
| 1551 | - if ( ! isset( $tooltips[ $name ] ) ) { |
|
| 1552 | - return; |
|
| 1553 | - } |
|
| 1554 | - |
|
| 1555 | - if ( 'open' == $class ) { |
|
| 1556 | - echo ' frm_help"'; |
|
| 1557 | - } else { |
|
| 1558 | - echo ' class="frm_help"'; |
|
| 1559 | - } |
|
| 1541 | + $tooltips = array( |
|
| 1542 | + 'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ), |
|
| 1543 | + 'email_to' => __( 'Add one or more recipient addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected]. [admin_email] is the address set in WP General Settings.', 'formidable' ), |
|
| 1544 | + 'cc' => __( 'Add CC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1545 | + 'bcc' => __( 'Add BCC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1546 | + 'reply_to' => __( 'If you would like a different reply to address than the "from" address, add a single address here. FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1547 | + 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ), |
|
| 1548 | + 'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ), |
|
| 1549 | + ); |
|
| 1550 | + |
|
| 1551 | + if ( ! isset( $tooltips[ $name ] ) ) { |
|
| 1552 | + return; |
|
| 1553 | + } |
|
| 1554 | + |
|
| 1555 | + if ( 'open' == $class ) { |
|
| 1556 | + echo ' frm_help"'; |
|
| 1557 | + } else { |
|
| 1558 | + echo ' class="frm_help"'; |
|
| 1559 | + } |
|
| 1560 | 1560 | |
| 1561 | 1561 | echo ' title="' . esc_attr( $tooltips[ $name ] ); |
| 1562 | 1562 | |
| 1563 | - if ( 'open' != $class ) { |
|
| 1564 | - echo '"'; |
|
| 1565 | - } |
|
| 1566 | - } |
|
| 1563 | + if ( 'open' != $class ) { |
|
| 1564 | + echo '"'; |
|
| 1565 | + } |
|
| 1566 | + } |
|
| 1567 | 1567 | |
| 1568 | 1568 | /** |
| 1569 | 1569 | * Add the current_page class to that page in the form nav |
@@ -1579,35 +1579,35 @@ discard block |
||
| 1579 | 1579 | } |
| 1580 | 1580 | } |
| 1581 | 1581 | |
| 1582 | - /** |
|
| 1583 | - * Prepare and json_encode post content |
|
| 1584 | - * |
|
| 1585 | - * @since 2.0 |
|
| 1586 | - * |
|
| 1587 | - * @param array $post_content |
|
| 1588 | - * @return string $post_content ( json encoded array ) |
|
| 1589 | - */ |
|
| 1590 | - public static function prepare_and_encode( $post_content ) { |
|
| 1591 | - //Loop through array to strip slashes and add only the needed ones |
|
| 1582 | + /** |
|
| 1583 | + * Prepare and json_encode post content |
|
| 1584 | + * |
|
| 1585 | + * @since 2.0 |
|
| 1586 | + * |
|
| 1587 | + * @param array $post_content |
|
| 1588 | + * @return string $post_content ( json encoded array ) |
|
| 1589 | + */ |
|
| 1590 | + public static function prepare_and_encode( $post_content ) { |
|
| 1591 | + //Loop through array to strip slashes and add only the needed ones |
|
| 1592 | 1592 | foreach ( $post_content as $key => $val ) { |
| 1593 | 1593 | // Replace problematic characters (like ") |
| 1594 | 1594 | $val = str_replace( '"', '"', $val ); |
| 1595 | 1595 | |
| 1596 | 1596 | self::prepare_action_slashes( $val, $key, $post_content ); |
| 1597 | - unset( $key, $val ); |
|
| 1598 | - } |
|
| 1597 | + unset( $key, $val ); |
|
| 1598 | + } |
|
| 1599 | 1599 | |
| 1600 | - // json_encode the array |
|
| 1601 | - $post_content = json_encode( $post_content ); |
|
| 1600 | + // json_encode the array |
|
| 1601 | + $post_content = json_encode( $post_content ); |
|
| 1602 | 1602 | |
| 1603 | - // add extra slashes for \r\n since WP strips them |
|
| 1603 | + // add extra slashes for \r\n since WP strips them |
|
| 1604 | 1604 | $post_content = str_replace( array( '\\r', '\\n', '\\u', '\\t' ), array( '\\\\r', '\\\\n', '\\\\u', '\\\\t' ), $post_content ); |
| 1605 | 1605 | |
| 1606 | - // allow for " |
|
| 1607 | - $post_content = str_replace( '"', '\\"', $post_content ); |
|
| 1606 | + // allow for " |
|
| 1607 | + $post_content = str_replace( '"', '\\"', $post_content ); |
|
| 1608 | 1608 | |
| 1609 | - return $post_content; |
|
| 1610 | - } |
|
| 1609 | + return $post_content; |
|
| 1610 | + } |
|
| 1611 | 1611 | |
| 1612 | 1612 | private static function prepare_action_slashes( $val, $key, &$post_content ) { |
| 1613 | 1613 | if ( ! isset( $post_content[ $key ] ) ) { |
@@ -1630,55 +1630,55 @@ discard block |
||
| 1630 | 1630 | |
| 1631 | 1631 | public static function maybe_json_decode( $string ) { |
| 1632 | 1632 | if ( is_array( $string ) ) { |
| 1633 | - return $string; |
|
| 1634 | - } |
|
| 1633 | + return $string; |
|
| 1634 | + } |
|
| 1635 | 1635 | |
| 1636 | 1636 | $new_string = json_decode( $string, true ); |
| 1637 | 1637 | if ( function_exists( 'json_last_error' ) ) { |
| 1638 | 1638 | // php 5.3+ |
| 1639 | - if ( json_last_error() == JSON_ERROR_NONE ) { |
|
| 1640 | - $string = $new_string; |
|
| 1641 | - } |
|
| 1639 | + if ( json_last_error() == JSON_ERROR_NONE ) { |
|
| 1640 | + $string = $new_string; |
|
| 1641 | + } |
|
| 1642 | 1642 | } elseif ( isset( $new_string ) ) { |
| 1643 | 1643 | // php < 5.3 fallback |
| 1644 | - $string = $new_string; |
|
| 1645 | - } |
|
| 1646 | - return $string; |
|
| 1647 | - } |
|
| 1648 | - |
|
| 1649 | - /** |
|
| 1650 | - * @since 1.07.10 |
|
| 1651 | - * |
|
| 1652 | - * @param string $post_type The name of the post type that may need to be highlighted |
|
| 1653 | - * echo The javascript to open and highlight the Formidable menu |
|
| 1654 | - */ |
|
| 1644 | + $string = $new_string; |
|
| 1645 | + } |
|
| 1646 | + return $string; |
|
| 1647 | + } |
|
| 1648 | + |
|
| 1649 | + /** |
|
| 1650 | + * @since 1.07.10 |
|
| 1651 | + * |
|
| 1652 | + * @param string $post_type The name of the post type that may need to be highlighted |
|
| 1653 | + * echo The javascript to open and highlight the Formidable menu |
|
| 1654 | + */ |
|
| 1655 | 1655 | public static function maybe_highlight_menu( $post_type ) { |
| 1656 | - global $post; |
|
| 1656 | + global $post; |
|
| 1657 | 1657 | |
| 1658 | 1658 | if ( isset( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] != $post_type ) { |
| 1659 | - return; |
|
| 1660 | - } |
|
| 1659 | + return; |
|
| 1660 | + } |
|
| 1661 | 1661 | |
| 1662 | 1662 | if ( is_object( $post ) && $post->post_type != $post_type ) { |
| 1663 | - return; |
|
| 1664 | - } |
|
| 1663 | + return; |
|
| 1664 | + } |
|
| 1665 | 1665 | |
| 1666 | - self::load_admin_wide_js(); |
|
| 1667 | - echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>'; |
|
| 1668 | - } |
|
| 1666 | + self::load_admin_wide_js(); |
|
| 1667 | + echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>'; |
|
| 1668 | + } |
|
| 1669 | 1669 | |
| 1670 | - /** |
|
| 1671 | - * Load the JS file on non-Formidable pages in the admin area |
|
| 1670 | + /** |
|
| 1671 | + * Load the JS file on non-Formidable pages in the admin area |
|
| 1672 | 1672 | * |
| 1673 | - * @since 2.0 |
|
| 1674 | - */ |
|
| 1673 | + * @since 2.0 |
|
| 1674 | + */ |
|
| 1675 | 1675 | public static function load_admin_wide_js( $load = true ) { |
| 1676 | 1676 | $version = self::plugin_version(); |
| 1677 | 1677 | wp_register_script( 'formidable_admin_global', self::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version ); |
| 1678 | 1678 | |
| 1679 | 1679 | $global_strings = array( |
| 1680 | 1680 | 'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ), |
| 1681 | - 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ), |
|
| 1681 | + 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ), |
|
| 1682 | 1682 | 'url' => self::plugin_url(), |
| 1683 | 1683 | 'loading' => __( 'Loading…', 'formidable' ), |
| 1684 | 1684 | 'nonce' => wp_create_nonce( 'frm_ajax' ), |
@@ -1688,7 +1688,7 @@ discard block |
||
| 1688 | 1688 | if ( $load ) { |
| 1689 | 1689 | wp_enqueue_script( 'formidable_admin_global' ); |
| 1690 | 1690 | } |
| 1691 | - } |
|
| 1691 | + } |
|
| 1692 | 1692 | |
| 1693 | 1693 | /** |
| 1694 | 1694 | * @since 2.0.9 |
@@ -1697,9 +1697,9 @@ discard block |
||
| 1697 | 1697 | wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() ); |
| 1698 | 1698 | } |
| 1699 | 1699 | |
| 1700 | - /** |
|
| 1701 | - * @param string $location |
|
| 1702 | - */ |
|
| 1700 | + /** |
|
| 1701 | + * @param string $location |
|
| 1702 | + */ |
|
| 1703 | 1703 | public static function localize_script( $location ) { |
| 1704 | 1704 | $ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' ); |
| 1705 | 1705 | $ajax_url = apply_filters( 'frm_ajax_url', $ajax_url ); |
@@ -1765,28 +1765,28 @@ discard block |
||
| 1765 | 1765 | } |
| 1766 | 1766 | } |
| 1767 | 1767 | |
| 1768 | - /** |
|
| 1768 | + /** |
|
| 1769 | 1769 | * Echo the message on the plugins listing page |
| 1770 | 1770 | * |
| 1771 | - * @since 1.07.10 |
|
| 1772 | - * |
|
| 1773 | - * @param float $min_version The version the add-on requires |
|
| 1774 | - */ |
|
| 1771 | + * @since 1.07.10 |
|
| 1772 | + * |
|
| 1773 | + * @param float $min_version The version the add-on requires |
|
| 1774 | + */ |
|
| 1775 | 1775 | public static function min_version_notice( $min_version ) { |
| 1776 | - $frm_version = self::plugin_version(); |
|
| 1776 | + $frm_version = self::plugin_version(); |
|
| 1777 | 1777 | |
| 1778 | - // check if Formidable meets minimum requirements |
|
| 1778 | + // check if Formidable meets minimum requirements |
|
| 1779 | 1779 | if ( version_compare( $frm_version, $min_version, '>=' ) ) { |
| 1780 | - return; |
|
| 1781 | - } |
|
| 1780 | + return; |
|
| 1781 | + } |
|
| 1782 | 1782 | |
| 1783 | 1783 | $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); |
| 1784 | 1784 | echo '<tr class="plugin-update-tr active"><th colspan="' . absint( $wp_list_table->get_column_count() ) . '" class="check-column plugin-update colspanchange"><div class="update-message">' . |
| 1785 | - esc_html__( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
|
| 1786 | - '</div></td></tr>'; |
|
| 1787 | - } |
|
| 1785 | + esc_html__( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
|
| 1786 | + '</div></td></tr>'; |
|
| 1787 | + } |
|
| 1788 | 1788 | |
| 1789 | - public static function locales( $type = 'date' ) { |
|
| 1789 | + public static function locales( $type = 'date' ) { |
|
| 1790 | 1790 | $locales = array( |
| 1791 | 1791 | 'en' => __( 'English', 'formidable' ), |
| 1792 | 1792 | '' => __( 'English/Western', 'formidable' ), |
@@ -1865,8 +1865,8 @@ discard block |
||
| 1865 | 1865 | $locales = array_diff_key( $locales, array_flip( $unset ) ); |
| 1866 | 1866 | $locales = apply_filters( 'frm_locales', $locales ); |
| 1867 | 1867 | |
| 1868 | - return $locales; |
|
| 1869 | - } |
|
| 1868 | + return $locales; |
|
| 1869 | + } |
|
| 1870 | 1870 | |
| 1871 | 1871 | /** |
| 1872 | 1872 | * Used to filter shortcode in text widgets |
@@ -261,6 +261,9 @@ discard block |
||
| 261 | 261 | FrmAppHelper::show_search_box( $text, $input_id ); |
| 262 | 262 | } |
| 263 | 263 | |
| 264 | + /** |
|
| 265 | + * @param string $param_name |
|
| 266 | + */ |
|
| 264 | 267 | private function hidden_search_inputs( $param_name ) { |
| 265 | 268 | if ( ! empty( $_REQUEST[ $param_name ] ) ) { |
| 266 | 269 | echo '<input type="hidden" name="' . esc_attr( $param_name ) . '" value="' . esc_attr( $_REQUEST[ $param_name ] ) . '" />'; |
@@ -399,6 +402,9 @@ discard block |
||
| 399 | 402 | return $action; |
| 400 | 403 | } |
| 401 | 404 | |
| 405 | + /** |
|
| 406 | + * @param string $action_name |
|
| 407 | + */ |
|
| 402 | 408 | private static function get_bulk_action( $action_name ) { |
| 403 | 409 | $action = false; |
| 404 | 410 | $action_param = self::get_param( |
@@ -213,8 +213,8 @@ discard block |
||
| 213 | 213 | return $this->get_pagenum(); |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | - if ( isset( $this->_pagination_args[ $key ] ) ) { |
|
| 217 | - return $this->_pagination_args[ $key ]; |
|
| 216 | + if ( isset( $this->_pagination_args[$key] ) ) { |
|
| 217 | + return $this->_pagination_args[$key]; |
|
| 218 | 218 | } |
| 219 | 219 | } |
| 220 | 220 | |
@@ -262,8 +262,8 @@ discard block |
||
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | private function hidden_search_inputs( $param_name ) { |
| 265 | - if ( ! empty( $_REQUEST[ $param_name ] ) ) { |
|
| 266 | - echo '<input type="hidden" name="' . esc_attr( $param_name ) . '" value="' . esc_attr( $_REQUEST[ $param_name ] ) . '" />'; |
|
| 265 | + if ( ! empty( $_REQUEST[$param_name] ) ) { |
|
| 266 | + echo '<input type="hidden" name="' . esc_attr( $param_name ) . '" value="' . esc_attr( $_REQUEST[$param_name] ) . '" />'; |
|
| 267 | 267 | } |
| 268 | 268 | } |
| 269 | 269 | |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | |
| 307 | 307 | echo "<ul class='subsubsub'>\n"; |
| 308 | 308 | foreach ( $views as $class => $view ) { |
| 309 | - $views[ $class ] = "\t" . '<li class="' . esc_attr( $class ) . '">' . $view; |
|
| 309 | + $views[$class] = "\t" . '<li class="' . esc_attr( $class ) . '">' . $view; |
|
| 310 | 310 | } |
| 311 | 311 | echo implode( " |</li>\n", $views ) . "</li>\n"; // WPCS: XSS ok. |
| 312 | 312 | echo '</ul>'; |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | |
| 434 | 434 | $out = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">'; |
| 435 | 435 | foreach ( $actions as $action => $link ) { |
| 436 | - ++$i; |
|
| 436 | + ++ $i; |
|
| 437 | 437 | ( $i == $action_count ) ? $sep = '' : $sep = ' | '; |
| 438 | 438 | $out .= "<span class='$action'>$link$sep</span>"; |
| 439 | 439 | } |
@@ -655,7 +655,7 @@ discard block |
||
| 655 | 655 | 'prev' => __( 'Previous page', 'formidable' ), |
| 656 | 656 | 'next' => __( 'Next page', 'formidable' ), |
| 657 | 657 | ); |
| 658 | - return $labels[ $link ]; |
|
| 658 | + return $labels[$link]; |
|
| 659 | 659 | } |
| 660 | 660 | |
| 661 | 661 | private function current_url() { |
@@ -746,7 +746,7 @@ discard block |
||
| 746 | 746 | |
| 747 | 747 | // If the primary column doesn't exist fall back to the |
| 748 | 748 | // first non-checkbox column. |
| 749 | - if ( ! isset( $columns[ $default ] ) ) { |
|
| 749 | + if ( ! isset( $columns[$default] ) ) { |
|
| 750 | 750 | $default = self::get_default_primary_column_name(); |
| 751 | 751 | } |
| 752 | 752 | |
@@ -760,7 +760,7 @@ discard block |
||
| 760 | 760 | */ |
| 761 | 761 | $column = apply_filters( 'list_table_primary_column', $default, $this->screen->id ); |
| 762 | 762 | |
| 763 | - if ( empty( $column ) || ! isset( $columns[ $column ] ) ) { |
|
| 763 | + if ( empty( $column ) || ! isset( $columns[$column] ) ) { |
|
| 764 | 764 | $column = $default; |
| 765 | 765 | } |
| 766 | 766 | |
@@ -782,7 +782,7 @@ discard block |
||
| 782 | 782 | // In 4.3, we added a fourth argument for primary column. |
| 783 | 783 | $column_headers = array( array(), array(), array(), $this->get_primary_column_name() ); |
| 784 | 784 | foreach ( $this->_column_headers as $key => $value ) { |
| 785 | - $column_headers[ $key ] = $value; |
|
| 785 | + $column_headers[$key] = $value; |
|
| 786 | 786 | } |
| 787 | 787 | |
| 788 | 788 | return $column_headers; |
@@ -815,7 +815,7 @@ discard block |
||
| 815 | 815 | $data[1] = false; |
| 816 | 816 | } |
| 817 | 817 | |
| 818 | - $sortable[ $id ] = $data; |
|
| 818 | + $sortable[$id] = $data; |
|
| 819 | 819 | } |
| 820 | 820 | |
| 821 | 821 | $primary = $this->get_primary_column_name(); |
@@ -870,7 +870,7 @@ discard block |
||
| 870 | 870 | static $cb_counter = 1; |
| 871 | 871 | $columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __( 'Select All', 'formidable' ) . '</label>' |
| 872 | 872 | . '<input id="cb-select-all-' . esc_attr( $cb_counter ) . '" type="checkbox" />'; |
| 873 | - $cb_counter++; |
|
| 873 | + $cb_counter ++; |
|
| 874 | 874 | } |
| 875 | 875 | |
| 876 | 876 | foreach ( $columns as $column_key => $column_display_name ) { |
@@ -890,8 +890,8 @@ discard block |
||
| 890 | 890 | $class[] = 'column-primary'; |
| 891 | 891 | } |
| 892 | 892 | |
| 893 | - if ( isset( $sortable[ $column_key ] ) ) { |
|
| 894 | - list( $orderby, $desc_first ) = $sortable[ $column_key ]; |
|
| 893 | + if ( isset( $sortable[$column_key] ) ) { |
|
| 894 | + list( $orderby, $desc_first ) = $sortable[$column_key]; |
|
| 895 | 895 | |
| 896 | 896 | if ( $current_orderby == $orderby ) { |
| 897 | 897 | $order = 'asc' == $current_order ? 'desc' : 'asc'; |
@@ -227,6 +227,9 @@ discard block |
||
| 227 | 227 | $this->delete_cache(); |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | + /** |
|
| 231 | + * @param string|false $is_active |
|
| 232 | + */ |
|
| 230 | 233 | public function set_active( $is_active ) { |
| 231 | 234 | update_option( $this->option_name . 'active', $is_active ); |
| 232 | 235 | $this->delete_cache(); |
@@ -341,6 +344,7 @@ discard block |
||
| 341 | 344 | * Get the API info for this plugin |
| 342 | 345 | * |
| 343 | 346 | * @since 3.04.03 |
| 347 | + * @param string $license |
|
| 344 | 348 | */ |
| 345 | 349 | protected function get_api_info( $license ) { |
| 346 | 350 | $api = new FrmFormApi( $license ); |
@@ -569,6 +573,9 @@ discard block |
||
| 569 | 573 | wp_die(); |
| 570 | 574 | } |
| 571 | 575 | |
| 576 | + /** |
|
| 577 | + * @param string $action |
|
| 578 | + */ |
|
| 572 | 579 | public function send_mothership_request( $action ) { |
| 573 | 580 | $api_params = array( |
| 574 | 581 | 'edd_action' => $action, |
@@ -41,15 +41,15 @@ discard block |
||
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | public function insert_installed_addon( $plugins ) { |
| 44 | - $plugins[ $this->plugin_slug ] = $this; |
|
| 44 | + $plugins[$this->plugin_slug] = $this; |
|
| 45 | 45 | return $plugins; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | public static function get_addon( $plugin_slug ) { |
| 49 | 49 | $plugins = apply_filters( 'frm_installed_addons', array() ); |
| 50 | 50 | $plugin = false; |
| 51 | - if ( isset( $plugins[ $plugin_slug ] ) ) { |
|
| 52 | - $plugin = $plugins[ $plugin_slug ]; |
|
| 51 | + if ( isset( $plugins[$plugin_slug] ) ) { |
|
| 52 | + $plugin = $plugins[$plugin_slug]; |
|
| 53 | 53 | } |
| 54 | 54 | return $plugin; |
| 55 | 55 | } |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | } else { |
| 107 | 107 | $api = new FrmFormApi( $this->license ); |
| 108 | 108 | $plugins = $api->get_api_info(); |
| 109 | - $_data = $plugins[ $item_id ]; |
|
| 109 | + $_data = $plugins[$item_id]; |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | $_data['sections'] = array( |
@@ -290,19 +290,19 @@ discard block |
||
| 290 | 290 | |
| 291 | 291 | if ( $this->is_current_version( $transient ) ) { |
| 292 | 292 | //make sure it doesn't show there is an update if plugin is up-to-date |
| 293 | - if ( isset( $transient->response[ $this->plugin_folder ] ) ) { |
|
| 294 | - unset( $transient->response[ $this->plugin_folder ] ); |
|
| 293 | + if ( isset( $transient->response[$this->plugin_folder] ) ) { |
|
| 294 | + unset( $transient->response[$this->plugin_folder] ); |
|
| 295 | 295 | } |
| 296 | - } elseif ( isset( $transient->response ) && isset( $transient->response[ $this->plugin_folder ] ) ) { |
|
| 297 | - $this->prepare_update_details( $transient->response[ $this->plugin_folder ] ); |
|
| 296 | + } elseif ( isset( $transient->response ) && isset( $transient->response[$this->plugin_folder] ) ) { |
|
| 297 | + $this->prepare_update_details( $transient->response[$this->plugin_folder] ); |
|
| 298 | 298 | |
| 299 | 299 | // if the transient has expired, clear the update and trigger it again |
| 300 | - if ( $transient->response[ $this->plugin_folder ] === false ) { |
|
| 300 | + if ( $transient->response[$this->plugin_folder] === false ) { |
|
| 301 | 301 | if ( ! $this->has_been_cleared() ) { |
| 302 | 302 | $this->cleared_plugins(); |
| 303 | 303 | $this->manually_queue_update(); |
| 304 | 304 | } |
| 305 | - unset( $transient->response[ $this->plugin_folder ] ); |
|
| 305 | + unset( $transient->response[$this->plugin_folder] ); |
|
| 306 | 306 | } |
| 307 | 307 | } |
| 308 | 308 | |
@@ -384,13 +384,13 @@ discard block |
||
| 384 | 384 | $version_info->new_version = $version_info->beta['version']; |
| 385 | 385 | $version_info->package = $version_info->beta['package']; |
| 386 | 386 | if ( isset( $version_info->plugin ) && ! empty( $version_info->plugin ) ) { |
| 387 | - $version_info->plugin = $version_info->beta['plugin']; |
|
| 387 | + $version_info->plugin = $version_info->beta['plugin']; |
|
| 388 | 388 | } |
| 389 | 389 | } |
| 390 | 390 | } |
| 391 | 391 | |
| 392 | 392 | private function is_current_version( $transient ) { |
| 393 | - if ( empty( $transient->checked ) || ! isset( $transient->checked[ $this->plugin_folder ] ) ) { |
|
| 393 | + if ( empty( $transient->checked ) || ! isset( $transient->checked[$this->plugin_folder] ) ) { |
|
| 394 | 394 | return false; |
| 395 | 395 | } |
| 396 | 396 | |
@@ -399,7 +399,7 @@ discard block |
||
| 399 | 399 | return true; |
| 400 | 400 | } |
| 401 | 401 | |
| 402 | - return isset( $transient->response ) && isset( $transient->response[ $this->plugin_folder ] ) && $transient->checked[ $this->plugin_folder ] === $transient->response[ $this->plugin_folder ]->new_version; |
|
| 402 | + return isset( $transient->response ) && isset( $transient->response[$this->plugin_folder] ) && $transient->checked[$this->plugin_folder] === $transient->response[$this->plugin_folder]->new_version; |
|
| 403 | 403 | } |
| 404 | 404 | |
| 405 | 405 | private function has_been_cleared() { |
@@ -479,8 +479,8 @@ discard block |
||
| 479 | 479 | $response['message'] = $response['status']; |
| 480 | 480 | } else { |
| 481 | 481 | $messages = $this->get_messages(); |
| 482 | - if ( is_string( $response['status'] ) && isset( $messages[ $response['status'] ] ) ) { |
|
| 483 | - $response['message'] = $messages[ $response['status'] ]; |
|
| 482 | + if ( is_string( $response['status'] ) && isset( $messages[$response['status']] ) ) { |
|
| 483 | + $response['message'] = $messages[$response['status']]; |
|
| 484 | 484 | } else { |
| 485 | 485 | $response['message'] = FrmAppHelper::kses( $response['status'], array( 'a' ) ); |
| 486 | 486 | } |
@@ -1,12 +1,12 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | if ( ! isset( $entry ) ) { |
| 3 | - $entry = $record; |
|
| 3 | + $entry = $record; |
|
| 4 | 4 | } ?> |
| 5 | 5 | |
| 6 | 6 | <div class="misc-pub-section curtime misc-pub-curtime"> |
| 7 | 7 | <span id="timestamp"> |
| 8 | 8 | <?php |
| 9 | - $date_format = __( 'M j, Y @ G:i', 'formidable' ); |
|
| 9 | + $date_format = __( 'M j, Y @ G:i', 'formidable' ); |
|
| 10 | 10 | printf( esc_html__( 'Published on: %1$s', 'formidable' ), '<b>' . esc_html( FrmAppHelper::get_localized_date( $date_format, $entry->created_at ) ) . '</b>' ); |
| 11 | 11 | ?> |
| 12 | 12 | </span> |
@@ -102,7 +102,7 @@ |
||
| 102 | 102 | esc_html__( 'License plan required: %s', 'formidable' ), |
| 103 | 103 | '<a href="' . esc_url( $pricing ) . '" target="_blank" rel="noopener">' . esc_html( $category ) . '</a>' |
| 104 | 104 | ); |
| 105 | - unset( $template['categories'][ $k ] ); |
|
| 105 | + unset( $template['categories'][$k] ); |
|
| 106 | 106 | break; |
| 107 | 107 | } |
| 108 | 108 | } |
@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | class FrmFormsController { |
| 4 | 4 | |
| 5 | - public static function menu() { |
|
| 5 | + public static function menu() { |
|
| 6 | 6 | $menu_label = __( 'Forms', 'formidable' ); |
| 7 | 7 | if ( ! FrmAppHelper::pro_is_installed() ) { |
| 8 | 8 | $menu_label .= ' (Lite)'; |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | add_submenu_page( 'formidable', 'Formidable | ' . $menu_label, $menu_label, 'frm_view_forms', 'formidable', 'FrmFormsController::route' ); |
| 11 | 11 | |
| 12 | 12 | self::maybe_load_listing_hooks(); |
| 13 | - } |
|
| 13 | + } |
|
| 14 | 14 | |
| 15 | 15 | public static function maybe_load_listing_hooks() { |
| 16 | 16 | $action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ); |
@@ -24,13 +24,13 @@ discard block |
||
| 24 | 24 | add_filter( 'manage_toplevel_page_formidable_sortable_columns', 'FrmFormsController::get_sortable_columns' ); |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - public static function head() { |
|
| 27 | + public static function head() { |
|
| 28 | 28 | wp_enqueue_script( 'formidable-editinplace' ); |
| 29 | 29 | |
| 30 | - if ( wp_is_mobile() ) { |
|
| 31 | - wp_enqueue_script( 'jquery-touch-punch' ); |
|
| 32 | - } |
|
| 33 | - } |
|
| 30 | + if ( wp_is_mobile() ) { |
|
| 31 | + wp_enqueue_script( 'jquery-touch-punch' ); |
|
| 32 | + } |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | 35 | public static function register_widgets() { |
| 36 | 36 | require_once( FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php' ); |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | public static function new_form( $values = array() ) { |
| 71 | 71 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 72 | 72 | |
| 73 | - global $frm_vars; |
|
| 73 | + global $frm_vars; |
|
| 74 | 74 | |
| 75 | 75 | $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
| 76 | 76 | $action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[ $action ]; |
@@ -81,17 +81,17 @@ discard block |
||
| 81 | 81 | } else if ( $action == 'new' ) { |
| 82 | 82 | $frm_field_selection = FrmField::field_selection(); |
| 83 | 83 | $values = FrmFormsHelper::setup_new_vars( $values ); |
| 84 | - $id = FrmForm::create( $values ); |
|
| 84 | + $id = FrmForm::create( $values ); |
|
| 85 | 85 | $form = FrmForm::getOne( $id ); |
| 86 | 86 | |
| 87 | 87 | self::create_default_email_action( $form ); |
| 88 | 88 | |
| 89 | 89 | $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' ); |
| 90 | 90 | |
| 91 | - $values['id'] = $id; |
|
| 91 | + $values['id'] = $id; |
|
| 92 | 92 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' ); |
| 93 | - } |
|
| 94 | - } |
|
| 93 | + } |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | 96 | /** |
| 97 | 97 | * Create the default email action |
@@ -100,41 +100,41 @@ discard block |
||
| 100 | 100 | * |
| 101 | 101 | * @param object $form |
| 102 | 102 | */ |
| 103 | - private static function create_default_email_action( $form ) { |
|
| 104 | - $create_email = apply_filters( 'frm_create_default_email_action', true, $form ); |
|
| 103 | + private static function create_default_email_action( $form ) { |
|
| 104 | + $create_email = apply_filters( 'frm_create_default_email_action', true, $form ); |
|
| 105 | 105 | |
| 106 | - if ( $create_email ) { |
|
| 107 | - $action_control = FrmFormActionsController::get_form_actions( 'email' ); |
|
| 108 | - $action_control->create( $form->id ); |
|
| 109 | - } |
|
| 110 | - } |
|
| 106 | + if ( $create_email ) { |
|
| 107 | + $action_control = FrmFormActionsController::get_form_actions( 'email' ); |
|
| 108 | + $action_control->create( $form->id ); |
|
| 109 | + } |
|
| 110 | + } |
|
| 111 | 111 | |
| 112 | 112 | public static function create( $values = array() ) { |
| 113 | 113 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 114 | 114 | |
| 115 | - global $frm_vars; |
|
| 116 | - if ( empty( $values ) ) { |
|
| 117 | - $values = $_POST; |
|
| 118 | - } |
|
| 115 | + global $frm_vars; |
|
| 116 | + if ( empty( $values ) ) { |
|
| 117 | + $values = $_POST; |
|
| 118 | + } |
|
| 119 | 119 | |
| 120 | - //Set radio button and checkbox meta equal to "other" value |
|
| 121 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
| 122 | - $values = FrmProEntry::mod_other_vals( $values, 'back' ); |
|
| 123 | - } |
|
| 120 | + //Set radio button and checkbox meta equal to "other" value |
|
| 121 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
| 122 | + $values = FrmProEntry::mod_other_vals( $values, 'back' ); |
|
| 123 | + } |
|
| 124 | 124 | |
| 125 | 125 | $id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
| 126 | 126 | |
| 127 | - if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) { |
|
| 128 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 129 | - $errors = array( 'form' => $frm_settings->admin_permission ); |
|
| 130 | - } else { |
|
| 127 | + if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) { |
|
| 128 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 129 | + $errors = array( 'form' => $frm_settings->admin_permission ); |
|
| 130 | + } else { |
|
| 131 | 131 | $errors = FrmForm::validate( $values ); |
| 132 | - } |
|
| 132 | + } |
|
| 133 | 133 | |
| 134 | 134 | if ( count( $errors ) > 0 ) { |
| 135 | - $hide_preview = true; |
|
| 135 | + $hide_preview = true; |
|
| 136 | 136 | $frm_field_selection = FrmField::field_selection(); |
| 137 | - $form = FrmForm::getOne( $id ); |
|
| 137 | + $form = FrmForm::getOne( $id ); |
|
| 138 | 138 | $fields = FrmField::get_all_for_form( $id ); |
| 139 | 139 | |
| 140 | 140 | $values = FrmAppHelper::setup_edit_vars( $form, 'forms', '', true ); |
@@ -142,30 +142,30 @@ discard block |
||
| 142 | 142 | $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' ); |
| 143 | 143 | |
| 144 | 144 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' ); |
| 145 | - } else { |
|
| 146 | - FrmForm::update( $id, $values, true ); |
|
| 145 | + } else { |
|
| 146 | + FrmForm::update( $id, $values, true ); |
|
| 147 | 147 | $url = admin_url( 'admin.php?page=formidable&frm_action=settings&id=' . $id ); |
| 148 | 148 | die( FrmAppHelper::js_redirect( $url ) ); // WPCS: XSS ok. |
| 149 | - } |
|
| 150 | - } |
|
| 149 | + } |
|
| 150 | + } |
|
| 151 | 151 | |
| 152 | - public static function edit( $values = false ) { |
|
| 152 | + public static function edit( $values = false ) { |
|
| 153 | 153 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 154 | 154 | |
| 155 | 155 | $id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
| 156 | 156 | return self::get_edit_vars( $id ); |
| 157 | - } |
|
| 157 | + } |
|
| 158 | 158 | |
| 159 | - public static function settings( $id = false, $message = '' ) { |
|
| 159 | + public static function settings( $id = false, $message = '' ) { |
|
| 160 | 160 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 161 | 161 | |
| 162 | 162 | if ( ! $id || ! is_numeric( $id ) ) { |
| 163 | 163 | $id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
| 164 | - } |
|
| 164 | + } |
|
| 165 | 165 | return self::get_settings_vars( $id, array(), $message ); |
| 166 | - } |
|
| 166 | + } |
|
| 167 | 167 | |
| 168 | - public static function update_settings() { |
|
| 168 | + public static function update_settings() { |
|
| 169 | 169 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 170 | 170 | |
| 171 | 171 | $id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
@@ -179,39 +179,39 @@ discard block |
||
| 179 | 179 | |
| 180 | 180 | FrmForm::update( $id, $_POST ); |
| 181 | 181 | |
| 182 | - $message = __( 'Settings Successfully Updated', 'formidable' ); |
|
| 182 | + $message = __( 'Settings Successfully Updated', 'formidable' ); |
|
| 183 | 183 | return self::get_settings_vars( $id, array(), $message ); |
| 184 | - } |
|
| 184 | + } |
|
| 185 | 185 | |
| 186 | 186 | public static function update( $values = array() ) { |
| 187 | 187 | if ( empty( $values ) ) { |
| 188 | - $values = $_POST; |
|
| 189 | - } |
|
| 188 | + $values = $_POST; |
|
| 189 | + } |
|
| 190 | 190 | |
| 191 | - //Set radio button and checkbox meta equal to "other" value |
|
| 192 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
| 193 | - $values = FrmProEntry::mod_other_vals( $values, 'back' ); |
|
| 194 | - } |
|
| 191 | + //Set radio button and checkbox meta equal to "other" value |
|
| 192 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
| 193 | + $values = FrmProEntry::mod_other_vals( $values, 'back' ); |
|
| 194 | + } |
|
| 195 | 195 | |
| 196 | - $errors = FrmForm::validate( $values ); |
|
| 197 | - $permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'frm_save_form', 'frm_save_form_nonce' ); |
|
| 198 | - if ( $permission_error !== false ) { |
|
| 199 | - $errors['form'] = $permission_error; |
|
| 200 | - } |
|
| 196 | + $errors = FrmForm::validate( $values ); |
|
| 197 | + $permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'frm_save_form', 'frm_save_form_nonce' ); |
|
| 198 | + if ( $permission_error !== false ) { |
|
| 199 | + $errors['form'] = $permission_error; |
|
| 200 | + } |
|
| 201 | 201 | |
| 202 | 202 | $id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
| 203 | 203 | |
| 204 | 204 | if ( count( $errors ) > 0 ) { |
| 205 | - return self::get_edit_vars( $id, $errors ); |
|
| 205 | + return self::get_edit_vars( $id, $errors ); |
|
| 206 | 206 | } else { |
| 207 | - FrmForm::update( $id, $values ); |
|
| 208 | - $message = __( 'Form was Successfully Updated', 'formidable' ); |
|
| 209 | - if ( defined( 'DOING_AJAX' ) ) { |
|
| 207 | + FrmForm::update( $id, $values ); |
|
| 208 | + $message = __( 'Form was Successfully Updated', 'formidable' ); |
|
| 209 | + if ( defined( 'DOING_AJAX' ) ) { |
|
| 210 | 210 | wp_die( esc_html( $message ) ); |
| 211 | - } |
|
| 211 | + } |
|
| 212 | 212 | return self::get_edit_vars( $id, array(), $message ); |
| 213 | - } |
|
| 214 | - } |
|
| 213 | + } |
|
| 214 | + } |
|
| 215 | 215 | |
| 216 | 216 | /** |
| 217 | 217 | * Redirect to the url for creating from a template |
@@ -234,30 +234,30 @@ discard block |
||
| 234 | 234 | wp_die(); |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | - public static function duplicate() { |
|
| 237 | + public static function duplicate() { |
|
| 238 | 238 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 239 | 239 | |
| 240 | 240 | $params = FrmForm::list_page_params(); |
| 241 | - $form = FrmForm::duplicate( $params['id'], $params['template'], true ); |
|
| 242 | - $message = $params['template'] ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' ); |
|
| 243 | - if ( $form ) { |
|
| 241 | + $form = FrmForm::duplicate( $params['id'], $params['template'], true ); |
|
| 242 | + $message = $params['template'] ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' ); |
|
| 243 | + if ( $form ) { |
|
| 244 | 244 | return self::get_edit_vars( $form, array(), $message, true ); |
| 245 | - } else { |
|
| 245 | + } else { |
|
| 246 | 246 | return self::display_forms_list( $params, __( 'There was a problem creating the new template.', 'formidable' ) ); |
| 247 | - } |
|
| 248 | - } |
|
| 247 | + } |
|
| 248 | + } |
|
| 249 | 249 | |
| 250 | - public static function page_preview() { |
|
| 250 | + public static function page_preview() { |
|
| 251 | 251 | $params = FrmForm::list_page_params(); |
| 252 | - if ( ! $params['form'] ) { |
|
| 253 | - return; |
|
| 254 | - } |
|
| 252 | + if ( ! $params['form'] ) { |
|
| 253 | + return; |
|
| 254 | + } |
|
| 255 | 255 | |
| 256 | - $form = FrmForm::getOne( $params['form'] ); |
|
| 256 | + $form = FrmForm::getOne( $params['form'] ); |
|
| 257 | 257 | if ( $form ) { |
| 258 | 258 | return self::show_form( $form->id, '', true, true ); |
| 259 | 259 | } |
| 260 | - } |
|
| 260 | + } |
|
| 261 | 261 | |
| 262 | 262 | /** |
| 263 | 263 | * @since 3.0 |
@@ -266,11 +266,11 @@ discard block |
||
| 266 | 266 | echo self::page_preview(); // WPCS: XSS ok. |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | - public static function preview() { |
|
| 270 | - do_action( 'frm_wp' ); |
|
| 269 | + public static function preview() { |
|
| 270 | + do_action( 'frm_wp' ); |
|
| 271 | 271 | |
| 272 | - global $frm_vars; |
|
| 273 | - $frm_vars['preview'] = true; |
|
| 272 | + global $frm_vars; |
|
| 273 | + $frm_vars['preview'] = true; |
|
| 274 | 274 | |
| 275 | 275 | self::load_wp(); |
| 276 | 276 | |
@@ -384,18 +384,18 @@ discard block |
||
| 384 | 384 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/direct.php' ); |
| 385 | 385 | } |
| 386 | 386 | |
| 387 | - public static function untrash() { |
|
| 387 | + public static function untrash() { |
|
| 388 | 388 | self::change_form_status( 'untrash' ); |
| 389 | - } |
|
| 389 | + } |
|
| 390 | 390 | |
| 391 | 391 | public static function bulk_untrash( $ids ) { |
| 392 | 392 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 393 | 393 | |
| 394 | - $count = FrmForm::set_status( $ids, 'published' ); |
|
| 394 | + $count = FrmForm::set_status( $ids, 'published' ); |
|
| 395 | 395 | |
| 396 | 396 | $message = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 ); |
| 397 | - return $message; |
|
| 398 | - } |
|
| 397 | + return $message; |
|
| 398 | + } |
|
| 399 | 399 | |
| 400 | 400 | /** |
| 401 | 401 | * @since 3.06 |
@@ -408,9 +408,9 @@ discard block |
||
| 408 | 408 | wp_die(); |
| 409 | 409 | } |
| 410 | 410 | |
| 411 | - public static function trash() { |
|
| 411 | + public static function trash() { |
|
| 412 | 412 | self::change_form_status( 'trash' ); |
| 413 | - } |
|
| 413 | + } |
|
| 414 | 414 | |
| 415 | 415 | /** |
| 416 | 416 | * @param string $status |
@@ -463,12 +463,12 @@ discard block |
||
| 463 | 463 | public static function bulk_trash( $ids ) { |
| 464 | 464 | FrmAppHelper::permission_check( 'frm_delete_forms' ); |
| 465 | 465 | |
| 466 | - $count = 0; |
|
| 467 | - foreach ( $ids as $id ) { |
|
| 468 | - if ( FrmForm::trash( $id ) ) { |
|
| 469 | - $count++; |
|
| 470 | - } |
|
| 471 | - } |
|
| 466 | + $count = 0; |
|
| 467 | + foreach ( $ids as $id ) { |
|
| 468 | + if ( FrmForm::trash( $id ) ) { |
|
| 469 | + $count++; |
|
| 470 | + } |
|
| 471 | + } |
|
| 472 | 472 | |
| 473 | 473 | $current_page = FrmAppHelper::get_simple_request( |
| 474 | 474 | array( |
@@ -483,56 +483,56 @@ discard block |
||
| 483 | 483 | '</a>' |
| 484 | 484 | ); |
| 485 | 485 | |
| 486 | - return $message; |
|
| 487 | - } |
|
| 486 | + return $message; |
|
| 487 | + } |
|
| 488 | 488 | |
| 489 | - public static function destroy() { |
|
| 489 | + public static function destroy() { |
|
| 490 | 490 | FrmAppHelper::permission_check( 'frm_delete_forms' ); |
| 491 | 491 | |
| 492 | 492 | $params = FrmForm::list_page_params(); |
| 493 | 493 | |
| 494 | - //check nonce url |
|
| 494 | + //check nonce url |
|
| 495 | 495 | check_admin_referer( 'destroy_form_' . $params['id'] ); |
| 496 | 496 | |
| 497 | - $count = 0; |
|
| 498 | - if ( FrmForm::destroy( $params['id'] ) ) { |
|
| 499 | - $count++; |
|
| 500 | - } |
|
| 497 | + $count = 0; |
|
| 498 | + if ( FrmForm::destroy( $params['id'] ) ) { |
|
| 499 | + $count++; |
|
| 500 | + } |
|
| 501 | 501 | |
| 502 | 502 | $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count ); |
| 503 | 503 | |
| 504 | 504 | self::display_forms_list( $params, $message ); |
| 505 | - } |
|
| 505 | + } |
|
| 506 | 506 | |
| 507 | 507 | public static function bulk_destroy( $ids ) { |
| 508 | 508 | FrmAppHelper::permission_check( 'frm_delete_forms' ); |
| 509 | 509 | |
| 510 | - $count = 0; |
|
| 511 | - foreach ( $ids as $id ) { |
|
| 512 | - $d = FrmForm::destroy( $id ); |
|
| 513 | - if ( $d ) { |
|
| 514 | - $count++; |
|
| 515 | - } |
|
| 516 | - } |
|
| 510 | + $count = 0; |
|
| 511 | + foreach ( $ids as $id ) { |
|
| 512 | + $d = FrmForm::destroy( $id ); |
|
| 513 | + if ( $d ) { |
|
| 514 | + $count++; |
|
| 515 | + } |
|
| 516 | + } |
|
| 517 | 517 | |
| 518 | 518 | $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count ); |
| 519 | 519 | |
| 520 | - return $message; |
|
| 521 | - } |
|
| 520 | + return $message; |
|
| 521 | + } |
|
| 522 | 522 | |
| 523 | - private static function delete_all() { |
|
| 524 | - //check nonce url |
|
| 523 | + private static function delete_all() { |
|
| 524 | + //check nonce url |
|
| 525 | 525 | $permission_error = FrmAppHelper::permission_nonce_error( 'frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable' ); |
| 526 | - if ( $permission_error !== false ) { |
|
| 526 | + if ( $permission_error !== false ) { |
|
| 527 | 527 | self::display_forms_list( array(), '', array( $permission_error ) ); |
| 528 | - return; |
|
| 529 | - } |
|
| 528 | + return; |
|
| 529 | + } |
|
| 530 | 530 | |
| 531 | 531 | $count = FrmForm::scheduled_delete( time() ); |
| 532 | 532 | $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count ); |
| 533 | 533 | |
| 534 | 534 | self::display_forms_list( array(), $message ); |
| 535 | - } |
|
| 535 | + } |
|
| 536 | 536 | |
| 537 | 537 | /** |
| 538 | 538 | * Create a custom template from a form |
@@ -575,11 +575,11 @@ discard block |
||
| 575 | 575 | } |
| 576 | 576 | |
| 577 | 577 | /** |
| 578 | - * Inserts Formidable button |
|
| 579 | - * Hook exists since 2.5.0 |
|
| 580 | - * |
|
| 581 | - * @since 2.0.15 |
|
| 582 | - */ |
|
| 578 | + * Inserts Formidable button |
|
| 579 | + * Hook exists since 2.5.0 |
|
| 580 | + * |
|
| 581 | + * @since 2.0.15 |
|
| 582 | + */ |
|
| 583 | 583 | public static function insert_form_button() { |
| 584 | 584 | if ( current_user_can( 'frm_view_forms' ) ) { |
| 585 | 585 | $menu_name = FrmAppHelper::get_menu_name(); |
@@ -590,45 +590,45 @@ discard block |
||
| 590 | 590 | } |
| 591 | 591 | } |
| 592 | 592 | |
| 593 | - public static function insert_form_popup() { |
|
| 593 | + public static function insert_form_popup() { |
|
| 594 | 594 | $page = basename( FrmAppHelper::get_server_value( 'PHP_SELF' ) ); |
| 595 | 595 | if ( ! in_array( $page, array( 'post.php', 'page.php', 'page-new.php', 'post-new.php' ) ) ) { |
| 596 | - return; |
|
| 597 | - } |
|
| 596 | + return; |
|
| 597 | + } |
|
| 598 | 598 | |
| 599 | - FrmAppHelper::load_admin_wide_js(); |
|
| 599 | + FrmAppHelper::load_admin_wide_js(); |
|
| 600 | 600 | |
| 601 | - $shortcodes = array( |
|
| 601 | + $shortcodes = array( |
|
| 602 | 602 | 'formidable' => array( |
| 603 | 603 | 'name' => __( 'Form', 'formidable' ), |
| 604 | 604 | 'label' => __( 'Insert a Form', 'formidable' ), |
| 605 | 605 | ), |
| 606 | - ); |
|
| 606 | + ); |
|
| 607 | 607 | |
| 608 | 608 | $shortcodes = apply_filters( 'frm_popup_shortcodes', $shortcodes ); |
| 609 | 609 | |
| 610 | 610 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/insert_form_popup.php' ); |
| 611 | - } |
|
| 611 | + } |
|
| 612 | 612 | |
| 613 | - public static function get_shortcode_opts() { |
|
| 613 | + public static function get_shortcode_opts() { |
|
| 614 | 614 | FrmAppHelper::permission_check( 'frm_view_forms' ); |
| 615 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 615 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 616 | 616 | |
| 617 | 617 | $shortcode = FrmAppHelper::get_post_param( 'shortcode', '', 'sanitize_text_field' ); |
| 618 | 618 | if ( empty( $shortcode ) ) { |
| 619 | - wp_die(); |
|
| 620 | - } |
|
| 619 | + wp_die(); |
|
| 620 | + } |
|
| 621 | 621 | |
| 622 | 622 | echo '<div id="sc-opts-' . esc_attr( $shortcode ) . '" class="frm_shortcode_option">'; |
| 623 | 623 | echo '<input type="radio" name="frmsc" value="' . esc_attr( $shortcode ) . '" id="sc-' . esc_attr( $shortcode ) . '" class="frm_hidden" />'; |
| 624 | 624 | |
| 625 | - $form_id = ''; |
|
| 626 | - $opts = array(); |
|
| 625 | + $form_id = ''; |
|
| 626 | + $opts = array(); |
|
| 627 | 627 | switch ( $shortcode ) { |
| 628 | - case 'formidable': |
|
| 629 | - $opts = array( |
|
| 628 | + case 'formidable': |
|
| 629 | + $opts = array( |
|
| 630 | 630 | 'form_id' => 'id', |
| 631 | - //'key' => ', |
|
| 631 | + //'key' => ', |
|
| 632 | 632 | 'title' => array( |
| 633 | 633 | 'val' => 1, |
| 634 | 634 | 'label' => __( 'Display form title', 'formidable' ), |
@@ -641,8 +641,8 @@ discard block |
||
| 641 | 641 | 'val' => 1, |
| 642 | 642 | 'label' => __( 'Minimize form HTML', 'formidable' ), |
| 643 | 643 | ), |
| 644 | - ); |
|
| 645 | - } |
|
| 644 | + ); |
|
| 645 | + } |
|
| 646 | 646 | $opts = apply_filters( 'frm_sc_popup_opts', $opts, $shortcode ); |
| 647 | 647 | |
| 648 | 648 | if ( isset( $opts['form_id'] ) && is_string( $opts['form_id'] ) ) { |
@@ -653,38 +653,38 @@ discard block |
||
| 653 | 653 | |
| 654 | 654 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/shortcode_opts.php' ); |
| 655 | 655 | |
| 656 | - echo '</div>'; |
|
| 656 | + echo '</div>'; |
|
| 657 | 657 | |
| 658 | - wp_die(); |
|
| 659 | - } |
|
| 658 | + wp_die(); |
|
| 659 | + } |
|
| 660 | 660 | |
| 661 | 661 | public static function display_forms_list( $params = array(), $message = '', $errors = array() ) { |
| 662 | - FrmAppHelper::permission_check( 'frm_view_forms' ); |
|
| 662 | + FrmAppHelper::permission_check( 'frm_view_forms' ); |
|
| 663 | 663 | |
| 664 | - global $wpdb, $frm_vars; |
|
| 664 | + global $wpdb, $frm_vars; |
|
| 665 | 665 | |
| 666 | 666 | if ( empty( $params ) ) { |
| 667 | 667 | $params = FrmForm::list_page_params(); |
| 668 | - } |
|
| 668 | + } |
|
| 669 | 669 | |
| 670 | - $wp_list_table = new FrmFormsListHelper( compact( 'params' ) ); |
|
| 670 | + $wp_list_table = new FrmFormsListHelper( compact( 'params' ) ); |
|
| 671 | 671 | |
| 672 | - $pagenum = $wp_list_table->get_pagenum(); |
|
| 672 | + $pagenum = $wp_list_table->get_pagenum(); |
|
| 673 | 673 | |
| 674 | - $wp_list_table->prepare_items(); |
|
| 674 | + $wp_list_table->prepare_items(); |
|
| 675 | 675 | |
| 676 | - $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); |
|
| 677 | - if ( $pagenum > $total_pages && $total_pages > 0 ) { |
|
| 676 | + $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); |
|
| 677 | + if ( $pagenum > $total_pages && $total_pages > 0 ) { |
|
| 678 | 678 | wp_redirect( esc_url_raw( add_query_arg( 'paged', $total_pages ) ) ); |
| 679 | - die(); |
|
| 680 | - } |
|
| 679 | + die(); |
|
| 680 | + } |
|
| 681 | 681 | |
| 682 | 682 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/list.php' ); |
| 683 | - } |
|
| 683 | + } |
|
| 684 | 684 | |
| 685 | 685 | public static function get_columns( $columns ) { |
| 686 | - $columns['cb'] = '<input type="checkbox" />'; |
|
| 687 | - $columns['id'] = 'ID'; |
|
| 686 | + $columns['cb'] = '<input type="checkbox" />'; |
|
| 687 | + $columns['id'] = 'ID'; |
|
| 688 | 688 | |
| 689 | 689 | $type = FrmAppHelper::get_simple_request( |
| 690 | 690 | array( |
@@ -694,18 +694,18 @@ discard block |
||
| 694 | 694 | ) |
| 695 | 695 | ); |
| 696 | 696 | |
| 697 | - if ( 'template' == $type ) { |
|
| 698 | - $columns['name'] = __( 'Template Name', 'formidable' ); |
|
| 699 | - $columns['type'] = __( 'Type', 'formidable' ); |
|
| 700 | - $columns['form_key'] = __( 'Key', 'formidable' ); |
|
| 701 | - } else { |
|
| 702 | - $columns['name'] = __( 'Form Title', 'formidable' ); |
|
| 703 | - $columns['entries'] = __( 'Entries', 'formidable' ); |
|
| 704 | - $columns['form_key'] = __( 'Key', 'formidable' ); |
|
| 705 | - $columns['shortcode'] = __( 'Shortcodes', 'formidable' ); |
|
| 706 | - } |
|
| 697 | + if ( 'template' == $type ) { |
|
| 698 | + $columns['name'] = __( 'Template Name', 'formidable' ); |
|
| 699 | + $columns['type'] = __( 'Type', 'formidable' ); |
|
| 700 | + $columns['form_key'] = __( 'Key', 'formidable' ); |
|
| 701 | + } else { |
|
| 702 | + $columns['name'] = __( 'Form Title', 'formidable' ); |
|
| 703 | + $columns['entries'] = __( 'Entries', 'formidable' ); |
|
| 704 | + $columns['form_key'] = __( 'Key', 'formidable' ); |
|
| 705 | + $columns['shortcode'] = __( 'Shortcodes', 'formidable' ); |
|
| 706 | + } |
|
| 707 | 707 | |
| 708 | - $columns['created_at'] = __( 'Date', 'formidable' ); |
|
| 708 | + $columns['created_at'] = __( 'Date', 'formidable' ); |
|
| 709 | 709 | |
| 710 | 710 | add_screen_option( |
| 711 | 711 | 'per_page', |
@@ -716,7 +716,7 @@ discard block |
||
| 716 | 716 | ) |
| 717 | 717 | ); |
| 718 | 718 | |
| 719 | - return $columns; |
|
| 719 | + return $columns; |
|
| 720 | 720 | } |
| 721 | 721 | |
| 722 | 722 | public static function get_sortable_columns() { |
@@ -746,11 +746,11 @@ discard block |
||
| 746 | 746 | } |
| 747 | 747 | |
| 748 | 748 | public static function save_per_page( $save, $option, $value ) { |
| 749 | - if ( $option == 'formidable_page_formidable_per_page' ) { |
|
| 750 | - $save = (int) $value; |
|
| 751 | - } |
|
| 752 | - return $save; |
|
| 753 | - } |
|
| 749 | + if ( $option == 'formidable_page_formidable_per_page' ) { |
|
| 750 | + $save = (int) $value; |
|
| 751 | + } |
|
| 752 | + return $save; |
|
| 753 | + } |
|
| 754 | 754 | |
| 755 | 755 | /** |
| 756 | 756 | * Show the template listing page |
@@ -796,27 +796,27 @@ discard block |
||
| 796 | 796 | } |
| 797 | 797 | |
| 798 | 798 | private static function get_edit_vars( $id, $errors = array(), $message = '', $create_link = false ) { |
| 799 | - global $frm_vars; |
|
| 799 | + global $frm_vars; |
|
| 800 | 800 | |
| 801 | - $form = FrmForm::getOne( $id ); |
|
| 802 | - if ( ! $form ) { |
|
| 803 | - wp_die( esc_html__( 'You are trying to edit a form that does not exist.', 'formidable' ) ); |
|
| 804 | - } |
|
| 801 | + $form = FrmForm::getOne( $id ); |
|
| 802 | + if ( ! $form ) { |
|
| 803 | + wp_die( esc_html__( 'You are trying to edit a form that does not exist.', 'formidable' ) ); |
|
| 804 | + } |
|
| 805 | 805 | |
| 806 | - if ( $form->parent_form_id ) { |
|
| 806 | + if ( $form->parent_form_id ) { |
|
| 807 | 807 | wp_die( sprintf( esc_html__( 'You are trying to edit a child form. Please edit from %1$shere%2$s', 'formidable' ), '<a href="' . esc_url( admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form->parent_form_id ) ) . '">', '</a>' ) ); |
| 808 | - } |
|
| 808 | + } |
|
| 809 | 809 | |
| 810 | 810 | $frm_field_selection = FrmField::field_selection(); |
| 811 | 811 | $fields = FrmField::get_all_for_form( $form->id ); |
| 812 | 812 | |
| 813 | - // Automatically add end section fields if they don't exist (2.0 migration) |
|
| 814 | - $reset_fields = false; |
|
| 815 | - FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields ); |
|
| 813 | + // Automatically add end section fields if they don't exist (2.0 migration) |
|
| 814 | + $reset_fields = false; |
|
| 815 | + FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields ); |
|
| 816 | 816 | |
| 817 | - if ( $reset_fields ) { |
|
| 818 | - $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' ); |
|
| 819 | - } |
|
| 817 | + if ( $reset_fields ) { |
|
| 818 | + $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' ); |
|
| 819 | + } |
|
| 820 | 820 | |
| 821 | 821 | unset( $end_section_values, $last_order, $open, $reset_fields ); |
| 822 | 822 | |
@@ -824,30 +824,30 @@ discard block |
||
| 824 | 824 | $values = FrmAppHelper::setup_edit_vars( $form, 'forms', '', true, array(), $args ); |
| 825 | 825 | $values['fields'] = $fields; |
| 826 | 826 | |
| 827 | - $edit_message = __( 'Form was Successfully Updated', 'formidable' ); |
|
| 828 | - if ( $form->is_template && $message == $edit_message ) { |
|
| 829 | - $message = __( 'Template was Successfully Updated', 'formidable' ); |
|
| 830 | - } |
|
| 827 | + $edit_message = __( 'Form was Successfully Updated', 'formidable' ); |
|
| 828 | + if ( $form->is_template && $message == $edit_message ) { |
|
| 829 | + $message = __( 'Template was Successfully Updated', 'formidable' ); |
|
| 830 | + } |
|
| 831 | 831 | |
| 832 | 832 | $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' ); |
| 833 | 833 | |
| 834 | - if ( $form->default_template ) { |
|
| 834 | + if ( $form->default_template ) { |
|
| 835 | 835 | wp_die( esc_html__( 'That template cannot be edited', 'formidable' ) ); |
| 836 | 836 | } elseif ( defined( 'DOING_AJAX' ) ) { |
| 837 | - wp_die(); |
|
| 838 | - } else if ( $create_link ) { |
|
| 837 | + wp_die(); |
|
| 838 | + } else if ( $create_link ) { |
|
| 839 | 839 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' ); |
| 840 | - } else { |
|
| 840 | + } else { |
|
| 841 | 841 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/edit.php' ); |
| 842 | - } |
|
| 843 | - } |
|
| 842 | + } |
|
| 843 | + } |
|
| 844 | 844 | |
| 845 | 845 | public static function get_settings_vars( $id, $errors = array(), $message = '' ) { |
| 846 | 846 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 847 | 847 | |
| 848 | - global $frm_vars; |
|
| 848 | + global $frm_vars; |
|
| 849 | 849 | |
| 850 | - $form = FrmForm::getOne( $id ); |
|
| 850 | + $form = FrmForm::getOne( $id ); |
|
| 851 | 851 | |
| 852 | 852 | $fields = FrmField::get_all_for_form( $id ); |
| 853 | 853 | $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true ); |
@@ -858,17 +858,17 @@ discard block |
||
| 858 | 858 | |
| 859 | 859 | self::clean_submit_html( $values ); |
| 860 | 860 | |
| 861 | - $action_controls = FrmFormActionsController::get_form_actions(); |
|
| 861 | + $action_controls = FrmFormActionsController::get_form_actions(); |
|
| 862 | 862 | |
| 863 | 863 | $sections = apply_filters( 'frm_add_form_settings_section', array(), $values ); |
| 864 | - $pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"'; |
|
| 864 | + $pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"'; |
|
| 865 | 865 | |
| 866 | 866 | $styles = apply_filters( 'frm_get_style_opts', array() ); |
| 867 | 867 | |
| 868 | 868 | $first_h3 = 'frm_first_h3'; |
| 869 | 869 | |
| 870 | 870 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings.php' ); |
| 871 | - } |
|
| 871 | + } |
|
| 872 | 872 | |
| 873 | 873 | /** |
| 874 | 874 | * Replace old Submit Button href with new href to avoid errors in Chrome |
@@ -883,10 +883,10 @@ discard block |
||
| 883 | 883 | } |
| 884 | 884 | } |
| 885 | 885 | |
| 886 | - public static function mb_tags_box( $form_id, $class = '' ) { |
|
| 886 | + public static function mb_tags_box( $form_id, $class = '' ) { |
|
| 887 | 887 | $fields = FrmField::get_all_for_form( $form_id, '', 'include' ); |
| 888 | - $linked_forms = array(); |
|
| 889 | - $col = 'one'; |
|
| 888 | + $linked_forms = array(); |
|
| 889 | + $col = 'one'; |
|
| 890 | 890 | $settings_tab = FrmAppHelper::is_admin_page( 'formidable' ) ? true : false; |
| 891 | 891 | |
| 892 | 892 | $cond_shortcodes = apply_filters( 'frm_conditional_shortcodes', array() ); |
@@ -895,7 +895,7 @@ discard block |
||
| 895 | 895 | $advanced_helpers = self::advanced_helpers( compact( 'fields', 'form_id' ) ); |
| 896 | 896 | |
| 897 | 897 | include( FrmAppHelper::plugin_path() . '/classes/views/shared/mb_adv_info.php' ); |
| 898 | - } |
|
| 898 | + } |
|
| 899 | 899 | |
| 900 | 900 | /** |
| 901 | 901 | * @since 3.04.01 |
@@ -989,7 +989,7 @@ discard block |
||
| 989 | 989 | '' => '', |
| 990 | 990 | 'siteurl' => __( 'Site URL', 'formidable' ), |
| 991 | 991 | 'sitename' => __( 'Site Name', 'formidable' ), |
| 992 | - ); |
|
| 992 | + ); |
|
| 993 | 993 | |
| 994 | 994 | if ( ! FrmAppHelper::pro_is_installed() ) { |
| 995 | 995 | unset( $entry_shortcodes['post_id'] ); |
@@ -1039,21 +1039,21 @@ discard block |
||
| 1039 | 1039 | wp_die(); |
| 1040 | 1040 | } |
| 1041 | 1041 | |
| 1042 | - public static function filter_content( $content, $form, $entry = false ) { |
|
| 1042 | + public static function filter_content( $content, $form, $entry = false ) { |
|
| 1043 | 1043 | self::get_entry_by_param( $entry ); |
| 1044 | - if ( ! $entry ) { |
|
| 1045 | - return $content; |
|
| 1046 | - } |
|
| 1044 | + if ( ! $entry ) { |
|
| 1045 | + return $content; |
|
| 1046 | + } |
|
| 1047 | 1047 | |
| 1048 | - if ( is_object( $form ) ) { |
|
| 1049 | - $form = $form->id; |
|
| 1050 | - } |
|
| 1048 | + if ( is_object( $form ) ) { |
|
| 1049 | + $form = $form->id; |
|
| 1050 | + } |
|
| 1051 | 1051 | |
| 1052 | - $shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form ); |
|
| 1053 | - $content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes ); |
|
| 1052 | + $shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form ); |
|
| 1053 | + $content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes ); |
|
| 1054 | 1054 | |
| 1055 | - return $content; |
|
| 1056 | - } |
|
| 1055 | + return $content; |
|
| 1056 | + } |
|
| 1057 | 1057 | |
| 1058 | 1058 | private static function get_entry_by_param( &$entry ) { |
| 1059 | 1059 | if ( ! $entry || ! is_object( $entry ) ) { |
@@ -1065,153 +1065,153 @@ discard block |
||
| 1065 | 1065 | } |
| 1066 | 1066 | } |
| 1067 | 1067 | |
| 1068 | - public static function replace_content_shortcodes( $content, $entry, $shortcodes ) { |
|
| 1069 | - return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes ); |
|
| 1070 | - } |
|
| 1068 | + public static function replace_content_shortcodes( $content, $entry, $shortcodes ) { |
|
| 1069 | + return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes ); |
|
| 1070 | + } |
|
| 1071 | 1071 | |
| 1072 | - public static function process_bulk_form_actions( $errors ) { |
|
| 1073 | - if ( ! $_REQUEST ) { |
|
| 1074 | - return $errors; |
|
| 1075 | - } |
|
| 1072 | + public static function process_bulk_form_actions( $errors ) { |
|
| 1073 | + if ( ! $_REQUEST ) { |
|
| 1074 | + return $errors; |
|
| 1075 | + } |
|
| 1076 | 1076 | |
| 1077 | 1077 | $bulkaction = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' ); |
| 1078 | - if ( $bulkaction == -1 ) { |
|
| 1078 | + if ( $bulkaction == -1 ) { |
|
| 1079 | 1079 | $bulkaction = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' ); |
| 1080 | - } |
|
| 1080 | + } |
|
| 1081 | 1081 | |
| 1082 | - if ( ! empty( $bulkaction ) && strpos( $bulkaction, 'bulk_' ) === 0 ) { |
|
| 1083 | - FrmAppHelper::remove_get_action(); |
|
| 1082 | + if ( ! empty( $bulkaction ) && strpos( $bulkaction, 'bulk_' ) === 0 ) { |
|
| 1083 | + FrmAppHelper::remove_get_action(); |
|
| 1084 | 1084 | |
| 1085 | - $bulkaction = str_replace( 'bulk_', '', $bulkaction ); |
|
| 1086 | - } |
|
| 1085 | + $bulkaction = str_replace( 'bulk_', '', $bulkaction ); |
|
| 1086 | + } |
|
| 1087 | 1087 | |
| 1088 | 1088 | $ids = FrmAppHelper::get_param( 'item-action', '', 'get', 'sanitize_text_field' ); |
| 1089 | - if ( empty( $ids ) ) { |
|
| 1090 | - $errors[] = __( 'No forms were specified', 'formidable' ); |
|
| 1091 | - return $errors; |
|
| 1092 | - } |
|
| 1093 | - |
|
| 1094 | - $permission_error = FrmAppHelper::permission_nonce_error( '', '_wpnonce', 'bulk-toplevel_page_formidable' ); |
|
| 1095 | - if ( $permission_error !== false ) { |
|
| 1096 | - $errors[] = $permission_error; |
|
| 1097 | - return $errors; |
|
| 1098 | - } |
|
| 1099 | - |
|
| 1100 | - if ( ! is_array( $ids ) ) { |
|
| 1101 | - $ids = explode( ',', $ids ); |
|
| 1102 | - } |
|
| 1103 | - |
|
| 1104 | - switch ( $bulkaction ) { |
|
| 1105 | - case 'delete': |
|
| 1106 | - $message = self::bulk_destroy( $ids ); |
|
| 1089 | + if ( empty( $ids ) ) { |
|
| 1090 | + $errors[] = __( 'No forms were specified', 'formidable' ); |
|
| 1091 | + return $errors; |
|
| 1092 | + } |
|
| 1093 | + |
|
| 1094 | + $permission_error = FrmAppHelper::permission_nonce_error( '', '_wpnonce', 'bulk-toplevel_page_formidable' ); |
|
| 1095 | + if ( $permission_error !== false ) { |
|
| 1096 | + $errors[] = $permission_error; |
|
| 1097 | + return $errors; |
|
| 1098 | + } |
|
| 1099 | + |
|
| 1100 | + if ( ! is_array( $ids ) ) { |
|
| 1101 | + $ids = explode( ',', $ids ); |
|
| 1102 | + } |
|
| 1103 | + |
|
| 1104 | + switch ( $bulkaction ) { |
|
| 1105 | + case 'delete': |
|
| 1106 | + $message = self::bulk_destroy( $ids ); |
|
| 1107 | 1107 | break; |
| 1108 | - case 'trash': |
|
| 1109 | - $message = self::bulk_trash( $ids ); |
|
| 1108 | + case 'trash': |
|
| 1109 | + $message = self::bulk_trash( $ids ); |
|
| 1110 | 1110 | break; |
| 1111 | - case 'untrash': |
|
| 1112 | - $message = self::bulk_untrash( $ids ); |
|
| 1113 | - } |
|
| 1111 | + case 'untrash': |
|
| 1112 | + $message = self::bulk_untrash( $ids ); |
|
| 1113 | + } |
|
| 1114 | 1114 | |
| 1115 | - if ( isset( $message ) && ! empty( $message ) ) { |
|
| 1115 | + if ( isset( $message ) && ! empty( $message ) ) { |
|
| 1116 | 1116 | echo '<div id="message" class="frm_updated_message">' . FrmAppHelper::kses( $message, array( 'a' ) ) . '</div>'; // WPCS: XSS ok. |
| 1117 | - } |
|
| 1117 | + } |
|
| 1118 | 1118 | |
| 1119 | - return $errors; |
|
| 1120 | - } |
|
| 1119 | + return $errors; |
|
| 1120 | + } |
|
| 1121 | 1121 | |
| 1122 | - public static function route() { |
|
| 1122 | + public static function route() { |
|
| 1123 | 1123 | $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
| 1124 | - $vars = array(); |
|
| 1124 | + $vars = array(); |
|
| 1125 | 1125 | if ( isset( $_POST['frm_compact_fields'] ) ) { |
| 1126 | 1126 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 1127 | 1127 | |
| 1128 | 1128 | $json_vars = htmlspecialchars_decode( nl2br( stripslashes( str_replace( '"', '\\\"', $_POST['frm_compact_fields'] ) ) ) ); |
| 1129 | 1129 | $json_vars = json_decode( $json_vars, true ); |
| 1130 | 1130 | if ( empty( $json_vars ) ) { |
| 1131 | - // json decoding failed so we should return an error message |
|
| 1131 | + // json decoding failed so we should return an error message |
|
| 1132 | 1132 | $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ); |
| 1133 | - if ( 'edit' == $action ) { |
|
| 1134 | - $action = 'update'; |
|
| 1135 | - } |
|
| 1133 | + if ( 'edit' == $action ) { |
|
| 1134 | + $action = 'update'; |
|
| 1135 | + } |
|
| 1136 | 1136 | |
| 1137 | 1137 | add_filter( 'frm_validate_form', 'FrmFormsController::json_error' ); |
| 1138 | - } else { |
|
| 1138 | + } else { |
|
| 1139 | 1139 | $vars = FrmAppHelper::json_to_array( $json_vars ); |
| 1140 | - $action = $vars[ $action ]; |
|
| 1140 | + $action = $vars[ $action ]; |
|
| 1141 | 1141 | unset( $_REQUEST['frm_compact_fields'], $_POST['frm_compact_fields'] ); |
| 1142 | 1142 | $_REQUEST = array_merge( $_REQUEST, $vars ); |
| 1143 | 1143 | $_POST = array_merge( $_POST, $_REQUEST ); |
| 1144 | - } |
|
| 1145 | - } else { |
|
| 1144 | + } |
|
| 1145 | + } else { |
|
| 1146 | 1146 | $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ); |
| 1147 | - if ( isset( $_REQUEST['delete_all'] ) ) { |
|
| 1148 | - // override the action for this page |
|
| 1149 | - $action = 'delete_all'; |
|
| 1150 | - } |
|
| 1151 | - } |
|
| 1147 | + if ( isset( $_REQUEST['delete_all'] ) ) { |
|
| 1148 | + // override the action for this page |
|
| 1149 | + $action = 'delete_all'; |
|
| 1150 | + } |
|
| 1151 | + } |
|
| 1152 | 1152 | |
| 1153 | 1153 | add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' ); |
| 1154 | - FrmAppHelper::trigger_hook_load( 'form' ); |
|
| 1154 | + FrmAppHelper::trigger_hook_load( 'form' ); |
|
| 1155 | 1155 | |
| 1156 | - switch ( $action ) { |
|
| 1157 | - case 'new': |
|
| 1156 | + switch ( $action ) { |
|
| 1157 | + case 'new': |
|
| 1158 | 1158 | return self::new_form( $vars ); |
| 1159 | 1159 | case 'add_new': |
| 1160 | 1160 | case 'list_templates': |
| 1161 | - case 'create': |
|
| 1162 | - case 'edit': |
|
| 1163 | - case 'update': |
|
| 1164 | - case 'duplicate': |
|
| 1165 | - case 'trash': |
|
| 1166 | - case 'untrash': |
|
| 1167 | - case 'destroy': |
|
| 1168 | - case 'delete_all': |
|
| 1169 | - case 'settings': |
|
| 1170 | - case 'update_settings': |
|
| 1161 | + case 'create': |
|
| 1162 | + case 'edit': |
|
| 1163 | + case 'update': |
|
| 1164 | + case 'duplicate': |
|
| 1165 | + case 'trash': |
|
| 1166 | + case 'untrash': |
|
| 1167 | + case 'destroy': |
|
| 1168 | + case 'delete_all': |
|
| 1169 | + case 'settings': |
|
| 1170 | + case 'update_settings': |
|
| 1171 | 1171 | return self::$action( $vars ); |
| 1172 | - default: |
|
| 1172 | + default: |
|
| 1173 | 1173 | do_action( 'frm_form_action_' . $action ); |
| 1174 | 1174 | if ( apply_filters( 'frm_form_stop_action_' . $action, false ) ) { |
| 1175 | - return; |
|
| 1176 | - } |
|
| 1175 | + return; |
|
| 1176 | + } |
|
| 1177 | 1177 | |
| 1178 | 1178 | $action = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' ); |
| 1179 | - if ( $action == -1 ) { |
|
| 1179 | + if ( $action == -1 ) { |
|
| 1180 | 1180 | $action = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' ); |
| 1181 | - } |
|
| 1181 | + } |
|
| 1182 | 1182 | |
| 1183 | 1183 | if ( strpos( $action, 'bulk_' ) === 0 ) { |
| 1184 | - FrmAppHelper::remove_get_action(); |
|
| 1185 | - return self::list_form(); |
|
| 1186 | - } |
|
| 1184 | + FrmAppHelper::remove_get_action(); |
|
| 1185 | + return self::list_form(); |
|
| 1186 | + } |
|
| 1187 | 1187 | |
| 1188 | - return self::display_forms_list(); |
|
| 1189 | - } |
|
| 1190 | - } |
|
| 1188 | + return self::display_forms_list(); |
|
| 1189 | + } |
|
| 1190 | + } |
|
| 1191 | 1191 | |
| 1192 | - public static function json_error( $errors ) { |
|
| 1193 | - $errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' ); |
|
| 1194 | - return $errors; |
|
| 1195 | - } |
|
| 1192 | + public static function json_error( $errors ) { |
|
| 1193 | + $errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' ); |
|
| 1194 | + return $errors; |
|
| 1195 | + } |
|
| 1196 | 1196 | |
| 1197 | 1197 | |
| 1198 | - /* FRONT-END FORMS */ |
|
| 1199 | - public static function admin_bar_css() { |
|
| 1198 | + /* FRONT-END FORMS */ |
|
| 1199 | + public static function admin_bar_css() { |
|
| 1200 | 1200 | if ( is_admin() || ! current_user_can( 'frm_edit_forms' ) ) { |
| 1201 | - return; |
|
| 1202 | - } |
|
| 1201 | + return; |
|
| 1202 | + } |
|
| 1203 | 1203 | |
| 1204 | 1204 | add_action( 'wp_before_admin_bar_render', 'FrmFormsController::admin_bar_configure' ); |
| 1205 | 1205 | FrmAppHelper::load_font_style(); |
| 1206 | 1206 | } |
| 1207 | 1207 | |
| 1208 | 1208 | public static function admin_bar_configure() { |
| 1209 | - global $frm_vars; |
|
| 1209 | + global $frm_vars; |
|
| 1210 | 1210 | if ( empty( $frm_vars['forms_loaded'] ) ) { |
| 1211 | - return; |
|
| 1212 | - } |
|
| 1211 | + return; |
|
| 1212 | + } |
|
| 1213 | 1213 | |
| 1214 | - $actions = array(); |
|
| 1214 | + $actions = array(); |
|
| 1215 | 1215 | foreach ( $frm_vars['forms_loaded'] as $form ) { |
| 1216 | 1216 | if ( is_object( $form ) ) { |
| 1217 | 1217 | $actions[ $form->id ] = $form->name; |
@@ -1266,18 +1266,18 @@ discard block |
||
| 1266 | 1266 | } |
| 1267 | 1267 | } |
| 1268 | 1268 | |
| 1269 | - //formidable shortcode |
|
| 1269 | + //formidable shortcode |
|
| 1270 | 1270 | public static function get_form_shortcode( $atts ) { |
| 1271 | - global $frm_vars; |
|
| 1271 | + global $frm_vars; |
|
| 1272 | 1272 | if ( isset( $frm_vars['skip_shortcode'] ) && $frm_vars['skip_shortcode'] ) { |
| 1273 | - $sc = '[formidable'; |
|
| 1273 | + $sc = '[formidable'; |
|
| 1274 | 1274 | if ( ! empty( $atts ) ) { |
| 1275 | 1275 | foreach ( $atts as $k => $v ) { |
| 1276 | 1276 | $sc .= ' ' . $k . '="' . esc_attr( $v ) . '"'; |
| 1277 | 1277 | } |
| 1278 | 1278 | } |
| 1279 | 1279 | return $sc . ']'; |
| 1280 | - } |
|
| 1280 | + } |
|
| 1281 | 1281 | |
| 1282 | 1282 | $shortcode_atts = shortcode_atts( |
| 1283 | 1283 | array( |
@@ -1295,27 +1295,27 @@ discard block |
||
| 1295 | 1295 | ); |
| 1296 | 1296 | do_action( 'formidable_shortcode_atts', $shortcode_atts, $atts ); |
| 1297 | 1297 | |
| 1298 | - return self::show_form( $shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'], $shortcode_atts['description'], $atts ); |
|
| 1299 | - } |
|
| 1298 | + return self::show_form( $shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'], $shortcode_atts['description'], $atts ); |
|
| 1299 | + } |
|
| 1300 | 1300 | |
| 1301 | - public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) { |
|
| 1302 | - if ( empty( $id ) ) { |
|
| 1303 | - $id = $key; |
|
| 1304 | - } |
|
| 1301 | + public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) { |
|
| 1302 | + if ( empty( $id ) ) { |
|
| 1303 | + $id = $key; |
|
| 1304 | + } |
|
| 1305 | 1305 | |
| 1306 | - $form = self::maybe_get_form_to_show( $id ); |
|
| 1307 | - if ( ! $form ) { |
|
| 1308 | - return __( 'Please select a valid form', 'formidable' ); |
|
| 1309 | - } |
|
| 1306 | + $form = self::maybe_get_form_to_show( $id ); |
|
| 1307 | + if ( ! $form ) { |
|
| 1308 | + return __( 'Please select a valid form', 'formidable' ); |
|
| 1309 | + } |
|
| 1310 | 1310 | |
| 1311 | 1311 | FrmAppController::maybe_update_styles(); |
| 1312 | 1312 | |
| 1313 | 1313 | add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' ); |
| 1314 | - FrmAppHelper::trigger_hook_load( 'form', $form ); |
|
| 1314 | + FrmAppHelper::trigger_hook_load( 'form', $form ); |
|
| 1315 | 1315 | |
| 1316 | - $form = apply_filters( 'frm_pre_display_form', $form ); |
|
| 1316 | + $form = apply_filters( 'frm_pre_display_form', $form ); |
|
| 1317 | 1317 | |
| 1318 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 1318 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 1319 | 1319 | |
| 1320 | 1320 | if ( self::is_viewable_draft_form( $form ) ) { |
| 1321 | 1321 | // don't show a draft form on a page |
@@ -1338,7 +1338,7 @@ discard block |
||
| 1338 | 1338 | } |
| 1339 | 1339 | |
| 1340 | 1340 | return $form; |
| 1341 | - } |
|
| 1341 | + } |
|
| 1342 | 1342 | |
| 1343 | 1343 | private static function maybe_get_form_to_show( $id ) { |
| 1344 | 1344 | $form = false; |
@@ -1367,21 +1367,21 @@ discard block |
||
| 1367 | 1367 | return $form->logged_in && get_current_user_id() && isset( $form->options['logged_in_role'] ) && $form->options['logged_in_role'] != '' && ! FrmAppHelper::user_has_permission( $form->options['logged_in_role'] ); |
| 1368 | 1368 | } |
| 1369 | 1369 | |
| 1370 | - public static function get_form( $form, $title, $description, $atts = array() ) { |
|
| 1370 | + public static function get_form( $form, $title, $description, $atts = array() ) { |
|
| 1371 | 1371 | ob_start(); |
| 1372 | 1372 | |
| 1373 | 1373 | do_action( 'frm_before_get_form', $atts ); |
| 1374 | 1374 | |
| 1375 | - self::get_form_contents( $form, $title, $description, $atts ); |
|
| 1375 | + self::get_form_contents( $form, $title, $description, $atts ); |
|
| 1376 | 1376 | self::enqueue_scripts( FrmForm::get_params( $form ) ); |
| 1377 | 1377 | |
| 1378 | - $contents = ob_get_contents(); |
|
| 1379 | - ob_end_clean(); |
|
| 1378 | + $contents = ob_get_contents(); |
|
| 1379 | + ob_end_clean(); |
|
| 1380 | 1380 | |
| 1381 | 1381 | self::maybe_minimize_form( $atts, $contents ); |
| 1382 | 1382 | |
| 1383 | - return $contents; |
|
| 1384 | - } |
|
| 1383 | + return $contents; |
|
| 1384 | + } |
|
| 1385 | 1385 | |
| 1386 | 1386 | public static function enqueue_scripts( $params ) { |
| 1387 | 1387 | do_action( 'frm_enqueue_form_scripts', $params ); |
@@ -1734,10 +1734,10 @@ discard block |
||
| 1734 | 1734 | } |
| 1735 | 1735 | |
| 1736 | 1736 | public static function defer_script_loading( $tag, $handle ) { |
| 1737 | - if ( 'recaptcha-api' == $handle && ! strpos( $tag, 'defer' ) ) { |
|
| 1738 | - $tag = str_replace( ' src', ' defer="defer" async="async" src', $tag ); |
|
| 1737 | + if ( 'recaptcha-api' == $handle && ! strpos( $tag, 'defer' ) ) { |
|
| 1738 | + $tag = str_replace( ' src', ' defer="defer" async="async" src', $tag ); |
|
| 1739 | 1739 | } |
| 1740 | - return $tag; |
|
| 1740 | + return $tag; |
|
| 1741 | 1741 | } |
| 1742 | 1742 | |
| 1743 | 1743 | public static function footer_js( $location = 'footer' ) { |
@@ -2,89 +2,89 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | class FrmHooksController { |
| 4 | 4 | |
| 5 | - /** |
|
| 6 | - * Trigger plugin-wide hook loading |
|
| 7 | - */ |
|
| 8 | - public static function trigger_load_hook( $hooks = 'load_hooks' ) { |
|
| 9 | - $controllers = apply_filters( 'frm_load_controllers', array( 'FrmHooksController' ) ); |
|
| 10 | - |
|
| 11 | - $trigger_hooks = $hooks; |
|
| 12 | - $hooks = (array) $hooks; |
|
| 13 | - |
|
| 14 | - if ( 'load_hooks' == $trigger_hooks ) { |
|
| 15 | - if ( is_admin() ) { |
|
| 16 | - $hooks[] = 'load_admin_hooks'; |
|
| 17 | - if ( defined( 'DOING_AJAX' ) ) { |
|
| 18 | - $hooks[] = 'load_ajax_hooks'; |
|
| 19 | - $hooks[] = 'load_form_hooks'; |
|
| 20 | - } |
|
| 21 | - } |
|
| 22 | - |
|
| 23 | - if ( is_multisite() ) { |
|
| 24 | - $hooks[] = 'load_multisite_hooks'; |
|
| 25 | - } |
|
| 26 | - } else { |
|
| 27 | - // Make sure the hooks are only triggered once |
|
| 28 | - add_filter( 'frm' . str_replace( 'load', '', $trigger_hooks ) . '_loaded', '__return_true' ); |
|
| 29 | - } |
|
| 30 | - unset( $trigger_hooks ); |
|
| 31 | - |
|
| 32 | - // Instansiate Controllers |
|
| 33 | - foreach ( $controllers as $c ) { |
|
| 34 | - foreach ( $hooks as $hook ) { |
|
| 5 | + /** |
|
| 6 | + * Trigger plugin-wide hook loading |
|
| 7 | + */ |
|
| 8 | + public static function trigger_load_hook( $hooks = 'load_hooks' ) { |
|
| 9 | + $controllers = apply_filters( 'frm_load_controllers', array( 'FrmHooksController' ) ); |
|
| 10 | + |
|
| 11 | + $trigger_hooks = $hooks; |
|
| 12 | + $hooks = (array) $hooks; |
|
| 13 | + |
|
| 14 | + if ( 'load_hooks' == $trigger_hooks ) { |
|
| 15 | + if ( is_admin() ) { |
|
| 16 | + $hooks[] = 'load_admin_hooks'; |
|
| 17 | + if ( defined( 'DOING_AJAX' ) ) { |
|
| 18 | + $hooks[] = 'load_ajax_hooks'; |
|
| 19 | + $hooks[] = 'load_form_hooks'; |
|
| 20 | + } |
|
| 21 | + } |
|
| 22 | + |
|
| 23 | + if ( is_multisite() ) { |
|
| 24 | + $hooks[] = 'load_multisite_hooks'; |
|
| 25 | + } |
|
| 26 | + } else { |
|
| 27 | + // Make sure the hooks are only triggered once |
|
| 28 | + add_filter( 'frm' . str_replace( 'load', '', $trigger_hooks ) . '_loaded', '__return_true' ); |
|
| 29 | + } |
|
| 30 | + unset( $trigger_hooks ); |
|
| 31 | + |
|
| 32 | + // Instansiate Controllers |
|
| 33 | + foreach ( $controllers as $c ) { |
|
| 34 | + foreach ( $hooks as $hook ) { |
|
| 35 | 35 | call_user_func( array( $c, $hook ) ); |
| 36 | 36 | unset( $hook ); |
| 37 | - } |
|
| 37 | + } |
|
| 38 | 38 | unset( $c ); |
| 39 | - } |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - } |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - public static function trigger_load_form_hooks() { |
|
| 44 | - self::trigger_load_hook( 'load_form_hooks' ); |
|
| 45 | - } |
|
| 43 | + public static function trigger_load_form_hooks() { |
|
| 44 | + self::trigger_load_hook( 'load_form_hooks' ); |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | 47 | public static function load_hooks() { |
| 48 | 48 | add_action( 'rest_api_init', 'FrmAppController::create_rest_routes', 0 ); |
| 49 | - add_action( 'plugins_loaded', 'FrmAppController::load_lang' ); |
|
| 49 | + add_action( 'plugins_loaded', 'FrmAppController::load_lang' ); |
|
| 50 | 50 | add_filter( 'widget_text', 'do_shortcode' ); |
| 51 | 51 | |
| 52 | - // Entries controller |
|
| 53 | - add_action( 'wp_loaded', 'FrmEntriesController::process_entry', 10, 0 ); |
|
| 54 | - add_action( 'frm_after_entry_processed', 'FrmEntriesController::delete_entry_after_save', 100 ); |
|
| 52 | + // Entries controller |
|
| 53 | + add_action( 'wp_loaded', 'FrmEntriesController::process_entry', 10, 0 ); |
|
| 54 | + add_action( 'frm_after_entry_processed', 'FrmEntriesController::delete_entry_after_save', 100 ); |
|
| 55 | 55 | |
| 56 | - // Form Actions Controller |
|
| 57 | - add_action( 'init', 'FrmFormActionsController::register_post_types', 1 ); |
|
| 56 | + // Form Actions Controller |
|
| 57 | + add_action( 'init', 'FrmFormActionsController::register_post_types', 1 ); |
|
| 58 | 58 | add_action( 'frm_after_create_entry', 'FrmFormActionsController::trigger_create_actions', 20, 3 ); |
| 59 | 59 | |
| 60 | - // Forms Controller |
|
| 61 | - add_action( 'widgets_init', 'FrmFormsController::register_widgets' ); |
|
| 60 | + // Forms Controller |
|
| 61 | + add_action( 'widgets_init', 'FrmFormsController::register_widgets' ); |
|
| 62 | 62 | add_action( 'init', 'FrmFormsController::front_head' ); |
| 63 | - add_filter( 'frm_content', 'FrmFormsController::filter_content', 10, 3 ); |
|
| 64 | - add_filter( 'frm_replace_content_shortcodes', 'FrmFormsController::replace_content_shortcodes', 20, 3 ); |
|
| 65 | - add_action( 'admin_bar_init', 'FrmFormsController::admin_bar_css' ); |
|
| 63 | + add_filter( 'frm_content', 'FrmFormsController::filter_content', 10, 3 ); |
|
| 64 | + add_filter( 'frm_replace_content_shortcodes', 'FrmFormsController::replace_content_shortcodes', 20, 3 ); |
|
| 65 | + add_action( 'admin_bar_init', 'FrmFormsController::admin_bar_css' ); |
|
| 66 | 66 | add_action( 'wp_footer', 'FrmFormsController::footer_js', 1, 0 ); |
| 67 | 67 | |
| 68 | 68 | add_action( 'wp_scheduled_delete', 'FrmForm::scheduled_delete' ); |
| 69 | 69 | |
| 70 | - // Form Shortcodes |
|
| 71 | - add_shortcode( 'formidable', 'FrmFormsController::get_form_shortcode' ); |
|
| 70 | + // Form Shortcodes |
|
| 71 | + add_shortcode( 'formidable', 'FrmFormsController::get_form_shortcode' ); |
|
| 72 | 72 | |
| 73 | - // Styles Controller |
|
| 74 | - add_action( 'init', 'FrmStylesController::register_post_types', 0 ); |
|
| 75 | - add_filter( 'frm_get_style_opts', 'FrmStylesController::get_style_opts' ); |
|
| 76 | - add_filter( 'frm_add_form_style_class', 'FrmStylesController::get_form_style_class', 10, 2 ); |
|
| 77 | - add_filter( 'frm_show_entry_styles', 'FrmStylesController::show_entry_styles' ); |
|
| 73 | + // Styles Controller |
|
| 74 | + add_action( 'init', 'FrmStylesController::register_post_types', 0 ); |
|
| 75 | + add_filter( 'frm_get_style_opts', 'FrmStylesController::get_style_opts' ); |
|
| 76 | + add_filter( 'frm_add_form_style_class', 'FrmStylesController::get_form_style_class', 10, 2 ); |
|
| 77 | + add_filter( 'frm_show_entry_styles', 'FrmStylesController::show_entry_styles' ); |
|
| 78 | 78 | |
| 79 | 79 | //Simple Blocks Controller |
| 80 | 80 | add_action( 'init', 'FrmSimpleBlocksController::register_simple_form_block' ); |
| 81 | - } |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | 83 | public static function load_admin_hooks() { |
| 84 | - add_action( 'admin_menu', 'FrmAppController::menu', 1 ); |
|
| 84 | + add_action( 'admin_menu', 'FrmAppController::menu', 1 ); |
|
| 85 | 85 | add_filter( 'admin_body_class', 'FrmAppController::add_admin_class', 999 ); |
| 86 | - add_action( 'admin_enqueue_scripts', 'FrmAppController::load_wp_admin_style' ); |
|
| 87 | - add_action( 'admin_notices', 'FrmAppController::pro_get_started_headline' ); |
|
| 86 | + add_action( 'admin_enqueue_scripts', 'FrmAppController::load_wp_admin_style' ); |
|
| 87 | + add_action( 'admin_notices', 'FrmAppController::pro_get_started_headline' ); |
|
| 88 | 88 | add_action( 'admin_init', 'FrmAppController::admin_init', 11 ); |
| 89 | 89 | add_filter( 'plugin_action_links_' . FrmAppHelper::plugin_folder() . '/formidable.php', 'FrmAppController::settings_link' ); |
| 90 | 90 | add_filter( 'admin_footer_text', 'FrmAppController::set_footer_text' ); |
@@ -95,123 +95,123 @@ discard block |
||
| 95 | 95 | add_action( 'admin_menu', 'FrmAddonsController::menu', 100 ); |
| 96 | 96 | add_filter( 'pre_set_site_transient_update_plugins', 'FrmAddonsController::check_update' ); |
| 97 | 97 | |
| 98 | - // Entries Controller |
|
| 99 | - add_action( 'admin_menu', 'FrmEntriesController::menu', 12 ); |
|
| 100 | - add_filter( 'contextual_help', 'FrmEntriesController::contextual_help', 10, 3 ); |
|
| 101 | - add_filter( 'set-screen-option', 'FrmEntriesController::save_per_page', 10, 3 ); |
|
| 102 | - add_filter( 'update_user_metadata', 'FrmEntriesController::check_hidden_cols', 10, 5 ); |
|
| 103 | - add_action( 'updated_user_meta', 'FrmEntriesController::update_hidden_cols', 10, 4 ); |
|
| 104 | - |
|
| 105 | - // Form Actions Controller |
|
| 106 | - if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
|
| 107 | - add_action( 'frm_before_update_form_settings', 'FrmFormActionsController::update_settings' ); |
|
| 108 | - } |
|
| 109 | - add_action( 'frm_after_duplicate_form', 'FrmFormActionsController::duplicate_form_actions', 20, 3 ); |
|
| 110 | - |
|
| 111 | - // Forms Controller |
|
| 112 | - add_action( 'admin_menu', 'FrmFormsController::menu', 10 ); |
|
| 113 | - add_action( 'admin_head-toplevel_page_formidable', 'FrmFormsController::head' ); |
|
| 114 | - |
|
| 115 | - add_filter( 'set-screen-option', 'FrmFormsController::save_per_page', 10, 3 ); |
|
| 116 | - add_action( 'admin_footer', 'FrmFormsController::insert_form_popup' ); |
|
| 98 | + // Entries Controller |
|
| 99 | + add_action( 'admin_menu', 'FrmEntriesController::menu', 12 ); |
|
| 100 | + add_filter( 'contextual_help', 'FrmEntriesController::contextual_help', 10, 3 ); |
|
| 101 | + add_filter( 'set-screen-option', 'FrmEntriesController::save_per_page', 10, 3 ); |
|
| 102 | + add_filter( 'update_user_metadata', 'FrmEntriesController::check_hidden_cols', 10, 5 ); |
|
| 103 | + add_action( 'updated_user_meta', 'FrmEntriesController::update_hidden_cols', 10, 4 ); |
|
| 104 | + |
|
| 105 | + // Form Actions Controller |
|
| 106 | + if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
|
| 107 | + add_action( 'frm_before_update_form_settings', 'FrmFormActionsController::update_settings' ); |
|
| 108 | + } |
|
| 109 | + add_action( 'frm_after_duplicate_form', 'FrmFormActionsController::duplicate_form_actions', 20, 3 ); |
|
| 110 | + |
|
| 111 | + // Forms Controller |
|
| 112 | + add_action( 'admin_menu', 'FrmFormsController::menu', 10 ); |
|
| 113 | + add_action( 'admin_head-toplevel_page_formidable', 'FrmFormsController::head' ); |
|
| 114 | + |
|
| 115 | + add_filter( 'set-screen-option', 'FrmFormsController::save_per_page', 10, 3 ); |
|
| 116 | + add_action( 'admin_footer', 'FrmFormsController::insert_form_popup' ); |
|
| 117 | 117 | add_action( 'media_buttons', 'FrmFormsController::insert_form_button' ); |
| 118 | 118 | add_action( 'et_pb_admin_excluded_shortcodes', 'FrmFormsController::prevent_divi_conflict' ); |
| 119 | 119 | |
| 120 | - // Forms Model |
|
| 121 | - add_action( 'frm_after_duplicate_form', 'FrmForm::after_duplicate', 10, 2 ); |
|
| 120 | + // Forms Model |
|
| 121 | + add_action( 'frm_after_duplicate_form', 'FrmForm::after_duplicate', 10, 2 ); |
|
| 122 | 122 | |
| 123 | - // Settings Controller |
|
| 124 | - add_action( 'admin_menu', 'FrmSettingsController::menu', 45 ); |
|
| 125 | - add_action( 'frm_before_settings', 'FrmSettingsController::license_box' ); |
|
| 123 | + // Settings Controller |
|
| 124 | + add_action( 'admin_menu', 'FrmSettingsController::menu', 45 ); |
|
| 125 | + add_action( 'frm_before_settings', 'FrmSettingsController::license_box' ); |
|
| 126 | 126 | add_action( 'frm_after_settings', 'FrmSettingsController::settings_cta' ); |
| 127 | 127 | add_action( 'wp_ajax_frm_settings_tab', 'FrmSettingsController::load_settings_tab' ); |
| 128 | 128 | |
| 129 | - // Styles Controller |
|
| 130 | - add_action( 'admin_menu', 'FrmStylesController::menu', 14 ); |
|
| 131 | - add_action( 'admin_init', 'FrmStylesController::admin_init' ); |
|
| 129 | + // Styles Controller |
|
| 130 | + add_action( 'admin_menu', 'FrmStylesController::menu', 14 ); |
|
| 131 | + add_action( 'admin_init', 'FrmStylesController::admin_init' ); |
|
| 132 | 132 | |
| 133 | - // XML Controller |
|
| 134 | - add_action( 'admin_menu', 'FrmXMLController::menu', 41 ); |
|
| 133 | + // XML Controller |
|
| 134 | + add_action( 'admin_menu', 'FrmXMLController::menu', 41 ); |
|
| 135 | 135 | |
| 136 | 136 | // Simple Blocks Controller |
| 137 | 137 | add_action( 'enqueue_block_editor_assets', 'FrmSimpleBlocksController::block_editor_assets' ); |
| 138 | - } |
|
| 138 | + } |
|
| 139 | 139 | |
| 140 | 140 | public static function load_ajax_hooks() { |
| 141 | 141 | add_action( 'wp_ajax_frm_install', 'FrmAppController::ajax_install' ); |
| 142 | - add_action( 'wp_ajax_frm_uninstall', 'FrmAppController::uninstall' ); |
|
| 143 | - add_action( 'wp_ajax_frm_deauthorize', 'FrmAppController::deauthorize' ); |
|
| 142 | + add_action( 'wp_ajax_frm_uninstall', 'FrmAppController::uninstall' ); |
|
| 143 | + add_action( 'wp_ajax_frm_deauthorize', 'FrmAppController::deauthorize' ); |
|
| 144 | 144 | |
| 145 | 145 | // Addons |
| 146 | 146 | add_action( 'wp_ajax_frm_addon_activate', 'FrmAddon::activate' ); |
| 147 | 147 | add_action( 'wp_ajax_frm_addon_deactivate', 'FrmAddon::deactivate' ); |
| 148 | 148 | add_action( 'wp_ajax_frm_install_addon', 'FrmAddonsController::ajax_install_addon' ); |
| 149 | 149 | |
| 150 | - // Fields Controller |
|
| 151 | - add_action( 'wp_ajax_frm_load_field', 'FrmFieldsController::load_field' ); |
|
| 152 | - add_action( 'wp_ajax_frm_insert_field', 'FrmFieldsController::create' ); |
|
| 153 | - add_action( 'wp_ajax_frm_update_ajax_option', 'FrmFieldsController::update_ajax_option' ); |
|
| 154 | - add_action( 'wp_ajax_frm_duplicate_field', 'FrmFieldsController::duplicate' ); |
|
| 155 | - add_action( 'wp_ajax_frm_delete_field', 'FrmFieldsController::destroy' ); |
|
| 156 | - add_action( 'wp_ajax_frm_add_field_option', 'FrmFieldsController::add_option' ); |
|
| 157 | - add_action( 'wp_ajax_frm_import_choices', 'FrmFieldsController::import_choices' ); |
|
| 158 | - add_action( 'wp_ajax_frm_import_options', 'FrmFieldsController::import_options' ); |
|
| 159 | - add_action( 'wp_ajax_frm_update_field_order', 'FrmFieldsController::update_order' ); |
|
| 160 | - |
|
| 161 | - // Form Actions Controller |
|
| 162 | - add_action( 'wp_ajax_frm_add_form_action', 'FrmFormActionsController::add_form_action' ); |
|
| 163 | - add_action( 'wp_ajax_frm_form_action_fill', 'FrmFormActionsController::fill_action' ); |
|
| 164 | - |
|
| 165 | - // Forms Controller |
|
| 150 | + // Fields Controller |
|
| 151 | + add_action( 'wp_ajax_frm_load_field', 'FrmFieldsController::load_field' ); |
|
| 152 | + add_action( 'wp_ajax_frm_insert_field', 'FrmFieldsController::create' ); |
|
| 153 | + add_action( 'wp_ajax_frm_update_ajax_option', 'FrmFieldsController::update_ajax_option' ); |
|
| 154 | + add_action( 'wp_ajax_frm_duplicate_field', 'FrmFieldsController::duplicate' ); |
|
| 155 | + add_action( 'wp_ajax_frm_delete_field', 'FrmFieldsController::destroy' ); |
|
| 156 | + add_action( 'wp_ajax_frm_add_field_option', 'FrmFieldsController::add_option' ); |
|
| 157 | + add_action( 'wp_ajax_frm_import_choices', 'FrmFieldsController::import_choices' ); |
|
| 158 | + add_action( 'wp_ajax_frm_import_options', 'FrmFieldsController::import_options' ); |
|
| 159 | + add_action( 'wp_ajax_frm_update_field_order', 'FrmFieldsController::update_order' ); |
|
| 160 | + |
|
| 161 | + // Form Actions Controller |
|
| 162 | + add_action( 'wp_ajax_frm_add_form_action', 'FrmFormActionsController::add_form_action' ); |
|
| 163 | + add_action( 'wp_ajax_frm_form_action_fill', 'FrmFormActionsController::fill_action' ); |
|
| 164 | + |
|
| 165 | + // Forms Controller |
|
| 166 | 166 | add_action( 'wp_ajax_frm_create_from_template', 'FrmFormsController::_create_from_template' ); |
| 167 | 167 | add_action( 'wp_ajax_frm_save_form', 'FrmFormsController::route' ); |
| 168 | - add_action( 'wp_ajax_frm_get_default_html', 'FrmFormsController::get_email_html' ); |
|
| 169 | - add_action( 'wp_ajax_frm_get_shortcode_opts', 'FrmFormsController::get_shortcode_opts' ); |
|
| 170 | - add_action( 'wp_ajax_frm_forms_preview', 'FrmFormsController::preview' ); |
|
| 171 | - add_action( 'wp_ajax_nopriv_frm_forms_preview', 'FrmFormsController::preview' ); |
|
| 168 | + add_action( 'wp_ajax_frm_get_default_html', 'FrmFormsController::get_email_html' ); |
|
| 169 | + add_action( 'wp_ajax_frm_get_shortcode_opts', 'FrmFormsController::get_shortcode_opts' ); |
|
| 170 | + add_action( 'wp_ajax_frm_forms_preview', 'FrmFormsController::preview' ); |
|
| 171 | + add_action( 'wp_ajax_nopriv_frm_forms_preview', 'FrmFormsController::preview' ); |
|
| 172 | 172 | add_action( 'wp_ajax_frm_forms_trash', 'FrmFormsController::ajax_trash' ); |
| 173 | 173 | add_action( 'wp_ajax_frm_build_template', 'FrmFormsController::build_template' ); |
| 174 | 174 | |
| 175 | 175 | // Settings |
| 176 | 176 | add_action( 'wp_ajax_frm_lite_settings_upgrade', 'FrmSettingsController::settings_cta_dismiss' ); |
| 177 | 177 | |
| 178 | - // Styles Controller |
|
| 179 | - add_action( 'wp_ajax_frm_settings_reset', 'FrmStylesController::reset_styling' ); |
|
| 180 | - add_action( 'wp_ajax_frm_change_styling', 'FrmStylesController::change_styling' ); |
|
| 181 | - add_action( 'wp_ajax_frmpro_load_css', 'FrmStylesController::load_css' ); |
|
| 182 | - add_action( 'wp_ajax_nopriv_frmpro_load_css', 'FrmStylesController::load_css' ); |
|
| 178 | + // Styles Controller |
|
| 179 | + add_action( 'wp_ajax_frm_settings_reset', 'FrmStylesController::reset_styling' ); |
|
| 180 | + add_action( 'wp_ajax_frm_change_styling', 'FrmStylesController::change_styling' ); |
|
| 181 | + add_action( 'wp_ajax_frmpro_load_css', 'FrmStylesController::load_css' ); |
|
| 182 | + add_action( 'wp_ajax_nopriv_frmpro_load_css', 'FrmStylesController::load_css' ); |
|
| 183 | 183 | add_action( 'wp_ajax_frmpro_css', 'FrmStylesController::load_saved_css' ); |
| 184 | 184 | add_action( 'wp_ajax_nopriv_frmpro_css', 'FrmStylesController::load_saved_css' ); |
| 185 | 185 | |
| 186 | - // XML Controller |
|
| 186 | + // XML Controller |
|
| 187 | 187 | add_action( 'wp_ajax_frm_install_template', 'FrmXMLController::install_template' ); |
| 188 | 188 | add_action( 'wp_ajax_frm_entries_csv', 'FrmXMLController::csv' ); |
| 189 | 189 | add_action( 'wp_ajax_nopriv_frm_entries_csv', 'FrmXMLController::csv' ); |
| 190 | - add_action( 'wp_ajax_frm_export_xml', 'FrmXMLController::export_xml' ); |
|
| 191 | - } |
|
| 190 | + add_action( 'wp_ajax_frm_export_xml', 'FrmXMLController::export_xml' ); |
|
| 191 | + } |
|
| 192 | 192 | |
| 193 | 193 | public static function load_form_hooks() { |
| 194 | - // Fields Controller |
|
| 195 | - add_filter( 'frm_field_type', 'FrmFieldsController::change_type' ); |
|
| 196 | - add_action( 'frm_field_input_html', 'FrmFieldsController::input_html' ); |
|
| 197 | - add_filter( 'frm_field_value_saved', 'FrmFieldsController::check_value', 50, 3 ); |
|
| 198 | - add_filter( 'frm_field_label_seen', 'FrmFieldsController::check_label' ); |
|
| 194 | + // Fields Controller |
|
| 195 | + add_filter( 'frm_field_type', 'FrmFieldsController::change_type' ); |
|
| 196 | + add_action( 'frm_field_input_html', 'FrmFieldsController::input_html' ); |
|
| 197 | + add_filter( 'frm_field_value_saved', 'FrmFieldsController::check_value', 50, 3 ); |
|
| 198 | + add_filter( 'frm_field_label_seen', 'FrmFieldsController::check_label' ); |
|
| 199 | 199 | |
| 200 | 200 | // Forms Controller |
| 201 | 201 | add_filter( 'frm_form_classes', 'FrmFormsController::form_classes' ); |
| 202 | 202 | |
| 203 | - // Styles Controller |
|
| 204 | - add_filter( 'frm_use_important_width', 'FrmStylesController::important_style', 10, 2 ); |
|
| 205 | - } |
|
| 203 | + // Styles Controller |
|
| 204 | + add_filter( 'frm_use_important_width', 'FrmStylesController::important_style', 10, 2 ); |
|
| 205 | + } |
|
| 206 | 206 | |
| 207 | 207 | public static function load_view_hooks() { |
| 208 | - // Hooks go here when a view is loaded |
|
| 209 | - } |
|
| 208 | + // Hooks go here when a view is loaded |
|
| 209 | + } |
|
| 210 | 210 | |
| 211 | 211 | public static function load_multisite_hooks() { |
| 212 | 212 | add_action( 'wpmu_upgrade_site', 'FrmAppController::network_upgrade_site' ); |
| 213 | 213 | |
| 214 | - // drop tables when mu site is deleted |
|
| 215 | - add_filter( 'wpmu_drop_tables', 'FrmAppController::drop_tables' ); |
|
| 216 | - } |
|
| 214 | + // drop tables when mu site is deleted |
|
| 215 | + add_filter( 'wpmu_drop_tables', 'FrmAppController::drop_tables' ); |
|
| 216 | + } |
|
| 217 | 217 | } |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | } else { |
| 53 | 53 | foreach ( $addons as $k => $addon ) { |
| 54 | 54 | if ( empty( $addon['excerpt'] ) && $k !== 'error' ) { |
| 55 | - unset( $addons[ $k ] ); |
|
| 55 | + unset( $addons[$k] ); |
|
| 56 | 56 | } |
| 57 | 57 | } |
| 58 | 58 | } |
@@ -211,16 +211,16 @@ discard block |
||
| 211 | 211 | continue; |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | - $wp_plugin = isset( $wp_plugins[ $folder ] ) ? $wp_plugins[ $folder ] : array(); |
|
| 214 | + $wp_plugin = isset( $wp_plugins[$folder] ) ? $wp_plugins[$folder] : array(); |
|
| 215 | 215 | $wp_version = isset( $wp_plugin['Version'] ) ? $wp_plugin['Version'] : '1.0'; |
| 216 | 216 | |
| 217 | 217 | if ( version_compare( $wp_version, $plugin->new_version, '<' ) ) { |
| 218 | 218 | $slug = explode( '/', $folder ); |
| 219 | 219 | $plugin->slug = $slug[0]; |
| 220 | - $transient->response[ $folder ] = $plugin; |
|
| 220 | + $transient->response[$folder] = $plugin; |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | - $transient->checked[ $folder ] = $wp_version; |
|
| 223 | + $transient->checked[$folder] = $wp_version; |
|
| 224 | 224 | |
| 225 | 225 | } |
| 226 | 226 | |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | $all_plugins = get_plugins(); |
| 243 | - return isset( $all_plugins[ $plugin ] ); |
|
| 243 | + return isset( $all_plugins[$plugin] ); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | /** |
@@ -279,13 +279,13 @@ discard block |
||
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | $download_id = isset( $plugin['id'] ) ? $plugin['id'] : 0; |
| 282 | - if ( ! empty( $download_id ) && ! isset( $version_info[ $download_id ]['package'] ) ) { |
|
| 282 | + if ( ! empty( $download_id ) && ! isset( $version_info[$download_id]['package'] ) ) { |
|
| 283 | 283 | // if this addon is using its own license, get the update url |
| 284 | 284 | $addon_info = $api->get_api_info(); |
| 285 | 285 | |
| 286 | - $version_info[ $download_id ] = $addon_info[ $download_id ]; |
|
| 286 | + $version_info[$download_id] = $addon_info[$download_id]; |
|
| 287 | 287 | if ( isset( $addon_info['error'] ) ) { |
| 288 | - $version_info[ $download_id ]['error'] = array( |
|
| 288 | + $version_info[$download_id]['error'] = array( |
|
| 289 | 289 | 'message' => $addon_info['error']['message'], |
| 290 | 290 | 'code' => $addon_info['error']['code'], |
| 291 | 291 | ); |
@@ -311,8 +311,8 @@ discard block |
||
| 311 | 311 | return $addon; |
| 312 | 312 | } |
| 313 | 313 | } |
| 314 | - } elseif ( isset( $addons[ $download_id ] ) ) { |
|
| 315 | - $plugin = $addons[ $download_id ]; |
|
| 314 | + } elseif ( isset( $addons[$download_id] ) ) { |
|
| 315 | + $plugin = $addons[$download_id]; |
|
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | return $plugin; |
@@ -363,7 +363,7 @@ discard block |
||
| 363 | 363 | self::prepare_addon_link( $addon['link'] ); |
| 364 | 364 | |
| 365 | 365 | self::set_addon_status( $addon ); |
| 366 | - $addons[ $id ] = $addon; |
|
| 366 | + $addons[$id] = $addon; |
|
| 367 | 367 | } |
| 368 | 368 | } |
| 369 | 369 | |