@@ -13,50 +13,50 @@ discard block |
||
| 13 | 13 | */ |
| 14 | 14 | public static $plug_version = '3.01'; |
| 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 | - } |
|
| 25 | - |
|
| 26 | - public static function plugin_folder() { |
|
| 27 | - return basename(self::plugin_path()); |
|
| 28 | - } |
|
| 29 | - |
|
| 30 | - public static function plugin_path() { |
|
| 31 | - return dirname(dirname(dirname(__FILE__))); |
|
| 32 | - } |
|
| 33 | - |
|
| 34 | - public static function plugin_url() { |
|
| 35 | - //prevously FRM_URL constant |
|
| 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 | + |
|
| 26 | + public static function plugin_folder() { |
|
| 27 | + return basename(self::plugin_path()); |
|
| 28 | + } |
|
| 29 | + |
|
| 30 | + public static function plugin_path() { |
|
| 31 | + return dirname(dirname(dirname(__FILE__))); |
|
| 32 | + } |
|
| 33 | + |
|
| 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 | - */ |
|
| 57 | - public static function site_name() { |
|
| 58 | - return get_option('blogname'); |
|
| 59 | - } |
|
| 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 | + public static function site_name() { |
|
| 58 | + return get_option('blogname'); |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | 61 | public static function make_affiliate_url( $url ) { |
| 62 | 62 | $affiliate_id = self::get_affiliate(); |
@@ -71,21 +71,21 @@ discard block |
||
| 71 | 71 | return absint( apply_filters( 'frm_affiliate_id', 0 ) ); |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - /** |
|
| 75 | - * Get the Formidable settings |
|
| 76 | - * |
|
| 77 | - * @since 2.0 |
|
| 78 | - * |
|
| 79 | - * @param None |
|
| 80 | - * @return FrmSettings $frm_setings |
|
| 81 | - */ |
|
| 82 | - public static function get_settings() { |
|
| 83 | - global $frm_settings; |
|
| 84 | - if ( empty($frm_settings) ) { |
|
| 85 | - $frm_settings = new FrmSettings(); |
|
| 86 | - } |
|
| 87 | - return $frm_settings; |
|
| 88 | - } |
|
| 74 | + /** |
|
| 75 | + * Get the Formidable settings |
|
| 76 | + * |
|
| 77 | + * @since 2.0 |
|
| 78 | + * |
|
| 79 | + * @param None |
|
| 80 | + * @return FrmSettings $frm_setings |
|
| 81 | + */ |
|
| 82 | + public static function get_settings() { |
|
| 83 | + global $frm_settings; |
|
| 84 | + if ( empty($frm_settings) ) { |
|
| 85 | + $frm_settings = new FrmSettings(); |
|
| 86 | + } |
|
| 87 | + return $frm_settings; |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | 90 | public static function get_menu_name() { |
| 91 | 91 | $frm_settings = FrmAppHelper::get_settings(); |
@@ -100,9 +100,9 @@ discard block |
||
| 100 | 100 | return ! $frm_settings->no_ips; |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - public static function pro_is_installed() { |
|
| 104 | - return apply_filters('frm_pro_installed', false); |
|
| 105 | - } |
|
| 103 | + public static function pro_is_installed() { |
|
| 104 | + return apply_filters('frm_pro_installed', false); |
|
| 105 | + } |
|
| 106 | 106 | |
| 107 | 107 | public static function is_formidable_admin() { |
| 108 | 108 | $page = self::simple_get( 'page', 'sanitize_title' ); |
@@ -119,50 +119,50 @@ discard block |
||
| 119 | 119 | return $is_formidable; |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - /** |
|
| 123 | - * Check for certain page in Formidable settings |
|
| 124 | - * |
|
| 125 | - * @since 2.0 |
|
| 126 | - * |
|
| 127 | - * @param string $page The name of the page to check |
|
| 128 | - * @return boolean |
|
| 129 | - */ |
|
| 122 | + /** |
|
| 123 | + * Check for certain page in Formidable settings |
|
| 124 | + * |
|
| 125 | + * @since 2.0 |
|
| 126 | + * |
|
| 127 | + * @param string $page The name of the page to check |
|
| 128 | + * @return boolean |
|
| 129 | + */ |
|
| 130 | 130 | public static function is_admin_page( $page = 'formidable' ) { |
| 131 | - global $pagenow; |
|
| 131 | + global $pagenow; |
|
| 132 | 132 | $get_page = self::simple_get( 'page', 'sanitize_title' ); |
| 133 | - if ( $pagenow ) { |
|
| 133 | + if ( $pagenow ) { |
|
| 134 | 134 | // allow this to be true during ajax load i.e. ajax form builder loading |
| 135 | 135 | return ( $pagenow == 'admin.php' || $pagenow == 'admin-ajax.php' ) && $get_page == $page; |
| 136 | - } |
|
| 136 | + } |
|
| 137 | 137 | |
| 138 | 138 | return is_admin() && $get_page == $page; |
| 139 | - } |
|
| 140 | - |
|
| 141 | - /** |
|
| 142 | - * Check for the form preview page |
|
| 143 | - * |
|
| 144 | - * @since 2.0 |
|
| 145 | - * |
|
| 146 | - * @param None |
|
| 147 | - * @return boolean |
|
| 148 | - */ |
|
| 149 | - public static function is_preview_page() { |
|
| 150 | - global $pagenow; |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + /** |
|
| 142 | + * Check for the form preview page |
|
| 143 | + * |
|
| 144 | + * @since 2.0 |
|
| 145 | + * |
|
| 146 | + * @param None |
|
| 147 | + * @return boolean |
|
| 148 | + */ |
|
| 149 | + public static function is_preview_page() { |
|
| 150 | + global $pagenow; |
|
| 151 | 151 | $action = FrmAppHelper::simple_get( 'action', 'sanitize_title' ); |
| 152 | 152 | return $pagenow && $pagenow == 'admin-ajax.php' && $action == 'frm_forms_preview'; |
| 153 | - } |
|
| 154 | - |
|
| 155 | - /** |
|
| 156 | - * Check for ajax except the form preview page |
|
| 157 | - * |
|
| 158 | - * @since 2.0 |
|
| 159 | - * |
|
| 160 | - * @param None |
|
| 161 | - * @return boolean |
|
| 162 | - */ |
|
| 163 | - public static function doing_ajax() { |
|
| 164 | - return self::wp_doing_ajax() && ! self::is_preview_page(); |
|
| 165 | - } |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + /** |
|
| 156 | + * Check for ajax except the form preview page |
|
| 157 | + * |
|
| 158 | + * @since 2.0 |
|
| 159 | + * |
|
| 160 | + * @param None |
|
| 161 | + * @return boolean |
|
| 162 | + */ |
|
| 163 | + public static function doing_ajax() { |
|
| 164 | + return self::wp_doing_ajax() && ! self::is_preview_page(); |
|
| 165 | + } |
|
| 166 | 166 | |
| 167 | 167 | public static function js_suffix() { |
| 168 | 168 | return defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
@@ -189,81 +189,81 @@ discard block |
||
| 189 | 189 | return isset( $frm_vars['prevent_caching'] ) && $frm_vars['prevent_caching']; |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | - /** |
|
| 193 | - * Check if on an admin page |
|
| 194 | - * |
|
| 195 | - * @since 2.0 |
|
| 196 | - * |
|
| 197 | - * @param None |
|
| 198 | - * @return boolean |
|
| 199 | - */ |
|
| 200 | - public static function is_admin() { |
|
| 201 | - return is_admin() && ! self::wp_doing_ajax(); |
|
| 202 | - } |
|
| 203 | - |
|
| 204 | - /** |
|
| 205 | - * Check if value contains blank value or empty array |
|
| 206 | - * |
|
| 207 | - * @since 2.0 |
|
| 208 | - * @param mixed $value - value to check |
|
| 192 | + /** |
|
| 193 | + * Check if on an admin page |
|
| 194 | + * |
|
| 195 | + * @since 2.0 |
|
| 196 | + * |
|
| 197 | + * @param None |
|
| 198 | + * @return boolean |
|
| 199 | + */ |
|
| 200 | + public static function is_admin() { |
|
| 201 | + return is_admin() && ! self::wp_doing_ajax(); |
|
| 202 | + } |
|
| 203 | + |
|
| 204 | + /** |
|
| 205 | + * Check if value contains blank value or empty array |
|
| 206 | + * |
|
| 207 | + * @since 2.0 |
|
| 208 | + * @param mixed $value - value to check |
|
| 209 | 209 | * @param string |
| 210 | - * @return boolean |
|
| 211 | - */ |
|
| 212 | - public static function is_empty_value( $value, $empty = '' ) { |
|
| 213 | - return ( is_array( $value ) && empty( $value ) ) || $value === $empty; |
|
| 214 | - } |
|
| 215 | - |
|
| 216 | - public static function is_not_empty_value( $value, $empty = '' ) { |
|
| 217 | - return ! self::is_empty_value( $value, $empty ); |
|
| 218 | - } |
|
| 219 | - |
|
| 220 | - /** |
|
| 221 | - * Get any value from the $_SERVER |
|
| 222 | - * |
|
| 223 | - * @since 2.0 |
|
| 224 | - * @param string $value |
|
| 225 | - * @return string |
|
| 226 | - */ |
|
| 210 | + * @return boolean |
|
| 211 | + */ |
|
| 212 | + public static function is_empty_value( $value, $empty = '' ) { |
|
| 213 | + return ( is_array( $value ) && empty( $value ) ) || $value === $empty; |
|
| 214 | + } |
|
| 215 | + |
|
| 216 | + public static function is_not_empty_value( $value, $empty = '' ) { |
|
| 217 | + return ! self::is_empty_value( $value, $empty ); |
|
| 218 | + } |
|
| 219 | + |
|
| 220 | + /** |
|
| 221 | + * Get any value from the $_SERVER |
|
| 222 | + * |
|
| 223 | + * @since 2.0 |
|
| 224 | + * @param string $value |
|
| 225 | + * @return string |
|
| 226 | + */ |
|
| 227 | 227 | public static function get_server_value( $value ) { |
| 228 | - return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; |
|
| 229 | - } |
|
| 230 | - |
|
| 231 | - /** |
|
| 232 | - * Check for the IP address in several places |
|
| 233 | - * Used by [ip] shortcode |
|
| 234 | - * |
|
| 235 | - * @return string The IP address of the current user |
|
| 236 | - */ |
|
| 237 | - public static function get_ip_address() { |
|
| 228 | + return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; |
|
| 229 | + } |
|
| 230 | + |
|
| 231 | + /** |
|
| 232 | + * Check for the IP address in several places |
|
| 233 | + * Used by [ip] shortcode |
|
| 234 | + * |
|
| 235 | + * @return string The IP address of the current user |
|
| 236 | + */ |
|
| 237 | + public static function get_ip_address() { |
|
| 238 | 238 | $ip = ''; |
| 239 | 239 | 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 ) { |
| 240 | - if ( ! isset( $_SERVER[ $key ] ) ) { |
|
| 241 | - continue; |
|
| 242 | - } |
|
| 240 | + if ( ! isset( $_SERVER[ $key ] ) ) { |
|
| 241 | + continue; |
|
| 242 | + } |
|
| 243 | 243 | |
| 244 | - foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { |
|
| 245 | - $ip = trim($ip); // just to be safe |
|
| 244 | + foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { |
|
| 245 | + $ip = trim($ip); // just to be safe |
|
| 246 | 246 | |
| 247 | - if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) { |
|
| 248 | - return sanitize_text_field( $ip ); |
|
| 249 | - } |
|
| 250 | - } |
|
| 251 | - } |
|
| 247 | + if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) { |
|
| 248 | + return sanitize_text_field( $ip ); |
|
| 249 | + } |
|
| 250 | + } |
|
| 251 | + } |
|
| 252 | 252 | |
| 253 | 253 | return sanitize_text_field( $ip ); |
| 254 | - } |
|
| 254 | + } |
|
| 255 | 255 | |
| 256 | - public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
|
| 257 | - if ( strpos($param, '[') ) { |
|
| 258 | - $params = explode('[', $param); |
|
| 259 | - $param = $params[0]; |
|
| 260 | - } |
|
| 256 | + public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
|
| 257 | + if ( strpos($param, '[') ) { |
|
| 258 | + $params = explode('[', $param); |
|
| 259 | + $param = $params[0]; |
|
| 260 | + } |
|
| 261 | 261 | |
| 262 | 262 | if ( $src == 'get' ) { |
| 263 | - $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); |
|
| 264 | - if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { |
|
| 265 | - $value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) ); |
|
| 266 | - } |
|
| 263 | + $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); |
|
| 264 | + if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { |
|
| 265 | + $value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) ); |
|
| 266 | + } |
|
| 267 | 267 | self::sanitize_value( $sanitize, $value ); |
| 268 | 268 | } else { |
| 269 | 269 | $value = self::get_simple_request( array( |
@@ -275,18 +275,18 @@ discard block |
||
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) { |
| 278 | - foreach ( $params as $k => $p ) { |
|
| 279 | - if ( ! $k || ! is_array($value) ) { |
|
| 280 | - continue; |
|
| 281 | - } |
|
| 278 | + foreach ( $params as $k => $p ) { |
|
| 279 | + if ( ! $k || ! is_array($value) ) { |
|
| 280 | + continue; |
|
| 281 | + } |
|
| 282 | 282 | |
| 283 | - $p = trim($p, ']'); |
|
| 284 | - $value = isset( $value[ $p ] ) ? $value[ $p ] : $default; |
|
| 285 | - } |
|
| 286 | - } |
|
| 283 | + $p = trim($p, ']'); |
|
| 284 | + $value = isset( $value[ $p ] ) ? $value[ $p ] : $default; |
|
| 285 | + } |
|
| 286 | + } |
|
| 287 | 287 | |
| 288 | - return $value; |
|
| 289 | - } |
|
| 288 | + return $value; |
|
| 289 | + } |
|
| 290 | 290 | |
| 291 | 291 | public static function get_post_param( $param, $default = '', $sanitize = '' ) { |
| 292 | 292 | return self::get_simple_request( array( |
@@ -350,12 +350,12 @@ discard block |
||
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | /** |
| 353 | - * Preserve backslashes in a value, but make sure value doesn't get compounding slashes |
|
| 354 | - * |
|
| 355 | - * @since 2.0.8 |
|
| 356 | - * @param string $value |
|
| 357 | - * @return string $value |
|
| 358 | - */ |
|
| 353 | + * Preserve backslashes in a value, but make sure value doesn't get compounding slashes |
|
| 354 | + * |
|
| 355 | + * @since 2.0.8 |
|
| 356 | + * @param string $value |
|
| 357 | + * @return string $value |
|
| 358 | + */ |
|
| 359 | 359 | public static function preserve_backslashes( $value ) { |
| 360 | 360 | // If backslashes have already been added, don't add them again |
| 361 | 361 | if ( strpos( $value, '\\\\' ) === false ) { |
@@ -377,14 +377,14 @@ discard block |
||
| 377 | 377 | } |
| 378 | 378 | } |
| 379 | 379 | |
| 380 | - public static function sanitize_request( $sanitize_method, &$values ) { |
|
| 381 | - $temp_values = $values; |
|
| 382 | - foreach ( $temp_values as $k => $val ) { |
|
| 383 | - if ( isset( $sanitize_method[ $k ] ) ) { |
|
| 380 | + public static function sanitize_request( $sanitize_method, &$values ) { |
|
| 381 | + $temp_values = $values; |
|
| 382 | + foreach ( $temp_values as $k => $val ) { |
|
| 383 | + if ( isset( $sanitize_method[ $k ] ) ) { |
|
| 384 | 384 | $values[ $k ] = call_user_func( $sanitize_method[ $k ], $val ); |
| 385 | - } |
|
| 386 | - } |
|
| 387 | - } |
|
| 385 | + } |
|
| 386 | + } |
|
| 387 | + } |
|
| 388 | 388 | |
| 389 | 389 | /** |
| 390 | 390 | * @deprecated 3.01 |
@@ -514,39 +514,39 @@ discard block |
||
| 514 | 514 | ); |
| 515 | 515 | } |
| 516 | 516 | |
| 517 | - /** |
|
| 518 | - * Used when switching the action for a bulk action |
|
| 519 | - * @since 2.0 |
|
| 520 | - */ |
|
| 521 | - public static function remove_get_action() { |
|
| 522 | - if ( ! isset($_GET) ) { |
|
| 523 | - return; |
|
| 524 | - } |
|
| 517 | + /** |
|
| 518 | + * Used when switching the action for a bulk action |
|
| 519 | + * @since 2.0 |
|
| 520 | + */ |
|
| 521 | + public static function remove_get_action() { |
|
| 522 | + if ( ! isset($_GET) ) { |
|
| 523 | + return; |
|
| 524 | + } |
|
| 525 | 525 | |
| 526 | - $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' ); |
|
| 527 | - if ( ! empty( $new_action ) ) { |
|
| 526 | + $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' ); |
|
| 527 | + if ( ! empty( $new_action ) ) { |
|
| 528 | 528 | $_SERVER['REQUEST_URI'] = str_replace( '&action=' . $new_action, '', FrmAppHelper::get_server_value( 'REQUEST_URI' ) ); |
| 529 | - } |
|
| 530 | - } |
|
| 529 | + } |
|
| 530 | + } |
|
| 531 | 531 | |
| 532 | - /** |
|
| 533 | - * Check the WP query for a parameter |
|
| 534 | - * |
|
| 535 | - * @since 2.0 |
|
| 536 | - * @return string|array |
|
| 537 | - */ |
|
| 538 | - public static function get_query_var( $value, $param ) { |
|
| 539 | - if ( $value != '' ) { |
|
| 540 | - return $value; |
|
| 541 | - } |
|
| 532 | + /** |
|
| 533 | + * Check the WP query for a parameter |
|
| 534 | + * |
|
| 535 | + * @since 2.0 |
|
| 536 | + * @return string|array |
|
| 537 | + */ |
|
| 538 | + public static function get_query_var( $value, $param ) { |
|
| 539 | + if ( $value != '' ) { |
|
| 540 | + return $value; |
|
| 541 | + } |
|
| 542 | 542 | |
| 543 | - global $wp_query; |
|
| 544 | - if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
| 545 | - $value = $wp_query->query_vars[ $param ]; |
|
| 546 | - } |
|
| 543 | + global $wp_query; |
|
| 544 | + if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
| 545 | + $value = $wp_query->query_vars[ $param ]; |
|
| 546 | + } |
|
| 547 | 547 | |
| 548 | - return $value; |
|
| 549 | - } |
|
| 548 | + return $value; |
|
| 549 | + } |
|
| 550 | 550 | |
| 551 | 551 | /** |
| 552 | 552 | * @since 3.0 |
@@ -568,16 +568,16 @@ discard block |
||
| 568 | 568 | } |
| 569 | 569 | } |
| 570 | 570 | |
| 571 | - /** |
|
| 572 | - * @param string $type |
|
| 573 | - */ |
|
| 574 | - public static function trigger_hook_load( $type, $object = null ) { |
|
| 575 | - // only load the form hooks once |
|
| 571 | + /** |
|
| 572 | + * @param string $type |
|
| 573 | + */ |
|
| 574 | + public static function trigger_hook_load( $type, $object = null ) { |
|
| 575 | + // only load the form hooks once |
|
| 576 | 576 | $hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object ); |
| 577 | - if ( ! $hooks_loaded ) { |
|
| 577 | + if ( ! $hooks_loaded ) { |
|
| 578 | 578 | do_action( 'frm_load_' . $type . '_hooks' ); |
| 579 | - } |
|
| 580 | - } |
|
| 579 | + } |
|
| 580 | + } |
|
| 581 | 581 | |
| 582 | 582 | /** |
| 583 | 583 | * Save all front-end js scripts into a single file |
@@ -599,29 +599,29 @@ discard block |
||
| 599 | 599 | $new_file->combine_files( $files ); |
| 600 | 600 | } |
| 601 | 601 | |
| 602 | - /** |
|
| 603 | - * Check a value from a shortcode to see if true or false. |
|
| 604 | - * True when value is 1, true, 'true', 'yes' |
|
| 605 | - * |
|
| 606 | - * @since 1.07.10 |
|
| 607 | - * |
|
| 608 | - * @param string $value The value to compare |
|
| 609 | - * @return boolean True or False |
|
| 610 | - */ |
|
| 602 | + /** |
|
| 603 | + * Check a value from a shortcode to see if true or false. |
|
| 604 | + * True when value is 1, true, 'true', 'yes' |
|
| 605 | + * |
|
| 606 | + * @since 1.07.10 |
|
| 607 | + * |
|
| 608 | + * @param string $value The value to compare |
|
| 609 | + * @return boolean True or False |
|
| 610 | + */ |
|
| 611 | 611 | public static function is_true( $value ) { |
| 612 | - return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value ); |
|
| 613 | - } |
|
| 612 | + return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value ); |
|
| 613 | + } |
|
| 614 | 614 | |
| 615 | - /** |
|
| 616 | - * Used to filter shortcode in text widgets |
|
| 615 | + /** |
|
| 616 | + * Used to filter shortcode in text widgets |
|
| 617 | 617 | * |
| 618 | 618 | * @deprecated 2.5.4 |
| 619 | 619 | * @codeCoverageIgnore |
| 620 | - */ |
|
| 621 | - public static function widget_text_filter_callback( $matches ) { |
|
| 620 | + */ |
|
| 621 | + public static function widget_text_filter_callback( $matches ) { |
|
| 622 | 622 | _deprecated_function( __METHOD__, '2.5.4' ); |
| 623 | - return do_shortcode( $matches[0] ); |
|
| 624 | - } |
|
| 623 | + return do_shortcode( $matches[0] ); |
|
| 624 | + } |
|
| 625 | 625 | |
| 626 | 626 | public static function get_pages() { |
| 627 | 627 | return get_posts( array( |
@@ -633,10 +633,10 @@ discard block |
||
| 633 | 633 | ) ); |
| 634 | 634 | } |
| 635 | 635 | |
| 636 | - public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
|
| 637 | - $pages = self::get_pages(); |
|
| 636 | + public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
|
| 637 | + $pages = self::get_pages(); |
|
| 638 | 638 | $selected = self::get_post_param( $field_name, $page_id, 'absint' ); |
| 639 | - ?> |
|
| 639 | + ?> |
|
| 640 | 640 | <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown"> |
| 641 | 641 | <option value=""> </option> |
| 642 | 642 | <?php foreach ( $pages as $page ) { ?> |
@@ -646,16 +646,16 @@ discard block |
||
| 646 | 646 | <?php } ?> |
| 647 | 647 | </select> |
| 648 | 648 | <?php |
| 649 | - } |
|
| 649 | + } |
|
| 650 | 650 | |
| 651 | 651 | public static function post_edit_link( $post_id ) { |
| 652 | - $post = get_post($post_id); |
|
| 653 | - if ( $post ) { |
|
| 652 | + $post = get_post($post_id); |
|
| 653 | + if ( $post ) { |
|
| 654 | 654 | $post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' ); |
| 655 | 655 | return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>'; |
| 656 | - } |
|
| 657 | - return ''; |
|
| 658 | - } |
|
| 656 | + } |
|
| 657 | + return ''; |
|
| 658 | + } |
|
| 659 | 659 | |
| 660 | 660 | public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) { |
| 661 | 661 | ?> |
@@ -666,87 +666,87 @@ discard block |
||
| 666 | 666 | } |
| 667 | 667 | |
| 668 | 668 | public static function roles_options( $capability ) { |
| 669 | - global $frm_vars; |
|
| 670 | - if ( isset($frm_vars['editable_roles']) ) { |
|
| 671 | - $editable_roles = $frm_vars['editable_roles']; |
|
| 672 | - } else { |
|
| 673 | - $editable_roles = get_editable_roles(); |
|
| 674 | - $frm_vars['editable_roles'] = $editable_roles; |
|
| 675 | - } |
|
| 676 | - |
|
| 677 | - foreach ( $editable_roles as $role => $details ) { |
|
| 669 | + global $frm_vars; |
|
| 670 | + if ( isset($frm_vars['editable_roles']) ) { |
|
| 671 | + $editable_roles = $frm_vars['editable_roles']; |
|
| 672 | + } else { |
|
| 673 | + $editable_roles = get_editable_roles(); |
|
| 674 | + $frm_vars['editable_roles'] = $editable_roles; |
|
| 675 | + } |
|
| 676 | + |
|
| 677 | + foreach ( $editable_roles as $role => $details ) { |
|
| 678 | 678 | $name = translate_user_role( $details['name'] ); |
| 679 | 679 | ?> |
| 680 | 680 | <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option> |
| 681 | 681 | <?php |
| 682 | - unset($role, $details); |
|
| 683 | - } |
|
| 684 | - } |
|
| 682 | + unset($role, $details); |
|
| 683 | + } |
|
| 684 | + } |
|
| 685 | 685 | |
| 686 | 686 | public static function frm_capabilities( $type = 'auto' ) { |
| 687 | - $cap = array( |
|
| 688 | - 'frm_view_forms' => __( 'View Forms and Templates', 'formidable' ), |
|
| 689 | - 'frm_edit_forms' => __( 'Add/Edit Forms and Templates', 'formidable' ), |
|
| 690 | - 'frm_delete_forms' => __( 'Delete Forms and Templates', 'formidable' ), |
|
| 691 | - 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ), |
|
| 692 | - 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ), |
|
| 693 | - 'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ), |
|
| 694 | - ); |
|
| 687 | + $cap = array( |
|
| 688 | + 'frm_view_forms' => __( 'View Forms and Templates', 'formidable' ), |
|
| 689 | + 'frm_edit_forms' => __( 'Add/Edit Forms and Templates', 'formidable' ), |
|
| 690 | + 'frm_delete_forms' => __( 'Delete Forms and Templates', 'formidable' ), |
|
| 691 | + 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ), |
|
| 692 | + 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ), |
|
| 693 | + 'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ), |
|
| 694 | + ); |
|
| 695 | 695 | |
| 696 | 696 | if ( ! self::pro_is_installed() && 'pro' != $type ) { |
| 697 | - return $cap; |
|
| 698 | - } |
|
| 697 | + return $cap; |
|
| 698 | + } |
|
| 699 | 699 | |
| 700 | - $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' ); |
|
| 701 | - $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' ); |
|
| 702 | - $cap['frm_view_reports'] = __( 'View Reports', 'formidable' ); |
|
| 703 | - $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' ); |
|
| 700 | + $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' ); |
|
| 701 | + $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' ); |
|
| 702 | + $cap['frm_view_reports'] = __( 'View Reports', 'formidable' ); |
|
| 703 | + $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' ); |
|
| 704 | 704 | |
| 705 | - return $cap; |
|
| 706 | - } |
|
| 705 | + return $cap; |
|
| 706 | + } |
|
| 707 | 707 | |
| 708 | 708 | public static function user_has_permission( $needed_role ) { |
| 709 | - if ( $needed_role == '-1' ) { |
|
| 710 | - return false; |
|
| 709 | + if ( $needed_role == '-1' ) { |
|
| 710 | + return false; |
|
| 711 | 711 | } |
| 712 | 712 | |
| 713 | - // $needed_role will be equal to blank if "Logged-in users" is selected |
|
| 714 | - if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) { |
|
| 715 | - return true; |
|
| 716 | - } |
|
| 713 | + // $needed_role will be equal to blank if "Logged-in users" is selected |
|
| 714 | + if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) { |
|
| 715 | + return true; |
|
| 716 | + } |
|
| 717 | 717 | |
| 718 | - $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ); |
|
| 719 | - foreach ( $roles as $role ) { |
|
| 718 | + $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ); |
|
| 719 | + foreach ( $roles as $role ) { |
|
| 720 | 720 | if ( current_user_can( $role ) ) { |
| 721 | - return true; |
|
| 721 | + return true; |
|
| 722 | 722 | } |
| 723 | - if ( $role == $needed_role ) { |
|
| 724 | - break; |
|
| 723 | + if ( $role == $needed_role ) { |
|
| 724 | + break; |
|
| 725 | 725 | } |
| 726 | - } |
|
| 727 | - return false; |
|
| 728 | - } |
|
| 729 | - |
|
| 730 | - /** |
|
| 731 | - * Make sure administrators can see Formidable menu |
|
| 732 | - * |
|
| 733 | - * @since 2.0 |
|
| 734 | - */ |
|
| 735 | - public static function maybe_add_permissions() { |
|
| 726 | + } |
|
| 727 | + return false; |
|
| 728 | + } |
|
| 729 | + |
|
| 730 | + /** |
|
| 731 | + * Make sure administrators can see Formidable menu |
|
| 732 | + * |
|
| 733 | + * @since 2.0 |
|
| 734 | + */ |
|
| 735 | + public static function maybe_add_permissions() { |
|
| 736 | 736 | self::force_capability( 'frm_view_entries' ); |
| 737 | 737 | |
| 738 | - if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) { |
|
| 739 | - return; |
|
| 740 | - } |
|
| 738 | + if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) { |
|
| 739 | + return; |
|
| 740 | + } |
|
| 741 | 741 | |
| 742 | 742 | $user_id = get_current_user_id(); |
| 743 | 743 | $user = new WP_User( $user_id ); |
| 744 | - $frm_roles = self::frm_capabilities(); |
|
| 745 | - foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 744 | + $frm_roles = self::frm_capabilities(); |
|
| 745 | + foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 746 | 746 | $user->add_cap( $frm_role ); |
| 747 | - unset($frm_role, $frm_role_description); |
|
| 748 | - } |
|
| 749 | - } |
|
| 747 | + unset($frm_role, $frm_role_description); |
|
| 748 | + } |
|
| 749 | + } |
|
| 750 | 750 | |
| 751 | 751 | /** |
| 752 | 752 | * Make sure admins have permission to see the menu items |
@@ -762,28 +762,28 @@ discard block |
||
| 762 | 762 | } |
| 763 | 763 | } |
| 764 | 764 | |
| 765 | - /** |
|
| 766 | - * Check if the user has permision for action. |
|
| 767 | - * Return permission message and stop the action if no permission |
|
| 768 | - * @since 2.0 |
|
| 769 | - * @param string $permission |
|
| 770 | - */ |
|
| 765 | + /** |
|
| 766 | + * Check if the user has permision for action. |
|
| 767 | + * Return permission message and stop the action if no permission |
|
| 768 | + * @since 2.0 |
|
| 769 | + * @param string $permission |
|
| 770 | + */ |
|
| 771 | 771 | public static function permission_check( $permission, $show_message = 'show' ) { |
| 772 | - $permission_error = self::permission_nonce_error($permission); |
|
| 773 | - if ( $permission_error !== false ) { |
|
| 774 | - if ( 'hide' == $show_message ) { |
|
| 775 | - $permission_error = ''; |
|
| 776 | - } |
|
| 777 | - wp_die($permission_error); |
|
| 778 | - } |
|
| 779 | - } |
|
| 780 | - |
|
| 781 | - /** |
|
| 782 | - * Check user permission and nonce |
|
| 783 | - * @since 2.0 |
|
| 784 | - * @param string $permission |
|
| 785 | - * @return false|string The permission message or false if allowed |
|
| 786 | - */ |
|
| 772 | + $permission_error = self::permission_nonce_error($permission); |
|
| 773 | + if ( $permission_error !== false ) { |
|
| 774 | + if ( 'hide' == $show_message ) { |
|
| 775 | + $permission_error = ''; |
|
| 776 | + } |
|
| 777 | + wp_die($permission_error); |
|
| 778 | + } |
|
| 779 | + } |
|
| 780 | + |
|
| 781 | + /** |
|
| 782 | + * Check user permission and nonce |
|
| 783 | + * @since 2.0 |
|
| 784 | + * @param string $permission |
|
| 785 | + * @return false|string The permission message or false if allowed |
|
| 786 | + */ |
|
| 787 | 787 | public static function permission_nonce_error( $permission, $nonce_name = '', $nonce = '' ) { |
| 788 | 788 | if ( ! empty( $permission ) && ! current_user_can( $permission ) && ! current_user_can( 'administrator' ) ) { |
| 789 | 789 | $frm_settings = self::get_settings(); |
@@ -791,23 +791,23 @@ discard block |
||
| 791 | 791 | } |
| 792 | 792 | |
| 793 | 793 | $error = false; |
| 794 | - if ( empty($nonce_name) ) { |
|
| 795 | - return $error; |
|
| 796 | - } |
|
| 794 | + if ( empty($nonce_name) ) { |
|
| 795 | + return $error; |
|
| 796 | + } |
|
| 797 | 797 | |
| 798 | - if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
| 799 | - $frm_settings = self::get_settings(); |
|
| 800 | - $error = $frm_settings->admin_permission; |
|
| 801 | - } |
|
| 798 | + if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
| 799 | + $frm_settings = self::get_settings(); |
|
| 800 | + $error = $frm_settings->admin_permission; |
|
| 801 | + } |
|
| 802 | 802 | |
| 803 | - return $error; |
|
| 804 | - } |
|
| 803 | + return $error; |
|
| 804 | + } |
|
| 805 | 805 | |
| 806 | - public static function checked( $values, $current ) { |
|
| 806 | + public static function checked( $values, $current ) { |
|
| 807 | 807 | if ( self::check_selected( $values, $current ) ) { |
| 808 | - echo ' checked="checked"'; |
|
| 808 | + echo ' checked="checked"'; |
|
| 809 | 809 | } |
| 810 | - } |
|
| 810 | + } |
|
| 811 | 811 | |
| 812 | 812 | public static function check_selected( $values, $current ) { |
| 813 | 813 | $values = self::recursive_function_map( $values, 'trim' ); |
@@ -845,24 +845,24 @@ discard block |
||
| 845 | 845 | return (bool) count( array_filter( array_keys( $array ), 'is_string' ) ); |
| 846 | 846 | } |
| 847 | 847 | |
| 848 | - /** |
|
| 849 | - * Flatten a multi-dimensional array |
|
| 850 | - */ |
|
| 848 | + /** |
|
| 849 | + * Flatten a multi-dimensional array |
|
| 850 | + */ |
|
| 851 | 851 | public static function array_flatten( $array, $keys = 'keep' ) { |
| 852 | - $return = array(); |
|
| 853 | - foreach ( $array as $key => $value ) { |
|
| 854 | - if ( is_array($value) ) { |
|
| 852 | + $return = array(); |
|
| 853 | + foreach ( $array as $key => $value ) { |
|
| 854 | + if ( is_array($value) ) { |
|
| 855 | 855 | $return = array_merge( $return, self::array_flatten( $value, $keys ) ); |
| 856 | - } else { |
|
| 856 | + } else { |
|
| 857 | 857 | if ( $keys == 'keep' ) { |
| 858 | 858 | $return[ $key ] = $value; |
| 859 | 859 | } else { |
| 860 | 860 | $return[] = $value; |
| 861 | 861 | } |
| 862 | - } |
|
| 863 | - } |
|
| 864 | - return $return; |
|
| 865 | - } |
|
| 862 | + } |
|
| 863 | + } |
|
| 864 | + return $return; |
|
| 865 | + } |
|
| 866 | 866 | |
| 867 | 867 | public static function esc_textarea( $text, $is_rich_text = false ) { |
| 868 | 868 | $safe_text = str_replace( '"', '"', $text ); |
@@ -873,38 +873,38 @@ discard block |
||
| 873 | 873 | return apply_filters( 'esc_textarea', $safe_text, $text ); |
| 874 | 874 | } |
| 875 | 875 | |
| 876 | - /** |
|
| 877 | - * Add auto paragraphs to text areas |
|
| 878 | - * @since 2.0 |
|
| 879 | - */ |
|
| 876 | + /** |
|
| 877 | + * Add auto paragraphs to text areas |
|
| 878 | + * @since 2.0 |
|
| 879 | + */ |
|
| 880 | 880 | public static function use_wpautop( $content ) { |
| 881 | - if ( apply_filters('frm_use_wpautop', true) ) { |
|
| 882 | - $content = wpautop(str_replace( '<br>', '<br />', $content)); |
|
| 883 | - } |
|
| 884 | - return $content; |
|
| 885 | - } |
|
| 881 | + if ( apply_filters('frm_use_wpautop', true) ) { |
|
| 882 | + $content = wpautop(str_replace( '<br>', '<br />', $content)); |
|
| 883 | + } |
|
| 884 | + return $content; |
|
| 885 | + } |
|
| 886 | 886 | |
| 887 | 887 | public static function replace_quotes( $val ) { |
| 888 | - //Replace double quotes |
|
| 888 | + //Replace double quotes |
|
| 889 | 889 | $val = str_replace( array( '“', '”', '″' ), '"', $val ); |
| 890 | - //Replace single quotes |
|
| 891 | - $val = str_replace( array( '‘', '’', '′', '′', '’', '‘' ), "'", $val ); |
|
| 892 | - return $val; |
|
| 893 | - } |
|
| 894 | - |
|
| 895 | - /** |
|
| 896 | - * @since 2.0 |
|
| 897 | - * @return string The base Google APIS url for the current version of jQuery UI |
|
| 898 | - */ |
|
| 899 | - public static function jquery_ui_base_url() { |
|
| 890 | + //Replace single quotes |
|
| 891 | + $val = str_replace( array( '‘', '’', '′', '′', '’', '‘' ), "'", $val ); |
|
| 892 | + return $val; |
|
| 893 | + } |
|
| 894 | + |
|
| 895 | + /** |
|
| 896 | + * @since 2.0 |
|
| 897 | + * @return string The base Google APIS url for the current version of jQuery UI |
|
| 898 | + */ |
|
| 899 | + public static function jquery_ui_base_url() { |
|
| 900 | 900 | $url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core', '1.11.4' ); |
| 901 | - $url = apply_filters('frm_jquery_ui_base_url', $url); |
|
| 902 | - return $url; |
|
| 903 | - } |
|
| 901 | + $url = apply_filters('frm_jquery_ui_base_url', $url); |
|
| 902 | + return $url; |
|
| 903 | + } |
|
| 904 | 904 | |
| 905 | - /** |
|
| 906 | - * @param string $handle |
|
| 907 | - */ |
|
| 905 | + /** |
|
| 906 | + * @param string $handle |
|
| 907 | + */ |
|
| 908 | 908 | public static function script_version( $handle, $default = 0 ) { |
| 909 | 909 | global $wp_scripts; |
| 910 | 910 | if ( ! $wp_scripts ) { |
@@ -926,75 +926,75 @@ discard block |
||
| 926 | 926 | |
| 927 | 927 | public static function js_redirect( $url ) { |
| 928 | 928 | return '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>'; |
| 929 | - } |
|
| 929 | + } |
|
| 930 | 930 | |
| 931 | 931 | public static function get_user_id_param( $user_id ) { |
| 932 | - if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) { |
|
| 933 | - return $user_id; |
|
| 934 | - } |
|
| 932 | + if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) { |
|
| 933 | + return $user_id; |
|
| 934 | + } |
|
| 935 | 935 | |
| 936 | 936 | $user_id = sanitize_text_field( $user_id ); |
| 937 | 937 | if ( $user_id == 'current' ) { |
| 938 | 938 | $user_id = get_current_user_id(); |
| 939 | 939 | } else { |
| 940 | - if ( is_email($user_id) ) { |
|
| 941 | - $user = get_user_by('email', $user_id); |
|
| 942 | - } else { |
|
| 943 | - $user = get_user_by('login', $user_id); |
|
| 944 | - } |
|
| 940 | + if ( is_email($user_id) ) { |
|
| 941 | + $user = get_user_by('email', $user_id); |
|
| 942 | + } else { |
|
| 943 | + $user = get_user_by('login', $user_id); |
|
| 944 | + } |
|
| 945 | 945 | |
| 946 | - if ( $user ) { |
|
| 947 | - $user_id = $user->ID; |
|
| 948 | - } |
|
| 949 | - unset($user); |
|
| 950 | - } |
|
| 946 | + if ( $user ) { |
|
| 947 | + $user_id = $user->ID; |
|
| 948 | + } |
|
| 949 | + unset($user); |
|
| 950 | + } |
|
| 951 | 951 | |
| 952 | - return $user_id; |
|
| 953 | - } |
|
| 952 | + return $user_id; |
|
| 953 | + } |
|
| 954 | 954 | |
| 955 | 955 | public static function get_file_contents( $filename, $atts = array() ) { |
| 956 | - if ( ! is_file($filename) ) { |
|
| 957 | - return false; |
|
| 958 | - } |
|
| 959 | - |
|
| 960 | - extract($atts); |
|
| 961 | - ob_start(); |
|
| 962 | - include($filename); |
|
| 963 | - $contents = ob_get_contents(); |
|
| 964 | - ob_end_clean(); |
|
| 965 | - return $contents; |
|
| 966 | - } |
|
| 967 | - |
|
| 968 | - /** |
|
| 969 | - * @param string $table_name |
|
| 970 | - * @param string $column |
|
| 956 | + if ( ! is_file($filename) ) { |
|
| 957 | + return false; |
|
| 958 | + } |
|
| 959 | + |
|
| 960 | + extract($atts); |
|
| 961 | + ob_start(); |
|
| 962 | + include($filename); |
|
| 963 | + $contents = ob_get_contents(); |
|
| 964 | + ob_end_clean(); |
|
| 965 | + return $contents; |
|
| 966 | + } |
|
| 967 | + |
|
| 968 | + /** |
|
| 969 | + * @param string $table_name |
|
| 970 | + * @param string $column |
|
| 971 | 971 | * @param int $id |
| 972 | 972 | * @param int $num_chars |
| 973 | - */ |
|
| 974 | - public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) { |
|
| 975 | - $key = ''; |
|
| 973 | + */ |
|
| 974 | + public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) { |
|
| 975 | + $key = ''; |
|
| 976 | 976 | |
| 977 | - if ( ! empty( $name ) ) { |
|
| 978 | - $key = sanitize_key($name); |
|
| 979 | - } |
|
| 977 | + if ( ! empty( $name ) ) { |
|
| 978 | + $key = sanitize_key($name); |
|
| 979 | + } |
|
| 980 | 980 | |
| 981 | 981 | if ( empty( $key ) ) { |
| 982 | - $max_slug_value = pow(36, $num_chars); |
|
| 983 | - $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
| 984 | - $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
| 985 | - } |
|
| 982 | + $max_slug_value = pow(36, $num_chars); |
|
| 983 | + $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
| 984 | + $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
| 985 | + } |
|
| 986 | 986 | |
| 987 | 987 | if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) { |
| 988 | 988 | $key = $key . 'a'; |
| 989 | - } |
|
| 989 | + } |
|
| 990 | 990 | |
| 991 | 991 | $key_check = FrmDb::get_var( $table_name, array( |
| 992 | 992 | $column => $key, |
| 993 | 993 | 'ID !' => $id, |
| 994 | 994 | ), $column ); |
| 995 | 995 | |
| 996 | - if ( $key_check || is_numeric($key_check) ) { |
|
| 997 | - $suffix = 2; |
|
| 996 | + if ( $key_check || is_numeric($key_check) ) { |
|
| 997 | + $suffix = 2; |
|
| 998 | 998 | do { |
| 999 | 999 | $alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix; |
| 1000 | 1000 | $key_check = FrmDb::get_var( $table_name, array( |
@@ -1004,23 +1004,23 @@ discard block |
||
| 1004 | 1004 | $suffix++; |
| 1005 | 1005 | } while ( $key_check || is_numeric( $key_check ) ); |
| 1006 | 1006 | $key = $alt_post_name; |
| 1007 | - } |
|
| 1008 | - return $key; |
|
| 1009 | - } |
|
| 1010 | - |
|
| 1011 | - /** |
|
| 1012 | - * Editing a Form or Entry |
|
| 1013 | - * @param string $table |
|
| 1014 | - * @return bool|array |
|
| 1015 | - */ |
|
| 1016 | - public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) { |
|
| 1017 | - if ( ! $record ) { |
|
| 1018 | - return false; |
|
| 1019 | - } |
|
| 1020 | - |
|
| 1021 | - if ( empty($post_values) ) { |
|
| 1022 | - $post_values = stripslashes_deep($_POST); |
|
| 1023 | - } |
|
| 1007 | + } |
|
| 1008 | + return $key; |
|
| 1009 | + } |
|
| 1010 | + |
|
| 1011 | + /** |
|
| 1012 | + * Editing a Form or Entry |
|
| 1013 | + * @param string $table |
|
| 1014 | + * @return bool|array |
|
| 1015 | + */ |
|
| 1016 | + public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) { |
|
| 1017 | + if ( ! $record ) { |
|
| 1018 | + return false; |
|
| 1019 | + } |
|
| 1020 | + |
|
| 1021 | + if ( empty($post_values) ) { |
|
| 1022 | + $post_values = stripslashes_deep($_POST); |
|
| 1023 | + } |
|
| 1024 | 1024 | |
| 1025 | 1025 | $values = array( |
| 1026 | 1026 | 'id' => $record->id, |
@@ -1028,25 +1028,25 @@ discard block |
||
| 1028 | 1028 | ); |
| 1029 | 1029 | |
| 1030 | 1030 | foreach ( array( 'name', 'description' ) as $var ) { |
| 1031 | - $default_val = isset($record->{$var}) ? $record->{$var} : ''; |
|
| 1031 | + $default_val = isset($record->{$var}) ? $record->{$var} : ''; |
|
| 1032 | 1032 | $values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' ); |
| 1033 | - unset($var, $default_val); |
|
| 1034 | - } |
|
| 1033 | + unset($var, $default_val); |
|
| 1034 | + } |
|
| 1035 | 1035 | |
| 1036 | - $values['description'] = self::use_wpautop($values['description']); |
|
| 1036 | + $values['description'] = self::use_wpautop($values['description']); |
|
| 1037 | 1037 | |
| 1038 | - self::fill_form_opts($record, $table, $post_values, $values); |
|
| 1038 | + self::fill_form_opts($record, $table, $post_values, $values); |
|
| 1039 | 1039 | |
| 1040 | 1040 | self::prepare_field_arrays( $fields, $record, $values, array_merge( $args, compact( 'default', 'post_values' ) ) ); |
| 1041 | 1041 | |
| 1042 | - if ( $table == 'entries' ) { |
|
| 1043 | - $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
|
| 1044 | - } else if ( $table == 'forms' ) { |
|
| 1045 | - $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values ); |
|
| 1046 | - } |
|
| 1042 | + if ( $table == 'entries' ) { |
|
| 1043 | + $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
|
| 1044 | + } else if ( $table == 'forms' ) { |
|
| 1045 | + $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values ); |
|
| 1046 | + } |
|
| 1047 | 1047 | |
| 1048 | - return $values; |
|
| 1049 | - } |
|
| 1048 | + return $values; |
|
| 1049 | + } |
|
| 1050 | 1050 | |
| 1051 | 1051 | private static function prepare_field_arrays( $fields, $record, array &$values, $args ) { |
| 1052 | 1052 | if ( ! empty( $fields ) ) { |
@@ -1059,46 +1059,46 @@ discard block |
||
| 1059 | 1059 | } |
| 1060 | 1060 | |
| 1061 | 1061 | private static function fill_field_defaults( $field, $record, array &$values, $args ) { |
| 1062 | - $post_values = $args['post_values']; |
|
| 1063 | - |
|
| 1064 | - if ( $args['default'] ) { |
|
| 1065 | - $meta_value = $field->default_value; |
|
| 1066 | - } else { |
|
| 1067 | - if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) { |
|
| 1068 | - if ( ! isset($field->field_options['custom_field']) ) { |
|
| 1069 | - $field->field_options['custom_field'] = ''; |
|
| 1070 | - } |
|
| 1062 | + $post_values = $args['post_values']; |
|
| 1063 | + |
|
| 1064 | + if ( $args['default'] ) { |
|
| 1065 | + $meta_value = $field->default_value; |
|
| 1066 | + } else { |
|
| 1067 | + if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) { |
|
| 1068 | + if ( ! isset($field->field_options['custom_field']) ) { |
|
| 1069 | + $field->field_options['custom_field'] = ''; |
|
| 1070 | + } |
|
| 1071 | 1071 | $meta_value = FrmProEntryMetaHelper::get_post_value( $record->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array( |
| 1072 | 1072 | 'truncate' => false, |
| 1073 | 1073 | 'type' => $field->type, |
| 1074 | 1074 | 'form_id' => $field->form_id, |
| 1075 | 1075 | 'field' => $field, |
| 1076 | 1076 | ) ); |
| 1077 | - } else { |
|
| 1077 | + } else { |
|
| 1078 | 1078 | $meta_value = FrmEntryMeta::get_meta_value( $record, $field->id ); |
| 1079 | - } |
|
| 1080 | - } |
|
| 1079 | + } |
|
| 1080 | + } |
|
| 1081 | 1081 | |
| 1082 | 1082 | $field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type; |
| 1083 | - $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
| 1083 | + $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
| 1084 | 1084 | |
| 1085 | 1085 | $field_array = self::start_field_array( $field ); |
| 1086 | 1086 | $field_array['value'] = $new_value; |
| 1087 | 1087 | $field_array['type'] = apply_filters( 'frm_field_type', $field_type, $field, $new_value ); |
| 1088 | 1088 | $field_array['parent_form_id'] = $args['parent_form_id']; |
| 1089 | 1089 | |
| 1090 | - $args['field_type'] = $field_type; |
|
| 1090 | + $args['field_type'] = $field_type; |
|
| 1091 | 1091 | |
| 1092 | 1092 | FrmFieldsHelper::prepare_edit_front_field( $field_array, $field, $values['id'], $args ); |
| 1093 | 1093 | |
| 1094 | - if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) { |
|
| 1095 | - $field_array['unique_msg'] = ''; |
|
| 1096 | - } |
|
| 1094 | + if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) { |
|
| 1095 | + $field_array['unique_msg'] = ''; |
|
| 1096 | + } |
|
| 1097 | 1097 | |
| 1098 | - $field_array = array_merge( $field->field_options, $field_array ); |
|
| 1098 | + $field_array = array_merge( $field->field_options, $field_array ); |
|
| 1099 | 1099 | |
| 1100 | - $values['fields'][ $field->id ] = $field_array; |
|
| 1101 | - } |
|
| 1100 | + $values['fields'][ $field->id ] = $field_array; |
|
| 1101 | + } |
|
| 1102 | 1102 | |
| 1103 | 1103 | /** |
| 1104 | 1104 | * @since 3.0 |
@@ -1119,48 +1119,48 @@ discard block |
||
| 1119 | 1119 | ); |
| 1120 | 1120 | } |
| 1121 | 1121 | |
| 1122 | - /** |
|
| 1123 | - * @param string $table |
|
| 1124 | - */ |
|
| 1122 | + /** |
|
| 1123 | + * @param string $table |
|
| 1124 | + */ |
|
| 1125 | 1125 | private static function fill_form_opts( $record, $table, $post_values, array &$values ) { |
| 1126 | - if ( $table == 'entries' ) { |
|
| 1127 | - $form = $record->form_id; |
|
| 1126 | + if ( $table == 'entries' ) { |
|
| 1127 | + $form = $record->form_id; |
|
| 1128 | 1128 | FrmForm::maybe_get_form( $form ); |
| 1129 | - } else { |
|
| 1130 | - $form = $record; |
|
| 1131 | - } |
|
| 1129 | + } else { |
|
| 1130 | + $form = $record; |
|
| 1131 | + } |
|
| 1132 | 1132 | |
| 1133 | - if ( ! $form ) { |
|
| 1134 | - return; |
|
| 1135 | - } |
|
| 1133 | + if ( ! $form ) { |
|
| 1134 | + return; |
|
| 1135 | + } |
|
| 1136 | 1136 | |
| 1137 | - $values['form_name'] = isset($record->form_id) ? $form->name : ''; |
|
| 1137 | + $values['form_name'] = isset($record->form_id) ? $form->name : ''; |
|
| 1138 | 1138 | $values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0; |
| 1139 | 1139 | |
| 1140 | - if ( ! is_array($form->options) ) { |
|
| 1141 | - return; |
|
| 1142 | - } |
|
| 1140 | + if ( ! is_array($form->options) ) { |
|
| 1141 | + return; |
|
| 1142 | + } |
|
| 1143 | 1143 | |
| 1144 | - foreach ( $form->options as $opt => $value ) { |
|
| 1145 | - $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
| 1146 | - } |
|
| 1144 | + foreach ( $form->options as $opt => $value ) { |
|
| 1145 | + $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
| 1146 | + } |
|
| 1147 | 1147 | |
| 1148 | - self::fill_form_defaults($post_values, $values); |
|
| 1149 | - } |
|
| 1148 | + self::fill_form_defaults($post_values, $values); |
|
| 1149 | + } |
|
| 1150 | 1150 | |
| 1151 | - /** |
|
| 1152 | - * Set to POST value or default |
|
| 1153 | - */ |
|
| 1151 | + /** |
|
| 1152 | + * Set to POST value or default |
|
| 1153 | + */ |
|
| 1154 | 1154 | private static function fill_form_defaults( $post_values, array &$values ) { |
| 1155 | - $form_defaults = FrmFormsHelper::get_default_opts(); |
|
| 1155 | + $form_defaults = FrmFormsHelper::get_default_opts(); |
|
| 1156 | 1156 | |
| 1157 | - foreach ( $form_defaults as $opt => $default ) { |
|
| 1158 | - if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
| 1157 | + foreach ( $form_defaults as $opt => $default ) { |
|
| 1158 | + if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
| 1159 | 1159 | $values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default; |
| 1160 | - } |
|
| 1160 | + } |
|
| 1161 | 1161 | |
| 1162 | - unset($opt, $defaut); |
|
| 1163 | - } |
|
| 1162 | + unset($opt, $defaut); |
|
| 1163 | + } |
|
| 1164 | 1164 | |
| 1165 | 1165 | if ( ! isset( $values['custom_style'] ) ) { |
| 1166 | 1166 | $values['custom_style'] = self::custom_style_value( $post_values ); |
@@ -1169,10 +1169,10 @@ discard block |
||
| 1169 | 1169 | foreach ( array( 'before', 'after', 'submit' ) as $h ) { |
| 1170 | 1170 | if ( ! isset( $values[ $h . '_html' ] ) ) { |
| 1171 | 1171 | $values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) ); |
| 1172 | - } |
|
| 1173 | - unset($h); |
|
| 1174 | - } |
|
| 1175 | - } |
|
| 1172 | + } |
|
| 1173 | + unset($h); |
|
| 1174 | + } |
|
| 1175 | + } |
|
| 1176 | 1176 | |
| 1177 | 1177 | /** |
| 1178 | 1178 | * @since 2.2.10 |
@@ -1195,55 +1195,55 @@ discard block |
||
| 1195 | 1195 | if ( $possible_email_field ) { |
| 1196 | 1196 | $class .= 'show_frm_not_email_to'; |
| 1197 | 1197 | } |
| 1198 | - ?> |
|
| 1198 | + ?> |
|
| 1199 | 1199 | <li> |
| 1200 | 1200 | <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> |
| 1201 | 1201 | <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> |
| 1202 | 1202 | <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> |
| 1203 | 1203 | </li> |
| 1204 | 1204 | <?php |
| 1205 | - } |
|
| 1205 | + } |
|
| 1206 | 1206 | |
| 1207 | 1207 | public static function truncate( $str, $length, $minword = 3, $continue = '...' ) { |
| 1208 | - if ( is_array( $str ) ) { |
|
| 1209 | - return ''; |
|
| 1208 | + if ( is_array( $str ) ) { |
|
| 1209 | + return ''; |
|
| 1210 | 1210 | } |
| 1211 | 1211 | |
| 1212 | - $length = (int) $length; |
|
| 1212 | + $length = (int) $length; |
|
| 1213 | 1213 | $str = wp_strip_all_tags( $str ); |
| 1214 | 1214 | $original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) ); |
| 1215 | 1215 | |
| 1216 | 1216 | if ( $length == 0 ) { |
| 1217 | - return ''; |
|
| 1218 | - } else if ( $length <= 10 ) { |
|
| 1217 | + return ''; |
|
| 1218 | + } else if ( $length <= 10 ) { |
|
| 1219 | 1219 | $sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) ); |
| 1220 | 1220 | return $sub . ( ( $length < $original_len ) ? $continue : '' ); |
| 1221 | - } |
|
| 1221 | + } |
|
| 1222 | 1222 | |
| 1223 | - $sub = ''; |
|
| 1224 | - $len = 0; |
|
| 1223 | + $sub = ''; |
|
| 1224 | + $len = 0; |
|
| 1225 | 1225 | |
| 1226 | 1226 | $words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) ); |
| 1227 | 1227 | |
| 1228 | 1228 | foreach ( $words as $word ) { |
| 1229 | 1229 | $part = ( ( $sub != '' ) ? ' ' : '' ) . $word; |
| 1230 | 1230 | $total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) ); |
| 1231 | - if ( $total_len > $length && str_word_count($sub) ) { |
|
| 1232 | - break; |
|
| 1233 | - } |
|
| 1231 | + if ( $total_len > $length && str_word_count($sub) ) { |
|
| 1232 | + break; |
|
| 1233 | + } |
|
| 1234 | 1234 | |
| 1235 | - $sub .= $part; |
|
| 1235 | + $sub .= $part; |
|
| 1236 | 1236 | $len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) ); |
| 1237 | 1237 | |
| 1238 | - if ( str_word_count($sub) > $minword && $total_len >= $length ) { |
|
| 1239 | - break; |
|
| 1240 | - } |
|
| 1238 | + if ( str_word_count($sub) > $minword && $total_len >= $length ) { |
|
| 1239 | + break; |
|
| 1240 | + } |
|
| 1241 | 1241 | |
| 1242 | - unset($total_len, $word); |
|
| 1243 | - } |
|
| 1242 | + unset($total_len, $word); |
|
| 1243 | + } |
|
| 1244 | 1244 | |
| 1245 | 1245 | return $sub . ( ( $len < $original_len ) ? $continue : '' ); |
| 1246 | - } |
|
| 1246 | + } |
|
| 1247 | 1247 | |
| 1248 | 1248 | public static function mb_function( $function_names, $args ) { |
| 1249 | 1249 | $mb_function_name = $function_names[0]; |
@@ -1255,18 +1255,18 @@ discard block |
||
| 1255 | 1255 | } |
| 1256 | 1256 | |
| 1257 | 1257 | public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) { |
| 1258 | - if ( empty($date) ) { |
|
| 1259 | - return $date; |
|
| 1260 | - } |
|
| 1258 | + if ( empty($date) ) { |
|
| 1259 | + return $date; |
|
| 1260 | + } |
|
| 1261 | 1261 | |
| 1262 | - if ( empty($date_format) ) { |
|
| 1263 | - $date_format = get_option('date_format'); |
|
| 1264 | - } |
|
| 1262 | + if ( empty($date_format) ) { |
|
| 1263 | + $date_format = get_option('date_format'); |
|
| 1264 | + } |
|
| 1265 | 1265 | |
| 1266 | - if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) { |
|
| 1267 | - $frmpro_settings = new FrmProSettings(); |
|
| 1268 | - $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d'); |
|
| 1269 | - } |
|
| 1266 | + if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) { |
|
| 1267 | + $frmpro_settings = new FrmProSettings(); |
|
| 1268 | + $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d'); |
|
| 1269 | + } |
|
| 1270 | 1270 | |
| 1271 | 1271 | $formatted = self::get_localized_date( $date_format, $date ); |
| 1272 | 1272 | |
@@ -1275,8 +1275,8 @@ discard block |
||
| 1275 | 1275 | $formatted .= self::add_time_to_date( $time_format, $date ); |
| 1276 | 1276 | } |
| 1277 | 1277 | |
| 1278 | - return $formatted; |
|
| 1279 | - } |
|
| 1278 | + return $formatted; |
|
| 1279 | + } |
|
| 1280 | 1280 | |
| 1281 | 1281 | private static function add_time_to_date( $time_format, $date ) { |
| 1282 | 1282 | if ( empty( $time_format ) ) { |
@@ -1358,119 +1358,119 @@ discard block |
||
| 1358 | 1358 | ); |
| 1359 | 1359 | } |
| 1360 | 1360 | |
| 1361 | - // Pagination Methods |
|
| 1361 | + // Pagination Methods |
|
| 1362 | 1362 | |
| 1363 | - /** |
|
| 1364 | - * @param integer $current_p |
|
| 1365 | - */ |
|
| 1363 | + /** |
|
| 1364 | + * @param integer $current_p |
|
| 1365 | + */ |
|
| 1366 | 1366 | public static function get_last_record_num( $r_count, $current_p, $p_size ) { |
| 1367 | 1367 | return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) ); |
| 1368 | 1368 | } |
| 1369 | 1369 | |
| 1370 | - /** |
|
| 1371 | - * @param integer $current_p |
|
| 1372 | - */ |
|
| 1373 | - public static function get_first_record_num( $r_count, $current_p, $p_size ) { |
|
| 1374 | - if ( $current_p == 1 ) { |
|
| 1375 | - return 1; |
|
| 1376 | - } else { |
|
| 1377 | - return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 ); |
|
| 1378 | - } |
|
| 1379 | - } |
|
| 1370 | + /** |
|
| 1371 | + * @param integer $current_p |
|
| 1372 | + */ |
|
| 1373 | + public static function get_first_record_num( $r_count, $current_p, $p_size ) { |
|
| 1374 | + if ( $current_p == 1 ) { |
|
| 1375 | + return 1; |
|
| 1376 | + } else { |
|
| 1377 | + return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 ); |
|
| 1378 | + } |
|
| 1379 | + } |
|
| 1380 | 1380 | |
| 1381 | 1381 | /** |
| 1382 | 1382 | * @return array |
| 1383 | 1383 | */ |
| 1384 | 1384 | public static function json_to_array( $json_vars ) { |
| 1385 | - $vars = array(); |
|
| 1386 | - foreach ( $json_vars as $jv ) { |
|
| 1387 | - $jv_name = explode('[', $jv['name']); |
|
| 1388 | - $last = count($jv_name) - 1; |
|
| 1389 | - foreach ( $jv_name as $p => $n ) { |
|
| 1390 | - $name = trim($n, ']'); |
|
| 1391 | - if ( ! isset($l1) ) { |
|
| 1392 | - $l1 = $name; |
|
| 1393 | - } |
|
| 1394 | - |
|
| 1395 | - if ( ! isset($l2) ) { |
|
| 1396 | - $l2 = $name; |
|
| 1397 | - } |
|
| 1398 | - |
|
| 1399 | - if ( ! isset($l3) ) { |
|
| 1400 | - $l3 = $name; |
|
| 1401 | - } |
|
| 1402 | - |
|
| 1403 | - $this_val = ( $p == $last ) ? $jv['value'] : array(); |
|
| 1404 | - |
|
| 1405 | - switch ( $p ) { |
|
| 1406 | - case 0: |
|
| 1407 | - $l1 = $name; |
|
| 1408 | - self::add_value_to_array( $name, $l1, $this_val, $vars ); |
|
| 1385 | + $vars = array(); |
|
| 1386 | + foreach ( $json_vars as $jv ) { |
|
| 1387 | + $jv_name = explode('[', $jv['name']); |
|
| 1388 | + $last = count($jv_name) - 1; |
|
| 1389 | + foreach ( $jv_name as $p => $n ) { |
|
| 1390 | + $name = trim($n, ']'); |
|
| 1391 | + if ( ! isset($l1) ) { |
|
| 1392 | + $l1 = $name; |
|
| 1393 | + } |
|
| 1394 | + |
|
| 1395 | + if ( ! isset($l2) ) { |
|
| 1396 | + $l2 = $name; |
|
| 1397 | + } |
|
| 1398 | + |
|
| 1399 | + if ( ! isset($l3) ) { |
|
| 1400 | + $l3 = $name; |
|
| 1401 | + } |
|
| 1402 | + |
|
| 1403 | + $this_val = ( $p == $last ) ? $jv['value'] : array(); |
|
| 1404 | + |
|
| 1405 | + switch ( $p ) { |
|
| 1406 | + case 0: |
|
| 1407 | + $l1 = $name; |
|
| 1408 | + self::add_value_to_array( $name, $l1, $this_val, $vars ); |
|
| 1409 | 1409 | break; |
| 1410 | 1410 | |
| 1411 | - case 1: |
|
| 1412 | - $l2 = $name; |
|
| 1413 | - self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
| 1411 | + case 1: |
|
| 1412 | + $l2 = $name; |
|
| 1413 | + self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
| 1414 | 1414 | break; |
| 1415 | 1415 | |
| 1416 | - case 2: |
|
| 1417 | - $l3 = $name; |
|
| 1418 | - self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
| 1416 | + case 2: |
|
| 1417 | + $l3 = $name; |
|
| 1418 | + self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
| 1419 | 1419 | break; |
| 1420 | 1420 | |
| 1421 | - case 3: |
|
| 1422 | - $l4 = $name; |
|
| 1423 | - self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
| 1424 | - } |
|
| 1421 | + case 3: |
|
| 1422 | + $l4 = $name; |
|
| 1423 | + self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
| 1424 | + } |
|
| 1425 | 1425 | |
| 1426 | - unset($this_val, $n); |
|
| 1427 | - } |
|
| 1426 | + unset($this_val, $n); |
|
| 1427 | + } |
|
| 1428 | 1428 | |
| 1429 | - unset($last, $jv); |
|
| 1430 | - } |
|
| 1429 | + unset($last, $jv); |
|
| 1430 | + } |
|
| 1431 | 1431 | |
| 1432 | - return $vars; |
|
| 1433 | - } |
|
| 1432 | + return $vars; |
|
| 1433 | + } |
|
| 1434 | 1434 | |
| 1435 | - /** |
|
| 1436 | - * @param string $name |
|
| 1437 | - * @param string $l1 |
|
| 1438 | - */ |
|
| 1439 | - public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
|
| 1440 | - if ( $name == '' ) { |
|
| 1441 | - $vars[] = $val; |
|
| 1442 | - } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
| 1443 | - $vars[ $l1 ] = $val; |
|
| 1444 | - } |
|
| 1445 | - } |
|
| 1435 | + /** |
|
| 1436 | + * @param string $name |
|
| 1437 | + * @param string $l1 |
|
| 1438 | + */ |
|
| 1439 | + public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
|
| 1440 | + if ( $name == '' ) { |
|
| 1441 | + $vars[] = $val; |
|
| 1442 | + } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
| 1443 | + $vars[ $l1 ] = $val; |
|
| 1444 | + } |
|
| 1445 | + } |
|
| 1446 | 1446 | |
| 1447 | 1447 | public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) { |
| 1448 | - $tooltips = array( |
|
| 1449 | - 'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ), |
|
| 1450 | - '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' ), |
|
| 1451 | - 'cc' => __( 'Add CC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1452 | - 'bcc' => __( 'Add BCC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1453 | - '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' ), |
|
| 1454 | - 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ), |
|
| 1455 | - '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() ) ), |
|
| 1456 | - ); |
|
| 1457 | - |
|
| 1458 | - if ( ! isset( $tooltips[ $name ] ) ) { |
|
| 1459 | - return; |
|
| 1460 | - } |
|
| 1461 | - |
|
| 1462 | - if ( 'open' == $class ) { |
|
| 1463 | - echo ' frm_help"'; |
|
| 1464 | - } else { |
|
| 1465 | - echo ' class="frm_help"'; |
|
| 1466 | - } |
|
| 1448 | + $tooltips = array( |
|
| 1449 | + 'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ), |
|
| 1450 | + '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' ), |
|
| 1451 | + 'cc' => __( 'Add CC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1452 | + 'bcc' => __( 'Add BCC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1453 | + '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' ), |
|
| 1454 | + 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ), |
|
| 1455 | + '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() ) ), |
|
| 1456 | + ); |
|
| 1457 | + |
|
| 1458 | + if ( ! isset( $tooltips[ $name ] ) ) { |
|
| 1459 | + return; |
|
| 1460 | + } |
|
| 1461 | + |
|
| 1462 | + if ( 'open' == $class ) { |
|
| 1463 | + echo ' frm_help"'; |
|
| 1464 | + } else { |
|
| 1465 | + echo ' class="frm_help"'; |
|
| 1466 | + } |
|
| 1467 | 1467 | |
| 1468 | 1468 | echo ' title="' . esc_attr( $tooltips[ $name ] ); |
| 1469 | 1469 | |
| 1470 | - if ( 'open' != $class ) { |
|
| 1471 | - echo '"'; |
|
| 1472 | - } |
|
| 1473 | - } |
|
| 1470 | + if ( 'open' != $class ) { |
|
| 1471 | + echo '"'; |
|
| 1472 | + } |
|
| 1473 | + } |
|
| 1474 | 1474 | |
| 1475 | 1475 | /** |
| 1476 | 1476 | * Add the current_page class to that page in the form nav |
@@ -1486,35 +1486,35 @@ discard block |
||
| 1486 | 1486 | } |
| 1487 | 1487 | } |
| 1488 | 1488 | |
| 1489 | - /** |
|
| 1490 | - * Prepare and json_encode post content |
|
| 1491 | - * |
|
| 1492 | - * @since 2.0 |
|
| 1493 | - * |
|
| 1494 | - * @param array $post_content |
|
| 1495 | - * @return string $post_content ( json encoded array ) |
|
| 1496 | - */ |
|
| 1497 | - public static function prepare_and_encode( $post_content ) { |
|
| 1498 | - //Loop through array to strip slashes and add only the needed ones |
|
| 1489 | + /** |
|
| 1490 | + * Prepare and json_encode post content |
|
| 1491 | + * |
|
| 1492 | + * @since 2.0 |
|
| 1493 | + * |
|
| 1494 | + * @param array $post_content |
|
| 1495 | + * @return string $post_content ( json encoded array ) |
|
| 1496 | + */ |
|
| 1497 | + public static function prepare_and_encode( $post_content ) { |
|
| 1498 | + //Loop through array to strip slashes and add only the needed ones |
|
| 1499 | 1499 | foreach ( $post_content as $key => $val ) { |
| 1500 | 1500 | // Replace problematic characters (like ") |
| 1501 | 1501 | $val = str_replace( '"', '"', $val ); |
| 1502 | 1502 | |
| 1503 | 1503 | self::prepare_action_slashes( $val, $key, $post_content ); |
| 1504 | - unset( $key, $val ); |
|
| 1505 | - } |
|
| 1504 | + unset( $key, $val ); |
|
| 1505 | + } |
|
| 1506 | 1506 | |
| 1507 | - // json_encode the array |
|
| 1508 | - $post_content = json_encode( $post_content ); |
|
| 1507 | + // json_encode the array |
|
| 1508 | + $post_content = json_encode( $post_content ); |
|
| 1509 | 1509 | |
| 1510 | - // add extra slashes for \r\n since WP strips them |
|
| 1510 | + // add extra slashes for \r\n since WP strips them |
|
| 1511 | 1511 | $post_content = str_replace( array( '\\r', '\\n', '\\u', '\\t' ), array( '\\\\r', '\\\\n', '\\\\u', '\\\\t' ), $post_content ); |
| 1512 | 1512 | |
| 1513 | - // allow for " |
|
| 1514 | - $post_content = str_replace( '"', '\\"', $post_content ); |
|
| 1513 | + // allow for " |
|
| 1514 | + $post_content = str_replace( '"', '\\"', $post_content ); |
|
| 1515 | 1515 | |
| 1516 | - return $post_content; |
|
| 1517 | - } |
|
| 1516 | + return $post_content; |
|
| 1517 | + } |
|
| 1518 | 1518 | |
| 1519 | 1519 | private static function prepare_action_slashes( $val, $key, &$post_content ) { |
| 1520 | 1520 | if ( ! isset( $post_content[ $key ] ) ) { |
@@ -1536,64 +1536,64 @@ discard block |
||
| 1536 | 1536 | } |
| 1537 | 1537 | |
| 1538 | 1538 | public static function maybe_json_decode( $string ) { |
| 1539 | - if ( is_array($string) ) { |
|
| 1540 | - return $string; |
|
| 1541 | - } |
|
| 1539 | + if ( is_array($string) ) { |
|
| 1540 | + return $string; |
|
| 1541 | + } |
|
| 1542 | 1542 | |
| 1543 | - $new_string = json_decode($string, true); |
|
| 1544 | - if ( function_exists('json_last_error') ) { |
|
| 1543 | + $new_string = json_decode($string, true); |
|
| 1544 | + if ( function_exists('json_last_error') ) { |
|
| 1545 | 1545 | // php 5.3+ |
| 1546 | - if ( json_last_error() == JSON_ERROR_NONE ) { |
|
| 1547 | - $string = $new_string; |
|
| 1548 | - } |
|
| 1549 | - } else if ( isset($new_string) ) { |
|
| 1546 | + if ( json_last_error() == JSON_ERROR_NONE ) { |
|
| 1547 | + $string = $new_string; |
|
| 1548 | + } |
|
| 1549 | + } else if ( isset($new_string) ) { |
|
| 1550 | 1550 | // php < 5.3 fallback |
| 1551 | - $string = $new_string; |
|
| 1552 | - } |
|
| 1553 | - return $string; |
|
| 1554 | - } |
|
| 1555 | - |
|
| 1556 | - /** |
|
| 1557 | - * @since 1.07.10 |
|
| 1558 | - * |
|
| 1559 | - * @param string $post_type The name of the post type that may need to be highlighted |
|
| 1560 | - * echo The javascript to open and highlight the Formidable menu |
|
| 1561 | - */ |
|
| 1551 | + $string = $new_string; |
|
| 1552 | + } |
|
| 1553 | + return $string; |
|
| 1554 | + } |
|
| 1555 | + |
|
| 1556 | + /** |
|
| 1557 | + * @since 1.07.10 |
|
| 1558 | + * |
|
| 1559 | + * @param string $post_type The name of the post type that may need to be highlighted |
|
| 1560 | + * echo The javascript to open and highlight the Formidable menu |
|
| 1561 | + */ |
|
| 1562 | 1562 | public static function maybe_highlight_menu( $post_type ) { |
| 1563 | - global $post; |
|
| 1563 | + global $post; |
|
| 1564 | 1564 | |
| 1565 | - if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) { |
|
| 1566 | - return; |
|
| 1567 | - } |
|
| 1565 | + if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) { |
|
| 1566 | + return; |
|
| 1567 | + } |
|
| 1568 | 1568 | |
| 1569 | - if ( is_object($post) && $post->post_type != $post_type ) { |
|
| 1570 | - return; |
|
| 1571 | - } |
|
| 1569 | + if ( is_object($post) && $post->post_type != $post_type ) { |
|
| 1570 | + return; |
|
| 1571 | + } |
|
| 1572 | 1572 | |
| 1573 | - self::load_admin_wide_js(); |
|
| 1574 | - echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>'; |
|
| 1575 | - } |
|
| 1573 | + self::load_admin_wide_js(); |
|
| 1574 | + echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>'; |
|
| 1575 | + } |
|
| 1576 | 1576 | |
| 1577 | - /** |
|
| 1578 | - * Load the JS file on non-Formidable pages in the admin area |
|
| 1579 | - * @since 2.0 |
|
| 1580 | - */ |
|
| 1577 | + /** |
|
| 1578 | + * Load the JS file on non-Formidable pages in the admin area |
|
| 1579 | + * @since 2.0 |
|
| 1580 | + */ |
|
| 1581 | 1581 | public static function load_admin_wide_js( $load = true ) { |
| 1582 | - $version = FrmAppHelper::plugin_version(); |
|
| 1582 | + $version = FrmAppHelper::plugin_version(); |
|
| 1583 | 1583 | wp_register_script( 'formidable_admin_global', FrmAppHelper::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version ); |
| 1584 | 1584 | |
| 1585 | - wp_localize_script( 'formidable_admin_global', 'frmGlobal', array( |
|
| 1585 | + wp_localize_script( 'formidable_admin_global', 'frmGlobal', array( |
|
| 1586 | 1586 | 'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ), |
| 1587 | - 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ), |
|
| 1587 | + 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ), |
|
| 1588 | 1588 | 'url' => FrmAppHelper::plugin_url(), |
| 1589 | 1589 | 'loading' => __( 'Loading…' ), |
| 1590 | 1590 | 'nonce' => wp_create_nonce( 'frm_ajax' ), |
| 1591 | - ) ); |
|
| 1591 | + ) ); |
|
| 1592 | 1592 | |
| 1593 | 1593 | if ( $load ) { |
| 1594 | 1594 | wp_enqueue_script( 'formidable_admin_global' ); |
| 1595 | 1595 | } |
| 1596 | - } |
|
| 1596 | + } |
|
| 1597 | 1597 | |
| 1598 | 1598 | /** |
| 1599 | 1599 | * @since 2.0.9 |
@@ -1602,9 +1602,9 @@ discard block |
||
| 1602 | 1602 | wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() ); |
| 1603 | 1603 | } |
| 1604 | 1604 | |
| 1605 | - /** |
|
| 1606 | - * @param string $location |
|
| 1607 | - */ |
|
| 1605 | + /** |
|
| 1606 | + * @param string $location |
|
| 1607 | + */ |
|
| 1608 | 1608 | public static function localize_script( $location ) { |
| 1609 | 1609 | $ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' ); |
| 1610 | 1610 | $ajax_url = apply_filters( 'frm_ajax_url', $ajax_url ); |
@@ -1660,27 +1660,27 @@ discard block |
||
| 1660 | 1660 | } |
| 1661 | 1661 | } |
| 1662 | 1662 | |
| 1663 | - /** |
|
| 1663 | + /** |
|
| 1664 | 1664 | * echo the message on the plugins listing page |
| 1665 | - * @since 1.07.10 |
|
| 1666 | - * |
|
| 1667 | - * @param float $min_version The version the add-on requires |
|
| 1668 | - */ |
|
| 1665 | + * @since 1.07.10 |
|
| 1666 | + * |
|
| 1667 | + * @param float $min_version The version the add-on requires |
|
| 1668 | + */ |
|
| 1669 | 1669 | public static function min_version_notice( $min_version ) { |
| 1670 | - $frm_version = self::plugin_version(); |
|
| 1670 | + $frm_version = self::plugin_version(); |
|
| 1671 | 1671 | |
| 1672 | - // check if Formidable meets minimum requirements |
|
| 1673 | - if ( version_compare($frm_version, $min_version, '>=') ) { |
|
| 1674 | - return; |
|
| 1675 | - } |
|
| 1672 | + // check if Formidable meets minimum requirements |
|
| 1673 | + if ( version_compare($frm_version, $min_version, '>=') ) { |
|
| 1674 | + return; |
|
| 1675 | + } |
|
| 1676 | 1676 | |
| 1677 | - $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
|
| 1677 | + $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
|
| 1678 | 1678 | 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">' . |
| 1679 | - __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
|
| 1680 | - '</div></td></tr>'; |
|
| 1681 | - } |
|
| 1679 | + __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
|
| 1680 | + '</div></td></tr>'; |
|
| 1681 | + } |
|
| 1682 | 1682 | |
| 1683 | - public static function locales( $type = 'date' ) { |
|
| 1683 | + public static function locales( $type = 'date' ) { |
|
| 1684 | 1684 | $locales = array( |
| 1685 | 1685 | 'en' => __( 'English', 'formidable' ), |
| 1686 | 1686 | '' => __( 'English/Western', 'formidable' ), |
@@ -1756,11 +1756,11 @@ discard block |
||
| 1756 | 1756 | $unset = array( 'en', 'fil', 'fr-CA', 'de-AT', 'de-AT', 'de-CH', 'iw', 'hi', 'pt', 'pt-PT', 'es-419', 'tr' ); |
| 1757 | 1757 | } |
| 1758 | 1758 | |
| 1759 | - $locales = array_diff_key($locales, array_flip($unset)); |
|
| 1760 | - $locales = apply_filters('frm_locales', $locales); |
|
| 1759 | + $locales = array_diff_key($locales, array_flip($unset)); |
|
| 1760 | + $locales = apply_filters('frm_locales', $locales); |
|
| 1761 | 1761 | |
| 1762 | - return $locales; |
|
| 1763 | - } |
|
| 1762 | + return $locales; |
|
| 1763 | + } |
|
| 1764 | 1764 | |
| 1765 | 1765 | /** |
| 1766 | 1766 | * Prepare and save settings in styles and actions |
@@ -26,55 +26,55 @@ discard block |
||
| 26 | 26 | } |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - /* Display in Back End */ |
|
| 30 | - public static function route() { |
|
| 29 | + /* Display in Back End */ |
|
| 30 | + public static function route() { |
|
| 31 | 31 | $action = FrmAppHelper::get_param( 'frm_action', '', 'get', 'sanitize_title' ); |
| 32 | 32 | |
| 33 | - switch ( $action ) { |
|
| 34 | - case 'show': |
|
| 35 | - case 'destroy': |
|
| 36 | - case 'destroy_all': |
|
| 37 | - return self::$action(); |
|
| 33 | + switch ( $action ) { |
|
| 34 | + case 'show': |
|
| 35 | + case 'destroy': |
|
| 36 | + case 'destroy_all': |
|
| 37 | + return self::$action(); |
|
| 38 | 38 | |
| 39 | - default: |
|
| 40 | - do_action( 'frm_entry_action_route', $action ); |
|
| 41 | - if ( apply_filters( 'frm_entry_stop_action_route', false, $action ) ) { |
|
| 42 | - return; |
|
| 43 | - } |
|
| 39 | + default: |
|
| 40 | + do_action( 'frm_entry_action_route', $action ); |
|
| 41 | + if ( apply_filters( 'frm_entry_stop_action_route', false, $action ) ) { |
|
| 42 | + return; |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - return self::display_list(); |
|
| 46 | - } |
|
| 47 | - } |
|
| 45 | + return self::display_list(); |
|
| 46 | + } |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | 49 | public static function contextual_help( $help, $screen_id, $screen ) { |
| 50 | - // Only add to certain screens. add_help_tab was introduced in WordPress 3.3 |
|
| 51 | - if ( ! method_exists( $screen, 'add_help_tab' ) ) { |
|
| 52 | - return $help; |
|
| 53 | - } |
|
| 50 | + // Only add to certain screens. add_help_tab was introduced in WordPress 3.3 |
|
| 51 | + if ( ! method_exists( $screen, 'add_help_tab' ) ) { |
|
| 52 | + return $help; |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | 55 | $action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ); |
| 56 | 56 | $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' ); |
| 57 | 57 | $show_help = ( $page == 'formidable-entries' && ( empty( $action ) || $action == 'list' ) ); |
| 58 | 58 | if ( ! $show_help ) { |
| 59 | - return $help; |
|
| 60 | - } |
|
| 59 | + return $help; |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | 62 | unset( $action, $page ); |
| 63 | 63 | |
| 64 | - $screen->add_help_tab( array( |
|
| 65 | - 'id' => 'formidable-entries-tab', |
|
| 66 | - 'title' => __( 'Overview', 'formidable' ), |
|
| 64 | + $screen->add_help_tab( array( |
|
| 65 | + 'id' => 'formidable-entries-tab', |
|
| 66 | + 'title' => __( 'Overview', 'formidable' ), |
|
| 67 | 67 | 'content' => '<p>' . esc_html__( 'This screen provides access to all of your entries. You can customize the display of this screen to suit your workflow.', 'formidable' ) . '</p> <p>' . esc_html__( 'Hovering over a row in the entries list will display action links that allow you to manage your entry.', 'formidable' ) . '</p>', |
| 68 | - )); |
|
| 68 | + )); |
|
| 69 | 69 | |
| 70 | - $screen->set_help_sidebar( |
|
| 70 | + $screen->set_help_sidebar( |
|
| 71 | 71 | '<p><strong>' . esc_html__( 'For more information:', 'formidable' ) . '</strong></p>' . |
| 72 | 72 | '<p><a href="' . esc_url( FrmAppHelper::make_affiliate_url( 'https://formidableforms.com/knowledgebase/manage-entries-from-the-back-end/' ) ) . '" target="_blank">' . esc_html__( 'Documentation on Entries', 'formidable' ) . '</a></p>' . |
| 73 | 73 | '<p><a href="' . esc_url( FrmAppHelper::make_affiliate_url( 'https://formidableforms.com/help-desk/' ) ) . '" target="_blank">' . esc_html__( 'Support', 'formidable' ) . '</a></p>' |
| 74 | - ); |
|
| 74 | + ); |
|
| 75 | 75 | |
| 76 | - return $help; |
|
| 77 | - } |
|
| 76 | + return $help; |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | 79 | /** |
| 80 | 80 | * Prevent the "screen options" tab from showing when |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | public static function manage_columns( $columns ) { |
| 95 | - global $frm_vars; |
|
| 95 | + global $frm_vars; |
|
| 96 | 96 | $form_id = FrmForm::get_current_form_id(); |
| 97 | 97 | |
| 98 | 98 | $columns[ $form_id . '_id' ] = 'ID'; |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | $columns[ $form_id . '_updated_at' ] = __( 'Entry update date', 'formidable' ); |
| 111 | 111 | self::maybe_add_ip_col( $form_id, $columns ); |
| 112 | 112 | |
| 113 | - $frm_vars['cols'] = $columns; |
|
| 113 | + $frm_vars['cols'] = $columns; |
|
| 114 | 114 | |
| 115 | 115 | $action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ); |
| 116 | 116 | if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $action, array( '', 'list', 'destroy' ) ) ) { |
@@ -119,10 +119,10 @@ discard block |
||
| 119 | 119 | 'default' => 20, |
| 120 | 120 | 'option' => 'formidable_page_formidable_entries_per_page', |
| 121 | 121 | ) ); |
| 122 | - } |
|
| 122 | + } |
|
| 123 | 123 | |
| 124 | - return $columns; |
|
| 125 | - } |
|
| 124 | + return $columns; |
|
| 125 | + } |
|
| 126 | 126 | |
| 127 | 127 | private static function get_columns_for_form( $form_id, &$columns ) { |
| 128 | 128 | $form_cols = FrmField::get_all_for_form( $form_id, '', 'include' ); |
@@ -187,67 +187,67 @@ discard block |
||
| 187 | 187 | public static function check_hidden_cols( $check, $object_id, $meta_key, $meta_value, $prev_value ) { |
| 188 | 188 | $this_page_name = self::hidden_column_key(); |
| 189 | 189 | if ( $meta_key != $this_page_name || $meta_value == $prev_value ) { |
| 190 | - return $check; |
|
| 191 | - } |
|
| 190 | + return $check; |
|
| 191 | + } |
|
| 192 | 192 | |
| 193 | 193 | if ( empty( $prev_value ) ) { |
| 194 | 194 | $prev_value = get_metadata( 'user', $object_id, $meta_key, true ); |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | - global $frm_vars; |
|
| 197 | + global $frm_vars; |
|
| 198 | 198 | //add a check so we don't create a loop |
| 199 | 199 | $frm_vars['prev_hidden_cols'] = ( isset( $frm_vars['prev_hidden_cols'] ) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value; |
| 200 | 200 | |
| 201 | - return $check; |
|
| 202 | - } |
|
| 201 | + return $check; |
|
| 202 | + } |
|
| 203 | 203 | |
| 204 | - //add hidden columns back from other forms |
|
| 204 | + //add hidden columns back from other forms |
|
| 205 | 205 | public static function update_hidden_cols( $meta_id, $object_id, $meta_key, $meta_value ) { |
| 206 | 206 | $this_page_name = self::hidden_column_key(); |
| 207 | 207 | if ( $meta_key != $this_page_name ) { |
| 208 | - return; |
|
| 209 | - } |
|
| 208 | + return; |
|
| 209 | + } |
|
| 210 | 210 | |
| 211 | 211 | global $frm_vars; |
| 212 | 212 | if ( ! isset( $frm_vars['prev_hidden_cols'] ) || ! $frm_vars['prev_hidden_cols'] ) { |
| 213 | 213 | return; //don't continue if there's no previous value |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | - foreach ( $meta_value as $mk => $mv ) { |
|
| 217 | - //remove blank values |
|
| 218 | - if ( empty( $mv ) ) { |
|
| 219 | - unset( $meta_value[ $mk ] ); |
|
| 220 | - } |
|
| 221 | - } |
|
| 216 | + foreach ( $meta_value as $mk => $mv ) { |
|
| 217 | + //remove blank values |
|
| 218 | + if ( empty( $mv ) ) { |
|
| 219 | + unset( $meta_value[ $mk ] ); |
|
| 220 | + } |
|
| 221 | + } |
|
| 222 | 222 | |
| 223 | 223 | $cur_form_prefix = reset( $meta_value ); |
| 224 | 224 | $cur_form_prefix = explode( '_', $cur_form_prefix ); |
| 225 | - $cur_form_prefix = $cur_form_prefix[0]; |
|
| 226 | - $save = false; |
|
| 225 | + $cur_form_prefix = $cur_form_prefix[0]; |
|
| 226 | + $save = false; |
|
| 227 | 227 | |
| 228 | - foreach ( (array) $frm_vars['prev_hidden_cols'] as $prev_hidden ) { |
|
| 228 | + foreach ( (array) $frm_vars['prev_hidden_cols'] as $prev_hidden ) { |
|
| 229 | 229 | if ( empty( $prev_hidden ) || in_array( $prev_hidden, $meta_value ) ) { |
| 230 | - //don't add blank cols or process included cols |
|
| 231 | - continue; |
|
| 232 | - } |
|
| 230 | + //don't add blank cols or process included cols |
|
| 231 | + continue; |
|
| 232 | + } |
|
| 233 | 233 | |
| 234 | 234 | $form_prefix = explode( '_', $prev_hidden ); |
| 235 | - $form_prefix = $form_prefix[0]; |
|
| 236 | - if ( $form_prefix == $cur_form_prefix ) { |
|
| 237 | - //don't add back columns that are meant to be hidden |
|
| 238 | - continue; |
|
| 239 | - } |
|
| 240 | - |
|
| 241 | - $meta_value[] = $prev_hidden; |
|
| 242 | - $save = true; |
|
| 235 | + $form_prefix = $form_prefix[0]; |
|
| 236 | + if ( $form_prefix == $cur_form_prefix ) { |
|
| 237 | + //don't add back columns that are meant to be hidden |
|
| 238 | + continue; |
|
| 239 | + } |
|
| 240 | + |
|
| 241 | + $meta_value[] = $prev_hidden; |
|
| 242 | + $save = true; |
|
| 243 | 243 | unset( $form_prefix ); |
| 244 | - } |
|
| 244 | + } |
|
| 245 | 245 | |
| 246 | 246 | if ( $save ) { |
| 247 | 247 | $user_id = get_current_user_id(); |
| 248 | 248 | update_user_option( $user_id, $this_page_name, $meta_value, true ); |
| 249 | - } |
|
| 250 | - } |
|
| 249 | + } |
|
| 250 | + } |
|
| 251 | 251 | |
| 252 | 252 | /** |
| 253 | 253 | * @since 2.05.07 |
@@ -268,11 +268,11 @@ discard block |
||
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | public static function save_per_page( $save, $option, $value ) { |
| 271 | - if ( $option == 'formidable_page_formidable_entries_per_page' ) { |
|
| 272 | - $save = (int) $value; |
|
| 273 | - } |
|
| 274 | - return $save; |
|
| 275 | - } |
|
| 271 | + if ( $option == 'formidable_page_formidable_entries_per_page' ) { |
|
| 272 | + $save = (int) $value; |
|
| 273 | + } |
|
| 274 | + return $save; |
|
| 275 | + } |
|
| 276 | 276 | |
| 277 | 277 | public static function sortable_columns() { |
| 278 | 278 | $form_id = FrmForm::get_current_form_id(); |
@@ -372,43 +372,43 @@ discard block |
||
| 372 | 372 | } |
| 373 | 373 | |
| 374 | 374 | public static function display_list( $message = '', $errors = array() ) { |
| 375 | - global $wpdb, $frm_vars; |
|
| 375 | + global $wpdb, $frm_vars; |
|
| 376 | 376 | |
| 377 | 377 | $form = FrmForm::maybe_get_current_form(); |
| 378 | 378 | $params = FrmForm::get_admin_params( $form ); |
| 379 | 379 | |
| 380 | - if ( $form ) { |
|
| 381 | - $params['form'] = $form->id; |
|
| 382 | - $frm_vars['current_form'] = $form; |
|
| 380 | + if ( $form ) { |
|
| 381 | + $params['form'] = $form->id; |
|
| 382 | + $frm_vars['current_form'] = $form; |
|
| 383 | 383 | |
| 384 | 384 | self::get_delete_form_time( $form, $errors ); |
| 385 | 385 | } |
| 386 | 386 | |
| 387 | - $table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' ); |
|
| 387 | + $table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' ); |
|
| 388 | 388 | |
| 389 | - $wp_list_table = new $table_class( array( 'params' => $params ) ); |
|
| 389 | + $wp_list_table = new $table_class( array( 'params' => $params ) ); |
|
| 390 | 390 | |
| 391 | - $pagenum = $wp_list_table->get_pagenum(); |
|
| 391 | + $pagenum = $wp_list_table->get_pagenum(); |
|
| 392 | 392 | |
| 393 | - $wp_list_table->prepare_items(); |
|
| 393 | + $wp_list_table->prepare_items(); |
|
| 394 | 394 | |
| 395 | - $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); |
|
| 396 | - if ( $pagenum > $total_pages && $total_pages > 0 ) { |
|
| 395 | + $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); |
|
| 396 | + if ( $pagenum > $total_pages && $total_pages > 0 ) { |
|
| 397 | 397 | $url = add_query_arg( 'paged', $total_pages ); |
| 398 | - if ( headers_sent() ) { |
|
| 398 | + if ( headers_sent() ) { |
|
| 399 | 399 | echo FrmAppHelper::js_redirect( $url ); |
| 400 | - } else { |
|
| 401 | - wp_redirect( esc_url_raw( $url ) ); |
|
| 402 | - } |
|
| 403 | - die(); |
|
| 404 | - } |
|
| 400 | + } else { |
|
| 401 | + wp_redirect( esc_url_raw( $url ) ); |
|
| 402 | + } |
|
| 403 | + die(); |
|
| 404 | + } |
|
| 405 | 405 | |
| 406 | 406 | if ( empty( $message ) && isset( $_GET['import-message'] ) ) { |
| 407 | - $message = __( 'Your import is complete', 'formidable' ); |
|
| 408 | - } |
|
| 407 | + $message = __( 'Your import is complete', 'formidable' ); |
|
| 408 | + } |
|
| 409 | 409 | |
| 410 | 410 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/list.php' ); |
| 411 | - } |
|
| 411 | + } |
|
| 412 | 412 | |
| 413 | 413 | private static function get_delete_form_time( $form, &$errors ) { |
| 414 | 414 | if ( 'trash' == $form->status ) { |
@@ -418,17 +418,17 @@ discard block |
||
| 418 | 418 | } |
| 419 | 419 | } |
| 420 | 420 | |
| 421 | - /* Back End CRUD */ |
|
| 421 | + /* Back End CRUD */ |
|
| 422 | 422 | public static function show( $id = 0 ) { |
| 423 | 423 | FrmAppHelper::permission_check( 'frm_view_entries' ); |
| 424 | 424 | |
| 425 | - if ( ! $id ) { |
|
| 425 | + if ( ! $id ) { |
|
| 426 | 426 | $id = FrmAppHelper::get_param( 'id', 0, 'get', 'absint' ); |
| 427 | 427 | |
| 428 | - if ( ! $id ) { |
|
| 428 | + if ( ! $id ) { |
|
| 429 | 429 | $id = FrmAppHelper::get_param( 'item_id', 0, 'get', 'absint' ); |
| 430 | - } |
|
| 431 | - } |
|
| 430 | + } |
|
| 431 | + } |
|
| 432 | 432 | |
| 433 | 433 | $entry = FrmEntry::getOne( $id, true ); |
| 434 | 434 | if ( ! $entry ) { |
@@ -444,63 +444,63 @@ discard block |
||
| 444 | 444 | } |
| 445 | 445 | |
| 446 | 446 | $fields = FrmField::get_all_for_form( $entry->form_id, '', 'include' ); |
| 447 | - $to_emails = array(); |
|
| 447 | + $to_emails = array(); |
|
| 448 | 448 | $form = FrmForm::getOne( $entry->form_id ); |
| 449 | 449 | |
| 450 | 450 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/show.php' ); |
| 451 | - } |
|
| 451 | + } |
|
| 452 | 452 | |
| 453 | - public static function destroy() { |
|
| 453 | + public static function destroy() { |
|
| 454 | 454 | FrmAppHelper::permission_check( 'frm_delete_entries' ); |
| 455 | 455 | |
| 456 | 456 | $params = FrmForm::get_admin_params(); |
| 457 | 457 | |
| 458 | 458 | if ( isset( $params['keep_post'] ) && $params['keep_post'] ) { |
| 459 | 459 | self::unlink_post( $params['id'] ); |
| 460 | - } |
|
| 460 | + } |
|
| 461 | 461 | |
| 462 | - $message = ''; |
|
| 463 | - if ( FrmEntry::destroy( $params['id'] ) ) { |
|
| 464 | - $message = __( 'Entry was Successfully Destroyed', 'formidable' ); |
|
| 465 | - } |
|
| 462 | + $message = ''; |
|
| 463 | + if ( FrmEntry::destroy( $params['id'] ) ) { |
|
| 464 | + $message = __( 'Entry was Successfully Destroyed', 'formidable' ); |
|
| 465 | + } |
|
| 466 | 466 | |
| 467 | - self::display_list( $message ); |
|
| 468 | - } |
|
| 467 | + self::display_list( $message ); |
|
| 468 | + } |
|
| 469 | 469 | |
| 470 | - public static function destroy_all() { |
|
| 471 | - if ( ! current_user_can( 'frm_delete_entries' ) ) { |
|
| 472 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 473 | - wp_die( $frm_settings->admin_permission ); |
|
| 474 | - } |
|
| 470 | + public static function destroy_all() { |
|
| 471 | + if ( ! current_user_can( 'frm_delete_entries' ) ) { |
|
| 472 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 473 | + wp_die( $frm_settings->admin_permission ); |
|
| 474 | + } |
|
| 475 | 475 | |
| 476 | 476 | $params = FrmForm::get_admin_params(); |
| 477 | - $message = ''; |
|
| 478 | - $errors = array(); |
|
| 479 | - $form_id = (int) $params['form']; |
|
| 477 | + $message = ''; |
|
| 478 | + $errors = array(); |
|
| 479 | + $form_id = (int) $params['form']; |
|
| 480 | 480 | |
| 481 | - if ( $form_id ) { |
|
| 482 | - $entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) ); |
|
| 481 | + if ( $form_id ) { |
|
| 482 | + $entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) ); |
|
| 483 | 483 | $action = FrmFormAction::get_action_for_form( $form_id, 'wppost', 1 ); |
| 484 | 484 | |
| 485 | - if ( $action ) { |
|
| 486 | - // this action takes a while, so only trigger it if there are posts to delete |
|
| 487 | - foreach ( $entry_ids as $entry_id ) { |
|
| 488 | - do_action( 'frm_before_destroy_entry', $entry_id ); |
|
| 489 | - unset( $entry_id ); |
|
| 490 | - } |
|
| 491 | - } |
|
| 485 | + if ( $action ) { |
|
| 486 | + // this action takes a while, so only trigger it if there are posts to delete |
|
| 487 | + foreach ( $entry_ids as $entry_id ) { |
|
| 488 | + do_action( 'frm_before_destroy_entry', $entry_id ); |
|
| 489 | + unset( $entry_id ); |
|
| 490 | + } |
|
| 491 | + } |
|
| 492 | 492 | |
| 493 | - $results = self::delete_form_entries( $form_id ); |
|
| 494 | - if ( $results ) { |
|
| 493 | + $results = self::delete_form_entries( $form_id ); |
|
| 494 | + if ( $results ) { |
|
| 495 | 495 | FrmEntry::clear_cache(); |
| 496 | - $message = __( 'Entries were Successfully Destroyed', 'formidable' ); |
|
| 497 | - } |
|
| 498 | - } else { |
|
| 499 | - $errors = __( 'No entries were specified', 'formidable' ); |
|
| 500 | - } |
|
| 496 | + $message = __( 'Entries were Successfully Destroyed', 'formidable' ); |
|
| 497 | + } |
|
| 498 | + } else { |
|
| 499 | + $errors = __( 'No entries were specified', 'formidable' ); |
|
| 500 | + } |
|
| 501 | 501 | |
| 502 | - self::display_list( $message, $errors ); |
|
| 503 | - } |
|
| 502 | + self::display_list( $message, $errors ); |
|
| 503 | + } |
|
| 504 | 504 | |
| 505 | 505 | /** |
| 506 | 506 | * @since 3.01 |
@@ -546,47 +546,47 @@ discard block |
||
| 546 | 546 | * @deprecated 1.07.05 |
| 547 | 547 | * @codeCoverageIgnore |
| 548 | 548 | */ |
| 549 | - public static function show_form( $id = '', $key = '', $title = false, $description = false ) { |
|
| 550 | - _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::show_form()' ); |
|
| 551 | - return FrmFormsController::show_form( $id, $key, $title, $description ); |
|
| 552 | - } |
|
| 549 | + public static function show_form( $id = '', $key = '', $title = false, $description = false ) { |
|
| 550 | + _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::show_form()' ); |
|
| 551 | + return FrmFormsController::show_form( $id, $key, $title, $description ); |
|
| 552 | + } |
|
| 553 | 553 | |
| 554 | 554 | /** |
| 555 | 555 | * @deprecated 1.07.05 |
| 556 | 556 | * @codeCoverageIgnore |
| 557 | 557 | */ |
| 558 | - public static function get_form( $filename, $form, $title, $description ) { |
|
| 559 | - _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form()' ); |
|
| 560 | - return FrmFormsController::get_form( $form, $title, $description ); |
|
| 561 | - } |
|
| 558 | + public static function get_form( $filename, $form, $title, $description ) { |
|
| 559 | + _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form()' ); |
|
| 560 | + return FrmFormsController::get_form( $form, $title, $description ); |
|
| 561 | + } |
|
| 562 | 562 | |
| 563 | - public static function process_entry( $errors = '', $ajax = false ) { |
|
| 563 | + public static function process_entry( $errors = '', $ajax = false ) { |
|
| 564 | 564 | $form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' ); |
| 565 | 565 | if ( FrmAppHelper::is_admin() || empty( $_POST ) || empty( $form_id ) || ! isset( $_POST['item_key'] ) ) { |
| 566 | - return; |
|
| 567 | - } |
|
| 566 | + return; |
|
| 567 | + } |
|
| 568 | 568 | |
| 569 | - global $frm_vars; |
|
| 569 | + global $frm_vars; |
|
| 570 | 570 | |
| 571 | 571 | $form = FrmForm::getOne( $form_id ); |
| 572 | - if ( ! $form ) { |
|
| 573 | - return; |
|
| 574 | - } |
|
| 572 | + if ( ! $form ) { |
|
| 573 | + return; |
|
| 574 | + } |
|
| 575 | 575 | |
| 576 | 576 | $params = FrmForm::get_params( $form ); |
| 577 | 577 | |
| 578 | - if ( ! isset( $frm_vars['form_params'] ) ) { |
|
| 579 | - $frm_vars['form_params'] = array(); |
|
| 580 | - } |
|
| 578 | + if ( ! isset( $frm_vars['form_params'] ) ) { |
|
| 579 | + $frm_vars['form_params'] = array(); |
|
| 580 | + } |
|
| 581 | 581 | $frm_vars['form_params'][ $form->id ] = $params; |
| 582 | 582 | |
| 583 | 583 | if ( isset( $frm_vars['created_entries'][ $form_id ] ) ) { |
| 584 | - return; |
|
| 585 | - } |
|
| 584 | + return; |
|
| 585 | + } |
|
| 586 | 586 | |
| 587 | - if ( $errors == '' && ! $ajax ) { |
|
| 587 | + if ( $errors == '' && ! $ajax ) { |
|
| 588 | 588 | $errors = FrmEntryValidate::validate( $_POST ); |
| 589 | - } |
|
| 589 | + } |
|
| 590 | 590 | |
| 591 | 591 | /** |
| 592 | 592 | * Use this filter to add trigger actions and add errors after |
@@ -597,24 +597,24 @@ discard block |
||
| 597 | 597 | |
| 598 | 598 | $frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors ); |
| 599 | 599 | |
| 600 | - if ( empty( $errors ) ) { |
|
| 600 | + if ( empty( $errors ) ) { |
|
| 601 | 601 | $_POST['frm_skip_cookie'] = 1; |
| 602 | 602 | $do_success = false; |
| 603 | - if ( $params['action'] == 'create' ) { |
|
| 603 | + if ( $params['action'] == 'create' ) { |
|
| 604 | 604 | if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) { |
| 605 | 605 | $frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST ); |
| 606 | 606 | $params['id'] = $frm_vars['created_entries'][ $form_id ]['entry_id']; |
| 607 | 607 | $do_success = true; |
| 608 | - } |
|
| 609 | - } |
|
| 608 | + } |
|
| 609 | + } |
|
| 610 | 610 | |
| 611 | - do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) ); |
|
| 611 | + do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) ); |
|
| 612 | 612 | if ( $do_success ) { |
| 613 | 613 | FrmFormsController::maybe_trigger_redirect( $form, $params, array( 'ajax' => $ajax ) ); |
| 614 | 614 | } |
| 615 | 615 | unset( $_POST['frm_skip_cookie'] ); |
| 616 | - } |
|
| 617 | - } |
|
| 616 | + } |
|
| 617 | + } |
|
| 618 | 618 | |
| 619 | 619 | /** |
| 620 | 620 | * Escape url entities before redirect |
@@ -628,27 +628,27 @@ discard block |
||
| 628 | 628 | return str_replace( array( ' ', '[', ']', '|', '@' ), array( '%20', '%5B', '%5D', '%7C', '%40' ), $url ); |
| 629 | 629 | } |
| 630 | 630 | |
| 631 | - public static function delete_entry_before_redirect( $url, $form, $atts ) { |
|
| 632 | - self::_delete_entry( $atts['id'], $form ); |
|
| 633 | - return $url; |
|
| 634 | - } |
|
| 631 | + public static function delete_entry_before_redirect( $url, $form, $atts ) { |
|
| 632 | + self::_delete_entry( $atts['id'], $form ); |
|
| 633 | + return $url; |
|
| 634 | + } |
|
| 635 | 635 | |
| 636 | - //Delete entry if not redirected |
|
| 637 | - public static function delete_entry_after_save( $atts ) { |
|
| 638 | - self::_delete_entry( $atts['entry_id'], $atts['form'] ); |
|
| 639 | - } |
|
| 636 | + //Delete entry if not redirected |
|
| 637 | + public static function delete_entry_after_save( $atts ) { |
|
| 638 | + self::_delete_entry( $atts['entry_id'], $atts['form'] ); |
|
| 639 | + } |
|
| 640 | 640 | |
| 641 | - private static function _delete_entry( $entry_id, $form ) { |
|
| 642 | - if ( ! $form ) { |
|
| 643 | - return; |
|
| 644 | - } |
|
| 641 | + private static function _delete_entry( $entry_id, $form ) { |
|
| 642 | + if ( ! $form ) { |
|
| 643 | + return; |
|
| 644 | + } |
|
| 645 | 645 | |
| 646 | - $form->options = maybe_unserialize( $form->options ); |
|
| 647 | - if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) { |
|
| 646 | + $form->options = maybe_unserialize( $form->options ); |
|
| 647 | + if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) { |
|
| 648 | 648 | self::unlink_post( $entry_id ); |
| 649 | - FrmEntry::destroy( $entry_id ); |
|
| 650 | - } |
|
| 651 | - } |
|
| 649 | + FrmEntry::destroy( $entry_id ); |
|
| 650 | + } |
|
| 651 | + } |
|
| 652 | 652 | |
| 653 | 653 | /** |
| 654 | 654 | * unlink entry from post |
@@ -720,5 +720,5 @@ discard block |
||
| 720 | 720 | } |
| 721 | 721 | |
| 722 | 722 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/sidebar-shared.php' ); |
| 723 | - } |
|
| 723 | + } |
|
| 724 | 724 | } |