@@ -12,50 +12,50 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | public static $plug_version = '2.05.05'; |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * @since 1.07.02 |
|
| 17 | - * |
|
| 18 | - * @param none |
|
| 19 | - * @return string The version of this plugin |
|
| 20 | - */ |
|
| 21 | - public static function plugin_version() { |
|
| 22 | - return self::$plug_version; |
|
| 23 | - } |
|
| 24 | - |
|
| 25 | - public static function plugin_folder() { |
|
| 26 | - return basename(self::plugin_path()); |
|
| 27 | - } |
|
| 28 | - |
|
| 29 | - public static function plugin_path() { |
|
| 30 | - return dirname(dirname(dirname(__FILE__))); |
|
| 31 | - } |
|
| 32 | - |
|
| 33 | - public static function plugin_url() { |
|
| 34 | - //prevously FRM_URL constant |
|
| 15 | + /** |
|
| 16 | + * @since 1.07.02 |
|
| 17 | + * |
|
| 18 | + * @param none |
|
| 19 | + * @return string The version of this plugin |
|
| 20 | + */ |
|
| 21 | + public static function plugin_version() { |
|
| 22 | + return self::$plug_version; |
|
| 23 | + } |
|
| 24 | + |
|
| 25 | + public static function plugin_folder() { |
|
| 26 | + return basename(self::plugin_path()); |
|
| 27 | + } |
|
| 28 | + |
|
| 29 | + public static function plugin_path() { |
|
| 30 | + return dirname(dirname(dirname(__FILE__))); |
|
| 31 | + } |
|
| 32 | + |
|
| 33 | + public static function plugin_url() { |
|
| 34 | + //prevously FRM_URL constant |
|
| 35 | 35 | return plugins_url( '', self::plugin_path() . '/formidable.php' ); |
| 36 | - } |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | 38 | public static function relative_plugin_url() { |
| 39 | 39 | return str_replace( array( 'https:', 'http:' ), '', self::plugin_url() ); |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * @return string Site URL |
|
| 44 | - */ |
|
| 45 | - public static function site_url() { |
|
| 46 | - return site_url(); |
|
| 47 | - } |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * Get the name of this site |
|
| 51 | - * Used for [sitename] shortcode |
|
| 52 | - * |
|
| 53 | - * @since 2.0 |
|
| 54 | - * @return string |
|
| 55 | - */ |
|
| 56 | - public static function site_name() { |
|
| 57 | - return get_option('blogname'); |
|
| 58 | - } |
|
| 42 | + /** |
|
| 43 | + * @return string Site URL |
|
| 44 | + */ |
|
| 45 | + public static function site_url() { |
|
| 46 | + return site_url(); |
|
| 47 | + } |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * Get the name of this site |
|
| 51 | + * Used for [sitename] shortcode |
|
| 52 | + * |
|
| 53 | + * @since 2.0 |
|
| 54 | + * @return string |
|
| 55 | + */ |
|
| 56 | + public static function site_name() { |
|
| 57 | + return get_option('blogname'); |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | 60 | public static function make_affiliate_url( $url ) { |
| 61 | 61 | $affiliate_id = self::get_affiliate(); |
@@ -70,21 +70,21 @@ discard block |
||
| 70 | 70 | return absint( apply_filters( 'frm_affiliate_id', 0 ) ); |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * Get the Formidable settings |
|
| 75 | - * |
|
| 76 | - * @since 2.0 |
|
| 77 | - * |
|
| 78 | - * @param None |
|
| 79 | - * @return FrmSettings $frm_setings |
|
| 80 | - */ |
|
| 81 | - public static function get_settings() { |
|
| 82 | - global $frm_settings; |
|
| 83 | - if ( empty($frm_settings) ) { |
|
| 84 | - $frm_settings = new FrmSettings(); |
|
| 85 | - } |
|
| 86 | - return $frm_settings; |
|
| 87 | - } |
|
| 73 | + /** |
|
| 74 | + * Get the Formidable settings |
|
| 75 | + * |
|
| 76 | + * @since 2.0 |
|
| 77 | + * |
|
| 78 | + * @param None |
|
| 79 | + * @return FrmSettings $frm_setings |
|
| 80 | + */ |
|
| 81 | + public static function get_settings() { |
|
| 82 | + global $frm_settings; |
|
| 83 | + if ( empty($frm_settings) ) { |
|
| 84 | + $frm_settings = new FrmSettings(); |
|
| 85 | + } |
|
| 86 | + return $frm_settings; |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | 89 | public static function get_menu_name() { |
| 90 | 90 | $frm_settings = FrmAppHelper::get_settings(); |
@@ -99,62 +99,62 @@ discard block |
||
| 99 | 99 | return ! $frm_settings->no_ips; |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - /** |
|
| 103 | - * Show a message in place of pro features |
|
| 104 | - * |
|
| 105 | - * @since 2.0 |
|
| 106 | - */ |
|
| 102 | + /** |
|
| 103 | + * Show a message in place of pro features |
|
| 104 | + * |
|
| 105 | + * @since 2.0 |
|
| 106 | + */ |
|
| 107 | 107 | public static function update_message() { |
| 108 | 108 | _deprecated_function( __FUNCTION__, '2.0.19' ); |
| 109 | - } |
|
| 110 | - |
|
| 111 | - public static function pro_is_installed() { |
|
| 112 | - return apply_filters('frm_pro_installed', false); |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - /** |
|
| 116 | - * Check for certain page in Formidable settings |
|
| 117 | - * |
|
| 118 | - * @since 2.0 |
|
| 119 | - * |
|
| 120 | - * @param string $page The name of the page to check |
|
| 121 | - * @return boolean |
|
| 122 | - */ |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + public static function pro_is_installed() { |
|
| 112 | + return apply_filters('frm_pro_installed', false); |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + /** |
|
| 116 | + * Check for certain page in Formidable settings |
|
| 117 | + * |
|
| 118 | + * @since 2.0 |
|
| 119 | + * |
|
| 120 | + * @param string $page The name of the page to check |
|
| 121 | + * @return boolean |
|
| 122 | + */ |
|
| 123 | 123 | public static function is_admin_page( $page = 'formidable' ) { |
| 124 | - global $pagenow; |
|
| 124 | + global $pagenow; |
|
| 125 | 125 | $get_page = self::simple_get( 'page', 'sanitize_title' ); |
| 126 | - if ( $pagenow ) { |
|
| 126 | + if ( $pagenow ) { |
|
| 127 | 127 | return $pagenow == 'admin.php' && $get_page == $page; |
| 128 | - } |
|
| 128 | + } |
|
| 129 | 129 | |
| 130 | 130 | return is_admin() && $get_page == $page; |
| 131 | - } |
|
| 132 | - |
|
| 133 | - /** |
|
| 134 | - * Check for the form preview page |
|
| 135 | - * |
|
| 136 | - * @since 2.0 |
|
| 137 | - * |
|
| 138 | - * @param None |
|
| 139 | - * @return boolean |
|
| 140 | - */ |
|
| 141 | - public static function is_preview_page() { |
|
| 142 | - global $pagenow; |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + /** |
|
| 134 | + * Check for the form preview page |
|
| 135 | + * |
|
| 136 | + * @since 2.0 |
|
| 137 | + * |
|
| 138 | + * @param None |
|
| 139 | + * @return boolean |
|
| 140 | + */ |
|
| 141 | + public static function is_preview_page() { |
|
| 142 | + global $pagenow; |
|
| 143 | 143 | $action = FrmAppHelper::simple_get( 'action', 'sanitize_title' ); |
| 144 | 144 | return $pagenow && $pagenow == 'admin-ajax.php' && $action == 'frm_forms_preview'; |
| 145 | - } |
|
| 145 | + } |
|
| 146 | 146 | |
| 147 | - /** |
|
| 148 | - * Check for ajax except the form preview page |
|
| 149 | - * |
|
| 150 | - * @since 2.0 |
|
| 151 | - * |
|
| 152 | - * @param None |
|
| 153 | - * @return boolean |
|
| 154 | - */ |
|
| 155 | - public static function doing_ajax() { |
|
| 156 | - return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page(); |
|
| 157 | - } |
|
| 147 | + /** |
|
| 148 | + * Check for ajax except the form preview page |
|
| 149 | + * |
|
| 150 | + * @since 2.0 |
|
| 151 | + * |
|
| 152 | + * @param None |
|
| 153 | + * @return boolean |
|
| 154 | + */ |
|
| 155 | + public static function doing_ajax() { |
|
| 156 | + return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page(); |
|
| 157 | + } |
|
| 158 | 158 | |
| 159 | 159 | /** |
| 160 | 160 | * @since 2.0.8 |
@@ -164,102 +164,102 @@ discard block |
||
| 164 | 164 | return isset( $frm_vars['prevent_caching'] ) && $frm_vars['prevent_caching']; |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - /** |
|
| 168 | - * Check if on an admin page |
|
| 169 | - * |
|
| 170 | - * @since 2.0 |
|
| 171 | - * |
|
| 172 | - * @param None |
|
| 173 | - * @return boolean |
|
| 174 | - */ |
|
| 175 | - public static function is_admin() { |
|
| 176 | - return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX ); |
|
| 177 | - } |
|
| 178 | - |
|
| 179 | - /** |
|
| 180 | - * Check if value contains blank value or empty array |
|
| 181 | - * |
|
| 182 | - * @since 2.0 |
|
| 183 | - * @param mixed $value - value to check |
|
| 167 | + /** |
|
| 168 | + * Check if on an admin page |
|
| 169 | + * |
|
| 170 | + * @since 2.0 |
|
| 171 | + * |
|
| 172 | + * @param None |
|
| 173 | + * @return boolean |
|
| 174 | + */ |
|
| 175 | + public static function is_admin() { |
|
| 176 | + return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX ); |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + /** |
|
| 180 | + * Check if value contains blank value or empty array |
|
| 181 | + * |
|
| 182 | + * @since 2.0 |
|
| 183 | + * @param mixed $value - value to check |
|
| 184 | 184 | * @param string |
| 185 | - * @return boolean |
|
| 186 | - */ |
|
| 187 | - public static function is_empty_value( $value, $empty = '' ) { |
|
| 188 | - return ( is_array( $value ) && empty( $value ) ) || $value == $empty; |
|
| 189 | - } |
|
| 190 | - |
|
| 191 | - public static function is_not_empty_value( $value, $empty = '' ) { |
|
| 192 | - return ! self::is_empty_value( $value, $empty ); |
|
| 193 | - } |
|
| 194 | - |
|
| 195 | - /** |
|
| 196 | - * Get any value from the $_SERVER |
|
| 197 | - * |
|
| 198 | - * @since 2.0 |
|
| 199 | - * @param string $value |
|
| 200 | - * @return string |
|
| 201 | - */ |
|
| 185 | + * @return boolean |
|
| 186 | + */ |
|
| 187 | + public static function is_empty_value( $value, $empty = '' ) { |
|
| 188 | + return ( is_array( $value ) && empty( $value ) ) || $value == $empty; |
|
| 189 | + } |
|
| 190 | + |
|
| 191 | + public static function is_not_empty_value( $value, $empty = '' ) { |
|
| 192 | + return ! self::is_empty_value( $value, $empty ); |
|
| 193 | + } |
|
| 194 | + |
|
| 195 | + /** |
|
| 196 | + * Get any value from the $_SERVER |
|
| 197 | + * |
|
| 198 | + * @since 2.0 |
|
| 199 | + * @param string $value |
|
| 200 | + * @return string |
|
| 201 | + */ |
|
| 202 | 202 | public static function get_server_value( $value ) { |
| 203 | - return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; |
|
| 204 | - } |
|
| 205 | - |
|
| 206 | - /** |
|
| 207 | - * Check for the IP address in several places |
|
| 208 | - * Used by [ip] shortcode |
|
| 209 | - * |
|
| 210 | - * @return string The IP address of the current user |
|
| 211 | - */ |
|
| 212 | - public static function get_ip_address() { |
|
| 203 | + return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; |
|
| 204 | + } |
|
| 205 | + |
|
| 206 | + /** |
|
| 207 | + * Check for the IP address in several places |
|
| 208 | + * Used by [ip] shortcode |
|
| 209 | + * |
|
| 210 | + * @return string The IP address of the current user |
|
| 211 | + */ |
|
| 212 | + public static function get_ip_address() { |
|
| 213 | 213 | $ip = ''; |
| 214 | - foreach ( array( |
|
| 215 | - 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', |
|
| 216 | - 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR', |
|
| 217 | - ) as $key ) { |
|
| 218 | - if ( ! isset( $_SERVER[ $key ] ) ) { |
|
| 219 | - continue; |
|
| 220 | - } |
|
| 221 | - |
|
| 222 | - foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { |
|
| 223 | - $ip = trim($ip); // just to be safe |
|
| 224 | - |
|
| 225 | - if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) { |
|
| 226 | - return $ip; |
|
| 227 | - } |
|
| 228 | - } |
|
| 229 | - } |
|
| 214 | + foreach ( array( |
|
| 215 | + 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', |
|
| 216 | + 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR', |
|
| 217 | + ) as $key ) { |
|
| 218 | + if ( ! isset( $_SERVER[ $key ] ) ) { |
|
| 219 | + continue; |
|
| 220 | + } |
|
| 221 | + |
|
| 222 | + foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { |
|
| 223 | + $ip = trim($ip); // just to be safe |
|
| 224 | + |
|
| 225 | + if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) { |
|
| 226 | + return $ip; |
|
| 227 | + } |
|
| 228 | + } |
|
| 229 | + } |
|
| 230 | 230 | |
| 231 | 231 | return sanitize_text_field( $ip ); |
| 232 | - } |
|
| 232 | + } |
|
| 233 | 233 | |
| 234 | - public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
|
| 235 | - if ( strpos($param, '[') ) { |
|
| 236 | - $params = explode('[', $param); |
|
| 237 | - $param = $params[0]; |
|
| 238 | - } |
|
| 234 | + public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
|
| 235 | + if ( strpos($param, '[') ) { |
|
| 236 | + $params = explode('[', $param); |
|
| 237 | + $param = $params[0]; |
|
| 238 | + } |
|
| 239 | 239 | |
| 240 | 240 | if ( $src == 'get' ) { |
| 241 | - $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); |
|
| 242 | - if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { |
|
| 243 | - $value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) ); |
|
| 244 | - } |
|
| 241 | + $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); |
|
| 242 | + if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { |
|
| 243 | + $value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) ); |
|
| 244 | + } |
|
| 245 | 245 | self::sanitize_value( $sanitize, $value ); |
| 246 | 246 | } else { |
| 247 | - $value = self::get_simple_request( array( 'type' => $src, 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) ); |
|
| 248 | - } |
|
| 247 | + $value = self::get_simple_request( array( 'type' => $src, 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) ); |
|
| 248 | + } |
|
| 249 | 249 | |
| 250 | 250 | if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) { |
| 251 | - foreach ( $params as $k => $p ) { |
|
| 252 | - if ( ! $k || ! is_array($value) ) { |
|
| 253 | - continue; |
|
| 254 | - } |
|
| 251 | + foreach ( $params as $k => $p ) { |
|
| 252 | + if ( ! $k || ! is_array($value) ) { |
|
| 253 | + continue; |
|
| 254 | + } |
|
| 255 | 255 | |
| 256 | - $p = trim($p, ']'); |
|
| 257 | - $value = isset( $value[ $p ] ) ? $value[ $p ] : $default; |
|
| 258 | - } |
|
| 259 | - } |
|
| 256 | + $p = trim($p, ']'); |
|
| 257 | + $value = isset( $value[ $p ] ) ? $value[ $p ] : $default; |
|
| 258 | + } |
|
| 259 | + } |
|
| 260 | 260 | |
| 261 | - return $value; |
|
| 262 | - } |
|
| 261 | + return $value; |
|
| 262 | + } |
|
| 263 | 263 | |
| 264 | 264 | public static function get_post_param( $param, $default = '', $sanitize = '' ) { |
| 265 | 265 | return self::get_simple_request( array( 'type' => 'post', 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) ); |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | */ |
| 276 | 276 | public static function simple_get( $param, $sanitize = 'sanitize_text_field', $default = '' ) { |
| 277 | 277 | return self::get_simple_request( array( 'type' => 'get', 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) ); |
| 278 | - } |
|
| 278 | + } |
|
| 279 | 279 | |
| 280 | 280 | /** |
| 281 | 281 | * Get a GET/POST/REQUEST value and sanitize it |
@@ -311,12 +311,12 @@ discard block |
||
| 311 | 311 | } |
| 312 | 312 | |
| 313 | 313 | /** |
| 314 | - * Preserve backslashes in a value, but make sure value doesn't get compounding slashes |
|
| 315 | - * |
|
| 316 | - * @since 2.0.8 |
|
| 317 | - * @param string $value |
|
| 318 | - * @return string $value |
|
| 319 | - */ |
|
| 314 | + * Preserve backslashes in a value, but make sure value doesn't get compounding slashes |
|
| 315 | + * |
|
| 316 | + * @since 2.0.8 |
|
| 317 | + * @param string $value |
|
| 318 | + * @return string $value |
|
| 319 | + */ |
|
| 320 | 320 | public static function preserve_backslashes( $value ) { |
| 321 | 321 | // If backslashes have already been added, don't add them again |
| 322 | 322 | if ( strpos( $value, '\\\\' ) === false ) { |
@@ -338,14 +338,14 @@ discard block |
||
| 338 | 338 | } |
| 339 | 339 | } |
| 340 | 340 | |
| 341 | - public static function sanitize_request( $sanitize_method, &$values ) { |
|
| 342 | - $temp_values = $values; |
|
| 343 | - foreach ( $temp_values as $k => $val ) { |
|
| 344 | - if ( isset( $sanitize_method[ $k ] ) ) { |
|
| 341 | + public static function sanitize_request( $sanitize_method, &$values ) { |
|
| 342 | + $temp_values = $values; |
|
| 343 | + foreach ( $temp_values as $k => $val ) { |
|
| 344 | + if ( isset( $sanitize_method[ $k ] ) ) { |
|
| 345 | 345 | $values[ $k ] = call_user_func( $sanitize_method[ $k ], $val ); |
| 346 | - } |
|
| 347 | - } |
|
| 348 | - } |
|
| 346 | + } |
|
| 347 | + } |
|
| 348 | + } |
|
| 349 | 349 | |
| 350 | 350 | public static function sanitize_array( &$values ) { |
| 351 | 351 | $temp_values = $values; |
@@ -469,77 +469,77 @@ discard block |
||
| 469 | 469 | ); |
| 470 | 470 | } |
| 471 | 471 | |
| 472 | - /** |
|
| 473 | - * Used when switching the action for a bulk action |
|
| 474 | - * @since 2.0 |
|
| 475 | - */ |
|
| 476 | - public static function remove_get_action() { |
|
| 477 | - if ( ! isset($_GET) ) { |
|
| 478 | - return; |
|
| 479 | - } |
|
| 472 | + /** |
|
| 473 | + * Used when switching the action for a bulk action |
|
| 474 | + * @since 2.0 |
|
| 475 | + */ |
|
| 476 | + public static function remove_get_action() { |
|
| 477 | + if ( ! isset($_GET) ) { |
|
| 478 | + return; |
|
| 479 | + } |
|
| 480 | 480 | |
| 481 | - $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' ); |
|
| 482 | - if ( ! empty( $new_action ) ) { |
|
| 481 | + $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' ); |
|
| 482 | + if ( ! empty( $new_action ) ) { |
|
| 483 | 483 | $_SERVER['REQUEST_URI'] = str_replace( '&action=' . $new_action, '', FrmAppHelper::get_server_value( 'REQUEST_URI' ) ); |
| 484 | - } |
|
| 485 | - } |
|
| 486 | - |
|
| 487 | - /** |
|
| 488 | - * Check the WP query for a parameter |
|
| 489 | - * |
|
| 490 | - * @since 2.0 |
|
| 491 | - * @return string|array |
|
| 492 | - */ |
|
| 493 | - public static function get_query_var( $value, $param ) { |
|
| 494 | - if ( $value != '' ) { |
|
| 495 | - return $value; |
|
| 496 | - } |
|
| 497 | - |
|
| 498 | - global $wp_query; |
|
| 499 | - if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
| 500 | - $value = $wp_query->query_vars[ $param ]; |
|
| 501 | - } |
|
| 502 | - |
|
| 503 | - return $value; |
|
| 504 | - } |
|
| 505 | - |
|
| 506 | - /** |
|
| 507 | - * @param string $type |
|
| 508 | - */ |
|
| 509 | - public static function trigger_hook_load( $type, $object = null ) { |
|
| 510 | - // only load the form hooks once |
|
| 484 | + } |
|
| 485 | + } |
|
| 486 | + |
|
| 487 | + /** |
|
| 488 | + * Check the WP query for a parameter |
|
| 489 | + * |
|
| 490 | + * @since 2.0 |
|
| 491 | + * @return string|array |
|
| 492 | + */ |
|
| 493 | + public static function get_query_var( $value, $param ) { |
|
| 494 | + if ( $value != '' ) { |
|
| 495 | + return $value; |
|
| 496 | + } |
|
| 497 | + |
|
| 498 | + global $wp_query; |
|
| 499 | + if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
| 500 | + $value = $wp_query->query_vars[ $param ]; |
|
| 501 | + } |
|
| 502 | + |
|
| 503 | + return $value; |
|
| 504 | + } |
|
| 505 | + |
|
| 506 | + /** |
|
| 507 | + * @param string $type |
|
| 508 | + */ |
|
| 509 | + public static function trigger_hook_load( $type, $object = null ) { |
|
| 510 | + // only load the form hooks once |
|
| 511 | 511 | $hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object ); |
| 512 | - if ( ! $hooks_loaded ) { |
|
| 512 | + if ( ! $hooks_loaded ) { |
|
| 513 | 513 | do_action( 'frm_load_' . $type . '_hooks' ); |
| 514 | - } |
|
| 515 | - } |
|
| 516 | - |
|
| 517 | - /** |
|
| 518 | - * Check cache before fetching values and saving to cache |
|
| 519 | - * |
|
| 520 | - * @since 2.0 |
|
| 521 | - * |
|
| 522 | - * @param string $cache_key The unique name for this cache |
|
| 523 | - * @param string $group The name of the cache group |
|
| 524 | - * @param string $query If blank, don't run a db call |
|
| 525 | - * @param string $type The wpdb function to use with this query |
|
| 526 | - * @return mixed $results The cache or query results |
|
| 527 | - */ |
|
| 528 | - public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) { |
|
| 529 | - $results = wp_cache_get($cache_key, $group); |
|
| 530 | - if ( ! self::is_empty_value( $results, false ) || empty($query) ) { |
|
| 531 | - return $results; |
|
| 532 | - } |
|
| 533 | - |
|
| 534 | - if ( 'get_posts' == $type ) { |
|
| 535 | - $results = get_posts($query); |
|
| 514 | + } |
|
| 515 | + } |
|
| 516 | + |
|
| 517 | + /** |
|
| 518 | + * Check cache before fetching values and saving to cache |
|
| 519 | + * |
|
| 520 | + * @since 2.0 |
|
| 521 | + * |
|
| 522 | + * @param string $cache_key The unique name for this cache |
|
| 523 | + * @param string $group The name of the cache group |
|
| 524 | + * @param string $query If blank, don't run a db call |
|
| 525 | + * @param string $type The wpdb function to use with this query |
|
| 526 | + * @return mixed $results The cache or query results |
|
| 527 | + */ |
|
| 528 | + public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) { |
|
| 529 | + $results = wp_cache_get($cache_key, $group); |
|
| 530 | + if ( ! self::is_empty_value( $results, false ) || empty($query) ) { |
|
| 531 | + return $results; |
|
| 532 | + } |
|
| 533 | + |
|
| 534 | + if ( 'get_posts' == $type ) { |
|
| 535 | + $results = get_posts($query); |
|
| 536 | 536 | } else if ( 'get_associative_results' == $type ) { |
| 537 | 537 | global $wpdb; |
| 538 | 538 | $results = $wpdb->get_results( $query, OBJECT_K ); |
| 539 | - } else { |
|
| 540 | - global $wpdb; |
|
| 541 | - $results = $wpdb->{$type}($query); |
|
| 542 | - } |
|
| 539 | + } else { |
|
| 540 | + global $wpdb; |
|
| 541 | + $results = $wpdb->{$type}($query); |
|
| 542 | + } |
|
| 543 | 543 | |
| 544 | 544 | self::set_cache( $cache_key, $results, $group, $time ); |
| 545 | 545 | |
@@ -572,44 +572,44 @@ discard block |
||
| 572 | 572 | return $cached; |
| 573 | 573 | } |
| 574 | 574 | |
| 575 | - /** |
|
| 576 | - * Data that should be stored for a long time can be stored in a transient. |
|
| 577 | - * First check the cache, then check the transient |
|
| 578 | - * @since 2.0 |
|
| 579 | - * @return mixed The cached value or false |
|
| 580 | - */ |
|
| 575 | + /** |
|
| 576 | + * Data that should be stored for a long time can be stored in a transient. |
|
| 577 | + * First check the cache, then check the transient |
|
| 578 | + * @since 2.0 |
|
| 579 | + * @return mixed The cached value or false |
|
| 580 | + */ |
|
| 581 | 581 | public static function check_cache_and_transient( $cache_key ) { |
| 582 | - // check caching layer first |
|
| 583 | - $results = self::check_cache( $cache_key ); |
|
| 584 | - if ( $results ) { |
|
| 585 | - return $results; |
|
| 586 | - } |
|
| 587 | - |
|
| 588 | - // then check the transient |
|
| 589 | - $results = get_transient($cache_key); |
|
| 590 | - if ( $results ) { |
|
| 591 | - wp_cache_set($cache_key, $results); |
|
| 592 | - } |
|
| 593 | - |
|
| 594 | - return $results; |
|
| 595 | - } |
|
| 596 | - |
|
| 597 | - /** |
|
| 598 | - * @since 2.0 |
|
| 599 | - * @param string $cache_key |
|
| 600 | - */ |
|
| 582 | + // check caching layer first |
|
| 583 | + $results = self::check_cache( $cache_key ); |
|
| 584 | + if ( $results ) { |
|
| 585 | + return $results; |
|
| 586 | + } |
|
| 587 | + |
|
| 588 | + // then check the transient |
|
| 589 | + $results = get_transient($cache_key); |
|
| 590 | + if ( $results ) { |
|
| 591 | + wp_cache_set($cache_key, $results); |
|
| 592 | + } |
|
| 593 | + |
|
| 594 | + return $results; |
|
| 595 | + } |
|
| 596 | + |
|
| 597 | + /** |
|
| 598 | + * @since 2.0 |
|
| 599 | + * @param string $cache_key |
|
| 600 | + */ |
|
| 601 | 601 | public static function delete_cache_and_transient( $cache_key, $group = 'default' ) { |
| 602 | 602 | delete_transient($cache_key); |
| 603 | 603 | wp_cache_delete( $cache_key, $group ); |
| 604 | 604 | } |
| 605 | 605 | |
| 606 | - /** |
|
| 607 | - * Delete all caching in a single group |
|
| 608 | - * |
|
| 609 | - * @since 2.0 |
|
| 610 | - * |
|
| 611 | - * @param string $group The name of the cache group |
|
| 612 | - */ |
|
| 606 | + /** |
|
| 607 | + * Delete all caching in a single group |
|
| 608 | + * |
|
| 609 | + * @since 2.0 |
|
| 610 | + * |
|
| 611 | + * @param string $group The name of the cache group |
|
| 612 | + */ |
|
| 613 | 613 | public static function cache_delete_group( $group ) { |
| 614 | 614 | $cached_keys = self::get_group_cached_keys( $group ); |
| 615 | 615 | |
@@ -622,35 +622,35 @@ discard block |
||
| 622 | 622 | } |
| 623 | 623 | } |
| 624 | 624 | |
| 625 | - /** |
|
| 626 | - * Check a value from a shortcode to see if true or false. |
|
| 627 | - * True when value is 1, true, 'true', 'yes' |
|
| 628 | - * |
|
| 629 | - * @since 1.07.10 |
|
| 630 | - * |
|
| 631 | - * @param string $value The value to compare |
|
| 632 | - * @return boolean True or False |
|
| 633 | - */ |
|
| 625 | + /** |
|
| 626 | + * Check a value from a shortcode to see if true or false. |
|
| 627 | + * True when value is 1, true, 'true', 'yes' |
|
| 628 | + * |
|
| 629 | + * @since 1.07.10 |
|
| 630 | + * |
|
| 631 | + * @param string $value The value to compare |
|
| 632 | + * @return boolean True or False |
|
| 633 | + */ |
|
| 634 | 634 | public static function is_true( $value ) { |
| 635 | - return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value ); |
|
| 636 | - } |
|
| 635 | + return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value ); |
|
| 636 | + } |
|
| 637 | 637 | |
| 638 | - /** |
|
| 639 | - * Used to filter shortcode in text widgets |
|
| 640 | - */ |
|
| 641 | - public static function widget_text_filter_callback( $matches ) { |
|
| 638 | + /** |
|
| 639 | + * Used to filter shortcode in text widgets |
|
| 640 | + */ |
|
| 641 | + public static function widget_text_filter_callback( $matches ) { |
|
| 642 | 642 | _deprecated_function( __METHOD__, '2.5.4' ); |
| 643 | - return do_shortcode( $matches[0] ); |
|
| 644 | - } |
|
| 643 | + return do_shortcode( $matches[0] ); |
|
| 644 | + } |
|
| 645 | 645 | |
| 646 | - public static function get_pages() { |
|
| 646 | + public static function get_pages() { |
|
| 647 | 647 | return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' ) ); |
| 648 | - } |
|
| 648 | + } |
|
| 649 | 649 | |
| 650 | - public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
|
| 651 | - $pages = self::get_pages(); |
|
| 650 | + public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
|
| 651 | + $pages = self::get_pages(); |
|
| 652 | 652 | $selected = self::get_post_param( $field_name, $page_id, 'absint' ); |
| 653 | - ?> |
|
| 653 | + ?> |
|
| 654 | 654 | <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown"> |
| 655 | 655 | <option value=""> </option> |
| 656 | 656 | <?php foreach ( $pages as $page ) { ?> |
@@ -660,108 +660,108 @@ discard block |
||
| 660 | 660 | <?php } ?> |
| 661 | 661 | </select> |
| 662 | 662 | <?php |
| 663 | - } |
|
| 663 | + } |
|
| 664 | 664 | |
| 665 | 665 | public static function post_edit_link( $post_id ) { |
| 666 | - $post = get_post($post_id); |
|
| 667 | - if ( $post ) { |
|
| 666 | + $post = get_post($post_id); |
|
| 667 | + if ( $post ) { |
|
| 668 | 668 | $post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' ); |
| 669 | 669 | return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>'; |
| 670 | - } |
|
| 671 | - return ''; |
|
| 672 | - } |
|
| 670 | + } |
|
| 671 | + return ''; |
|
| 672 | + } |
|
| 673 | 673 | |
| 674 | 674 | public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) { |
| 675 | - ?> |
|
| 675 | + ?> |
|
| 676 | 676 | <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" <?php |
| 677 | - echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : ''; |
|
| 678 | - ?> class="frm_multiselect"> |
|
| 677 | + echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : ''; |
|
| 678 | + ?> class="frm_multiselect"> |
|
| 679 | 679 | <?php self::roles_options($capability); ?> |
| 680 | 680 | </select> |
| 681 | 681 | <?php |
| 682 | - } |
|
| 682 | + } |
|
| 683 | 683 | |
| 684 | 684 | public static function roles_options( $capability ) { |
| 685 | - global $frm_vars; |
|
| 686 | - if ( isset($frm_vars['editable_roles']) ) { |
|
| 687 | - $editable_roles = $frm_vars['editable_roles']; |
|
| 688 | - } else { |
|
| 689 | - $editable_roles = get_editable_roles(); |
|
| 690 | - $frm_vars['editable_roles'] = $editable_roles; |
|
| 691 | - } |
|
| 692 | - |
|
| 693 | - foreach ( $editable_roles as $role => $details ) { |
|
| 694 | - $name = translate_user_role($details['name'] ); ?> |
|
| 685 | + global $frm_vars; |
|
| 686 | + if ( isset($frm_vars['editable_roles']) ) { |
|
| 687 | + $editable_roles = $frm_vars['editable_roles']; |
|
| 688 | + } else { |
|
| 689 | + $editable_roles = get_editable_roles(); |
|
| 690 | + $frm_vars['editable_roles'] = $editable_roles; |
|
| 691 | + } |
|
| 692 | + |
|
| 693 | + foreach ( $editable_roles as $role => $details ) { |
|
| 694 | + $name = translate_user_role($details['name'] ); ?> |
|
| 695 | 695 | <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option> |
| 696 | 696 | <?php |
| 697 | - unset($role, $details); |
|
| 698 | - } |
|
| 699 | - } |
|
| 697 | + unset($role, $details); |
|
| 698 | + } |
|
| 699 | + } |
|
| 700 | 700 | |
| 701 | 701 | public static function frm_capabilities( $type = 'auto' ) { |
| 702 | - $cap = array( |
|
| 703 | - 'frm_view_forms' => __( 'View Forms and Templates', 'formidable' ), |
|
| 704 | - 'frm_edit_forms' => __( 'Add/Edit Forms and Templates', 'formidable' ), |
|
| 705 | - 'frm_delete_forms' => __( 'Delete Forms and Templates', 'formidable' ), |
|
| 706 | - 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ), |
|
| 707 | - 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ), |
|
| 708 | - 'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ), |
|
| 709 | - ); |
|
| 702 | + $cap = array( |
|
| 703 | + 'frm_view_forms' => __( 'View Forms and Templates', 'formidable' ), |
|
| 704 | + 'frm_edit_forms' => __( 'Add/Edit Forms and Templates', 'formidable' ), |
|
| 705 | + 'frm_delete_forms' => __( 'Delete Forms and Templates', 'formidable' ), |
|
| 706 | + 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ), |
|
| 707 | + 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ), |
|
| 708 | + 'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ), |
|
| 709 | + ); |
|
| 710 | 710 | |
| 711 | 711 | if ( ! self::pro_is_installed() && 'pro' != $type ) { |
| 712 | - return $cap; |
|
| 713 | - } |
|
| 712 | + return $cap; |
|
| 713 | + } |
|
| 714 | 714 | |
| 715 | - $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' ); |
|
| 716 | - $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' ); |
|
| 717 | - $cap['frm_view_reports'] = __( 'View Reports', 'formidable' ); |
|
| 718 | - $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' ); |
|
| 715 | + $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' ); |
|
| 716 | + $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' ); |
|
| 717 | + $cap['frm_view_reports'] = __( 'View Reports', 'formidable' ); |
|
| 718 | + $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' ); |
|
| 719 | 719 | |
| 720 | - return $cap; |
|
| 721 | - } |
|
| 720 | + return $cap; |
|
| 721 | + } |
|
| 722 | 722 | |
| 723 | 723 | public static function user_has_permission( $needed_role ) { |
| 724 | - if ( $needed_role == '-1' ) { |
|
| 725 | - return false; |
|
| 724 | + if ( $needed_role == '-1' ) { |
|
| 725 | + return false; |
|
| 726 | 726 | } |
| 727 | 727 | |
| 728 | - // $needed_role will be equal to blank if "Logged-in users" is selected |
|
| 729 | - if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) { |
|
| 730 | - return true; |
|
| 731 | - } |
|
| 728 | + // $needed_role will be equal to blank if "Logged-in users" is selected |
|
| 729 | + if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) { |
|
| 730 | + return true; |
|
| 731 | + } |
|
| 732 | 732 | |
| 733 | - $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ); |
|
| 734 | - foreach ( $roles as $role ) { |
|
| 733 | + $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ); |
|
| 734 | + foreach ( $roles as $role ) { |
|
| 735 | 735 | if ( current_user_can( $role ) ) { |
| 736 | - return true; |
|
| 736 | + return true; |
|
| 737 | 737 | } |
| 738 | - if ( $role == $needed_role ) { |
|
| 739 | - break; |
|
| 738 | + if ( $role == $needed_role ) { |
|
| 739 | + break; |
|
| 740 | 740 | } |
| 741 | - } |
|
| 742 | - return false; |
|
| 743 | - } |
|
| 744 | - |
|
| 745 | - /** |
|
| 746 | - * Make sure administrators can see Formidable menu |
|
| 747 | - * |
|
| 748 | - * @since 2.0 |
|
| 749 | - */ |
|
| 750 | - public static function maybe_add_permissions() { |
|
| 741 | + } |
|
| 742 | + return false; |
|
| 743 | + } |
|
| 744 | + |
|
| 745 | + /** |
|
| 746 | + * Make sure administrators can see Formidable menu |
|
| 747 | + * |
|
| 748 | + * @since 2.0 |
|
| 749 | + */ |
|
| 750 | + public static function maybe_add_permissions() { |
|
| 751 | 751 | self::force_capability( 'frm_view_entries' ); |
| 752 | 752 | |
| 753 | - if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) { |
|
| 754 | - return; |
|
| 755 | - } |
|
| 753 | + if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) { |
|
| 754 | + return; |
|
| 755 | + } |
|
| 756 | 756 | |
| 757 | 757 | $user_id = get_current_user_id(); |
| 758 | 758 | $user = new WP_User( $user_id ); |
| 759 | - $frm_roles = self::frm_capabilities(); |
|
| 760 | - foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 759 | + $frm_roles = self::frm_capabilities(); |
|
| 760 | + foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 761 | 761 | $user->add_cap( $frm_role ); |
| 762 | - unset($frm_role, $frm_role_description); |
|
| 763 | - } |
|
| 764 | - } |
|
| 762 | + unset($frm_role, $frm_role_description); |
|
| 763 | + } |
|
| 764 | + } |
|
| 765 | 765 | |
| 766 | 766 | /** |
| 767 | 767 | * Make sure admins have permission to see the menu items |
@@ -777,28 +777,28 @@ discard block |
||
| 777 | 777 | } |
| 778 | 778 | } |
| 779 | 779 | |
| 780 | - /** |
|
| 781 | - * Check if the user has permision for action. |
|
| 782 | - * Return permission message and stop the action if no permission |
|
| 783 | - * @since 2.0 |
|
| 784 | - * @param string $permission |
|
| 785 | - */ |
|
| 780 | + /** |
|
| 781 | + * Check if the user has permision for action. |
|
| 782 | + * Return permission message and stop the action if no permission |
|
| 783 | + * @since 2.0 |
|
| 784 | + * @param string $permission |
|
| 785 | + */ |
|
| 786 | 786 | public static function permission_check( $permission, $show_message = 'show' ) { |
| 787 | - $permission_error = self::permission_nonce_error($permission); |
|
| 788 | - if ( $permission_error !== false ) { |
|
| 789 | - if ( 'hide' == $show_message ) { |
|
| 790 | - $permission_error = ''; |
|
| 791 | - } |
|
| 792 | - wp_die($permission_error); |
|
| 793 | - } |
|
| 794 | - } |
|
| 795 | - |
|
| 796 | - /** |
|
| 797 | - * Check user permission and nonce |
|
| 798 | - * @since 2.0 |
|
| 799 | - * @param string $permission |
|
| 800 | - * @return false|string The permission message or false if allowed |
|
| 801 | - */ |
|
| 787 | + $permission_error = self::permission_nonce_error($permission); |
|
| 788 | + if ( $permission_error !== false ) { |
|
| 789 | + if ( 'hide' == $show_message ) { |
|
| 790 | + $permission_error = ''; |
|
| 791 | + } |
|
| 792 | + wp_die($permission_error); |
|
| 793 | + } |
|
| 794 | + } |
|
| 795 | + |
|
| 796 | + /** |
|
| 797 | + * Check user permission and nonce |
|
| 798 | + * @since 2.0 |
|
| 799 | + * @param string $permission |
|
| 800 | + * @return false|string The permission message or false if allowed |
|
| 801 | + */ |
|
| 802 | 802 | public static function permission_nonce_error( $permission, $nonce_name = '', $nonce = '' ) { |
| 803 | 803 | if ( ! empty( $permission ) && ! current_user_can( $permission ) && ! current_user_can( 'administrator' ) ) { |
| 804 | 804 | $frm_settings = self::get_settings(); |
@@ -806,23 +806,23 @@ discard block |
||
| 806 | 806 | } |
| 807 | 807 | |
| 808 | 808 | $error = false; |
| 809 | - if ( empty($nonce_name) ) { |
|
| 810 | - return $error; |
|
| 811 | - } |
|
| 809 | + if ( empty($nonce_name) ) { |
|
| 810 | + return $error; |
|
| 811 | + } |
|
| 812 | 812 | |
| 813 | - if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
| 814 | - $frm_settings = self::get_settings(); |
|
| 815 | - $error = $frm_settings->admin_permission; |
|
| 816 | - } |
|
| 813 | + if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
| 814 | + $frm_settings = self::get_settings(); |
|
| 815 | + $error = $frm_settings->admin_permission; |
|
| 816 | + } |
|
| 817 | 817 | |
| 818 | - return $error; |
|
| 819 | - } |
|
| 818 | + return $error; |
|
| 819 | + } |
|
| 820 | 820 | |
| 821 | - public static function checked( $values, $current ) { |
|
| 821 | + public static function checked( $values, $current ) { |
|
| 822 | 822 | if ( self::check_selected( $values, $current ) ) { |
| 823 | - echo ' checked="checked"'; |
|
| 823 | + echo ' checked="checked"'; |
|
| 824 | 824 | } |
| 825 | - } |
|
| 825 | + } |
|
| 826 | 826 | |
| 827 | 827 | public static function check_selected( $values, $current ) { |
| 828 | 828 | $values = self::recursive_function_map( $values, 'trim' ); |
@@ -832,50 +832,50 @@ discard block |
||
| 832 | 832 | return ( is_array( $values ) && in_array( $current, $values ) ) || ( ! is_array( $values ) && $values == $current ); |
| 833 | 833 | } |
| 834 | 834 | |
| 835 | - /** |
|
| 836 | - * Check if current field option is an "other" option |
|
| 837 | - * |
|
| 838 | - * @since 2.0 |
|
| 839 | - * |
|
| 840 | - * @param string $opt_key |
|
| 841 | - * @return boolean Returns true if current field option is an "Other" option |
|
| 842 | - */ |
|
| 843 | - public static function is_other_opt( $opt_key ) { |
|
| 844 | - _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::is_other_opt' ); |
|
| 845 | - return FrmFieldsHelper::is_other_opt( $opt_key ); |
|
| 846 | - } |
|
| 847 | - |
|
| 848 | - /** |
|
| 849 | - * Get value that belongs in "Other" text box |
|
| 850 | - * |
|
| 851 | - * @since 2.0 |
|
| 852 | - * |
|
| 853 | - * @param string $opt_key |
|
| 854 | - * @param array $field |
|
| 855 | - * @return string $other_val |
|
| 856 | - */ |
|
| 857 | - public static function get_other_val( $opt_key, $field, $parent = false, $pointer = false ) { |
|
| 835 | + /** |
|
| 836 | + * Check if current field option is an "other" option |
|
| 837 | + * |
|
| 838 | + * @since 2.0 |
|
| 839 | + * |
|
| 840 | + * @param string $opt_key |
|
| 841 | + * @return boolean Returns true if current field option is an "Other" option |
|
| 842 | + */ |
|
| 843 | + public static function is_other_opt( $opt_key ) { |
|
| 844 | + _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::is_other_opt' ); |
|
| 845 | + return FrmFieldsHelper::is_other_opt( $opt_key ); |
|
| 846 | + } |
|
| 847 | + |
|
| 848 | + /** |
|
| 849 | + * Get value that belongs in "Other" text box |
|
| 850 | + * |
|
| 851 | + * @since 2.0 |
|
| 852 | + * |
|
| 853 | + * @param string $opt_key |
|
| 854 | + * @param array $field |
|
| 855 | + * @return string $other_val |
|
| 856 | + */ |
|
| 857 | + public static function get_other_val( $opt_key, $field, $parent = false, $pointer = false ) { |
|
| 858 | 858 | _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::get_other_val' ); |
| 859 | 859 | return FrmFieldsHelper::get_other_val( compact( 'opt_key', 'field', 'parent', 'pointer' ) ); |
| 860 | - } |
|
| 861 | - |
|
| 862 | - /** |
|
| 863 | - * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val. |
|
| 864 | - * Intended for front-end use |
|
| 865 | - * |
|
| 866 | - * @since 2.0 |
|
| 867 | - * |
|
| 868 | - * @param array $field |
|
| 869 | - * @param boolean $other_opt |
|
| 870 | - * @param string $checked |
|
| 871 | - * @param array $args should include opt_key and field name |
|
| 872 | - * @return string $other_val |
|
| 873 | - */ |
|
| 874 | - public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) { |
|
| 860 | + } |
|
| 861 | + |
|
| 862 | + /** |
|
| 863 | + * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val. |
|
| 864 | + * Intended for front-end use |
|
| 865 | + * |
|
| 866 | + * @since 2.0 |
|
| 867 | + * |
|
| 868 | + * @param array $field |
|
| 869 | + * @param boolean $other_opt |
|
| 870 | + * @param string $checked |
|
| 871 | + * @param array $args should include opt_key and field name |
|
| 872 | + * @return string $other_val |
|
| 873 | + */ |
|
| 874 | + public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) { |
|
| 875 | 875 | _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::prepare_other_input' ); |
| 876 | 876 | $args['field'] = $field; |
| 877 | 877 | return FrmFieldsHelper::prepare_other_input( $args, $other_opt, $checked ); |
| 878 | - } |
|
| 878 | + } |
|
| 879 | 879 | |
| 880 | 880 | public static function recursive_function_map( $value, $function ) { |
| 881 | 881 | if ( is_array( $value ) ) { |
@@ -905,24 +905,24 @@ discard block |
||
| 905 | 905 | return (bool) count( array_filter( array_keys( $array ), 'is_string' ) ); |
| 906 | 906 | } |
| 907 | 907 | |
| 908 | - /** |
|
| 909 | - * Flatten a multi-dimensional array |
|
| 910 | - */ |
|
| 908 | + /** |
|
| 909 | + * Flatten a multi-dimensional array |
|
| 910 | + */ |
|
| 911 | 911 | public static function array_flatten( $array, $keys = 'keep' ) { |
| 912 | - $return = array(); |
|
| 913 | - foreach ( $array as $key => $value ) { |
|
| 914 | - if ( is_array($value) ) { |
|
| 912 | + $return = array(); |
|
| 913 | + foreach ( $array as $key => $value ) { |
|
| 914 | + if ( is_array($value) ) { |
|
| 915 | 915 | $return = array_merge( $return, self::array_flatten( $value, $keys ) ); |
| 916 | - } else { |
|
| 916 | + } else { |
|
| 917 | 917 | if ( $keys == 'keep' ) { |
| 918 | 918 | $return[ $key ] = $value; |
| 919 | 919 | } else { |
| 920 | 920 | $return[] = $value; |
| 921 | 921 | } |
| 922 | - } |
|
| 923 | - } |
|
| 924 | - return $return; |
|
| 925 | - } |
|
| 922 | + } |
|
| 923 | + } |
|
| 924 | + return $return; |
|
| 925 | + } |
|
| 926 | 926 | |
| 927 | 927 | public static function esc_textarea( $text, $is_rich_text = false ) { |
| 928 | 928 | $safe_text = str_replace( '"', '"', $text ); |
@@ -933,38 +933,38 @@ discard block |
||
| 933 | 933 | return apply_filters( 'esc_textarea', $safe_text, $text ); |
| 934 | 934 | } |
| 935 | 935 | |
| 936 | - /** |
|
| 937 | - * Add auto paragraphs to text areas |
|
| 938 | - * @since 2.0 |
|
| 939 | - */ |
|
| 936 | + /** |
|
| 937 | + * Add auto paragraphs to text areas |
|
| 938 | + * @since 2.0 |
|
| 939 | + */ |
|
| 940 | 940 | public static function use_wpautop( $content ) { |
| 941 | - if ( apply_filters('frm_use_wpautop', true) ) { |
|
| 942 | - $content = wpautop(str_replace( '<br>', '<br />', $content)); |
|
| 943 | - } |
|
| 944 | - return $content; |
|
| 945 | - } |
|
| 941 | + if ( apply_filters('frm_use_wpautop', true) ) { |
|
| 942 | + $content = wpautop(str_replace( '<br>', '<br />', $content)); |
|
| 943 | + } |
|
| 944 | + return $content; |
|
| 945 | + } |
|
| 946 | 946 | |
| 947 | 947 | public static function replace_quotes( $val ) { |
| 948 | - //Replace double quotes |
|
| 948 | + //Replace double quotes |
|
| 949 | 949 | $val = str_replace( array( '“', '”', '″' ), '"', $val ); |
| 950 | - //Replace single quotes |
|
| 951 | - $val = str_replace( array( '‘', '’', '′', '′', '’', '‘' ), "'", $val ); |
|
| 952 | - return $val; |
|
| 953 | - } |
|
| 954 | - |
|
| 955 | - /** |
|
| 956 | - * @since 2.0 |
|
| 957 | - * @return string The base Google APIS url for the current version of jQuery UI |
|
| 958 | - */ |
|
| 959 | - public static function jquery_ui_base_url() { |
|
| 950 | + //Replace single quotes |
|
| 951 | + $val = str_replace( array( '‘', '’', '′', '′', '’', '‘' ), "'", $val ); |
|
| 952 | + return $val; |
|
| 953 | + } |
|
| 954 | + |
|
| 955 | + /** |
|
| 956 | + * @since 2.0 |
|
| 957 | + * @return string The base Google APIS url for the current version of jQuery UI |
|
| 958 | + */ |
|
| 959 | + public static function jquery_ui_base_url() { |
|
| 960 | 960 | $url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core', '1.11.4' ); |
| 961 | - $url = apply_filters('frm_jquery_ui_base_url', $url); |
|
| 962 | - return $url; |
|
| 963 | - } |
|
| 961 | + $url = apply_filters('frm_jquery_ui_base_url', $url); |
|
| 962 | + return $url; |
|
| 963 | + } |
|
| 964 | 964 | |
| 965 | - /** |
|
| 966 | - * @param string $handle |
|
| 967 | - */ |
|
| 965 | + /** |
|
| 966 | + * @param string $handle |
|
| 967 | + */ |
|
| 968 | 968 | public static function script_version( $handle, $default = 0 ) { |
| 969 | 969 | global $wp_scripts; |
| 970 | 970 | if ( ! $wp_scripts ) { |
@@ -986,241 +986,241 @@ discard block |
||
| 986 | 986 | |
| 987 | 987 | public static function js_redirect( $url ) { |
| 988 | 988 | return '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>'; |
| 989 | - } |
|
| 989 | + } |
|
| 990 | 990 | |
| 991 | 991 | public static function get_user_id_param( $user_id ) { |
| 992 | - if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) { |
|
| 993 | - return $user_id; |
|
| 994 | - } |
|
| 992 | + if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) { |
|
| 993 | + return $user_id; |
|
| 994 | + } |
|
| 995 | 995 | |
| 996 | 996 | if ( $user_id == 'current' ) { |
| 997 | 997 | $user_id = get_current_user_id(); |
| 998 | 998 | } else { |
| 999 | - if ( is_email($user_id) ) { |
|
| 1000 | - $user = get_user_by('email', $user_id); |
|
| 1001 | - } else { |
|
| 1002 | - $user = get_user_by('login', $user_id); |
|
| 1003 | - } |
|
| 999 | + if ( is_email($user_id) ) { |
|
| 1000 | + $user = get_user_by('email', $user_id); |
|
| 1001 | + } else { |
|
| 1002 | + $user = get_user_by('login', $user_id); |
|
| 1003 | + } |
|
| 1004 | 1004 | |
| 1005 | - if ( $user ) { |
|
| 1006 | - $user_id = $user->ID; |
|
| 1007 | - } |
|
| 1008 | - unset($user); |
|
| 1009 | - } |
|
| 1005 | + if ( $user ) { |
|
| 1006 | + $user_id = $user->ID; |
|
| 1007 | + } |
|
| 1008 | + unset($user); |
|
| 1009 | + } |
|
| 1010 | 1010 | |
| 1011 | - return $user_id; |
|
| 1012 | - } |
|
| 1011 | + return $user_id; |
|
| 1012 | + } |
|
| 1013 | 1013 | |
| 1014 | 1014 | public static function get_file_contents( $filename, $atts = array() ) { |
| 1015 | - if ( ! is_file($filename) ) { |
|
| 1016 | - return false; |
|
| 1017 | - } |
|
| 1018 | - |
|
| 1019 | - extract($atts); |
|
| 1020 | - ob_start(); |
|
| 1021 | - include($filename); |
|
| 1022 | - $contents = ob_get_contents(); |
|
| 1023 | - ob_end_clean(); |
|
| 1024 | - return $contents; |
|
| 1025 | - } |
|
| 1026 | - |
|
| 1027 | - /** |
|
| 1028 | - * @param string $table_name |
|
| 1029 | - * @param string $column |
|
| 1015 | + if ( ! is_file($filename) ) { |
|
| 1016 | + return false; |
|
| 1017 | + } |
|
| 1018 | + |
|
| 1019 | + extract($atts); |
|
| 1020 | + ob_start(); |
|
| 1021 | + include($filename); |
|
| 1022 | + $contents = ob_get_contents(); |
|
| 1023 | + ob_end_clean(); |
|
| 1024 | + return $contents; |
|
| 1025 | + } |
|
| 1026 | + |
|
| 1027 | + /** |
|
| 1028 | + * @param string $table_name |
|
| 1029 | + * @param string $column |
|
| 1030 | 1030 | * @param int $id |
| 1031 | 1031 | * @param int $num_chars |
| 1032 | - */ |
|
| 1033 | - public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) { |
|
| 1034 | - $key = ''; |
|
| 1032 | + */ |
|
| 1033 | + public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) { |
|
| 1034 | + $key = ''; |
|
| 1035 | 1035 | |
| 1036 | - if ( ! empty( $name ) ) { |
|
| 1037 | - $key = sanitize_key($name); |
|
| 1038 | - } |
|
| 1036 | + if ( ! empty( $name ) ) { |
|
| 1037 | + $key = sanitize_key($name); |
|
| 1038 | + } |
|
| 1039 | 1039 | |
| 1040 | 1040 | if ( empty( $key ) ) { |
| 1041 | - $max_slug_value = pow(36, $num_chars); |
|
| 1042 | - $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
| 1043 | - $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
| 1044 | - } |
|
| 1041 | + $max_slug_value = pow(36, $num_chars); |
|
| 1042 | + $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
| 1043 | + $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
| 1044 | + } |
|
| 1045 | 1045 | |
| 1046 | 1046 | if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) { |
| 1047 | 1047 | $key = $key . 'a'; |
| 1048 | - } |
|
| 1048 | + } |
|
| 1049 | 1049 | |
| 1050 | 1050 | $key_check = FrmDb::get_var( $table_name, array( $column => $key, 'ID !' => $id ), $column ); |
| 1051 | 1051 | |
| 1052 | - if ( $key_check || is_numeric($key_check) ) { |
|
| 1053 | - $suffix = 2; |
|
| 1052 | + if ( $key_check || is_numeric($key_check) ) { |
|
| 1053 | + $suffix = 2; |
|
| 1054 | 1054 | do { |
| 1055 | 1055 | $alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix; |
| 1056 | 1056 | $key_check = FrmDb::get_var( $table_name, array( $column => $alt_post_name, 'ID !' => $id ), $column ); |
| 1057 | 1057 | $suffix++; |
| 1058 | 1058 | } while ( $key_check || is_numeric( $key_check ) ); |
| 1059 | 1059 | $key = $alt_post_name; |
| 1060 | - } |
|
| 1061 | - return $key; |
|
| 1062 | - } |
|
| 1063 | - |
|
| 1064 | - /** |
|
| 1065 | - * Editing a Form or Entry |
|
| 1066 | - * @param string $table |
|
| 1067 | - * @return bool|array |
|
| 1068 | - */ |
|
| 1069 | - public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) { |
|
| 1070 | - if ( ! $record ) { |
|
| 1071 | - return false; |
|
| 1072 | - } |
|
| 1073 | - |
|
| 1074 | - if ( empty($post_values) ) { |
|
| 1075 | - $post_values = stripslashes_deep($_POST); |
|
| 1076 | - } |
|
| 1060 | + } |
|
| 1061 | + return $key; |
|
| 1062 | + } |
|
| 1063 | + |
|
| 1064 | + /** |
|
| 1065 | + * Editing a Form or Entry |
|
| 1066 | + * @param string $table |
|
| 1067 | + * @return bool|array |
|
| 1068 | + */ |
|
| 1069 | + public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) { |
|
| 1070 | + if ( ! $record ) { |
|
| 1071 | + return false; |
|
| 1072 | + } |
|
| 1073 | + |
|
| 1074 | + if ( empty($post_values) ) { |
|
| 1075 | + $post_values = stripslashes_deep($_POST); |
|
| 1076 | + } |
|
| 1077 | 1077 | |
| 1078 | 1078 | $values = array( 'id' => $record->id, 'fields' => array() ); |
| 1079 | 1079 | |
| 1080 | 1080 | foreach ( array( 'name', 'description' ) as $var ) { |
| 1081 | - $default_val = isset($record->{$var}) ? $record->{$var} : ''; |
|
| 1081 | + $default_val = isset($record->{$var}) ? $record->{$var} : ''; |
|
| 1082 | 1082 | $values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' ); |
| 1083 | - unset($var, $default_val); |
|
| 1084 | - } |
|
| 1085 | - |
|
| 1086 | - $values['description'] = self::use_wpautop($values['description']); |
|
| 1087 | - $frm_settings = self::get_settings(); |
|
| 1088 | - $is_form_builder = self::is_admin_page('formidable' ); |
|
| 1089 | - |
|
| 1090 | - foreach ( (array) $fields as $field ) { |
|
| 1091 | - // Make sure to filter default values (for placeholder text), but not on the form builder page |
|
| 1092 | - if ( ! $is_form_builder ) { |
|
| 1093 | - $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true ); |
|
| 1094 | - } |
|
| 1083 | + unset($var, $default_val); |
|
| 1084 | + } |
|
| 1085 | + |
|
| 1086 | + $values['description'] = self::use_wpautop($values['description']); |
|
| 1087 | + $frm_settings = self::get_settings(); |
|
| 1088 | + $is_form_builder = self::is_admin_page('formidable' ); |
|
| 1089 | + |
|
| 1090 | + foreach ( (array) $fields as $field ) { |
|
| 1091 | + // Make sure to filter default values (for placeholder text), but not on the form builder page |
|
| 1092 | + if ( ! $is_form_builder ) { |
|
| 1093 | + $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true ); |
|
| 1094 | + } |
|
| 1095 | 1095 | $parent_form_id = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id; |
| 1096 | 1096 | self::fill_field_defaults($field, $record, $values, compact('default', 'post_values', 'frm_settings', 'parent_form_id' ) ); |
| 1097 | - } |
|
| 1097 | + } |
|
| 1098 | 1098 | |
| 1099 | - self::fill_form_opts($record, $table, $post_values, $values); |
|
| 1099 | + self::fill_form_opts($record, $table, $post_values, $values); |
|
| 1100 | 1100 | |
| 1101 | - if ( $table == 'entries' ) { |
|
| 1102 | - $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
|
| 1103 | - } else if ( $table == 'forms' ) { |
|
| 1104 | - $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values ); |
|
| 1105 | - } |
|
| 1101 | + if ( $table == 'entries' ) { |
|
| 1102 | + $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
|
| 1103 | + } else if ( $table == 'forms' ) { |
|
| 1104 | + $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values ); |
|
| 1105 | + } |
|
| 1106 | 1106 | |
| 1107 | - return $values; |
|
| 1108 | - } |
|
| 1107 | + return $values; |
|
| 1108 | + } |
|
| 1109 | 1109 | |
| 1110 | 1110 | private static function fill_field_defaults( $field, $record, array &$values, $args ) { |
| 1111 | - $post_values = $args['post_values']; |
|
| 1112 | - |
|
| 1113 | - if ( $args['default'] ) { |
|
| 1114 | - $meta_value = $field->default_value; |
|
| 1115 | - } else { |
|
| 1116 | - if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) { |
|
| 1117 | - if ( ! isset($field->field_options['custom_field']) ) { |
|
| 1118 | - $field->field_options['custom_field'] = ''; |
|
| 1119 | - } |
|
| 1111 | + $post_values = $args['post_values']; |
|
| 1112 | + |
|
| 1113 | + if ( $args['default'] ) { |
|
| 1114 | + $meta_value = $field->default_value; |
|
| 1115 | + } else { |
|
| 1116 | + if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) { |
|
| 1117 | + if ( ! isset($field->field_options['custom_field']) ) { |
|
| 1118 | + $field->field_options['custom_field'] = ''; |
|
| 1119 | + } |
|
| 1120 | 1120 | $meta_value = FrmProEntryMetaHelper::get_post_value( $record->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array( 'truncate' => false, 'type' => $field->type, 'form_id' => $field->form_id, 'field' => $field ) ); |
| 1121 | - } else { |
|
| 1121 | + } else { |
|
| 1122 | 1122 | $meta_value = FrmEntryMeta::get_meta_value( $record, $field->id ); |
| 1123 | - } |
|
| 1124 | - } |
|
| 1123 | + } |
|
| 1124 | + } |
|
| 1125 | 1125 | |
| 1126 | 1126 | $field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type; |
| 1127 | - $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
| 1128 | - |
|
| 1129 | - $field_array = array( |
|
| 1130 | - 'id' => $field->id, |
|
| 1131 | - 'value' => $new_value, |
|
| 1132 | - 'default_value' => $field->default_value, |
|
| 1133 | - 'name' => $field->name, |
|
| 1134 | - 'description' => $field->description, |
|
| 1135 | - 'type' => apply_filters('frm_field_type', $field_type, $field, $new_value), |
|
| 1136 | - 'options' => $field->options, |
|
| 1137 | - 'required' => $field->required, |
|
| 1138 | - 'field_key' => $field->field_key, |
|
| 1139 | - 'field_order' => $field->field_order, |
|
| 1140 | - 'form_id' => $field->form_id, |
|
| 1127 | + $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
| 1128 | + |
|
| 1129 | + $field_array = array( |
|
| 1130 | + 'id' => $field->id, |
|
| 1131 | + 'value' => $new_value, |
|
| 1132 | + 'default_value' => $field->default_value, |
|
| 1133 | + 'name' => $field->name, |
|
| 1134 | + 'description' => $field->description, |
|
| 1135 | + 'type' => apply_filters('frm_field_type', $field_type, $field, $new_value), |
|
| 1136 | + 'options' => $field->options, |
|
| 1137 | + 'required' => $field->required, |
|
| 1138 | + 'field_key' => $field->field_key, |
|
| 1139 | + 'field_order' => $field->field_order, |
|
| 1140 | + 'form_id' => $field->form_id, |
|
| 1141 | 1141 | 'parent_form_id' => $args['parent_form_id'], |
| 1142 | - ); |
|
| 1142 | + ); |
|
| 1143 | 1143 | |
| 1144 | - $args['field_type'] = $field_type; |
|
| 1145 | - self::fill_field_opts($field, $field_array, $args); |
|
| 1144 | + $args['field_type'] = $field_type; |
|
| 1145 | + self::fill_field_opts($field, $field_array, $args); |
|
| 1146 | 1146 | // Track the original field's type |
| 1147 | 1147 | $field_array['original_type'] = isset( $field->field_options['original_type'] ) ? $field->field_options['original_type'] : $field->type; |
| 1148 | 1148 | |
| 1149 | - $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() ); |
|
| 1149 | + $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() ); |
|
| 1150 | 1150 | |
| 1151 | - if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) { |
|
| 1152 | - $field_array['unique_msg'] = ''; |
|
| 1153 | - } |
|
| 1151 | + if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) { |
|
| 1152 | + $field_array['unique_msg'] = ''; |
|
| 1153 | + } |
|
| 1154 | 1154 | |
| 1155 | - $field_array = array_merge( $field->field_options, $field_array ); |
|
| 1155 | + $field_array = array_merge( $field->field_options, $field_array ); |
|
| 1156 | 1156 | |
| 1157 | - $values['fields'][ $field->id ] = $field_array; |
|
| 1158 | - } |
|
| 1157 | + $values['fields'][ $field->id ] = $field_array; |
|
| 1158 | + } |
|
| 1159 | 1159 | |
| 1160 | 1160 | private static function fill_field_opts( $field, array &$field_array, $args ) { |
| 1161 | - $post_values = $args['post_values']; |
|
| 1162 | - $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); |
|
| 1161 | + $post_values = $args['post_values']; |
|
| 1162 | + $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); |
|
| 1163 | 1163 | |
| 1164 | - foreach ( $opt_defaults as $opt => $default_opt ) { |
|
| 1164 | + foreach ( $opt_defaults as $opt => $default_opt ) { |
|
| 1165 | 1165 | $field_array[ $opt ] = ( $post_values && isset( $post_values['field_options'][ $opt . '_' . $field->id ] ) ) ? maybe_unserialize( $post_values['field_options'][ $opt . '_' . $field->id ] ) : ( isset( $field->field_options[ $opt ] ) ? $field->field_options[ $opt ] : $default_opt ); |
| 1166 | - if ( $opt == 'blank' && $field_array[ $opt ] == '' ) { |
|
| 1167 | - $field_array[ $opt ] = $args['frm_settings']->blank_msg; |
|
| 1168 | - } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) { |
|
| 1169 | - if ( $args['field_type'] == 'captcha' ) { |
|
| 1170 | - $field_array[ $opt ] = $args['frm_settings']->re_msg; |
|
| 1171 | - } else { |
|
| 1172 | - $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] ); |
|
| 1173 | - } |
|
| 1174 | - } |
|
| 1175 | - } |
|
| 1176 | - |
|
| 1177 | - if ( $field_array['custom_html'] == '' ) { |
|
| 1178 | - $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']); |
|
| 1179 | - } |
|
| 1180 | - } |
|
| 1181 | - |
|
| 1182 | - /** |
|
| 1183 | - * @param string $table |
|
| 1184 | - */ |
|
| 1166 | + if ( $opt == 'blank' && $field_array[ $opt ] == '' ) { |
|
| 1167 | + $field_array[ $opt ] = $args['frm_settings']->blank_msg; |
|
| 1168 | + } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) { |
|
| 1169 | + if ( $args['field_type'] == 'captcha' ) { |
|
| 1170 | + $field_array[ $opt ] = $args['frm_settings']->re_msg; |
|
| 1171 | + } else { |
|
| 1172 | + $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] ); |
|
| 1173 | + } |
|
| 1174 | + } |
|
| 1175 | + } |
|
| 1176 | + |
|
| 1177 | + if ( $field_array['custom_html'] == '' ) { |
|
| 1178 | + $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']); |
|
| 1179 | + } |
|
| 1180 | + } |
|
| 1181 | + |
|
| 1182 | + /** |
|
| 1183 | + * @param string $table |
|
| 1184 | + */ |
|
| 1185 | 1185 | private static function fill_form_opts( $record, $table, $post_values, array &$values ) { |
| 1186 | - if ( $table == 'entries' ) { |
|
| 1187 | - $form = $record->form_id; |
|
| 1186 | + if ( $table == 'entries' ) { |
|
| 1187 | + $form = $record->form_id; |
|
| 1188 | 1188 | FrmForm::maybe_get_form( $form ); |
| 1189 | - } else { |
|
| 1190 | - $form = $record; |
|
| 1191 | - } |
|
| 1189 | + } else { |
|
| 1190 | + $form = $record; |
|
| 1191 | + } |
|
| 1192 | 1192 | |
| 1193 | - if ( ! $form ) { |
|
| 1194 | - return; |
|
| 1195 | - } |
|
| 1193 | + if ( ! $form ) { |
|
| 1194 | + return; |
|
| 1195 | + } |
|
| 1196 | 1196 | |
| 1197 | - $values['form_name'] = isset($record->form_id) ? $form->name : ''; |
|
| 1197 | + $values['form_name'] = isset($record->form_id) ? $form->name : ''; |
|
| 1198 | 1198 | $values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0; |
| 1199 | 1199 | |
| 1200 | - if ( ! is_array($form->options) ) { |
|
| 1201 | - return; |
|
| 1202 | - } |
|
| 1200 | + if ( ! is_array($form->options) ) { |
|
| 1201 | + return; |
|
| 1202 | + } |
|
| 1203 | 1203 | |
| 1204 | - foreach ( $form->options as $opt => $value ) { |
|
| 1205 | - $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
| 1206 | - } |
|
| 1204 | + foreach ( $form->options as $opt => $value ) { |
|
| 1205 | + $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
| 1206 | + } |
|
| 1207 | 1207 | |
| 1208 | - self::fill_form_defaults($post_values, $values); |
|
| 1209 | - } |
|
| 1208 | + self::fill_form_defaults($post_values, $values); |
|
| 1209 | + } |
|
| 1210 | 1210 | |
| 1211 | - /** |
|
| 1212 | - * Set to POST value or default |
|
| 1213 | - */ |
|
| 1211 | + /** |
|
| 1212 | + * Set to POST value or default |
|
| 1213 | + */ |
|
| 1214 | 1214 | private static function fill_form_defaults( $post_values, array &$values ) { |
| 1215 | - $form_defaults = FrmFormsHelper::get_default_opts(); |
|
| 1215 | + $form_defaults = FrmFormsHelper::get_default_opts(); |
|
| 1216 | 1216 | |
| 1217 | - foreach ( $form_defaults as $opt => $default ) { |
|
| 1218 | - if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
| 1217 | + foreach ( $form_defaults as $opt => $default ) { |
|
| 1218 | + if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
| 1219 | 1219 | $values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default; |
| 1220 | - } |
|
| 1220 | + } |
|
| 1221 | 1221 | |
| 1222 | - unset($opt, $defaut); |
|
| 1223 | - } |
|
| 1222 | + unset($opt, $defaut); |
|
| 1223 | + } |
|
| 1224 | 1224 | |
| 1225 | 1225 | if ( ! isset( $values['custom_style'] ) ) { |
| 1226 | 1226 | $values['custom_style'] = self::custom_style_value( $post_values ); |
@@ -1229,10 +1229,10 @@ discard block |
||
| 1229 | 1229 | foreach ( array( 'before', 'after', 'submit' ) as $h ) { |
| 1230 | 1230 | if ( ! isset( $values[ $h . '_html' ] ) ) { |
| 1231 | 1231 | $values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) ); |
| 1232 | - } |
|
| 1233 | - unset($h); |
|
| 1234 | - } |
|
| 1235 | - } |
|
| 1232 | + } |
|
| 1233 | + unset($h); |
|
| 1234 | + } |
|
| 1235 | + } |
|
| 1236 | 1236 | |
| 1237 | 1237 | /** |
| 1238 | 1238 | * @since 2.2.10 |
@@ -1255,59 +1255,59 @@ discard block |
||
| 1255 | 1255 | } |
| 1256 | 1256 | |
| 1257 | 1257 | public static function insert_opt_html( $args ) { |
| 1258 | - $class = ''; |
|
| 1259 | - if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) { |
|
| 1260 | - $class .= 'show_frm_not_email_to'; |
|
| 1261 | - } |
|
| 1262 | - ?> |
|
| 1258 | + $class = ''; |
|
| 1259 | + if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) { |
|
| 1260 | + $class .= 'show_frm_not_email_to'; |
|
| 1261 | + } |
|
| 1262 | + ?> |
|
| 1263 | 1263 | <li> |
| 1264 | 1264 | <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> |
| 1265 | 1265 | <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> |
| 1266 | 1266 | <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> |
| 1267 | 1267 | </li> |
| 1268 | 1268 | <?php |
| 1269 | - } |
|
| 1269 | + } |
|
| 1270 | 1270 | |
| 1271 | 1271 | public static function truncate( $str, $length, $minword = 3, $continue = '...' ) { |
| 1272 | - if ( is_array( $str ) ) { |
|
| 1273 | - return ''; |
|
| 1272 | + if ( is_array( $str ) ) { |
|
| 1273 | + return ''; |
|
| 1274 | 1274 | } |
| 1275 | 1275 | |
| 1276 | - $length = (int) $length; |
|
| 1276 | + $length = (int) $length; |
|
| 1277 | 1277 | $str = wp_strip_all_tags( $str ); |
| 1278 | 1278 | $original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) ); |
| 1279 | 1279 | |
| 1280 | 1280 | if ( $length == 0 ) { |
| 1281 | - return ''; |
|
| 1282 | - } else if ( $length <= 10 ) { |
|
| 1281 | + return ''; |
|
| 1282 | + } else if ( $length <= 10 ) { |
|
| 1283 | 1283 | $sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) ); |
| 1284 | - return $sub . (($length < $original_len) ? $continue : ''); |
|
| 1285 | - } |
|
| 1284 | + return $sub . (($length < $original_len) ? $continue : ''); |
|
| 1285 | + } |
|
| 1286 | 1286 | |
| 1287 | - $sub = ''; |
|
| 1288 | - $len = 0; |
|
| 1287 | + $sub = ''; |
|
| 1288 | + $len = 0; |
|
| 1289 | 1289 | |
| 1290 | 1290 | $words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) ); |
| 1291 | 1291 | |
| 1292 | 1292 | foreach ( $words as $word ) { |
| 1293 | - $part = (($sub != '') ? ' ' : '') . $word; |
|
| 1293 | + $part = (($sub != '') ? ' ' : '') . $word; |
|
| 1294 | 1294 | $total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) ); |
| 1295 | - if ( $total_len > $length && str_word_count($sub) ) { |
|
| 1296 | - break; |
|
| 1297 | - } |
|
| 1295 | + if ( $total_len > $length && str_word_count($sub) ) { |
|
| 1296 | + break; |
|
| 1297 | + } |
|
| 1298 | 1298 | |
| 1299 | - $sub .= $part; |
|
| 1299 | + $sub .= $part; |
|
| 1300 | 1300 | $len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) ); |
| 1301 | 1301 | |
| 1302 | - if ( str_word_count($sub) > $minword && $total_len >= $length ) { |
|
| 1303 | - break; |
|
| 1304 | - } |
|
| 1302 | + if ( str_word_count($sub) > $minword && $total_len >= $length ) { |
|
| 1303 | + break; |
|
| 1304 | + } |
|
| 1305 | 1305 | |
| 1306 | - unset($total_len, $word); |
|
| 1307 | - } |
|
| 1306 | + unset($total_len, $word); |
|
| 1307 | + } |
|
| 1308 | 1308 | |
| 1309 | - return $sub . (($len < $original_len) ? $continue : ''); |
|
| 1310 | - } |
|
| 1309 | + return $sub . (($len < $original_len) ? $continue : ''); |
|
| 1310 | + } |
|
| 1311 | 1311 | |
| 1312 | 1312 | public static function mb_function( $function_names, $args ) { |
| 1313 | 1313 | $mb_function_name = $function_names[0]; |
@@ -1319,18 +1319,18 @@ discard block |
||
| 1319 | 1319 | } |
| 1320 | 1320 | |
| 1321 | 1321 | public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) { |
| 1322 | - if ( empty($date) ) { |
|
| 1323 | - return $date; |
|
| 1324 | - } |
|
| 1322 | + if ( empty($date) ) { |
|
| 1323 | + return $date; |
|
| 1324 | + } |
|
| 1325 | 1325 | |
| 1326 | - if ( empty($date_format) ) { |
|
| 1327 | - $date_format = get_option('date_format'); |
|
| 1328 | - } |
|
| 1326 | + if ( empty($date_format) ) { |
|
| 1327 | + $date_format = get_option('date_format'); |
|
| 1328 | + } |
|
| 1329 | 1329 | |
| 1330 | - if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) { |
|
| 1331 | - $frmpro_settings = new FrmProSettings(); |
|
| 1332 | - $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d'); |
|
| 1333 | - } |
|
| 1330 | + if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) { |
|
| 1331 | + $frmpro_settings = new FrmProSettings(); |
|
| 1332 | + $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d'); |
|
| 1333 | + } |
|
| 1334 | 1334 | |
| 1335 | 1335 | $formatted = self::get_localized_date( $date_format, $date ); |
| 1336 | 1336 | |
@@ -1339,8 +1339,8 @@ discard block |
||
| 1339 | 1339 | $formatted .= self::add_time_to_date( $time_format, $date ); |
| 1340 | 1340 | } |
| 1341 | 1341 | |
| 1342 | - return $formatted; |
|
| 1343 | - } |
|
| 1342 | + return $formatted; |
|
| 1343 | + } |
|
| 1344 | 1344 | |
| 1345 | 1345 | private static function add_time_to_date( $time_format, $date ) { |
| 1346 | 1346 | if ( empty( $time_format ) ) { |
@@ -1422,61 +1422,61 @@ discard block |
||
| 1422 | 1422 | ); |
| 1423 | 1423 | } |
| 1424 | 1424 | |
| 1425 | - /** |
|
| 1426 | - * Added for < WP 4.0 compatability |
|
| 1427 | - * |
|
| 1428 | - * @since 1.07.10 |
|
| 1429 | - * |
|
| 1430 | - * @param string $term The value to escape |
|
| 1431 | - * @return string The escaped value |
|
| 1432 | - */ |
|
| 1425 | + /** |
|
| 1426 | + * Added for < WP 4.0 compatability |
|
| 1427 | + * |
|
| 1428 | + * @since 1.07.10 |
|
| 1429 | + * |
|
| 1430 | + * @param string $term The value to escape |
|
| 1431 | + * @return string The escaped value |
|
| 1432 | + */ |
|
| 1433 | 1433 | public static function esc_like( $term ) { |
| 1434 | - global $wpdb; |
|
| 1435 | - if ( method_exists($wpdb, 'esc_like') ) { |
|
| 1434 | + global $wpdb; |
|
| 1435 | + if ( method_exists($wpdb, 'esc_like') ) { |
|
| 1436 | 1436 | // WP 4.0 |
| 1437 | - $term = $wpdb->esc_like( $term ); |
|
| 1438 | - } else { |
|
| 1439 | - $term = like_escape( $term ); |
|
| 1440 | - } |
|
| 1437 | + $term = $wpdb->esc_like( $term ); |
|
| 1438 | + } else { |
|
| 1439 | + $term = like_escape( $term ); |
|
| 1440 | + } |
|
| 1441 | 1441 | |
| 1442 | - return $term; |
|
| 1443 | - } |
|
| 1442 | + return $term; |
|
| 1443 | + } |
|
| 1444 | 1444 | |
| 1445 | - /** |
|
| 1446 | - * @param string $order_query |
|
| 1447 | - */ |
|
| 1445 | + /** |
|
| 1446 | + * @param string $order_query |
|
| 1447 | + */ |
|
| 1448 | 1448 | public static function esc_order( $order_query ) { |
| 1449 | - if ( empty($order_query) ) { |
|
| 1450 | - return ''; |
|
| 1451 | - } |
|
| 1452 | - |
|
| 1453 | - // remove ORDER BY before santizing |
|
| 1454 | - $order_query = strtolower($order_query); |
|
| 1455 | - if ( strpos($order_query, 'order by') !== false ) { |
|
| 1456 | - $order_query = str_replace('order by', '', $order_query); |
|
| 1457 | - } |
|
| 1458 | - |
|
| 1459 | - $order_query = explode(' ', trim($order_query)); |
|
| 1460 | - |
|
| 1461 | - $order_fields = array( |
|
| 1462 | - 'id', 'form_key', 'name', 'description', |
|
| 1463 | - 'parent_form_id', 'logged_in', 'is_template', |
|
| 1464 | - 'default_template', 'status', 'created_at', |
|
| 1465 | - ); |
|
| 1466 | - |
|
| 1467 | - $order = trim(trim(reset($order_query), ',')); |
|
| 1468 | - if ( ! in_array($order, $order_fields) ) { |
|
| 1469 | - return ''; |
|
| 1470 | - } |
|
| 1471 | - |
|
| 1472 | - $order_by = ''; |
|
| 1473 | - if ( count($order_query) > 1 ) { |
|
| 1449 | + if ( empty($order_query) ) { |
|
| 1450 | + return ''; |
|
| 1451 | + } |
|
| 1452 | + |
|
| 1453 | + // remove ORDER BY before santizing |
|
| 1454 | + $order_query = strtolower($order_query); |
|
| 1455 | + if ( strpos($order_query, 'order by') !== false ) { |
|
| 1456 | + $order_query = str_replace('order by', '', $order_query); |
|
| 1457 | + } |
|
| 1458 | + |
|
| 1459 | + $order_query = explode(' ', trim($order_query)); |
|
| 1460 | + |
|
| 1461 | + $order_fields = array( |
|
| 1462 | + 'id', 'form_key', 'name', 'description', |
|
| 1463 | + 'parent_form_id', 'logged_in', 'is_template', |
|
| 1464 | + 'default_template', 'status', 'created_at', |
|
| 1465 | + ); |
|
| 1466 | + |
|
| 1467 | + $order = trim(trim(reset($order_query), ',')); |
|
| 1468 | + if ( ! in_array($order, $order_fields) ) { |
|
| 1469 | + return ''; |
|
| 1470 | + } |
|
| 1471 | + |
|
| 1472 | + $order_by = ''; |
|
| 1473 | + if ( count($order_query) > 1 ) { |
|
| 1474 | 1474 | $order_by = end( $order_query ); |
| 1475 | 1475 | self::esc_order_by( $order_by ); |
| 1476 | - } |
|
| 1476 | + } |
|
| 1477 | 1477 | |
| 1478 | 1478 | return ' ORDER BY ' . $order . ' ' . $order_by; |
| 1479 | - } |
|
| 1479 | + } |
|
| 1480 | 1480 | |
| 1481 | 1481 | /** |
| 1482 | 1482 | * Make sure this is ordering by either ASC or DESC |
@@ -1488,169 +1488,169 @@ discard block |
||
| 1488 | 1488 | } |
| 1489 | 1489 | } |
| 1490 | 1490 | |
| 1491 | - /** |
|
| 1492 | - * @param string $limit |
|
| 1493 | - */ |
|
| 1491 | + /** |
|
| 1492 | + * @param string $limit |
|
| 1493 | + */ |
|
| 1494 | 1494 | public static function esc_limit( $limit ) { |
| 1495 | - if ( empty($limit) ) { |
|
| 1496 | - return ''; |
|
| 1497 | - } |
|
| 1495 | + if ( empty($limit) ) { |
|
| 1496 | + return ''; |
|
| 1497 | + } |
|
| 1498 | 1498 | |
| 1499 | - $limit = trim(str_replace(' limit', '', strtolower($limit))); |
|
| 1500 | - if ( is_numeric($limit) ) { |
|
| 1499 | + $limit = trim(str_replace(' limit', '', strtolower($limit))); |
|
| 1500 | + if ( is_numeric($limit) ) { |
|
| 1501 | 1501 | return ' LIMIT ' . $limit; |
| 1502 | - } |
|
| 1502 | + } |
|
| 1503 | 1503 | |
| 1504 | - $limit = explode(',', trim($limit)); |
|
| 1505 | - foreach ( $limit as $k => $l ) { |
|
| 1506 | - if ( is_numeric( $l ) ) { |
|
| 1507 | - $limit[ $k ] = $l; |
|
| 1508 | - } |
|
| 1509 | - } |
|
| 1504 | + $limit = explode(',', trim($limit)); |
|
| 1505 | + foreach ( $limit as $k => $l ) { |
|
| 1506 | + if ( is_numeric( $l ) ) { |
|
| 1507 | + $limit[ $k ] = $l; |
|
| 1508 | + } |
|
| 1509 | + } |
|
| 1510 | 1510 | |
| 1511 | - $limit = implode(',', $limit); |
|
| 1511 | + $limit = implode(',', $limit); |
|
| 1512 | 1512 | return ' LIMIT ' . $limit; |
| 1513 | - } |
|
| 1514 | - |
|
| 1515 | - /** |
|
| 1516 | - * Get an array of values ready to go through $wpdb->prepare |
|
| 1517 | - * @since 2.0 |
|
| 1518 | - */ |
|
| 1519 | - public static function prepare_array_values( $array, $type = '%s' ) { |
|
| 1520 | - $placeholders = array_fill(0, count($array), $type); |
|
| 1521 | - return implode(', ', $placeholders); |
|
| 1522 | - } |
|
| 1523 | - |
|
| 1524 | - public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) { |
|
| 1525 | - if ( empty($where) ) { |
|
| 1526 | - return ''; |
|
| 1527 | - } |
|
| 1513 | + } |
|
| 1514 | + |
|
| 1515 | + /** |
|
| 1516 | + * Get an array of values ready to go through $wpdb->prepare |
|
| 1517 | + * @since 2.0 |
|
| 1518 | + */ |
|
| 1519 | + public static function prepare_array_values( $array, $type = '%s' ) { |
|
| 1520 | + $placeholders = array_fill(0, count($array), $type); |
|
| 1521 | + return implode(', ', $placeholders); |
|
| 1522 | + } |
|
| 1523 | + |
|
| 1524 | + public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) { |
|
| 1525 | + if ( empty($where) ) { |
|
| 1526 | + return ''; |
|
| 1527 | + } |
|
| 1528 | 1528 | |
| 1529 | 1529 | if ( is_array( $where ) ) { |
| 1530 | - global $wpdb; |
|
| 1531 | - FrmDb::get_where_clause_and_values( $where, $starts_with ); |
|
| 1530 | + global $wpdb; |
|
| 1531 | + FrmDb::get_where_clause_and_values( $where, $starts_with ); |
|
| 1532 | 1532 | $where = $wpdb->prepare( $where['where'], $where['values'] ); |
| 1533 | 1533 | } else { |
| 1534 | - $where = $starts_with . $where; |
|
| 1535 | - } |
|
| 1534 | + $where = $starts_with . $where; |
|
| 1535 | + } |
|
| 1536 | 1536 | |
| 1537 | - return $where; |
|
| 1538 | - } |
|
| 1537 | + return $where; |
|
| 1538 | + } |
|
| 1539 | 1539 | |
| 1540 | - // Pagination Methods |
|
| 1540 | + // Pagination Methods |
|
| 1541 | 1541 | |
| 1542 | - /** |
|
| 1543 | - * @param integer $current_p |
|
| 1544 | - */ |
|
| 1542 | + /** |
|
| 1543 | + * @param integer $current_p |
|
| 1544 | + */ |
|
| 1545 | 1545 | public static function get_last_record_num( $r_count, $current_p, $p_size ) { |
| 1546 | 1546 | return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) ); |
| 1547 | 1547 | } |
| 1548 | 1548 | |
| 1549 | - /** |
|
| 1550 | - * @param integer $current_p |
|
| 1551 | - */ |
|
| 1552 | - public static function get_first_record_num( $r_count, $current_p, $p_size ) { |
|
| 1553 | - if ( $current_p == 1 ) { |
|
| 1554 | - return 1; |
|
| 1555 | - } else { |
|
| 1556 | - return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 ); |
|
| 1557 | - } |
|
| 1558 | - } |
|
| 1549 | + /** |
|
| 1550 | + * @param integer $current_p |
|
| 1551 | + */ |
|
| 1552 | + public static function get_first_record_num( $r_count, $current_p, $p_size ) { |
|
| 1553 | + if ( $current_p == 1 ) { |
|
| 1554 | + return 1; |
|
| 1555 | + } else { |
|
| 1556 | + return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 ); |
|
| 1557 | + } |
|
| 1558 | + } |
|
| 1559 | 1559 | |
| 1560 | 1560 | /** |
| 1561 | 1561 | * @return array |
| 1562 | 1562 | */ |
| 1563 | 1563 | public static function json_to_array( $json_vars ) { |
| 1564 | - $vars = array(); |
|
| 1565 | - foreach ( $json_vars as $jv ) { |
|
| 1566 | - $jv_name = explode('[', $jv['name']); |
|
| 1567 | - $last = count($jv_name) - 1; |
|
| 1568 | - foreach ( $jv_name as $p => $n ) { |
|
| 1569 | - $name = trim($n, ']'); |
|
| 1570 | - if ( ! isset($l1) ) { |
|
| 1571 | - $l1 = $name; |
|
| 1572 | - } |
|
| 1573 | - |
|
| 1574 | - if ( ! isset($l2) ) { |
|
| 1575 | - $l2 = $name; |
|
| 1576 | - } |
|
| 1577 | - |
|
| 1578 | - if ( ! isset($l3) ) { |
|
| 1579 | - $l3 = $name; |
|
| 1580 | - } |
|
| 1581 | - |
|
| 1582 | - $this_val = ( $p == $last ) ? $jv['value'] : array(); |
|
| 1583 | - |
|
| 1584 | - switch ( $p ) { |
|
| 1585 | - case 0: |
|
| 1586 | - $l1 = $name; |
|
| 1587 | - self::add_value_to_array( $name, $l1, $this_val, $vars ); |
|
| 1588 | - break; |
|
| 1589 | - |
|
| 1590 | - case 1: |
|
| 1591 | - $l2 = $name; |
|
| 1592 | - self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
| 1593 | - break; |
|
| 1594 | - |
|
| 1595 | - case 2: |
|
| 1596 | - $l3 = $name; |
|
| 1597 | - self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
| 1598 | - break; |
|
| 1599 | - |
|
| 1600 | - case 3: |
|
| 1601 | - $l4 = $name; |
|
| 1602 | - self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
| 1603 | - break; |
|
| 1604 | - } |
|
| 1605 | - |
|
| 1606 | - unset($this_val, $n); |
|
| 1607 | - } |
|
| 1608 | - |
|
| 1609 | - unset($last, $jv); |
|
| 1610 | - } |
|
| 1611 | - |
|
| 1612 | - return $vars; |
|
| 1613 | - } |
|
| 1614 | - |
|
| 1615 | - /** |
|
| 1616 | - * @param string $name |
|
| 1617 | - * @param string $l1 |
|
| 1618 | - */ |
|
| 1619 | - public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
|
| 1620 | - if ( $name == '' ) { |
|
| 1621 | - $vars[] = $val; |
|
| 1622 | - } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
| 1623 | - $vars[ $l1 ] = $val; |
|
| 1624 | - } |
|
| 1625 | - } |
|
| 1564 | + $vars = array(); |
|
| 1565 | + foreach ( $json_vars as $jv ) { |
|
| 1566 | + $jv_name = explode('[', $jv['name']); |
|
| 1567 | + $last = count($jv_name) - 1; |
|
| 1568 | + foreach ( $jv_name as $p => $n ) { |
|
| 1569 | + $name = trim($n, ']'); |
|
| 1570 | + if ( ! isset($l1) ) { |
|
| 1571 | + $l1 = $name; |
|
| 1572 | + } |
|
| 1573 | + |
|
| 1574 | + if ( ! isset($l2) ) { |
|
| 1575 | + $l2 = $name; |
|
| 1576 | + } |
|
| 1577 | + |
|
| 1578 | + if ( ! isset($l3) ) { |
|
| 1579 | + $l3 = $name; |
|
| 1580 | + } |
|
| 1581 | + |
|
| 1582 | + $this_val = ( $p == $last ) ? $jv['value'] : array(); |
|
| 1583 | + |
|
| 1584 | + switch ( $p ) { |
|
| 1585 | + case 0: |
|
| 1586 | + $l1 = $name; |
|
| 1587 | + self::add_value_to_array( $name, $l1, $this_val, $vars ); |
|
| 1588 | + break; |
|
| 1589 | + |
|
| 1590 | + case 1: |
|
| 1591 | + $l2 = $name; |
|
| 1592 | + self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
| 1593 | + break; |
|
| 1594 | + |
|
| 1595 | + case 2: |
|
| 1596 | + $l3 = $name; |
|
| 1597 | + self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
| 1598 | + break; |
|
| 1599 | + |
|
| 1600 | + case 3: |
|
| 1601 | + $l4 = $name; |
|
| 1602 | + self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
| 1603 | + break; |
|
| 1604 | + } |
|
| 1605 | + |
|
| 1606 | + unset($this_val, $n); |
|
| 1607 | + } |
|
| 1608 | + |
|
| 1609 | + unset($last, $jv); |
|
| 1610 | + } |
|
| 1611 | + |
|
| 1612 | + return $vars; |
|
| 1613 | + } |
|
| 1614 | + |
|
| 1615 | + /** |
|
| 1616 | + * @param string $name |
|
| 1617 | + * @param string $l1 |
|
| 1618 | + */ |
|
| 1619 | + public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
|
| 1620 | + if ( $name == '' ) { |
|
| 1621 | + $vars[] = $val; |
|
| 1622 | + } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
| 1623 | + $vars[ $l1 ] = $val; |
|
| 1624 | + } |
|
| 1625 | + } |
|
| 1626 | 1626 | |
| 1627 | 1627 | public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) { |
| 1628 | - $tooltips = array( |
|
| 1629 | - 'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ), |
|
| 1630 | - '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' ), |
|
| 1631 | - 'cc' => __( 'Add CC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1632 | - 'bcc' => __( 'Add BCC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1633 | - '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' ), |
|
| 1634 | - 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ), |
|
| 1635 | - '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() ) ), |
|
| 1636 | - ); |
|
| 1637 | - |
|
| 1638 | - if ( ! isset( $tooltips[ $name ] ) ) { |
|
| 1639 | - return; |
|
| 1640 | - } |
|
| 1641 | - |
|
| 1642 | - if ( 'open' == $class ) { |
|
| 1643 | - echo ' frm_help"'; |
|
| 1644 | - } else { |
|
| 1645 | - echo ' class="frm_help"'; |
|
| 1646 | - } |
|
| 1628 | + $tooltips = array( |
|
| 1629 | + 'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ), |
|
| 1630 | + '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' ), |
|
| 1631 | + 'cc' => __( 'Add CC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1632 | + 'bcc' => __( 'Add BCC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1633 | + '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' ), |
|
| 1634 | + 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ), |
|
| 1635 | + '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() ) ), |
|
| 1636 | + ); |
|
| 1637 | + |
|
| 1638 | + if ( ! isset( $tooltips[ $name ] ) ) { |
|
| 1639 | + return; |
|
| 1640 | + } |
|
| 1641 | + |
|
| 1642 | + if ( 'open' == $class ) { |
|
| 1643 | + echo ' frm_help"'; |
|
| 1644 | + } else { |
|
| 1645 | + echo ' class="frm_help"'; |
|
| 1646 | + } |
|
| 1647 | 1647 | |
| 1648 | 1648 | echo ' title="' . esc_attr( $tooltips[ $name ] ); |
| 1649 | 1649 | |
| 1650 | - if ( 'open' != $class ) { |
|
| 1651 | - echo '"'; |
|
| 1652 | - } |
|
| 1653 | - } |
|
| 1650 | + if ( 'open' != $class ) { |
|
| 1651 | + echo '"'; |
|
| 1652 | + } |
|
| 1653 | + } |
|
| 1654 | 1654 | |
| 1655 | 1655 | /** |
| 1656 | 1656 | * Add the current_page class to that page in the form nav |
@@ -1666,35 +1666,35 @@ discard block |
||
| 1666 | 1666 | } |
| 1667 | 1667 | } |
| 1668 | 1668 | |
| 1669 | - /** |
|
| 1670 | - * Prepare and json_encode post content |
|
| 1671 | - * |
|
| 1672 | - * @since 2.0 |
|
| 1673 | - * |
|
| 1674 | - * @param array $post_content |
|
| 1675 | - * @return string $post_content ( json encoded array ) |
|
| 1676 | - */ |
|
| 1677 | - public static function prepare_and_encode( $post_content ) { |
|
| 1678 | - //Loop through array to strip slashes and add only the needed ones |
|
| 1669 | + /** |
|
| 1670 | + * Prepare and json_encode post content |
|
| 1671 | + * |
|
| 1672 | + * @since 2.0 |
|
| 1673 | + * |
|
| 1674 | + * @param array $post_content |
|
| 1675 | + * @return string $post_content ( json encoded array ) |
|
| 1676 | + */ |
|
| 1677 | + public static function prepare_and_encode( $post_content ) { |
|
| 1678 | + //Loop through array to strip slashes and add only the needed ones |
|
| 1679 | 1679 | foreach ( $post_content as $key => $val ) { |
| 1680 | 1680 | // Replace problematic characters (like ") |
| 1681 | 1681 | $val = str_replace( '"', '"', $val ); |
| 1682 | 1682 | |
| 1683 | 1683 | self::prepare_action_slashes( $val, $key, $post_content ); |
| 1684 | - unset( $key, $val ); |
|
| 1685 | - } |
|
| 1684 | + unset( $key, $val ); |
|
| 1685 | + } |
|
| 1686 | 1686 | |
| 1687 | - // json_encode the array |
|
| 1688 | - $post_content = json_encode( $post_content ); |
|
| 1687 | + // json_encode the array |
|
| 1688 | + $post_content = json_encode( $post_content ); |
|
| 1689 | 1689 | |
| 1690 | - // add extra slashes for \r\n since WP strips them |
|
| 1690 | + // add extra slashes for \r\n since WP strips them |
|
| 1691 | 1691 | $post_content = str_replace( array( '\\r', '\\n', '\\u', '\\t' ), array( '\\\\r', '\\\\n', '\\\\u', '\\\\t' ), $post_content ); |
| 1692 | 1692 | |
| 1693 | - // allow for " |
|
| 1694 | - $post_content = str_replace( '"', '\\"', $post_content ); |
|
| 1693 | + // allow for " |
|
| 1694 | + $post_content = str_replace( '"', '\\"', $post_content ); |
|
| 1695 | 1695 | |
| 1696 | - return $post_content; |
|
| 1697 | - } |
|
| 1696 | + return $post_content; |
|
| 1697 | + } |
|
| 1698 | 1698 | |
| 1699 | 1699 | private static function prepare_action_slashes( $val, $key, &$post_content ) { |
| 1700 | 1700 | if ( ! isset( $post_content[ $key ] ) ) { |
@@ -1762,64 +1762,64 @@ discard block |
||
| 1762 | 1762 | } |
| 1763 | 1763 | |
| 1764 | 1764 | public static function maybe_json_decode( $string ) { |
| 1765 | - if ( is_array($string) ) { |
|
| 1766 | - return $string; |
|
| 1767 | - } |
|
| 1765 | + if ( is_array($string) ) { |
|
| 1766 | + return $string; |
|
| 1767 | + } |
|
| 1768 | 1768 | |
| 1769 | - $new_string = json_decode($string, true); |
|
| 1770 | - if ( function_exists('json_last_error') ) { |
|
| 1769 | + $new_string = json_decode($string, true); |
|
| 1770 | + if ( function_exists('json_last_error') ) { |
|
| 1771 | 1771 | // php 5.3+ |
| 1772 | - if ( json_last_error() == JSON_ERROR_NONE ) { |
|
| 1773 | - $string = $new_string; |
|
| 1774 | - } |
|
| 1775 | - } else if ( isset($new_string) ) { |
|
| 1772 | + if ( json_last_error() == JSON_ERROR_NONE ) { |
|
| 1773 | + $string = $new_string; |
|
| 1774 | + } |
|
| 1775 | + } else if ( isset($new_string) ) { |
|
| 1776 | 1776 | // php < 5.3 fallback |
| 1777 | - $string = $new_string; |
|
| 1778 | - } |
|
| 1779 | - return $string; |
|
| 1780 | - } |
|
| 1781 | - |
|
| 1782 | - /** |
|
| 1783 | - * @since 1.07.10 |
|
| 1784 | - * |
|
| 1785 | - * @param string $post_type The name of the post type that may need to be highlighted |
|
| 1786 | - * echo The javascript to open and highlight the Formidable menu |
|
| 1787 | - */ |
|
| 1777 | + $string = $new_string; |
|
| 1778 | + } |
|
| 1779 | + return $string; |
|
| 1780 | + } |
|
| 1781 | + |
|
| 1782 | + /** |
|
| 1783 | + * @since 1.07.10 |
|
| 1784 | + * |
|
| 1785 | + * @param string $post_type The name of the post type that may need to be highlighted |
|
| 1786 | + * echo The javascript to open and highlight the Formidable menu |
|
| 1787 | + */ |
|
| 1788 | 1788 | public static function maybe_highlight_menu( $post_type ) { |
| 1789 | - global $post; |
|
| 1789 | + global $post; |
|
| 1790 | 1790 | |
| 1791 | - if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) { |
|
| 1792 | - return; |
|
| 1793 | - } |
|
| 1791 | + if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) { |
|
| 1792 | + return; |
|
| 1793 | + } |
|
| 1794 | 1794 | |
| 1795 | - if ( is_object($post) && $post->post_type != $post_type ) { |
|
| 1796 | - return; |
|
| 1797 | - } |
|
| 1795 | + if ( is_object($post) && $post->post_type != $post_type ) { |
|
| 1796 | + return; |
|
| 1797 | + } |
|
| 1798 | 1798 | |
| 1799 | - self::load_admin_wide_js(); |
|
| 1800 | - echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>'; |
|
| 1801 | - } |
|
| 1799 | + self::load_admin_wide_js(); |
|
| 1800 | + echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>'; |
|
| 1801 | + } |
|
| 1802 | 1802 | |
| 1803 | - /** |
|
| 1804 | - * Load the JS file on non-Formidable pages in the admin area |
|
| 1805 | - * @since 2.0 |
|
| 1806 | - */ |
|
| 1803 | + /** |
|
| 1804 | + * Load the JS file on non-Formidable pages in the admin area |
|
| 1805 | + * @since 2.0 |
|
| 1806 | + */ |
|
| 1807 | 1807 | public static function load_admin_wide_js( $load = true ) { |
| 1808 | - $version = FrmAppHelper::plugin_version(); |
|
| 1808 | + $version = FrmAppHelper::plugin_version(); |
|
| 1809 | 1809 | wp_register_script( 'formidable_admin_global', FrmAppHelper::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version ); |
| 1810 | 1810 | |
| 1811 | - wp_localize_script( 'formidable_admin_global', 'frmGlobal', array( |
|
| 1811 | + wp_localize_script( 'formidable_admin_global', 'frmGlobal', array( |
|
| 1812 | 1812 | 'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ), |
| 1813 | - 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ), |
|
| 1813 | + 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ), |
|
| 1814 | 1814 | 'url' => FrmAppHelper::plugin_url(), |
| 1815 | 1815 | 'loading' => __( 'Loading…' ), |
| 1816 | 1816 | 'nonce' => wp_create_nonce( 'frm_ajax' ), |
| 1817 | - ) ); |
|
| 1817 | + ) ); |
|
| 1818 | 1818 | |
| 1819 | 1819 | if ( $load ) { |
| 1820 | 1820 | wp_enqueue_script( 'formidable_admin_global' ); |
| 1821 | 1821 | } |
| 1822 | - } |
|
| 1822 | + } |
|
| 1823 | 1823 | |
| 1824 | 1824 | /** |
| 1825 | 1825 | * @since 2.0.9 |
@@ -1828,9 +1828,9 @@ discard block |
||
| 1828 | 1828 | wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() ); |
| 1829 | 1829 | } |
| 1830 | 1830 | |
| 1831 | - /** |
|
| 1832 | - * @param string $location |
|
| 1833 | - */ |
|
| 1831 | + /** |
|
| 1832 | + * @param string $location |
|
| 1833 | + */ |
|
| 1834 | 1834 | public static function localize_script( $location ) { |
| 1835 | 1835 | $ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' ); |
| 1836 | 1836 | $ajax_url = apply_filters( 'frm_ajax_url', $ajax_url ); |
@@ -1886,81 +1886,81 @@ discard block |
||
| 1886 | 1886 | } |
| 1887 | 1887 | } |
| 1888 | 1888 | |
| 1889 | - /** |
|
| 1889 | + /** |
|
| 1890 | 1890 | * echo the message on the plugins listing page |
| 1891 | - * @since 1.07.10 |
|
| 1892 | - * |
|
| 1893 | - * @param float $min_version The version the add-on requires |
|
| 1894 | - */ |
|
| 1891 | + * @since 1.07.10 |
|
| 1892 | + * |
|
| 1893 | + * @param float $min_version The version the add-on requires |
|
| 1894 | + */ |
|
| 1895 | 1895 | public static function min_version_notice( $min_version ) { |
| 1896 | - $frm_version = self::plugin_version(); |
|
| 1896 | + $frm_version = self::plugin_version(); |
|
| 1897 | 1897 | |
| 1898 | - // check if Formidable meets minimum requirements |
|
| 1899 | - if ( version_compare($frm_version, $min_version, '>=') ) { |
|
| 1900 | - return; |
|
| 1901 | - } |
|
| 1898 | + // check if Formidable meets minimum requirements |
|
| 1899 | + if ( version_compare($frm_version, $min_version, '>=') ) { |
|
| 1900 | + return; |
|
| 1901 | + } |
|
| 1902 | 1902 | |
| 1903 | - $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
|
| 1903 | + $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
|
| 1904 | 1904 | 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">' . |
| 1905 | - __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
|
| 1906 | - '</div></td></tr>'; |
|
| 1907 | - } |
|
| 1908 | - |
|
| 1909 | - public static function locales( $type = 'date' ) { |
|
| 1910 | - $locales = array( |
|
| 1911 | - 'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ), |
|
| 1912 | - 'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ), |
|
| 1913 | - 'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ), |
|
| 1914 | - 'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ), |
|
| 1915 | - 'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ), |
|
| 1916 | - 'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ), |
|
| 1917 | - 'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ), |
|
| 1918 | - 'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ), |
|
| 1919 | - 'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ), |
|
| 1920 | - 'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ), |
|
| 1921 | - 'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ), |
|
| 1922 | - 'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ), |
|
| 1923 | - 'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ), |
|
| 1924 | - 'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ), |
|
| 1925 | - 'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ), |
|
| 1926 | - 'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ), |
|
| 1927 | - 'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ), |
|
| 1928 | - 'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ), |
|
| 1929 | - 'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ), |
|
| 1930 | - 'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ), |
|
| 1931 | - 'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ), |
|
| 1932 | - 'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ), |
|
| 1933 | - 'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ), |
|
| 1934 | - 'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ), |
|
| 1935 | - 'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ), |
|
| 1936 | - 'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ), |
|
| 1937 | - 'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ), |
|
| 1938 | - 'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ), |
|
| 1939 | - 'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ), |
|
| 1940 | - 'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ), |
|
| 1941 | - 'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ), |
|
| 1942 | - 'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ), |
|
| 1943 | - ); |
|
| 1944 | - |
|
| 1945 | - if ( $type == 'captcha' ) { |
|
| 1946 | - // remove the languages unavailable for the captcha |
|
| 1947 | - $unset = array( |
|
| 1948 | - '', 'af', 'sq', 'hy', 'az', 'eu', 'bs', |
|
| 1949 | - 'zh-HK', 'eo', 'et', 'fo', 'fr-CH', |
|
| 1950 | - 'he', 'is', 'ms', 'sr-SR', 'ta', 'tu', |
|
| 1951 | - ); |
|
| 1952 | - } else { |
|
| 1953 | - // remove the languages unavailable for the datepicker |
|
| 1954 | - $unset = array( |
|
| 1955 | - 'en', 'fil', 'fr-CA', 'de-AT', 'de-AT', |
|
| 1956 | - 'de-CH', 'iw', 'hi', 'pt', 'pt-PT', |
|
| 1957 | - 'es-419', 'tr', |
|
| 1958 | - ); |
|
| 1959 | - } |
|
| 1960 | - |
|
| 1961 | - $locales = array_diff_key($locales, array_flip($unset)); |
|
| 1962 | - $locales = apply_filters('frm_locales', $locales); |
|
| 1963 | - |
|
| 1964 | - return $locales; |
|
| 1965 | - } |
|
| 1905 | + __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
|
| 1906 | + '</div></td></tr>'; |
|
| 1907 | + } |
|
| 1908 | + |
|
| 1909 | + public static function locales( $type = 'date' ) { |
|
| 1910 | + $locales = array( |
|
| 1911 | + 'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ), |
|
| 1912 | + 'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ), |
|
| 1913 | + 'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ), |
|
| 1914 | + 'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ), |
|
| 1915 | + 'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ), |
|
| 1916 | + 'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ), |
|
| 1917 | + 'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ), |
|
| 1918 | + 'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ), |
|
| 1919 | + 'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ), |
|
| 1920 | + 'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ), |
|
| 1921 | + 'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ), |
|
| 1922 | + 'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ), |
|
| 1923 | + 'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ), |
|
| 1924 | + 'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ), |
|
| 1925 | + 'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ), |
|
| 1926 | + 'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ), |
|
| 1927 | + 'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ), |
|
| 1928 | + 'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ), |
|
| 1929 | + 'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ), |
|
| 1930 | + 'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ), |
|
| 1931 | + 'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ), |
|
| 1932 | + 'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ), |
|
| 1933 | + 'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ), |
|
| 1934 | + 'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ), |
|
| 1935 | + 'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ), |
|
| 1936 | + 'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ), |
|
| 1937 | + 'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ), |
|
| 1938 | + 'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ), |
|
| 1939 | + 'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ), |
|
| 1940 | + 'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ), |
|
| 1941 | + 'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ), |
|
| 1942 | + 'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ), |
|
| 1943 | + ); |
|
| 1944 | + |
|
| 1945 | + if ( $type == 'captcha' ) { |
|
| 1946 | + // remove the languages unavailable for the captcha |
|
| 1947 | + $unset = array( |
|
| 1948 | + '', 'af', 'sq', 'hy', 'az', 'eu', 'bs', |
|
| 1949 | + 'zh-HK', 'eo', 'et', 'fo', 'fr-CH', |
|
| 1950 | + 'he', 'is', 'ms', 'sr-SR', 'ta', 'tu', |
|
| 1951 | + ); |
|
| 1952 | + } else { |
|
| 1953 | + // remove the languages unavailable for the datepicker |
|
| 1954 | + $unset = array( |
|
| 1955 | + 'en', 'fil', 'fr-CA', 'de-AT', 'de-AT', |
|
| 1956 | + 'de-CH', 'iw', 'hi', 'pt', 'pt-PT', |
|
| 1957 | + 'es-419', 'tr', |
|
| 1958 | + ); |
|
| 1959 | + } |
|
| 1960 | + |
|
| 1961 | + $locales = array_diff_key($locales, array_flip($unset)); |
|
| 1962 | + $locales = apply_filters('frm_locales', $locales); |
|
| 1963 | + |
|
| 1964 | + return $locales; |
|
| 1965 | + } |
|
| 1966 | 1966 | } |