| @@ -746,6 +746,9 @@ discard block | ||
| 746 | 746 | return FrmFieldsHelper::prepare_other_input( $args, $other_opt, $checked ); | 
| 747 | 747 | } | 
| 748 | 748 | |
| 749 | + /** | |
| 750 | + * @param string $function | |
| 751 | + */ | |
| 749 | 752 |  	public static function recursive_function_map( $value, $function ) { | 
| 750 | 753 |  		if ( is_array( $value ) ) { | 
| 751 | 754 | $original_function = $function; | 
| @@ -1173,6 +1176,9 @@ discard block | ||
| 1173 | 1176 | return $sub . (($len < $original_len) ? $continue : ''); | 
| 1174 | 1177 | } | 
| 1175 | 1178 | |
| 1179 | + /** | |
| 1180 | + * @param string[] $function_names | |
| 1181 | + */ | |
| 1176 | 1182 |  	public static function mb_function( $function_names, $args ) { | 
| 1177 | 1183 | $mb_function_name = $function_names[0]; | 
| 1178 | 1184 | $function_name = $function_names[1]; | 
| @@ -1206,6 +1212,9 @@ discard block | ||
| 1206 | 1212 | return $formatted; | 
| 1207 | 1213 | } | 
| 1208 | 1214 | |
| 1215 | + /** | |
| 1216 | + * @param string $time_format | |
| 1217 | + */ | |
| 1209 | 1218 |  	private static function add_time_to_date( $time_format, $date ) { | 
| 1210 | 1219 |  		if ( empty( $time_format ) ) { | 
| 1211 | 1220 |  			$time_format = get_option('time_format'); | 
| @@ -12,50 +12,50 @@ discard block | ||
| 12 | 12 | */ | 
| 13 | 13 | public static $plug_version = '2.0.23b3'; | 
| 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(); | 
| @@ -75,83 +75,83 @@ discard block | ||
| 75 | 75 | return $affiliate_id; | 
| 76 | 76 | } | 
| 77 | 77 | |
| 78 | - /** | |
| 79 | - * Get the Formidable settings | |
| 80 | - * | |
| 81 | - * @since 2.0 | |
| 82 | - * | |
| 83 | - * @param None | |
| 84 | - * @return FrmSettings $frm_setings | |
| 85 | - */ | |
| 86 | -    public static function get_settings() { | |
| 87 | - global $frm_settings; | |
| 88 | -        if ( empty($frm_settings) ) { | |
| 89 | - $frm_settings = new FrmSettings(); | |
| 90 | - } | |
| 91 | - return $frm_settings; | |
| 92 | - } | |
| 78 | + /** | |
| 79 | + * Get the Formidable settings | |
| 80 | + * | |
| 81 | + * @since 2.0 | |
| 82 | + * | |
| 83 | + * @param None | |
| 84 | + * @return FrmSettings $frm_setings | |
| 85 | + */ | |
| 86 | +	public static function get_settings() { | |
| 87 | + global $frm_settings; | |
| 88 | +		if ( empty($frm_settings) ) { | |
| 89 | + $frm_settings = new FrmSettings(); | |
| 90 | + } | |
| 91 | + return $frm_settings; | |
| 92 | + } | |
| 93 | 93 | |
| 94 | 94 |  	public static function get_menu_name() { | 
| 95 | 95 | $frm_settings = FrmAppHelper::get_settings(); | 
| 96 | 96 | return $frm_settings->menu; | 
| 97 | 97 | } | 
| 98 | 98 | |
| 99 | - /** | |
| 100 | - * Show a message in place of pro features | |
| 101 | - * | |
| 102 | - * @since 2.0 | |
| 103 | - */ | |
| 99 | + /** | |
| 100 | + * Show a message in place of pro features | |
| 101 | + * | |
| 102 | + * @since 2.0 | |
| 103 | + */ | |
| 104 | 104 |  	public static function update_message( $features, $class = '' ) { | 
| 105 | 105 | _deprecated_function( __FUNCTION__, '2.0.19' ); | 
| 106 | - } | |
| 107 | - | |
| 108 | -    public static function pro_is_installed() { | |
| 109 | -        return apply_filters('frm_pro_installed', false); | |
| 110 | - } | |
| 111 | - | |
| 112 | - /** | |
| 113 | - * Check for certain page in Formidable settings | |
| 114 | - * | |
| 115 | - * @since 2.0 | |
| 116 | - * | |
| 117 | - * @param string $page The name of the page to check | |
| 118 | - * @return boolean | |
| 119 | - */ | |
| 106 | + } | |
| 107 | + | |
| 108 | +	public static function pro_is_installed() { | |
| 109 | +		return apply_filters('frm_pro_installed', false); | |
| 110 | + } | |
| 111 | + | |
| 112 | + /** | |
| 113 | + * Check for certain page in Formidable settings | |
| 114 | + * | |
| 115 | + * @since 2.0 | |
| 116 | + * | |
| 117 | + * @param string $page The name of the page to check | |
| 118 | + * @return boolean | |
| 119 | + */ | |
| 120 | 120 |  	public static function is_admin_page( $page = 'formidable' ) { | 
| 121 | - global $pagenow; | |
| 121 | + global $pagenow; | |
| 122 | 122 | $get_page = self::simple_get( 'page', 'sanitize_title' ); | 
| 123 | -        if ( $pagenow ) { | |
| 123 | +		if ( $pagenow ) { | |
| 124 | 124 | return $pagenow == 'admin.php' && $get_page == $page; | 
| 125 | - } | |
| 125 | + } | |
| 126 | 126 | |
| 127 | 127 | return is_admin() && $get_page == $page; | 
| 128 | - } | |
| 129 | - | |
| 130 | - /** | |
| 131 | - * Check for the form preview page | |
| 132 | - * | |
| 133 | - * @since 2.0 | |
| 134 | - * | |
| 135 | - * @param None | |
| 136 | - * @return boolean | |
| 137 | - */ | |
| 138 | -    public static function is_preview_page() { | |
| 139 | - global $pagenow; | |
| 128 | + } | |
| 129 | + | |
| 130 | + /** | |
| 131 | + * Check for the form preview page | |
| 132 | + * | |
| 133 | + * @since 2.0 | |
| 134 | + * | |
| 135 | + * @param None | |
| 136 | + * @return boolean | |
| 137 | + */ | |
| 138 | +	public static function is_preview_page() { | |
| 139 | + global $pagenow; | |
| 140 | 140 | $action = FrmAppHelper::simple_get( 'action', 'sanitize_title' ); | 
| 141 | 141 | return $pagenow && $pagenow == 'admin-ajax.php' && $action == 'frm_forms_preview'; | 
| 142 | - } | |
| 142 | + } | |
| 143 | 143 | |
| 144 | - /** | |
| 145 | - * Check for ajax except the form preview page | |
| 146 | - * | |
| 147 | - * @since 2.0 | |
| 148 | - * | |
| 149 | - * @param None | |
| 150 | - * @return boolean | |
| 151 | - */ | |
| 152 | -    public static function doing_ajax() { | |
| 153 | -        return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page(); | |
| 154 | - } | |
| 144 | + /** | |
| 145 | + * Check for ajax except the form preview page | |
| 146 | + * | |
| 147 | + * @since 2.0 | |
| 148 | + * | |
| 149 | + * @param None | |
| 150 | + * @return boolean | |
| 151 | + */ | |
| 152 | +	public static function doing_ajax() { | |
| 153 | +		return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page(); | |
| 154 | + } | |
| 155 | 155 | |
| 156 | 156 | /** | 
| 157 | 157 | * @since 2.0.8 | 
| @@ -161,101 +161,101 @@ discard block | ||
| 161 | 161 | return isset( $frm_vars['prevent_caching'] ) && $frm_vars['prevent_caching']; | 
| 162 | 162 | } | 
| 163 | 163 | |
| 164 | - /** | |
| 165 | - * Check if on an admin page | |
| 166 | - * | |
| 167 | - * @since 2.0 | |
| 168 | - * | |
| 169 | - * @param None | |
| 170 | - * @return boolean | |
| 171 | - */ | |
| 172 | -    public static function is_admin() { | |
| 173 | -        return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX ); | |
| 174 | - } | |
| 175 | - | |
| 176 | - /** | |
| 177 | - * Check if value contains blank value or empty array | |
| 178 | - * | |
| 179 | - * @since 2.0 | |
| 180 | - * @param $value - value to check | |
| 181 | - * @return boolean | |
| 182 | - */ | |
| 183 | -    public static function is_empty_value( $value, $empty = '' ) { | |
| 184 | - return ( is_array( $value ) && empty( $value ) ) || $value == $empty; | |
| 185 | - } | |
| 186 | - | |
| 187 | -    public static function is_not_empty_value( $value, $empty = '' ) { | |
| 188 | - return ! self::is_empty_value( $value, $empty ); | |
| 189 | - } | |
| 190 | - | |
| 191 | - /** | |
| 192 | - * Get any value from the $_SERVER | |
| 193 | - * | |
| 194 | - * @since 2.0 | |
| 195 | - * @param string $value | |
| 196 | - * @return string | |
| 197 | - */ | |
| 164 | + /** | |
| 165 | + * Check if on an admin page | |
| 166 | + * | |
| 167 | + * @since 2.0 | |
| 168 | + * | |
| 169 | + * @param None | |
| 170 | + * @return boolean | |
| 171 | + */ | |
| 172 | +	public static function is_admin() { | |
| 173 | +		return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX ); | |
| 174 | + } | |
| 175 | + | |
| 176 | + /** | |
| 177 | + * Check if value contains blank value or empty array | |
| 178 | + * | |
| 179 | + * @since 2.0 | |
| 180 | + * @param $value - value to check | |
| 181 | + * @return boolean | |
| 182 | + */ | |
| 183 | +	public static function is_empty_value( $value, $empty = '' ) { | |
| 184 | + return ( is_array( $value ) && empty( $value ) ) || $value == $empty; | |
| 185 | + } | |
| 186 | + | |
| 187 | +	public static function is_not_empty_value( $value, $empty = '' ) { | |
| 188 | + return ! self::is_empty_value( $value, $empty ); | |
| 189 | + } | |
| 190 | + | |
| 191 | + /** | |
| 192 | + * Get any value from the $_SERVER | |
| 193 | + * | |
| 194 | + * @since 2.0 | |
| 195 | + * @param string $value | |
| 196 | + * @return string | |
| 197 | + */ | |
| 198 | 198 |  	public static function get_server_value( $value ) { | 
| 199 | - return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; | |
| 200 | - } | |
| 201 | - | |
| 202 | - /** | |
| 203 | - * Check for the IP address in several places | |
| 204 | - * Used by [ip] shortcode | |
| 205 | - * | |
| 206 | - * @return string The IP address of the current user | |
| 207 | - */ | |
| 208 | -    public static function get_ip_address() { | |
| 199 | + return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; | |
| 200 | + } | |
| 201 | + | |
| 202 | + /** | |
| 203 | + * Check for the IP address in several places | |
| 204 | + * Used by [ip] shortcode | |
| 205 | + * | |
| 206 | + * @return string The IP address of the current user | |
| 207 | + */ | |
| 208 | +	public static function get_ip_address() { | |
| 209 | 209 | $ip = ''; | 
| 210 | - foreach ( array( | |
| 211 | - 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', | |
| 212 | - 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR', | |
| 213 | -        ) as $key ) { | |
| 214 | -            if ( ! isset( $_SERVER[ $key ] ) ) { | |
| 215 | - continue; | |
| 216 | - } | |
| 217 | - | |
| 218 | -            foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { | |
| 219 | - $ip = trim($ip); // just to be safe | |
| 220 | - | |
| 221 | -                if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) { | |
| 222 | - return $ip; | |
| 223 | - } | |
| 224 | - } | |
| 225 | - } | |
| 210 | + foreach ( array( | |
| 211 | + 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', | |
| 212 | + 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR', | |
| 213 | +		) as $key ) { | |
| 214 | +			if ( ! isset( $_SERVER[ $key ] ) ) { | |
| 215 | + continue; | |
| 216 | + } | |
| 217 | + | |
| 218 | +			foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { | |
| 219 | + $ip = trim($ip); // just to be safe | |
| 220 | + | |
| 221 | +				if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) { | |
| 222 | + return $ip; | |
| 223 | + } | |
| 224 | + } | |
| 225 | + } | |
| 226 | 226 | |
| 227 | 227 | return sanitize_text_field( $ip ); | 
| 228 | - } | |
| 228 | + } | |
| 229 | 229 | |
| 230 | -    public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { | |
| 231 | -        if ( strpos($param, '[') ) { | |
| 232 | -            $params = explode('[', $param); | |
| 233 | - $param = $params[0]; | |
| 234 | - } | |
| 230 | +	public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { | |
| 231 | +		if ( strpos($param, '[') ) { | |
| 232 | +			$params = explode('[', $param); | |
| 233 | + $param = $params[0]; | |
| 234 | + } | |
| 235 | 235 | |
| 236 | 236 |  		if ( $src == 'get' ) { | 
| 237 | - $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); | |
| 238 | -            if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { | |
| 239 | - $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[ $param ] ) ) ); | |
| 240 | - } | |
| 237 | + $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); | |
| 238 | +			if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { | |
| 239 | + $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[ $param ] ) ) ); | |
| 240 | + } | |
| 241 | 241 | self::sanitize_value( $sanitize, $value ); | 
| 242 | 242 |  		} else { | 
| 243 | - $value = self::get_simple_request( array( 'type' => $src, 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) ); | |
| 244 | - } | |
| 243 | + $value = self::get_simple_request( array( 'type' => $src, 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) ); | |
| 244 | + } | |
| 245 | 245 | |
| 246 | 246 |  		if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) { | 
| 247 | -            foreach ( $params as $k => $p ) { | |
| 248 | -                if ( ! $k || ! is_array($value) ) { | |
| 249 | - continue; | |
| 250 | - } | |
| 247 | +			foreach ( $params as $k => $p ) { | |
| 248 | +				if ( ! $k || ! is_array($value) ) { | |
| 249 | + continue; | |
| 250 | + } | |
| 251 | 251 | |
| 252 | - $p = trim($p, ']'); | |
| 253 | - $value = isset( $value[ $p ] ) ? $value[ $p ] : $default; | |
| 254 | - } | |
| 255 | - } | |
| 252 | + $p = trim($p, ']'); | |
| 253 | + $value = isset( $value[ $p ] ) ? $value[ $p ] : $default; | |
| 254 | + } | |
| 255 | + } | |
| 256 | 256 | |
| 257 | - return $value; | |
| 258 | - } | |
| 257 | + return $value; | |
| 258 | + } | |
| 259 | 259 | |
| 260 | 260 | /** | 
| 261 | 261 | * | 
| @@ -276,7 +276,7 @@ discard block | ||
| 276 | 276 | */ | 
| 277 | 277 |  	public static function simple_get( $param, $sanitize = 'sanitize_text_field', $default = '' ) { | 
| 278 | 278 | return self::get_simple_request( array( 'type' => 'get', 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) ); | 
| 279 | - } | |
| 279 | + } | |
| 280 | 280 | |
| 281 | 281 | /** | 
| 282 | 282 | * Get a GET/POST/REQUEST value and sanitize it | 
| @@ -310,12 +310,12 @@ discard block | ||
| 310 | 310 | } | 
| 311 | 311 | |
| 312 | 312 | /** | 
| 313 | - * Preserve backslashes in a value, but make sure value doesn't get compounding slashes | |
| 314 | - * | |
| 315 | - * @since 2.0.8 | |
| 316 | - * @param string $value | |
| 317 | - * @return string $value | |
| 318 | - */ | |
| 313 | + * Preserve backslashes in a value, but make sure value doesn't get compounding slashes | |
| 314 | + * | |
| 315 | + * @since 2.0.8 | |
| 316 | + * @param string $value | |
| 317 | + * @return string $value | |
| 318 | + */ | |
| 319 | 319 |  	public static function preserve_backslashes( $value ) { | 
| 320 | 320 | // If backslashes have already been added, don't add them again | 
| 321 | 321 |  		if ( strpos( $value, '\\\\' ) === false ) { | 
| @@ -334,14 +334,14 @@ discard block | ||
| 334 | 334 | } | 
| 335 | 335 | } | 
| 336 | 336 | |
| 337 | -    public static function sanitize_request( $sanitize_method, &$values ) { | |
| 338 | - $temp_values = $values; | |
| 339 | -        foreach ( $temp_values as $k => $val ) { | |
| 340 | -            if ( isset( $sanitize_method[ $k ] ) ) { | |
| 337 | +	public static function sanitize_request( $sanitize_method, &$values ) { | |
| 338 | + $temp_values = $values; | |
| 339 | +		foreach ( $temp_values as $k => $val ) { | |
| 340 | +			if ( isset( $sanitize_method[ $k ] ) ) { | |
| 341 | 341 | $values[ $k ] = call_user_func( $sanitize_method[ $k ], $val ); | 
| 342 | - } | |
| 343 | - } | |
| 344 | - } | |
| 342 | + } | |
| 343 | + } | |
| 344 | + } | |
| 345 | 345 | |
| 346 | 346 |  	public static function sanitize_array( &$values ) { | 
| 347 | 347 | $temp_values = $values; | 
| @@ -356,12 +356,12 @@ discard block | ||
| 356 | 356 | */ | 
| 357 | 357 |  	public static function kses( $value, $allowed = array() ) { | 
| 358 | 358 | $html = array( | 
| 359 | - 'a' => array( | |
| 359 | + 'a' => array( | |
| 360 | 360 | 'href' => array(), | 
| 361 | 361 | 'title' => array(), | 
| 362 | 362 | 'id' => array(), | 
| 363 | 363 | 'class' => array(), | 
| 364 | - ), | |
| 364 | + ), | |
| 365 | 365 | ); | 
| 366 | 366 | |
| 367 | 367 | $allowed_html = array(); | 
| @@ -372,176 +372,176 @@ discard block | ||
| 372 | 372 | return wp_kses( $value, $allowed_html ); | 
| 373 | 373 | } | 
| 374 | 374 | |
| 375 | - /** | |
| 376 | - * Used when switching the action for a bulk action | |
| 377 | - * @since 2.0 | |
| 378 | - */ | |
| 379 | -    public static function remove_get_action() { | |
| 380 | -        if ( ! isset($_GET) ) { | |
| 381 | - return; | |
| 382 | - } | |
| 375 | + /** | |
| 376 | + * Used when switching the action for a bulk action | |
| 377 | + * @since 2.0 | |
| 378 | + */ | |
| 379 | +	public static function remove_get_action() { | |
| 380 | +		if ( ! isset($_GET) ) { | |
| 381 | + return; | |
| 382 | + } | |
| 383 | 383 | |
| 384 | - $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' ); | |
| 385 | -        if ( ! empty( $new_action ) ) { | |
| 384 | + $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' ); | |
| 385 | +		if ( ! empty( $new_action ) ) { | |
| 386 | 386 | $_SERVER['REQUEST_URI'] = str_replace( '&action=' . $new_action, '', FrmAppHelper::get_server_value( 'REQUEST_URI' ) ); | 
| 387 | - } | |
| 388 | - } | |
| 389 | - | |
| 390 | - /** | |
| 391 | - * Check the WP query for a parameter | |
| 392 | - * | |
| 393 | - * @since 2.0 | |
| 394 | - * @return string|array | |
| 395 | - */ | |
| 396 | -    public static function get_query_var( $value, $param ) { | |
| 397 | -        if ( $value != '' ) { | |
| 398 | - return $value; | |
| 399 | - } | |
| 400 | - | |
| 401 | - global $wp_query; | |
| 402 | -        if ( isset( $wp_query->query_vars[ $param ] ) ) { | |
| 403 | - $value = $wp_query->query_vars[ $param ]; | |
| 404 | - } | |
| 405 | - | |
| 406 | - return $value; | |
| 407 | - } | |
| 408 | - | |
| 409 | - /** | |
| 410 | - * @param string $type | |
| 411 | - */ | |
| 412 | -    public static function trigger_hook_load( $type, $object = null ) { | |
| 413 | - // only load the form hooks once | |
| 387 | + } | |
| 388 | + } | |
| 389 | + | |
| 390 | + /** | |
| 391 | + * Check the WP query for a parameter | |
| 392 | + * | |
| 393 | + * @since 2.0 | |
| 394 | + * @return string|array | |
| 395 | + */ | |
| 396 | +	public static function get_query_var( $value, $param ) { | |
| 397 | +		if ( $value != '' ) { | |
| 398 | + return $value; | |
| 399 | + } | |
| 400 | + | |
| 401 | + global $wp_query; | |
| 402 | +		if ( isset( $wp_query->query_vars[ $param ] ) ) { | |
| 403 | + $value = $wp_query->query_vars[ $param ]; | |
| 404 | + } | |
| 405 | + | |
| 406 | + return $value; | |
| 407 | + } | |
| 408 | + | |
| 409 | + /** | |
| 410 | + * @param string $type | |
| 411 | + */ | |
| 412 | +	public static function trigger_hook_load( $type, $object = null ) { | |
| 413 | + // only load the form hooks once | |
| 414 | 414 | $hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object ); | 
| 415 | -        if ( ! $hooks_loaded ) { | |
| 415 | +		if ( ! $hooks_loaded ) { | |
| 416 | 416 | do_action( 'frm_load_' . $type . '_hooks' ); | 
| 417 | - } | |
| 418 | - } | |
| 419 | - | |
| 420 | - /** | |
| 421 | - * Check cache before fetching values and saving to cache | |
| 422 | - * | |
| 423 | - * @since 2.0 | |
| 424 | - * | |
| 425 | - * @param string $cache_key The unique name for this cache | |
| 426 | - * @param string $group The name of the cache group | |
| 427 | - * @param string $query If blank, don't run a db call | |
| 428 | - * @param string $type The wpdb function to use with this query | |
| 429 | - * @return mixed $results The cache or query results | |
| 430 | - */ | |
| 431 | -    public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) { | |
| 432 | - $results = wp_cache_get($cache_key, $group); | |
| 433 | -        if ( ! self::is_empty_value( $results, false ) || empty($query) ) { | |
| 434 | - return $results; | |
| 435 | - } | |
| 436 | - | |
| 437 | -        if ( 'get_posts' == $type ) { | |
| 438 | - $results = get_posts($query); | |
| 439 | -        } else { | |
| 440 | - global $wpdb; | |
| 441 | -            $results = $wpdb->{$type}($query); | |
| 442 | - } | |
| 417 | + } | |
| 418 | + } | |
| 419 | + | |
| 420 | + /** | |
| 421 | + * Check cache before fetching values and saving to cache | |
| 422 | + * | |
| 423 | + * @since 2.0 | |
| 424 | + * | |
| 425 | + * @param string $cache_key The unique name for this cache | |
| 426 | + * @param string $group The name of the cache group | |
| 427 | + * @param string $query If blank, don't run a db call | |
| 428 | + * @param string $type The wpdb function to use with this query | |
| 429 | + * @return mixed $results The cache or query results | |
| 430 | + */ | |
| 431 | +	public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) { | |
| 432 | + $results = wp_cache_get($cache_key, $group); | |
| 433 | +		if ( ! self::is_empty_value( $results, false ) || empty($query) ) { | |
| 434 | + return $results; | |
| 435 | + } | |
| 436 | + | |
| 437 | +		if ( 'get_posts' == $type ) { | |
| 438 | + $results = get_posts($query); | |
| 439 | +		} else { | |
| 440 | + global $wpdb; | |
| 441 | +			$results = $wpdb->{$type}($query); | |
| 442 | + } | |
| 443 | 443 | |
| 444 | 444 |  		if ( ! self::prevent_caching() ) { | 
| 445 | 445 | wp_cache_set( $cache_key, $results, $group, $time ); | 
| 446 | 446 | } | 
| 447 | 447 | |
| 448 | - return $results; | |
| 449 | - } | |
| 448 | + return $results; | |
| 449 | + } | |
| 450 | 450 | |
| 451 | - /** | |
| 452 | - * Data that should be stored for a long time can be stored in a transient. | |
| 453 | - * First check the cache, then check the transient | |
| 454 | - * @since 2.0 | |
| 455 | - * @return mixed The cached value or false | |
| 456 | - */ | |
| 451 | + /** | |
| 452 | + * Data that should be stored for a long time can be stored in a transient. | |
| 453 | + * First check the cache, then check the transient | |
| 454 | + * @since 2.0 | |
| 455 | + * @return mixed The cached value or false | |
| 456 | + */ | |
| 457 | 457 |  	public static function check_cache_and_transient( $cache_key ) { | 
| 458 | - // check caching layer first | |
| 459 | - $results = self::check_cache( $cache_key ); | |
| 460 | -        if ( $results ) { | |
| 461 | - return $results; | |
| 462 | - } | |
| 463 | - | |
| 464 | - // then check the transient | |
| 465 | - $results = get_transient($cache_key); | |
| 466 | -        if ( $results ) { | |
| 467 | - wp_cache_set($cache_key, $results); | |
| 468 | - } | |
| 469 | - | |
| 470 | - return $results; | |
| 471 | - } | |
| 472 | - | |
| 473 | - /** | |
| 474 | - * @since 2.0 | |
| 475 | - * @param string $cache_key | |
| 476 | - */ | |
| 458 | + // check caching layer first | |
| 459 | + $results = self::check_cache( $cache_key ); | |
| 460 | +		if ( $results ) { | |
| 461 | + return $results; | |
| 462 | + } | |
| 463 | + | |
| 464 | + // then check the transient | |
| 465 | + $results = get_transient($cache_key); | |
| 466 | +		if ( $results ) { | |
| 467 | + wp_cache_set($cache_key, $results); | |
| 468 | + } | |
| 469 | + | |
| 470 | + return $results; | |
| 471 | + } | |
| 472 | + | |
| 473 | + /** | |
| 474 | + * @since 2.0 | |
| 475 | + * @param string $cache_key | |
| 476 | + */ | |
| 477 | 477 |  	public static function delete_cache_and_transient( $cache_key ) { | 
| 478 | - delete_transient($cache_key); | |
| 479 | - wp_cache_delete($cache_key); | |
| 480 | - } | |
| 481 | - | |
| 482 | - /** | |
| 483 | - * Delete all caching in a single group | |
| 484 | - * | |
| 485 | - * @since 2.0 | |
| 486 | - * | |
| 487 | - * @param string $group The name of the cache group | |
| 488 | - * @return boolean True or False | |
| 489 | - */ | |
| 478 | + delete_transient($cache_key); | |
| 479 | + wp_cache_delete($cache_key); | |
| 480 | + } | |
| 481 | + | |
| 482 | + /** | |
| 483 | + * Delete all caching in a single group | |
| 484 | + * | |
| 485 | + * @since 2.0 | |
| 486 | + * | |
| 487 | + * @param string $group The name of the cache group | |
| 488 | + * @return boolean True or False | |
| 489 | + */ | |
| 490 | 490 |  	public static function cache_delete_group( $group ) { | 
| 491 | - global $wp_object_cache; | |
| 492 | - | |
| 493 | -        if ( isset( $wp_object_cache->cache[ $group ] ) ) { | |
| 494 | -            foreach ( $wp_object_cache->cache[ $group ] as $k => $v ) { | |
| 495 | - wp_cache_delete($k, $group); | |
| 496 | - } | |
| 497 | - return true; | |
| 498 | - } | |
| 499 | - | |
| 500 | - return false; | |
| 501 | - } | |
| 502 | - | |
| 503 | - /** | |
| 504 | - * Check a value from a shortcode to see if true or false. | |
| 505 | - * True when value is 1, true, 'true', 'yes' | |
| 506 | - * | |
| 507 | - * @since 1.07.10 | |
| 508 | - * | |
| 509 | - * @param string $value The value to compare | |
| 510 | - * @return boolean True or False | |
| 511 | - */ | |
| 491 | + global $wp_object_cache; | |
| 492 | + | |
| 493 | +		if ( isset( $wp_object_cache->cache[ $group ] ) ) { | |
| 494 | +			foreach ( $wp_object_cache->cache[ $group ] as $k => $v ) { | |
| 495 | + wp_cache_delete($k, $group); | |
| 496 | + } | |
| 497 | + return true; | |
| 498 | + } | |
| 499 | + | |
| 500 | + return false; | |
| 501 | + } | |
| 502 | + | |
| 503 | + /** | |
| 504 | + * Check a value from a shortcode to see if true or false. | |
| 505 | + * True when value is 1, true, 'true', 'yes' | |
| 506 | + * | |
| 507 | + * @since 1.07.10 | |
| 508 | + * | |
| 509 | + * @param string $value The value to compare | |
| 510 | + * @return boolean True or False | |
| 511 | + */ | |
| 512 | 512 |  	public static function is_true( $value ) { | 
| 513 | - return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value ); | |
| 514 | - } | |
| 513 | + return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value ); | |
| 514 | + } | |
| 515 | 515 | |
| 516 | - /** | |
| 517 | - * Used to filter shortcode in text widgets | |
| 518 | - */ | |
| 519 | -    public static function widget_text_filter_callback( $matches ) { | |
| 520 | - return do_shortcode( $matches[0] ); | |
| 521 | - } | |
| 516 | + /** | |
| 517 | + * Used to filter shortcode in text widgets | |
| 518 | + */ | |
| 519 | +	public static function widget_text_filter_callback( $matches ) { | |
| 520 | + return do_shortcode( $matches[0] ); | |
| 521 | + } | |
| 522 | 522 | |
| 523 | 523 |  	public static function load_scripts( $scripts ) { | 
| 524 | - _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_script' ); | |
| 525 | -        foreach ( (array) $scripts as $s ) { | |
| 526 | - wp_enqueue_script($s); | |
| 527 | - } | |
| 528 | - } | |
| 524 | + _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_script' ); | |
| 525 | +		foreach ( (array) $scripts as $s ) { | |
| 526 | + wp_enqueue_script($s); | |
| 527 | + } | |
| 528 | + } | |
| 529 | 529 | |
| 530 | 530 |  	public static function load_styles( $styles ) { | 
| 531 | - _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_style' ); | |
| 532 | -        foreach ( (array) $styles as $s ) { | |
| 533 | - wp_enqueue_style($s); | |
| 534 | - } | |
| 535 | - } | |
| 531 | + _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_style' ); | |
| 532 | +		foreach ( (array) $styles as $s ) { | |
| 533 | + wp_enqueue_style($s); | |
| 534 | + } | |
| 535 | + } | |
| 536 | 536 | |
| 537 | -    public static function get_pages() { | |
| 537 | +	public static function get_pages() { | |
| 538 | 538 | return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' ) ); | 
| 539 | - } | |
| 539 | + } | |
| 540 | 540 | |
| 541 | -    public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { | |
| 542 | - $pages = self::get_pages(); | |
| 541 | +	public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { | |
| 542 | + $pages = self::get_pages(); | |
| 543 | 543 | $selected = self::get_post_param( $field_name, $page_id, 'absint' ); | 
| 544 | - ?> | |
| 544 | + ?> | |
| 545 | 545 | <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown"> | 
| 546 | 546 | <option value=""> </option> | 
| 547 | 547 |              <?php foreach ( $pages as $page ) { ?> | 
| @@ -551,108 +551,108 @@ discard block | ||
| 551 | 551 | <?php } ?> | 
| 552 | 552 | </select> | 
| 553 | 553 | <?php | 
| 554 | - } | |
| 554 | + } | |
| 555 | 555 | |
| 556 | 556 |  	public static function post_edit_link( $post_id ) { | 
| 557 | - $post = get_post($post_id); | |
| 558 | -        if ( $post ) { | |
| 557 | + $post = get_post($post_id); | |
| 558 | +		if ( $post ) { | |
| 559 | 559 | $post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' ); | 
| 560 | 560 | return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>'; | 
| 561 | - } | |
| 562 | - return ''; | |
| 563 | - } | |
| 561 | + } | |
| 562 | + return ''; | |
| 563 | + } | |
| 564 | 564 | |
| 565 | 565 |  	public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) { | 
| 566 | - ?> | |
| 566 | + ?> | |
| 567 | 567 | <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" <?php | 
| 568 | - echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : ''; | |
| 569 | - ?> class="frm_multiselect"> | |
| 568 | + echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : ''; | |
| 569 | + ?> class="frm_multiselect"> | |
| 570 | 570 | <?php self::roles_options($capability); ?> | 
| 571 | 571 | </select> | 
| 572 | 572 | <?php | 
| 573 | - } | |
| 573 | + } | |
| 574 | 574 | |
| 575 | 575 |  	public static function roles_options( $capability ) { | 
| 576 | - global $frm_vars; | |
| 577 | -        if ( isset($frm_vars['editable_roles']) ) { | |
| 578 | - $editable_roles = $frm_vars['editable_roles']; | |
| 579 | -        } else { | |
| 580 | - $editable_roles = get_editable_roles(); | |
| 581 | - $frm_vars['editable_roles'] = $editable_roles; | |
| 582 | - } | |
| 583 | - | |
| 584 | -        foreach ( $editable_roles as $role => $details ) { | |
| 585 | - $name = translate_user_role($details['name'] ); ?> | |
| 576 | + global $frm_vars; | |
| 577 | +		if ( isset($frm_vars['editable_roles']) ) { | |
| 578 | + $editable_roles = $frm_vars['editable_roles']; | |
| 579 | +		} else { | |
| 580 | + $editable_roles = get_editable_roles(); | |
| 581 | + $frm_vars['editable_roles'] = $editable_roles; | |
| 582 | + } | |
| 583 | + | |
| 584 | +		foreach ( $editable_roles as $role => $details ) { | |
| 585 | + $name = translate_user_role($details['name'] ); ?> | |
| 586 | 586 | <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option> | 
| 587 | 587 | <?php | 
| 588 | - unset($role, $details); | |
| 589 | - } | |
| 590 | - } | |
| 588 | + unset($role, $details); | |
| 589 | + } | |
| 590 | + } | |
| 591 | 591 | |
| 592 | 592 |  	public static function frm_capabilities( $type = 'auto' ) { | 
| 593 | - $cap = array( | |
| 594 | - 'frm_view_forms' => __( 'View Forms and Templates', 'formidable' ), | |
| 595 | - 'frm_edit_forms' => __( 'Add/Edit Forms and Templates', 'formidable' ), | |
| 596 | - 'frm_delete_forms' => __( 'Delete Forms and Templates', 'formidable' ), | |
| 597 | - 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ), | |
| 598 | - 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ), | |
| 599 | - 'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ), | |
| 600 | - ); | |
| 593 | + $cap = array( | |
| 594 | + 'frm_view_forms' => __( 'View Forms and Templates', 'formidable' ), | |
| 595 | + 'frm_edit_forms' => __( 'Add/Edit Forms and Templates', 'formidable' ), | |
| 596 | + 'frm_delete_forms' => __( 'Delete Forms and Templates', 'formidable' ), | |
| 597 | + 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ), | |
| 598 | + 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ), | |
| 599 | + 'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ), | |
| 600 | + ); | |
| 601 | 601 | |
| 602 | 602 |  		if ( ! self::pro_is_installed() && 'pro' != $type ) { | 
| 603 | - return $cap; | |
| 604 | - } | |
| 603 | + return $cap; | |
| 604 | + } | |
| 605 | 605 | |
| 606 | - $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' ); | |
| 607 | - $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' ); | |
| 608 | - $cap['frm_view_reports'] = __( 'View Reports', 'formidable' ); | |
| 609 | - $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' ); | |
| 606 | + $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' ); | |
| 607 | + $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' ); | |
| 608 | + $cap['frm_view_reports'] = __( 'View Reports', 'formidable' ); | |
| 609 | + $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' ); | |
| 610 | 610 | |
| 611 | - return $cap; | |
| 612 | - } | |
| 611 | + return $cap; | |
| 612 | + } | |
| 613 | 613 | |
| 614 | 614 |  	public static function user_has_permission( $needed_role ) { | 
| 615 | -        if ( $needed_role == '-1' ) { | |
| 616 | - return false; | |
| 615 | +		if ( $needed_role == '-1' ) { | |
| 616 | + return false; | |
| 617 | 617 | } | 
| 618 | 618 | |
| 619 | - // $needed_role will be equal to blank if "Logged-in users" is selected | |
| 620 | -        if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) { | |
| 621 | - return true; | |
| 622 | - } | |
| 619 | + // $needed_role will be equal to blank if "Logged-in users" is selected | |
| 620 | +		if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) { | |
| 621 | + return true; | |
| 622 | + } | |
| 623 | 623 | |
| 624 | - $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ); | |
| 625 | -        foreach ( $roles as $role ) { | |
| 624 | + $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ); | |
| 625 | +		foreach ( $roles as $role ) { | |
| 626 | 626 |  			if ( current_user_can( $role ) ) { | 
| 627 | - return true; | |
| 627 | + return true; | |
| 628 | 628 | } | 
| 629 | -        	if ( $role == $needed_role ) { | |
| 630 | - break; | |
| 629 | +			if ( $role == $needed_role ) { | |
| 630 | + break; | |
| 631 | 631 | } | 
| 632 | - } | |
| 633 | - return false; | |
| 634 | - } | |
| 635 | - | |
| 636 | - /** | |
| 637 | - * Make sure administrators can see Formidable menu | |
| 638 | - * | |
| 639 | - * @since 2.0 | |
| 640 | - */ | |
| 641 | -    public static function maybe_add_permissions() { | |
| 632 | + } | |
| 633 | + return false; | |
| 634 | + } | |
| 635 | + | |
| 636 | + /** | |
| 637 | + * Make sure administrators can see Formidable menu | |
| 638 | + * | |
| 639 | + * @since 2.0 | |
| 640 | + */ | |
| 641 | +	public static function maybe_add_permissions() { | |
| 642 | 642 | self::force_capability( 'frm_view_entries' ); | 
| 643 | 643 | |
| 644 | -        if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) { | |
| 645 | - return; | |
| 646 | - } | |
| 644 | +		if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) { | |
| 645 | + return; | |
| 646 | + } | |
| 647 | 647 | |
| 648 | 648 | $user_id = get_current_user_id(); | 
| 649 | 649 | $user = new WP_User( $user_id ); | 
| 650 | - $frm_roles = self::frm_capabilities(); | |
| 651 | -        foreach ( $frm_roles as $frm_role => $frm_role_description ) { | |
| 650 | + $frm_roles = self::frm_capabilities(); | |
| 651 | +		foreach ( $frm_roles as $frm_role => $frm_role_description ) { | |
| 652 | 652 | $user->add_cap( $frm_role ); | 
| 653 | - unset($frm_role, $frm_role_description); | |
| 654 | - } | |
| 655 | - } | |
| 653 | + unset($frm_role, $frm_role_description); | |
| 654 | + } | |
| 655 | + } | |
| 656 | 656 | |
| 657 | 657 | /** | 
| 658 | 658 | * Make sure admins have permission to see the menu items | 
| @@ -668,28 +668,28 @@ discard block | ||
| 668 | 668 | } | 
| 669 | 669 | } | 
| 670 | 670 | |
| 671 | - /** | |
| 672 | - * Check if the user has permision for action. | |
| 673 | - * Return permission message and stop the action if no permission | |
| 674 | - * @since 2.0 | |
| 675 | - * @param string $permission | |
| 676 | - */ | |
| 671 | + /** | |
| 672 | + * Check if the user has permision for action. | |
| 673 | + * Return permission message and stop the action if no permission | |
| 674 | + * @since 2.0 | |
| 675 | + * @param string $permission | |
| 676 | + */ | |
| 677 | 677 |  	public static function permission_check( $permission, $show_message = 'show' ) { | 
| 678 | - $permission_error = self::permission_nonce_error($permission); | |
| 679 | -        if ( $permission_error !== false ) { | |
| 680 | -            if ( 'hide' == $show_message ) { | |
| 681 | - $permission_error = ''; | |
| 682 | - } | |
| 683 | - wp_die($permission_error); | |
| 684 | - } | |
| 685 | - } | |
| 686 | - | |
| 687 | - /** | |
| 688 | - * Check user permission and nonce | |
| 689 | - * @since 2.0 | |
| 690 | - * @param string $permission | |
| 691 | - * @return false|string The permission message or false if allowed | |
| 692 | - */ | |
| 678 | + $permission_error = self::permission_nonce_error($permission); | |
| 679 | +		if ( $permission_error !== false ) { | |
| 680 | +			if ( 'hide' == $show_message ) { | |
| 681 | + $permission_error = ''; | |
| 682 | + } | |
| 683 | + wp_die($permission_error); | |
| 684 | + } | |
| 685 | + } | |
| 686 | + | |
| 687 | + /** | |
| 688 | + * Check user permission and nonce | |
| 689 | + * @since 2.0 | |
| 690 | + * @param string $permission | |
| 691 | + * @return false|string The permission message or false if allowed | |
| 692 | + */ | |
| 693 | 693 |  	public static function permission_nonce_error( $permission, $nonce_name = '', $nonce = '' ) { | 
| 694 | 694 |  		if ( ! empty( $permission ) && ! current_user_can( $permission ) && ! current_user_can( 'administrator' ) ) { | 
| 695 | 695 | $frm_settings = self::get_settings(); | 
| @@ -697,23 +697,23 @@ discard block | ||
| 697 | 697 | } | 
| 698 | 698 | |
| 699 | 699 | $error = false; | 
| 700 | -        if ( empty($nonce_name) ) { | |
| 701 | - return $error; | |
| 702 | - } | |
| 700 | +		if ( empty($nonce_name) ) { | |
| 701 | + return $error; | |
| 702 | + } | |
| 703 | 703 | |
| 704 | -        if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { | |
| 705 | - $frm_settings = self::get_settings(); | |
| 706 | - $error = $frm_settings->admin_permission; | |
| 707 | - } | |
| 704 | +		if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { | |
| 705 | + $frm_settings = self::get_settings(); | |
| 706 | + $error = $frm_settings->admin_permission; | |
| 707 | + } | |
| 708 | 708 | |
| 709 | - return $error; | |
| 710 | - } | |
| 709 | + return $error; | |
| 710 | + } | |
| 711 | 711 | |
| 712 | -    public static function checked( $values, $current ) { | |
| 712 | +	public static function checked( $values, $current ) { | |
| 713 | 713 |  		if ( self::check_selected( $values, $current ) ) { | 
| 714 | - echo ' checked="checked"'; | |
| 714 | + echo ' checked="checked"'; | |
| 715 | 715 | } | 
| 716 | - } | |
| 716 | + } | |
| 717 | 717 | |
| 718 | 718 |  	public static function check_selected( $values, $current ) { | 
| 719 | 719 | $values = self::recursive_function_map( $values, 'trim' ); | 
| @@ -723,50 +723,50 @@ discard block | ||
| 723 | 723 | return ( is_array( $values ) && in_array( $current, $values ) ) || ( ! is_array( $values ) && $values == $current ); | 
| 724 | 724 | } | 
| 725 | 725 | |
| 726 | - /** | |
| 727 | - * Check if current field option is an "other" option | |
| 728 | - * | |
| 729 | - * @since 2.0 | |
| 730 | - * | |
| 731 | - * @param string $opt_key | |
| 732 | - * @return boolean Returns true if current field option is an "Other" option | |
| 733 | - */ | |
| 734 | -    public static function is_other_opt( $opt_key ) { | |
| 735 | - _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::is_other_opt' ); | |
| 736 | - return FrmFieldsHelper::is_other_opt( $opt_key ); | |
| 737 | - } | |
| 738 | - | |
| 739 | - /** | |
| 740 | - * Get value that belongs in "Other" text box | |
| 741 | - * | |
| 742 | - * @since 2.0 | |
| 743 | - * | |
| 744 | - * @param string $opt_key | |
| 745 | - * @param array $field | |
| 746 | - * @return string $other_val | |
| 747 | - */ | |
| 748 | -    public static function get_other_val( $opt_key, $field, $parent = false, $pointer = false ) { | |
| 726 | + /** | |
| 727 | + * Check if current field option is an "other" option | |
| 728 | + * | |
| 729 | + * @since 2.0 | |
| 730 | + * | |
| 731 | + * @param string $opt_key | |
| 732 | + * @return boolean Returns true if current field option is an "Other" option | |
| 733 | + */ | |
| 734 | +	public static function is_other_opt( $opt_key ) { | |
| 735 | + _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::is_other_opt' ); | |
| 736 | + return FrmFieldsHelper::is_other_opt( $opt_key ); | |
| 737 | + } | |
| 738 | + | |
| 739 | + /** | |
| 740 | + * Get value that belongs in "Other" text box | |
| 741 | + * | |
| 742 | + * @since 2.0 | |
| 743 | + * | |
| 744 | + * @param string $opt_key | |
| 745 | + * @param array $field | |
| 746 | + * @return string $other_val | |
| 747 | + */ | |
| 748 | +	public static function get_other_val( $opt_key, $field, $parent = false, $pointer = false ) { | |
| 749 | 749 | _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::get_other_val' ); | 
| 750 | 750 | return FrmFieldsHelper::get_other_val( compact( 'opt_key', 'field', 'parent', 'pointer' ) ); | 
| 751 | - } | |
| 752 | - | |
| 753 | - /** | |
| 754 | - * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val. | |
| 755 | - * Intended for front-end use | |
| 756 | - * | |
| 757 | - * @since 2.0 | |
| 758 | - * | |
| 759 | - * @param array $field | |
| 760 | - * @param boolean $other_opt | |
| 761 | - * @param string $checked | |
| 762 | - * @param array $args should include opt_key and field name | |
| 763 | - * @return string $other_val | |
| 764 | - */ | |
| 765 | -    public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) { | |
| 751 | + } | |
| 752 | + | |
| 753 | + /** | |
| 754 | + * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val. | |
| 755 | + * Intended for front-end use | |
| 756 | + * | |
| 757 | + * @since 2.0 | |
| 758 | + * | |
| 759 | + * @param array $field | |
| 760 | + * @param boolean $other_opt | |
| 761 | + * @param string $checked | |
| 762 | + * @param array $args should include opt_key and field name | |
| 763 | + * @return string $other_val | |
| 764 | + */ | |
| 765 | +	public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) { | |
| 766 | 766 | _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::prepare_other_input' ); | 
| 767 | 767 | $args['field'] = $field; | 
| 768 | 768 | return FrmFieldsHelper::prepare_other_input( $args, $other_opt, $checked ); | 
| 769 | - } | |
| 769 | + } | |
| 770 | 770 | |
| 771 | 771 |  	public static function recursive_function_map( $value, $function ) { | 
| 772 | 772 |  		if ( is_array( $value ) ) { | 
| @@ -796,331 +796,331 @@ discard block | ||
| 796 | 796 | return (bool) count( array_filter( array_keys( $array ), 'is_string' ) ); | 
| 797 | 797 | } | 
| 798 | 798 | |
| 799 | - /** | |
| 800 | - * Flatten a multi-dimensional array | |
| 801 | - */ | |
| 799 | + /** | |
| 800 | + * Flatten a multi-dimensional array | |
| 801 | + */ | |
| 802 | 802 |  	public static function array_flatten( $array, $keys = 'keep' ) { | 
| 803 | - $return = array(); | |
| 804 | -        foreach ( $array as $key => $value ) { | |
| 805 | -            if ( is_array($value) ) { | |
| 803 | + $return = array(); | |
| 804 | +		foreach ( $array as $key => $value ) { | |
| 805 | +			if ( is_array($value) ) { | |
| 806 | 806 | $return = array_merge( $return, self::array_flatten( $value, $keys ) ); | 
| 807 | -            } else { | |
| 807 | +			} else { | |
| 808 | 808 |  				if ( $keys == 'keep' ) { | 
| 809 | 809 | $return[ $key ] = $value; | 
| 810 | 810 |  				} else { | 
| 811 | 811 | $return[] = $value; | 
| 812 | 812 | } | 
| 813 | - } | |
| 814 | - } | |
| 815 | - return $return; | |
| 816 | - } | |
| 817 | - | |
| 818 | -    public static function esc_textarea( $text ) { | |
| 819 | -        $safe_text = str_replace('"', '"', $text); | |
| 820 | - $safe_text = htmlspecialchars( $safe_text, ENT_NOQUOTES ); | |
| 821 | - return apply_filters( 'esc_textarea', $safe_text, $text ); | |
| 822 | - } | |
| 823 | - | |
| 824 | - /** | |
| 825 | - * Add auto paragraphs to text areas | |
| 826 | - * @since 2.0 | |
| 827 | - */ | |
| 813 | + } | |
| 814 | + } | |
| 815 | + return $return; | |
| 816 | + } | |
| 817 | + | |
| 818 | +	public static function esc_textarea( $text ) { | |
| 819 | +		$safe_text = str_replace('"', '"', $text); | |
| 820 | + $safe_text = htmlspecialchars( $safe_text, ENT_NOQUOTES ); | |
| 821 | + return apply_filters( 'esc_textarea', $safe_text, $text ); | |
| 822 | + } | |
| 823 | + | |
| 824 | + /** | |
| 825 | + * Add auto paragraphs to text areas | |
| 826 | + * @since 2.0 | |
| 827 | + */ | |
| 828 | 828 |  	public static function use_wpautop( $content ) { | 
| 829 | -        if ( apply_filters('frm_use_wpautop', true) ) { | |
| 830 | - $content = wpautop(str_replace( '<br>', '<br />', $content)); | |
| 831 | - } | |
| 832 | - return $content; | |
| 833 | - } | |
| 829 | +		if ( apply_filters('frm_use_wpautop', true) ) { | |
| 830 | + $content = wpautop(str_replace( '<br>', '<br />', $content)); | |
| 831 | + } | |
| 832 | + return $content; | |
| 833 | + } | |
| 834 | 834 | |
| 835 | 835 |  	public static function replace_quotes( $val ) { | 
| 836 | - //Replace double quotes | |
| 836 | + //Replace double quotes | |
| 837 | 837 | $val = str_replace( array( '“', '”', '″' ), '"', $val ); | 
| 838 | - //Replace single quotes | |
| 839 | - $val = str_replace( array( '‘', '’', '′', '′', '’', '‘' ), "'", $val ); | |
| 840 | - return $val; | |
| 841 | - } | |
| 842 | - | |
| 843 | - /** | |
| 844 | - * @since 2.0 | |
| 845 | - * @return string The base Google APIS url for the current version of jQuery UI | |
| 846 | - */ | |
| 847 | -    public static function jquery_ui_base_url() { | |
| 838 | + //Replace single quotes | |
| 839 | + $val = str_replace( array( '‘', '’', '′', '′', '’', '‘' ), "'", $val ); | |
| 840 | + return $val; | |
| 841 | + } | |
| 842 | + | |
| 843 | + /** | |
| 844 | + * @since 2.0 | |
| 845 | + * @return string The base Google APIS url for the current version of jQuery UI | |
| 846 | + */ | |
| 847 | +	public static function jquery_ui_base_url() { | |
| 848 | 848 |  		$url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version('jquery-ui-core'); | 
| 849 | -        $url = apply_filters('frm_jquery_ui_base_url', $url); | |
| 850 | - return $url; | |
| 851 | - } | |
| 849 | +		$url = apply_filters('frm_jquery_ui_base_url', $url); | |
| 850 | + return $url; | |
| 851 | + } | |
| 852 | 852 | |
| 853 | - /** | |
| 854 | - * @param string $handle | |
| 855 | - */ | |
| 853 | + /** | |
| 854 | + * @param string $handle | |
| 855 | + */ | |
| 856 | 856 |  	public static function script_version( $handle ) { | 
| 857 | - global $wp_scripts; | |
| 858 | -    	if ( ! $wp_scripts ) { | |
| 859 | - return false; | |
| 860 | - } | |
| 857 | + global $wp_scripts; | |
| 858 | +		if ( ! $wp_scripts ) { | |
| 859 | + return false; | |
| 860 | + } | |
| 861 | 861 | |
| 862 | - $ver = 0; | |
| 862 | + $ver = 0; | |
| 863 | 863 | |
| 864 | -        if ( ! isset( $wp_scripts->registered[ $handle ] ) ) { | |
| 865 | - return $ver; | |
| 866 | - } | |
| 864 | +		if ( ! isset( $wp_scripts->registered[ $handle ] ) ) { | |
| 865 | + return $ver; | |
| 866 | + } | |
| 867 | 867 | |
| 868 | - $query = $wp_scripts->registered[ $handle ]; | |
| 869 | -    	if ( is_object( $query ) ) { | |
| 870 | - $ver = $query->ver; | |
| 871 | - } | |
| 868 | + $query = $wp_scripts->registered[ $handle ]; | |
| 869 | +		if ( is_object( $query ) ) { | |
| 870 | + $ver = $query->ver; | |
| 871 | + } | |
| 872 | 872 | |
| 873 | - return $ver; | |
| 874 | - } | |
| 873 | + return $ver; | |
| 874 | + } | |
| 875 | 875 | |
| 876 | 876 |  	public static function js_redirect( $url ) { | 
| 877 | 877 | return '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>'; | 
| 878 | - } | |
| 878 | + } | |
| 879 | 879 | |
| 880 | 880 |  	public static function get_user_id_param( $user_id ) { | 
| 881 | -        if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) { | |
| 882 | - return $user_id; | |
| 883 | - } | |
| 881 | +		if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) { | |
| 882 | + return $user_id; | |
| 883 | + } | |
| 884 | 884 | |
| 885 | 885 |  		if ( $user_id == 'current' ) { | 
| 886 | 886 | $user_id = get_current_user_id(); | 
| 887 | 887 |  		} else { | 
| 888 | -            if ( is_email($user_id) ) { | |
| 889 | -                $user = get_user_by('email', $user_id); | |
| 890 | -            } else { | |
| 891 | -                $user = get_user_by('login', $user_id); | |
| 892 | - } | |
| 888 | +			if ( is_email($user_id) ) { | |
| 889 | +				$user = get_user_by('email', $user_id); | |
| 890 | +			} else { | |
| 891 | +				$user = get_user_by('login', $user_id); | |
| 892 | + } | |
| 893 | 893 | |
| 894 | -            if ( $user ) { | |
| 895 | - $user_id = $user->ID; | |
| 896 | - } | |
| 897 | - unset($user); | |
| 898 | - } | |
| 894 | +			if ( $user ) { | |
| 895 | + $user_id = $user->ID; | |
| 896 | + } | |
| 897 | + unset($user); | |
| 898 | + } | |
| 899 | 899 | |
| 900 | - return $user_id; | |
| 901 | - } | |
| 900 | + return $user_id; | |
| 901 | + } | |
| 902 | 902 | |
| 903 | 903 |  	public static function get_file_contents( $filename, $atts = array() ) { | 
| 904 | -        if ( ! is_file($filename) ) { | |
| 905 | - return false; | |
| 906 | - } | |
| 907 | - | |
| 908 | - extract($atts); | |
| 909 | - ob_start(); | |
| 910 | - include($filename); | |
| 911 | - $contents = ob_get_contents(); | |
| 912 | - ob_end_clean(); | |
| 913 | - return $contents; | |
| 914 | - } | |
| 915 | - | |
| 916 | - /** | |
| 917 | - * @param string $table_name | |
| 918 | - * @param string $column | |
| 904 | +		if ( ! is_file($filename) ) { | |
| 905 | + return false; | |
| 906 | + } | |
| 907 | + | |
| 908 | + extract($atts); | |
| 909 | + ob_start(); | |
| 910 | + include($filename); | |
| 911 | + $contents = ob_get_contents(); | |
| 912 | + ob_end_clean(); | |
| 913 | + return $contents; | |
| 914 | + } | |
| 915 | + | |
| 916 | + /** | |
| 917 | + * @param string $table_name | |
| 918 | + * @param string $column | |
| 919 | 919 | * @param int $id | 
| 920 | 920 | * @param int $num_chars | 
| 921 | - */ | |
| 922 | -    public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) { | |
| 923 | - $key = ''; | |
| 921 | + */ | |
| 922 | +	public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) { | |
| 923 | + $key = ''; | |
| 924 | 924 | |
| 925 | -        if ( ! empty( $name ) ) { | |
| 926 | - $key = sanitize_key($name); | |
| 927 | - } | |
| 925 | +		if ( ! empty( $name ) ) { | |
| 926 | + $key = sanitize_key($name); | |
| 927 | + } | |
| 928 | 928 | |
| 929 | 929 |  		if ( empty( $key ) ) { | 
| 930 | - $max_slug_value = pow(36, $num_chars); | |
| 931 | - $min_slug_value = 37; // we want to have at least 2 characters in the slug | |
| 932 | - $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); | |
| 933 | - } | |
| 930 | + $max_slug_value = pow(36, $num_chars); | |
| 931 | + $min_slug_value = 37; // we want to have at least 2 characters in the slug | |
| 932 | + $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); | |
| 933 | + } | |
| 934 | 934 | |
| 935 | 935 |  		if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) { | 
| 936 | 936 | $key = $key . 'a'; | 
| 937 | - } | |
| 937 | + } | |
| 938 | 938 | |
| 939 | 939 | $key_check = FrmDb::get_var( $table_name, array( $column => $key, 'ID !' => $id ), $column ); | 
| 940 | 940 | |
| 941 | -        if ( $key_check || is_numeric($key_check) ) { | |
| 942 | - $suffix = 2; | |
| 941 | +		if ( $key_check || is_numeric($key_check) ) { | |
| 942 | + $suffix = 2; | |
| 943 | 943 |  			do { | 
| 944 | 944 | $alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix; | 
| 945 | 945 | $key_check = FrmDb::get_var( $table_name, array( $column => $alt_post_name, 'ID !' => $id ), $column ); | 
| 946 | 946 | $suffix++; | 
| 947 | 947 | } while ($key_check || is_numeric($key_check)); | 
| 948 | 948 | $key = $alt_post_name; | 
| 949 | - } | |
| 950 | - return $key; | |
| 951 | - } | |
| 952 | - | |
| 953 | - /** | |
| 954 | - * Editing a Form or Entry | |
| 955 | - * @param string $table | |
| 956 | - * @return bool|array | |
| 957 | - */ | |
| 958 | -    public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) { | |
| 959 | -        if ( ! $record ) { | |
| 960 | - return false; | |
| 961 | - } | |
| 962 | - | |
| 963 | -        if ( empty($post_values) ) { | |
| 964 | - $post_values = stripslashes_deep($_POST); | |
| 965 | - } | |
| 949 | + } | |
| 950 | + return $key; | |
| 951 | + } | |
| 952 | + | |
| 953 | + /** | |
| 954 | + * Editing a Form or Entry | |
| 955 | + * @param string $table | |
| 956 | + * @return bool|array | |
| 957 | + */ | |
| 958 | +	public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) { | |
| 959 | +		if ( ! $record ) { | |
| 960 | + return false; | |
| 961 | + } | |
| 962 | + | |
| 963 | +		if ( empty($post_values) ) { | |
| 964 | + $post_values = stripslashes_deep($_POST); | |
| 965 | + } | |
| 966 | 966 | |
| 967 | 967 | $values = array( 'id' => $record->id, 'fields' => array() ); | 
| 968 | 968 | |
| 969 | 969 |  		foreach ( array( 'name', 'description' ) as $var ) { | 
| 970 | -            $default_val = isset($record->{$var}) ? $record->{$var} : ''; | |
| 971 | - $values[ $var ] = self::get_param( $var, $default_val ); | |
| 972 | - unset($var, $default_val); | |
| 973 | - } | |
| 974 | - | |
| 975 | - $values['description'] = self::use_wpautop($values['description']); | |
| 976 | - $frm_settings = self::get_settings(); | |
| 977 | -        $is_form_builder = self::is_admin_page('formidable' ); | |
| 978 | - | |
| 979 | -        foreach ( (array) $fields as $field ) { | |
| 980 | - // Make sure to filter default values (for placeholder text), but not on the form builder page | |
| 981 | -            if ( ! $is_form_builder ) { | |
| 982 | -                $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true ); | |
| 983 | - } | |
| 970 | +			$default_val = isset($record->{$var}) ? $record->{$var} : ''; | |
| 971 | + $values[ $var ] = self::get_param( $var, $default_val ); | |
| 972 | + unset($var, $default_val); | |
| 973 | + } | |
| 974 | + | |
| 975 | + $values['description'] = self::use_wpautop($values['description']); | |
| 976 | + $frm_settings = self::get_settings(); | |
| 977 | +		$is_form_builder = self::is_admin_page('formidable' ); | |
| 978 | + | |
| 979 | +		foreach ( (array) $fields as $field ) { | |
| 980 | + // Make sure to filter default values (for placeholder text), but not on the form builder page | |
| 981 | +			if ( ! $is_form_builder ) { | |
| 982 | +				$field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true ); | |
| 983 | + } | |
| 984 | 984 | $parent_form_id = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id; | 
| 985 | 985 |  			self::fill_field_defaults($field, $record, $values, compact('default', 'post_values', 'frm_settings', 'parent_form_id' ) ); | 
| 986 | - } | |
| 986 | + } | |
| 987 | 987 | |
| 988 | - self::fill_form_opts($record, $table, $post_values, $values); | |
| 988 | + self::fill_form_opts($record, $table, $post_values, $values); | |
| 989 | 989 | |
| 990 | -        if ( $table == 'entries' ) { | |
| 991 | - $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); | |
| 992 | -        } else if ( $table == 'forms' ) { | |
| 993 | - $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values ); | |
| 994 | - } | |
| 990 | +		if ( $table == 'entries' ) { | |
| 991 | + $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); | |
| 992 | +		} else if ( $table == 'forms' ) { | |
| 993 | + $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values ); | |
| 994 | + } | |
| 995 | 995 | |
| 996 | - return $values; | |
| 997 | - } | |
| 996 | + return $values; | |
| 997 | + } | |
| 998 | 998 | |
| 999 | 999 |  	private static function fill_field_defaults( $field, $record, array &$values, $args ) { | 
| 1000 | - $post_values = $args['post_values']; | |
| 1001 | - | |
| 1002 | -        if ( $args['default'] ) { | |
| 1003 | - $meta_value = $field->default_value; | |
| 1004 | -        } else { | |
| 1005 | -            if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) { | |
| 1006 | -                if ( ! isset($field->field_options['custom_field']) ) { | |
| 1007 | - $field->field_options['custom_field'] = ''; | |
| 1008 | - } | |
| 1000 | + $post_values = $args['post_values']; | |
| 1001 | + | |
| 1002 | +		if ( $args['default'] ) { | |
| 1003 | + $meta_value = $field->default_value; | |
| 1004 | +		} else { | |
| 1005 | +			if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) { | |
| 1006 | +				if ( ! isset($field->field_options['custom_field']) ) { | |
| 1007 | + $field->field_options['custom_field'] = ''; | |
| 1008 | + } | |
| 1009 | 1009 | $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 ) ); | 
| 1010 | -            } else { | |
| 1010 | +			} else { | |
| 1011 | 1011 | $meta_value = FrmEntryMeta::get_meta_value( $record, $field->id ); | 
| 1012 | - } | |
| 1013 | - } | |
| 1012 | + } | |
| 1013 | + } | |
| 1014 | 1014 | |
| 1015 | 1015 | $field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type; | 
| 1016 | - $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; | |
| 1017 | - | |
| 1018 | - $field_array = array( | |
| 1019 | - 'id' => $field->id, | |
| 1020 | - 'value' => $new_value, | |
| 1021 | - 'default_value' => $field->default_value, | |
| 1022 | - 'name' => $field->name, | |
| 1023 | - 'description' => $field->description, | |
| 1024 | -            'type'          => apply_filters('frm_field_type', $field_type, $field, $new_value), | |
| 1025 | - 'options' => $field->options, | |
| 1026 | - 'required' => $field->required, | |
| 1027 | - 'field_key' => $field->field_key, | |
| 1028 | - 'field_order' => $field->field_order, | |
| 1029 | - 'form_id' => $field->form_id, | |
| 1016 | + $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; | |
| 1017 | + | |
| 1018 | + $field_array = array( | |
| 1019 | + 'id' => $field->id, | |
| 1020 | + 'value' => $new_value, | |
| 1021 | + 'default_value' => $field->default_value, | |
| 1022 | + 'name' => $field->name, | |
| 1023 | + 'description' => $field->description, | |
| 1024 | +			'type'          => apply_filters('frm_field_type', $field_type, $field, $new_value), | |
| 1025 | + 'options' => $field->options, | |
| 1026 | + 'required' => $field->required, | |
| 1027 | + 'field_key' => $field->field_key, | |
| 1028 | + 'field_order' => $field->field_order, | |
| 1029 | + 'form_id' => $field->form_id, | |
| 1030 | 1030 | 'parent_form_id' => $args['parent_form_id'], | 
| 1031 | - ); | |
| 1031 | + ); | |
| 1032 | 1032 | |
| 1033 | - $args['field_type'] = $field_type; | |
| 1034 | - self::fill_field_opts($field, $field_array, $args); | |
| 1033 | + $args['field_type'] = $field_type; | |
| 1034 | + self::fill_field_opts($field, $field_array, $args); | |
| 1035 | 1035 | |
| 1036 | -        $field_array = apply_filters('frm_setup_edit_fields_vars', $field_array, $field, $values['id']); | |
| 1036 | +		$field_array = apply_filters('frm_setup_edit_fields_vars', $field_array, $field, $values['id']); | |
| 1037 | 1037 | |
| 1038 | -        if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) { | |
| 1039 | - $field_array['unique_msg'] = ''; | |
| 1040 | - } | |
| 1038 | +		if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) { | |
| 1039 | + $field_array['unique_msg'] = ''; | |
| 1040 | + } | |
| 1041 | 1041 | |
| 1042 | - $field_array = array_merge( $field->field_options, $field_array ); | |
| 1042 | + $field_array = array_merge( $field->field_options, $field_array ); | |
| 1043 | 1043 | |
| 1044 | - $values['fields'][ $field->id ] = $field_array; | |
| 1045 | - } | |
| 1044 | + $values['fields'][ $field->id ] = $field_array; | |
| 1045 | + } | |
| 1046 | 1046 | |
| 1047 | 1047 |  	private static function fill_field_opts( $field, array &$field_array, $args ) { | 
| 1048 | - $post_values = $args['post_values']; | |
| 1049 | - $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); | |
| 1048 | + $post_values = $args['post_values']; | |
| 1049 | + $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); | |
| 1050 | 1050 | |
| 1051 | -        foreach ( $opt_defaults as $opt => $default_opt ) { | |
| 1051 | +		foreach ( $opt_defaults as $opt => $default_opt ) { | |
| 1052 | 1052 | $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 ); | 
| 1053 | -            if ( $opt == 'blank' && $field_array[ $opt ] == '' ) { | |
| 1054 | - $field_array[ $opt ] = $args['frm_settings']->blank_msg; | |
| 1055 | -            } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) { | |
| 1056 | -                if ( $args['field_type'] == 'captcha' ) { | |
| 1057 | - $field_array[ $opt ] = $args['frm_settings']->re_msg; | |
| 1058 | -                } else { | |
| 1059 | - $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] ); | |
| 1060 | - } | |
| 1061 | - } | |
| 1062 | - } | |
| 1063 | - | |
| 1064 | -        if ( $field_array['custom_html'] == '' ) { | |
| 1065 | - $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']); | |
| 1066 | - } | |
| 1067 | - } | |
| 1068 | - | |
| 1069 | - /** | |
| 1070 | - * @param string $table | |
| 1071 | - */ | |
| 1053 | +			if ( $opt == 'blank' && $field_array[ $opt ] == '' ) { | |
| 1054 | + $field_array[ $opt ] = $args['frm_settings']->blank_msg; | |
| 1055 | +			} else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) { | |
| 1056 | +				if ( $args['field_type'] == 'captcha' ) { | |
| 1057 | + $field_array[ $opt ] = $args['frm_settings']->re_msg; | |
| 1058 | +				} else { | |
| 1059 | + $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] ); | |
| 1060 | + } | |
| 1061 | + } | |
| 1062 | + } | |
| 1063 | + | |
| 1064 | +		if ( $field_array['custom_html'] == '' ) { | |
| 1065 | + $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']); | |
| 1066 | + } | |
| 1067 | + } | |
| 1068 | + | |
| 1069 | + /** | |
| 1070 | + * @param string $table | |
| 1071 | + */ | |
| 1072 | 1072 |  	private static function fill_form_opts( $record, $table, $post_values, array &$values ) { | 
| 1073 | -        if ( $table == 'entries' ) { | |
| 1074 | - $form = $record->form_id; | |
| 1073 | +		if ( $table == 'entries' ) { | |
| 1074 | + $form = $record->form_id; | |
| 1075 | 1075 | FrmForm::maybe_get_form( $form ); | 
| 1076 | -        } else { | |
| 1077 | - $form = $record; | |
| 1078 | - } | |
| 1076 | +		} else { | |
| 1077 | + $form = $record; | |
| 1078 | + } | |
| 1079 | 1079 | |
| 1080 | -        if ( ! $form ) { | |
| 1081 | - return; | |
| 1082 | - } | |
| 1080 | +		if ( ! $form ) { | |
| 1081 | + return; | |
| 1082 | + } | |
| 1083 | 1083 | |
| 1084 | - $values['form_name'] = isset($record->form_id) ? $form->name : ''; | |
| 1084 | + $values['form_name'] = isset($record->form_id) ? $form->name : ''; | |
| 1085 | 1085 | $values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0; | 
| 1086 | 1086 | |
| 1087 | -        if ( ! is_array($form->options) ) { | |
| 1088 | - return; | |
| 1089 | - } | |
| 1087 | +		if ( ! is_array($form->options) ) { | |
| 1088 | + return; | |
| 1089 | + } | |
| 1090 | 1090 | |
| 1091 | -        foreach ( $form->options as $opt => $value ) { | |
| 1092 | - $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; | |
| 1093 | - } | |
| 1091 | +		foreach ( $form->options as $opt => $value ) { | |
| 1092 | + $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; | |
| 1093 | + } | |
| 1094 | 1094 | |
| 1095 | - self::fill_form_defaults($post_values, $values); | |
| 1096 | - } | |
| 1095 | + self::fill_form_defaults($post_values, $values); | |
| 1096 | + } | |
| 1097 | 1097 | |
| 1098 | - /** | |
| 1099 | - * Set to POST value or default | |
| 1100 | - */ | |
| 1098 | + /** | |
| 1099 | + * Set to POST value or default | |
| 1100 | + */ | |
| 1101 | 1101 |  	private static function fill_form_defaults( $post_values, array &$values ) { | 
| 1102 | - $form_defaults = FrmFormsHelper::get_default_opts(); | |
| 1102 | + $form_defaults = FrmFormsHelper::get_default_opts(); | |
| 1103 | 1103 | |
| 1104 | -        foreach ( $form_defaults as $opt => $default ) { | |
| 1105 | -            if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { | |
| 1104 | +		foreach ( $form_defaults as $opt => $default ) { | |
| 1105 | +			if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { | |
| 1106 | 1106 | $values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default; | 
| 1107 | - } | |
| 1107 | + } | |
| 1108 | 1108 | |
| 1109 | - unset($opt, $defaut); | |
| 1110 | - } | |
| 1109 | + unset($opt, $defaut); | |
| 1110 | + } | |
| 1111 | 1111 | |
| 1112 | -        if ( ! isset($values['custom_style']) ) { | |
| 1113 | - $frm_settings = self::get_settings(); | |
| 1112 | +		if ( ! isset($values['custom_style']) ) { | |
| 1113 | + $frm_settings = self::get_settings(); | |
| 1114 | 1114 | $values['custom_style'] = ( $post_values && isset( $post_values['options']['custom_style'] ) ) ? absint( $_POST['options']['custom_style'] ) : ( $frm_settings->load_style != 'none' ); | 
| 1115 | - } | |
| 1115 | + } | |
| 1116 | 1116 | |
| 1117 | 1117 |  		foreach ( array( 'before', 'after', 'submit' ) as $h ) { | 
| 1118 | 1118 |  			if ( ! isset( $values[ $h . '_html' ] ) ) { | 
| 1119 | 1119 | $values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) ); | 
| 1120 | - } | |
| 1121 | - unset($h); | |
| 1122 | - } | |
| 1123 | - } | |
| 1120 | + } | |
| 1121 | + unset($h); | |
| 1122 | + } | |
| 1123 | + } | |
| 1124 | 1124 | |
| 1125 | 1125 |  	public static function get_meta_value( $field_id, $entry ) { | 
| 1126 | 1126 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryMeta::get_meta_value' ); | 
| @@ -1128,69 +1128,69 @@ discard block | ||
| 1128 | 1128 | } | 
| 1129 | 1129 | |
| 1130 | 1130 |  	public static function insert_opt_html( $args ) { | 
| 1131 | - $class = ''; | |
| 1132 | -        if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) { | |
| 1133 | - $class .= 'show_frm_not_email_to'; | |
| 1134 | - } | |
| 1135 | - ?> | |
| 1131 | + $class = ''; | |
| 1132 | +		if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) { | |
| 1133 | + $class .= 'show_frm_not_email_to'; | |
| 1134 | + } | |
| 1135 | + ?> | |
| 1136 | 1136 | <li> | 
| 1137 | 1137 | <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> | 
| 1138 | 1138 | <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> | 
| 1139 | 1139 | <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> | 
| 1140 | 1140 | </li> | 
| 1141 | 1141 | <?php | 
| 1142 | - } | |
| 1142 | + } | |
| 1143 | 1143 | |
| 1144 | -    public static function get_us_states() { | |
| 1145 | - _deprecated_function( __FUNCTION__, '2.0', 'FrmFieldsHelper::get_us_states' ); | |
| 1146 | - return FrmFieldsHelper::get_us_states(); | |
| 1147 | - } | |
| 1144 | +	public static function get_us_states() { | |
| 1145 | + _deprecated_function( __FUNCTION__, '2.0', 'FrmFieldsHelper::get_us_states' ); | |
| 1146 | + return FrmFieldsHelper::get_us_states(); | |
| 1147 | + } | |
| 1148 | 1148 | |
| 1149 | -    public static function get_countries() { | |
| 1150 | - _deprecated_function( __FUNCTION__, '2.0', 'FrmFieldsHelper::get_countries' ); | |
| 1151 | - return FrmFieldsHelper::get_countries(); | |
| 1152 | - } | |
| 1149 | +	public static function get_countries() { | |
| 1150 | + _deprecated_function( __FUNCTION__, '2.0', 'FrmFieldsHelper::get_countries' ); | |
| 1151 | + return FrmFieldsHelper::get_countries(); | |
| 1152 | + } | |
| 1153 | 1153 | |
| 1154 | 1154 |  	public static function truncate( $str, $length, $minword = 3, $continue = '...' ) { | 
| 1155 | -        if ( is_array( $str ) ) { | |
| 1156 | - return; | |
| 1155 | +		if ( is_array( $str ) ) { | |
| 1156 | + return; | |
| 1157 | 1157 | } | 
| 1158 | 1158 | |
| 1159 | - $length = (int) $length; | |
| 1159 | + $length = (int) $length; | |
| 1160 | 1160 | $str = wp_strip_all_tags( $str ); | 
| 1161 | 1161 | $original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) ); | 
| 1162 | 1162 | |
| 1163 | 1163 |  		if ( $length == 0 ) { | 
| 1164 | - return ''; | |
| 1165 | -        } else if ( $length <= 10 ) { | |
| 1164 | + return ''; | |
| 1165 | +		} else if ( $length <= 10 ) { | |
| 1166 | 1166 | $sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) ); | 
| 1167 | - return $sub . (($length < $original_len) ? $continue : ''); | |
| 1168 | - } | |
| 1167 | + return $sub . (($length < $original_len) ? $continue : ''); | |
| 1168 | + } | |
| 1169 | 1169 | |
| 1170 | - $sub = ''; | |
| 1171 | - $len = 0; | |
| 1170 | + $sub = ''; | |
| 1171 | + $len = 0; | |
| 1172 | 1172 | |
| 1173 | 1173 | $words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) ); | 
| 1174 | 1174 | |
| 1175 | 1175 |  		foreach ( $words as $word ) { | 
| 1176 | - $part = (($sub != '') ? ' ' : '') . $word; | |
| 1176 | + $part = (($sub != '') ? ' ' : '') . $word; | |
| 1177 | 1177 | $total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) ); | 
| 1178 | -            if ( $total_len > $length && str_word_count($sub) ) { | |
| 1179 | - break; | |
| 1180 | - } | |
| 1178 | +			if ( $total_len > $length && str_word_count($sub) ) { | |
| 1179 | + break; | |
| 1180 | + } | |
| 1181 | 1181 | |
| 1182 | - $sub .= $part; | |
| 1182 | + $sub .= $part; | |
| 1183 | 1183 | $len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) ); | 
| 1184 | 1184 | |
| 1185 | -            if ( str_word_count($sub) > $minword && $total_len >= $length ) { | |
| 1186 | - break; | |
| 1187 | - } | |
| 1185 | +			if ( str_word_count($sub) > $minword && $total_len >= $length ) { | |
| 1186 | + break; | |
| 1187 | + } | |
| 1188 | 1188 | |
| 1189 | - unset($total_len, $word); | |
| 1190 | - } | |
| 1189 | + unset($total_len, $word); | |
| 1190 | + } | |
| 1191 | 1191 | |
| 1192 | - return $sub . (($len < $original_len) ? $continue : ''); | |
| 1193 | - } | |
| 1192 | + return $sub . (($len < $original_len) ? $continue : ''); | |
| 1193 | + } | |
| 1194 | 1194 | |
| 1195 | 1195 |  	public static function mb_function( $function_names, $args ) { | 
| 1196 | 1196 | $mb_function_name = $function_names[0]; | 
| @@ -1202,18 +1202,18 @@ discard block | ||
| 1202 | 1202 | } | 
| 1203 | 1203 | |
| 1204 | 1204 |  	public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) { | 
| 1205 | -        if ( empty($date) ) { | |
| 1206 | - return $date; | |
| 1207 | - } | |
| 1205 | +		if ( empty($date) ) { | |
| 1206 | + return $date; | |
| 1207 | + } | |
| 1208 | 1208 | |
| 1209 | -        if ( empty($date_format) ) { | |
| 1210 | -            $date_format = get_option('date_format'); | |
| 1211 | - } | |
| 1209 | +		if ( empty($date_format) ) { | |
| 1210 | +			$date_format = get_option('date_format'); | |
| 1211 | + } | |
| 1212 | 1212 | |
| 1213 | -        if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) { | |
| 1214 | - $frmpro_settings = new FrmProSettings(); | |
| 1215 | - $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d'); | |
| 1216 | - } | |
| 1213 | +		if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) { | |
| 1214 | + $frmpro_settings = new FrmProSettings(); | |
| 1215 | + $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d'); | |
| 1216 | + } | |
| 1217 | 1217 | |
| 1218 | 1218 | $formatted = self::get_localized_date( $date_format, $date ); | 
| 1219 | 1219 | |
| @@ -1222,8 +1222,8 @@ discard block | ||
| 1222 | 1222 | $formatted .= self::add_time_to_date( $time_format, $date ); | 
| 1223 | 1223 | } | 
| 1224 | 1224 | |
| 1225 | - return $formatted; | |
| 1226 | - } | |
| 1225 | + return $formatted; | |
| 1226 | + } | |
| 1227 | 1227 | |
| 1228 | 1228 |  	private static function add_time_to_date( $time_format, $date ) { | 
| 1229 | 1229 |  		if ( empty( $time_format ) ) { | 
| @@ -1304,61 +1304,61 @@ discard block | ||
| 1304 | 1304 | ); | 
| 1305 | 1305 | } | 
| 1306 | 1306 | |
| 1307 | - /** | |
| 1308 | - * Added for < WP 4.0 compatability | |
| 1309 | - * | |
| 1310 | - * @since 1.07.10 | |
| 1311 | - * | |
| 1312 | - * @param string $term The value to escape | |
| 1313 | - * @return string The escaped value | |
| 1314 | - */ | |
| 1307 | + /** | |
| 1308 | + * Added for < WP 4.0 compatability | |
| 1309 | + * | |
| 1310 | + * @since 1.07.10 | |
| 1311 | + * | |
| 1312 | + * @param string $term The value to escape | |
| 1313 | + * @return string The escaped value | |
| 1314 | + */ | |
| 1315 | 1315 |  	public static function esc_like( $term ) { | 
| 1316 | - global $wpdb; | |
| 1317 | -        if ( method_exists($wpdb, 'esc_like') ) { | |
| 1316 | + global $wpdb; | |
| 1317 | +		if ( method_exists($wpdb, 'esc_like') ) { | |
| 1318 | 1318 | // WP 4.0 | 
| 1319 | - $term = $wpdb->esc_like( $term ); | |
| 1320 | -        } else { | |
| 1321 | - $term = like_escape( $term ); | |
| 1322 | - } | |
| 1319 | + $term = $wpdb->esc_like( $term ); | |
| 1320 | +		} else { | |
| 1321 | + $term = like_escape( $term ); | |
| 1322 | + } | |
| 1323 | 1323 | |
| 1324 | - return $term; | |
| 1325 | - } | |
| 1324 | + return $term; | |
| 1325 | + } | |
| 1326 | 1326 | |
| 1327 | - /** | |
| 1328 | - * @param string $order_query | |
| 1329 | - */ | |
| 1327 | + /** | |
| 1328 | + * @param string $order_query | |
| 1329 | + */ | |
| 1330 | 1330 |  	public static function esc_order( $order_query ) { | 
| 1331 | -        if ( empty($order_query) ) { | |
| 1332 | - return ''; | |
| 1333 | - } | |
| 1334 | - | |
| 1335 | - // remove ORDER BY before santizing | |
| 1336 | - $order_query = strtolower($order_query); | |
| 1337 | -        if ( strpos($order_query, 'order by') !== false ) { | |
| 1338 | -            $order_query = str_replace('order by', '', $order_query); | |
| 1339 | - } | |
| 1340 | - | |
| 1341 | -        $order_query = explode(' ', trim($order_query)); | |
| 1342 | - | |
| 1343 | - $order_fields = array( | |
| 1344 | - 'id', 'form_key', 'name', 'description', | |
| 1345 | - 'parent_form_id', 'logged_in', 'is_template', | |
| 1346 | - 'default_template', 'status', 'created_at', | |
| 1347 | - ); | |
| 1348 | - | |
| 1349 | - $order = trim(trim(reset($order_query), ',')); | |
| 1350 | -        if ( ! in_array($order, $order_fields) ) { | |
| 1351 | - return ''; | |
| 1352 | - } | |
| 1353 | - | |
| 1354 | - $order_by = ''; | |
| 1355 | -        if ( count($order_query) > 1 ) { | |
| 1331 | +		if ( empty($order_query) ) { | |
| 1332 | + return ''; | |
| 1333 | + } | |
| 1334 | + | |
| 1335 | + // remove ORDER BY before santizing | |
| 1336 | + $order_query = strtolower($order_query); | |
| 1337 | +		if ( strpos($order_query, 'order by') !== false ) { | |
| 1338 | +			$order_query = str_replace('order by', '', $order_query); | |
| 1339 | + } | |
| 1340 | + | |
| 1341 | +		$order_query = explode(' ', trim($order_query)); | |
| 1342 | + | |
| 1343 | + $order_fields = array( | |
| 1344 | + 'id', 'form_key', 'name', 'description', | |
| 1345 | + 'parent_form_id', 'logged_in', 'is_template', | |
| 1346 | + 'default_template', 'status', 'created_at', | |
| 1347 | + ); | |
| 1348 | + | |
| 1349 | + $order = trim(trim(reset($order_query), ',')); | |
| 1350 | +		if ( ! in_array($order, $order_fields) ) { | |
| 1351 | + return ''; | |
| 1352 | + } | |
| 1353 | + | |
| 1354 | + $order_by = ''; | |
| 1355 | +		if ( count($order_query) > 1 ) { | |
| 1356 | 1356 | $order_by = end( $order_query ); | 
| 1357 | 1357 | self::esc_order_by( $order_by ); | 
| 1358 | - } | |
| 1358 | + } | |
| 1359 | 1359 | |
| 1360 | 1360 | return ' ORDER BY ' . $order . ' ' . $order_by; | 
| 1361 | - } | |
| 1361 | + } | |
| 1362 | 1362 | |
| 1363 | 1363 | /** | 
| 1364 | 1364 | * Make sure this is ordering by either ASC or DESC | 
| @@ -1370,183 +1370,183 @@ discard block | ||
| 1370 | 1370 | } | 
| 1371 | 1371 | } | 
| 1372 | 1372 | |
| 1373 | - /** | |
| 1374 | - * @param string $limit | |
| 1375 | - */ | |
| 1373 | + /** | |
| 1374 | + * @param string $limit | |
| 1375 | + */ | |
| 1376 | 1376 |  	public static function esc_limit( $limit ) { | 
| 1377 | -        if ( empty($limit) ) { | |
| 1378 | - return ''; | |
| 1379 | - } | |
| 1377 | +		if ( empty($limit) ) { | |
| 1378 | + return ''; | |
| 1379 | + } | |
| 1380 | 1380 | |
| 1381 | -        $limit = trim(str_replace(' limit', '', strtolower($limit))); | |
| 1382 | -        if ( is_numeric($limit) ) { | |
| 1381 | +		$limit = trim(str_replace(' limit', '', strtolower($limit))); | |
| 1382 | +		if ( is_numeric($limit) ) { | |
| 1383 | 1383 | return ' LIMIT ' . $limit; | 
| 1384 | - } | |
| 1384 | + } | |
| 1385 | 1385 | |
| 1386 | -        $limit = explode(',', trim($limit)); | |
| 1387 | -        foreach ( $limit as $k => $l ) { | |
| 1388 | -            if ( is_numeric( $l ) ) { | |
| 1389 | - $limit[ $k ] = $l; | |
| 1390 | - } | |
| 1391 | - } | |
| 1386 | +		$limit = explode(',', trim($limit)); | |
| 1387 | +		foreach ( $limit as $k => $l ) { | |
| 1388 | +			if ( is_numeric( $l ) ) { | |
| 1389 | + $limit[ $k ] = $l; | |
| 1390 | + } | |
| 1391 | + } | |
| 1392 | 1392 | |
| 1393 | -        $limit = implode(',', $limit); | |
| 1393 | +		$limit = implode(',', $limit); | |
| 1394 | 1394 | return ' LIMIT ' . $limit; | 
| 1395 | - } | |
| 1396 | - | |
| 1397 | - /** | |
| 1398 | - * Get an array of values ready to go through $wpdb->prepare | |
| 1399 | - * @since 2.0 | |
| 1400 | - */ | |
| 1401 | -    public static function prepare_array_values( $array, $type = '%s' ) { | |
| 1402 | - $placeholders = array_fill(0, count($array), $type); | |
| 1403 | -        return implode(', ', $placeholders); | |
| 1404 | - } | |
| 1405 | - | |
| 1406 | -    public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) { | |
| 1407 | -        if ( empty($where) ) { | |
| 1408 | - return ''; | |
| 1409 | - } | |
| 1395 | + } | |
| 1396 | + | |
| 1397 | + /** | |
| 1398 | + * Get an array of values ready to go through $wpdb->prepare | |
| 1399 | + * @since 2.0 | |
| 1400 | + */ | |
| 1401 | +	public static function prepare_array_values( $array, $type = '%s' ) { | |
| 1402 | + $placeholders = array_fill(0, count($array), $type); | |
| 1403 | +		return implode(', ', $placeholders); | |
| 1404 | + } | |
| 1405 | + | |
| 1406 | +	public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) { | |
| 1407 | +		if ( empty($where) ) { | |
| 1408 | + return ''; | |
| 1409 | + } | |
| 1410 | 1410 | |
| 1411 | 1411 |  		if ( is_array( $where ) ) { | 
| 1412 | - global $wpdb; | |
| 1413 | - FrmDb::get_where_clause_and_values( $where, $starts_with ); | |
| 1412 | + global $wpdb; | |
| 1413 | + FrmDb::get_where_clause_and_values( $where, $starts_with ); | |
| 1414 | 1414 | $where = $wpdb->prepare( $where['where'], $where['values'] ); | 
| 1415 | 1415 |  		} else { | 
| 1416 | - $where = $starts_with . $where; | |
| 1417 | - } | |
| 1416 | + $where = $starts_with . $where; | |
| 1417 | + } | |
| 1418 | 1418 | |
| 1419 | - return $where; | |
| 1420 | - } | |
| 1419 | + return $where; | |
| 1420 | + } | |
| 1421 | 1421 | |
| 1422 | - // Pagination Methods | |
| 1422 | + // Pagination Methods | |
| 1423 | 1423 | |
| 1424 | - /** | |
| 1425 | - * @param integer $current_p | |
| 1426 | - */ | |
| 1424 | + /** | |
| 1425 | + * @param integer $current_p | |
| 1426 | + */ | |
| 1427 | 1427 |  	public static function get_last_record_num( $r_count, $current_p, $p_size ) { | 
| 1428 | 1428 | return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) ); | 
| 1429 | 1429 | } | 
| 1430 | 1430 | |
| 1431 | - /** | |
| 1432 | - * @param integer $current_p | |
| 1433 | - */ | |
| 1434 | -    public static function get_first_record_num( $r_count, $current_p, $p_size ) { | |
| 1435 | -        if ( $current_p == 1 ) { | |
| 1436 | - return 1; | |
| 1437 | -        } else { | |
| 1438 | - return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 ); | |
| 1439 | - } | |
| 1440 | - } | |
| 1441 | - | |
| 1442 | - /** | |
| 1443 | - * @param string $table_name | |
| 1444 | - */ | |
| 1445 | -    public static function &getRecordCount( $where = '', $table_name ) { | |
| 1446 | - _deprecated_function( __FUNCTION__, '2.0', 'FrmDb::get_count' ); | |
| 1447 | - $count = FrmDb::get_count( $table_name, $where ); | |
| 1448 | - return $count; | |
| 1449 | - } | |
| 1450 | - | |
| 1451 | -    public static function get_referer_info() { | |
| 1452 | - _deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::get_server_value' ); | |
| 1453 | -        return self::get_server_value('HTTP_REFERER'); | |
| 1454 | - } | |
| 1431 | + /** | |
| 1432 | + * @param integer $current_p | |
| 1433 | + */ | |
| 1434 | +	public static function get_first_record_num( $r_count, $current_p, $p_size ) { | |
| 1435 | +		if ( $current_p == 1 ) { | |
| 1436 | + return 1; | |
| 1437 | +		} else { | |
| 1438 | + return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 ); | |
| 1439 | + } | |
| 1440 | + } | |
| 1441 | + | |
| 1442 | + /** | |
| 1443 | + * @param string $table_name | |
| 1444 | + */ | |
| 1445 | +	public static function &getRecordCount( $where = '', $table_name ) { | |
| 1446 | + _deprecated_function( __FUNCTION__, '2.0', 'FrmDb::get_count' ); | |
| 1447 | + $count = FrmDb::get_count( $table_name, $where ); | |
| 1448 | + return $count; | |
| 1449 | + } | |
| 1450 | + | |
| 1451 | +	public static function get_referer_info() { | |
| 1452 | + _deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::get_server_value' ); | |
| 1453 | +		return self::get_server_value('HTTP_REFERER'); | |
| 1454 | + } | |
| 1455 | 1455 | |
| 1456 | 1456 | /** | 
| 1457 | 1457 | * @return array | 
| 1458 | 1458 | */ | 
| 1459 | 1459 |  	public static function json_to_array( $json_vars ) { | 
| 1460 | - $vars = array(); | |
| 1461 | -        foreach ( $json_vars as $jv ) { | |
| 1462 | -            $jv_name = explode('[', $jv['name']); | |
| 1463 | - $last = count($jv_name) - 1; | |
| 1464 | -            foreach ( $jv_name as $p => $n ) { | |
| 1465 | - $name = trim($n, ']'); | |
| 1466 | -                if ( ! isset($l1) ) { | |
| 1467 | - $l1 = $name; | |
| 1468 | - } | |
| 1469 | - | |
| 1470 | -                if ( ! isset($l2) ) { | |
| 1471 | - $l2 = $name; | |
| 1472 | - } | |
| 1473 | - | |
| 1474 | -                if ( ! isset($l3) ) { | |
| 1475 | - $l3 = $name; | |
| 1476 | - } | |
| 1477 | - | |
| 1478 | - $this_val = ( $p == $last ) ? $jv['value'] : array(); | |
| 1479 | - | |
| 1480 | -                switch ( $p ) { | |
| 1481 | - case 0: | |
| 1482 | - $l1 = $name; | |
| 1483 | - self::add_value_to_array( $name, $l1, $this_val, $vars ); | |
| 1484 | - break; | |
| 1485 | - | |
| 1486 | - case 1: | |
| 1487 | - $l2 = $name; | |
| 1488 | - self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); | |
| 1489 | - break; | |
| 1490 | - | |
| 1491 | - case 2: | |
| 1492 | - $l3 = $name; | |
| 1493 | - self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); | |
| 1494 | - break; | |
| 1495 | - | |
| 1496 | - case 3: | |
| 1497 | - $l4 = $name; | |
| 1498 | - self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); | |
| 1499 | - break; | |
| 1500 | - } | |
| 1501 | - | |
| 1502 | - unset($this_val, $n); | |
| 1503 | - } | |
| 1504 | - | |
| 1505 | - unset($last, $jv); | |
| 1506 | - } | |
| 1507 | - | |
| 1508 | - return $vars; | |
| 1509 | - } | |
| 1510 | - | |
| 1511 | - /** | |
| 1512 | - * @param string $name | |
| 1513 | - * @param string $l1 | |
| 1514 | - */ | |
| 1515 | -    public static function add_value_to_array( $name, $l1, $val, &$vars ) { | |
| 1516 | -        if ( $name == '' ) { | |
| 1517 | - $vars[] = $val; | |
| 1518 | -        } else if ( ! isset( $vars[ $l1 ] ) ) { | |
| 1519 | - $vars[ $l1 ] = $val; | |
| 1520 | - } | |
| 1521 | - } | |
| 1460 | + $vars = array(); | |
| 1461 | +		foreach ( $json_vars as $jv ) { | |
| 1462 | +			$jv_name = explode('[', $jv['name']); | |
| 1463 | + $last = count($jv_name) - 1; | |
| 1464 | +			foreach ( $jv_name as $p => $n ) { | |
| 1465 | + $name = trim($n, ']'); | |
| 1466 | +				if ( ! isset($l1) ) { | |
| 1467 | + $l1 = $name; | |
| 1468 | + } | |
| 1469 | + | |
| 1470 | +				if ( ! isset($l2) ) { | |
| 1471 | + $l2 = $name; | |
| 1472 | + } | |
| 1473 | + | |
| 1474 | +				if ( ! isset($l3) ) { | |
| 1475 | + $l3 = $name; | |
| 1476 | + } | |
| 1477 | + | |
| 1478 | + $this_val = ( $p == $last ) ? $jv['value'] : array(); | |
| 1479 | + | |
| 1480 | +				switch ( $p ) { | |
| 1481 | + case 0: | |
| 1482 | + $l1 = $name; | |
| 1483 | + self::add_value_to_array( $name, $l1, $this_val, $vars ); | |
| 1484 | + break; | |
| 1485 | + | |
| 1486 | + case 1: | |
| 1487 | + $l2 = $name; | |
| 1488 | + self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); | |
| 1489 | + break; | |
| 1490 | + | |
| 1491 | + case 2: | |
| 1492 | + $l3 = $name; | |
| 1493 | + self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); | |
| 1494 | + break; | |
| 1495 | + | |
| 1496 | + case 3: | |
| 1497 | + $l4 = $name; | |
| 1498 | + self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); | |
| 1499 | + break; | |
| 1500 | + } | |
| 1501 | + | |
| 1502 | + unset($this_val, $n); | |
| 1503 | + } | |
| 1504 | + | |
| 1505 | + unset($last, $jv); | |
| 1506 | + } | |
| 1507 | + | |
| 1508 | + return $vars; | |
| 1509 | + } | |
| 1510 | + | |
| 1511 | + /** | |
| 1512 | + * @param string $name | |
| 1513 | + * @param string $l1 | |
| 1514 | + */ | |
| 1515 | +	public static function add_value_to_array( $name, $l1, $val, &$vars ) { | |
| 1516 | +		if ( $name == '' ) { | |
| 1517 | + $vars[] = $val; | |
| 1518 | +		} else if ( ! isset( $vars[ $l1 ] ) ) { | |
| 1519 | + $vars[ $l1 ] = $val; | |
| 1520 | + } | |
| 1521 | + } | |
| 1522 | 1522 | |
| 1523 | 1523 |  	public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) { | 
| 1524 | - $tooltips = array( | |
| 1525 | - 'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ), | |
| 1526 | - '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' ), | |
| 1527 | - 'cc' => __( 'Add CC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), | |
| 1528 | - 'bcc' => __( 'Add BCC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), | |
| 1529 | - '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' ), | |
| 1530 | - 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ), | |
| 1531 | - '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() ) ), | |
| 1532 | - ); | |
| 1533 | - | |
| 1534 | -        if ( ! isset( $tooltips[ $name ] ) ) { | |
| 1535 | - return; | |
| 1536 | - } | |
| 1537 | - | |
| 1538 | -        if ( 'open' == $class ) { | |
| 1539 | - echo ' frm_help"'; | |
| 1540 | -        } else { | |
| 1541 | - echo ' class="frm_help"'; | |
| 1542 | - } | |
| 1524 | + $tooltips = array( | |
| 1525 | + 'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ), | |
| 1526 | + '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' ), | |
| 1527 | + 'cc' => __( 'Add CC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), | |
| 1528 | + 'bcc' => __( 'Add BCC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), | |
| 1529 | + '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' ), | |
| 1530 | + 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ), | |
| 1531 | + '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() ) ), | |
| 1532 | + ); | |
| 1533 | + | |
| 1534 | +		if ( ! isset( $tooltips[ $name ] ) ) { | |
| 1535 | + return; | |
| 1536 | + } | |
| 1537 | + | |
| 1538 | +		if ( 'open' == $class ) { | |
| 1539 | + echo ' frm_help"'; | |
| 1540 | +		} else { | |
| 1541 | + echo ' class="frm_help"'; | |
| 1542 | + } | |
| 1543 | 1543 | |
| 1544 | 1544 | echo ' title="' . esc_attr( $tooltips[ $name ] ); | 
| 1545 | 1545 | |
| 1546 | -        if ( 'open' != $class ) { | |
| 1547 | - echo '"'; | |
| 1548 | - } | |
| 1549 | - } | |
| 1546 | +		if ( 'open' != $class ) { | |
| 1547 | + echo '"'; | |
| 1548 | + } | |
| 1549 | + } | |
| 1550 | 1550 | |
| 1551 | 1551 | /** | 
| 1552 | 1552 | * Add the current_page class to that page in the form nav | 
| @@ -1562,35 +1562,35 @@ discard block | ||
| 1562 | 1562 | } | 
| 1563 | 1563 | } | 
| 1564 | 1564 | |
| 1565 | - /** | |
| 1566 | - * Prepare and json_encode post content | |
| 1567 | - * | |
| 1568 | - * @since 2.0 | |
| 1569 | - * | |
| 1570 | - * @param array $post_content | |
| 1571 | - * @return string $post_content ( json encoded array ) | |
| 1572 | - */ | |
| 1573 | -    public static function prepare_and_encode( $post_content ) { | |
| 1574 | - //Loop through array to strip slashes and add only the needed ones | |
| 1565 | + /** | |
| 1566 | + * Prepare and json_encode post content | |
| 1567 | + * | |
| 1568 | + * @since 2.0 | |
| 1569 | + * | |
| 1570 | + * @param array $post_content | |
| 1571 | + * @return string $post_content ( json encoded array ) | |
| 1572 | + */ | |
| 1573 | +	public static function prepare_and_encode( $post_content ) { | |
| 1574 | + //Loop through array to strip slashes and add only the needed ones | |
| 1575 | 1575 |  		foreach ( $post_content as $key => $val ) { | 
| 1576 | 1576 | // Replace problematic characters (like ") | 
| 1577 | 1577 | $val = str_replace( '"', '"', $val ); | 
| 1578 | 1578 | |
| 1579 | 1579 | self::prepare_action_slashes( $val, $key, $post_content ); | 
| 1580 | - unset( $key, $val ); | |
| 1581 | - } | |
| 1580 | + unset( $key, $val ); | |
| 1581 | + } | |
| 1582 | 1582 | |
| 1583 | - // json_encode the array | |
| 1584 | - $post_content = json_encode( $post_content ); | |
| 1583 | + // json_encode the array | |
| 1584 | + $post_content = json_encode( $post_content ); | |
| 1585 | 1585 | |
| 1586 | - // add extra slashes for \r\n since WP strips them | |
| 1586 | + // add extra slashes for \r\n since WP strips them | |
| 1587 | 1587 | $post_content = str_replace( array( '\\r', '\\n', '\\u', '\\t' ), array( '\\\\r', '\\\\n', '\\\\u', '\\\\t' ), $post_content ); | 
| 1588 | 1588 | |
| 1589 | - // allow for " | |
| 1590 | - $post_content = str_replace( '"', '\\"', $post_content ); | |
| 1589 | + // allow for " | |
| 1590 | + $post_content = str_replace( '"', '\\"', $post_content ); | |
| 1591 | 1591 | |
| 1592 | - return $post_content; | |
| 1593 | - } | |
| 1592 | + return $post_content; | |
| 1593 | + } | |
| 1594 | 1594 | |
| 1595 | 1595 |  	private static function prepare_action_slashes( $val, $key, &$post_content ) { | 
| 1596 | 1596 |  		if ( ! isset( $post_content[ $key ] ) ) { | 
| @@ -1658,64 +1658,64 @@ discard block | ||
| 1658 | 1658 | } | 
| 1659 | 1659 | |
| 1660 | 1660 |  	public static function maybe_json_decode( $string ) { | 
| 1661 | -        if ( is_array($string) ) { | |
| 1662 | - return $string; | |
| 1663 | - } | |
| 1661 | +		if ( is_array($string) ) { | |
| 1662 | + return $string; | |
| 1663 | + } | |
| 1664 | 1664 | |
| 1665 | - $new_string = json_decode($string, true); | |
| 1666 | -        if ( function_exists('json_last_error') ) { | |
| 1665 | + $new_string = json_decode($string, true); | |
| 1666 | +		if ( function_exists('json_last_error') ) { | |
| 1667 | 1667 | // php 5.3+ | 
| 1668 | -            if ( json_last_error() == JSON_ERROR_NONE ) { | |
| 1669 | - $string = $new_string; | |
| 1670 | - } | |
| 1671 | -        } else if ( isset($new_string) ) { | |
| 1668 | +			if ( json_last_error() == JSON_ERROR_NONE ) { | |
| 1669 | + $string = $new_string; | |
| 1670 | + } | |
| 1671 | +		} else if ( isset($new_string) ) { | |
| 1672 | 1672 | // php < 5.3 fallback | 
| 1673 | - $string = $new_string; | |
| 1674 | - } | |
| 1675 | - return $string; | |
| 1676 | - } | |
| 1677 | - | |
| 1678 | - /** | |
| 1679 | - * @since 1.07.10 | |
| 1680 | - * | |
| 1681 | - * @param string $post_type The name of the post type that may need to be highlighted | |
| 1682 | - * @return echo The javascript to open and highlight the Formidable menu | |
| 1683 | - */ | |
| 1673 | + $string = $new_string; | |
| 1674 | + } | |
| 1675 | + return $string; | |
| 1676 | + } | |
| 1677 | + | |
| 1678 | + /** | |
| 1679 | + * @since 1.07.10 | |
| 1680 | + * | |
| 1681 | + * @param string $post_type The name of the post type that may need to be highlighted | |
| 1682 | + * @return echo The javascript to open and highlight the Formidable menu | |
| 1683 | + */ | |
| 1684 | 1684 |  	public static function maybe_highlight_menu( $post_type ) { | 
| 1685 | - global $post, $pagenow; | |
| 1685 | + global $post, $pagenow; | |
| 1686 | 1686 | |
| 1687 | -        if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) { | |
| 1688 | - return; | |
| 1689 | - } | |
| 1687 | +		if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) { | |
| 1688 | + return; | |
| 1689 | + } | |
| 1690 | 1690 | |
| 1691 | -        if ( is_object($post) && $post->post_type != $post_type ) { | |
| 1692 | - return; | |
| 1693 | - } | |
| 1691 | +		if ( is_object($post) && $post->post_type != $post_type ) { | |
| 1692 | + return; | |
| 1693 | + } | |
| 1694 | 1694 | |
| 1695 | - self::load_admin_wide_js(); | |
| 1696 | -        echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>'; | |
| 1697 | - } | |
| 1695 | + self::load_admin_wide_js(); | |
| 1696 | +		echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>'; | |
| 1697 | + } | |
| 1698 | 1698 | |
| 1699 | - /** | |
| 1700 | - * Load the JS file on non-Formidable pages in the admin area | |
| 1701 | - * @since 2.0 | |
| 1702 | - */ | |
| 1699 | + /** | |
| 1700 | + * Load the JS file on non-Formidable pages in the admin area | |
| 1701 | + * @since 2.0 | |
| 1702 | + */ | |
| 1703 | 1703 |  	public static function load_admin_wide_js( $load = true ) { | 
| 1704 | - $version = FrmAppHelper::plugin_version(); | |
| 1704 | + $version = FrmAppHelper::plugin_version(); | |
| 1705 | 1705 | wp_register_script( 'formidable_admin_global', FrmAppHelper::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version ); | 
| 1706 | 1706 | |
| 1707 | - wp_localize_script( 'formidable_admin_global', 'frmGlobal', array( | |
| 1707 | + wp_localize_script( 'formidable_admin_global', 'frmGlobal', array( | |
| 1708 | 1708 | 'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ), | 
| 1709 | - 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ), | |
| 1709 | + 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ), | |
| 1710 | 1710 | 'url' => FrmAppHelper::plugin_url(), | 
| 1711 | 1711 | 'loading' => __( 'Loading…' ), | 
| 1712 | 1712 | 'nonce' => wp_create_nonce( 'frm_ajax' ), | 
| 1713 | - ) ); | |
| 1713 | + ) ); | |
| 1714 | 1714 | |
| 1715 | 1715 |  		if ( $load ) { | 
| 1716 | 1716 | wp_enqueue_script( 'formidable_admin_global' ); | 
| 1717 | 1717 | } | 
| 1718 | - } | |
| 1718 | + } | |
| 1719 | 1719 | |
| 1720 | 1720 | /** | 
| 1721 | 1721 | * @since 2.0.9 | 
| @@ -1724,9 +1724,9 @@ discard block | ||
| 1724 | 1724 | wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() ); | 
| 1725 | 1725 | } | 
| 1726 | 1726 | |
| 1727 | - /** | |
| 1728 | - * @param string $location | |
| 1729 | - */ | |
| 1727 | + /** | |
| 1728 | + * @param string $location | |
| 1729 | + */ | |
| 1730 | 1730 |  	public static function localize_script( $location ) { | 
| 1731 | 1731 | $ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' ); | 
| 1732 | 1732 | $ajax_url = apply_filters( 'frm_ajax_url', $ajax_url ); | 
| @@ -1776,81 +1776,81 @@ discard block | ||
| 1776 | 1776 | } | 
| 1777 | 1777 | } | 
| 1778 | 1778 | |
| 1779 | - /** | |
| 1779 | + /** | |
| 1780 | 1780 | * echo the message on the plugins listing page | 
| 1781 | - * @since 1.07.10 | |
| 1782 | - * | |
| 1783 | - * @param float $min_version The version the add-on requires | |
| 1784 | - */ | |
| 1781 | + * @since 1.07.10 | |
| 1782 | + * | |
| 1783 | + * @param float $min_version The version the add-on requires | |
| 1784 | + */ | |
| 1785 | 1785 |  	public static function min_version_notice( $min_version ) { | 
| 1786 | - $frm_version = self::plugin_version(); | |
| 1786 | + $frm_version = self::plugin_version(); | |
| 1787 | 1787 | |
| 1788 | - // check if Formidable meets minimum requirements | |
| 1789 | -        if ( version_compare($frm_version, $min_version, '>=') ) { | |
| 1790 | - return; | |
| 1791 | - } | |
| 1788 | + // check if Formidable meets minimum requirements | |
| 1789 | +		if ( version_compare($frm_version, $min_version, '>=') ) { | |
| 1790 | + return; | |
| 1791 | + } | |
| 1792 | 1792 | |
| 1793 | -        $wp_list_table = _get_list_table('WP_Plugins_List_Table'); | |
| 1793 | +		$wp_list_table = _get_list_table('WP_Plugins_List_Table'); | |
| 1794 | 1794 | 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">' . | 
| 1795 | - __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . | |
| 1796 | - '</div></td></tr>'; | |
| 1797 | - } | |
| 1798 | - | |
| 1799 | -    public static function locales( $type = 'date' ) { | |
| 1800 | - $locales = array( | |
| 1801 | - 'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ), | |
| 1802 | - 'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ), | |
| 1803 | - 'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ), | |
| 1804 | - 'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ), | |
| 1805 | - 'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ), | |
| 1806 | - 'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ), | |
| 1807 | - 'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ), | |
| 1808 | - 'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ), | |
| 1809 | - 'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ), | |
| 1810 | - 'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ), | |
| 1811 | - 'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ), | |
| 1812 | - 'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ), | |
| 1813 | - 'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ), | |
| 1814 | - 'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ), | |
| 1815 | - 'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ), | |
| 1816 | - 'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ), | |
| 1817 | - 'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ), | |
| 1818 | - 'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ), | |
| 1819 | - 'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ), | |
| 1820 | - 'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ), | |
| 1821 | - 'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ), | |
| 1822 | - 'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ), | |
| 1823 | - 'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ), | |
| 1824 | - 'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ), | |
| 1825 | - 'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ), | |
| 1826 | - 'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ), | |
| 1827 | - 'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ), | |
| 1828 | - 'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ), | |
| 1829 | - 'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ), | |
| 1830 | - 'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ), | |
| 1831 | - 'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ), | |
| 1832 | - 'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ), | |
| 1833 | - ); | |
| 1834 | - | |
| 1835 | -        if ( $type == 'captcha' ) { | |
| 1836 | - // remove the languages unavailable for the captcha | |
| 1837 | - $unset = array( | |
| 1838 | - '', 'af', 'sq', 'hy', 'az', 'eu', 'bs', | |
| 1839 | - 'zh-HK', 'eo', 'et', 'fo', 'fr-CH', | |
| 1840 | - 'he', 'is', 'ms', 'sr-SR', 'ta', 'tu', | |
| 1841 | - ); | |
| 1842 | -        } else { | |
| 1843 | - // remove the languages unavailable for the datepicker | |
| 1844 | - $unset = array( | |
| 1845 | - 'en', 'fil', 'fr-CA', 'de-AT', 'de-AT', | |
| 1846 | - 'de-CH', 'iw', 'hi', 'pt', 'pt-PT', | |
| 1847 | - 'es-419', 'tr', | |
| 1848 | - ); | |
| 1849 | - } | |
| 1850 | - | |
| 1851 | - $locales = array_diff_key($locales, array_flip($unset)); | |
| 1852 | -        $locales = apply_filters('frm_locales', $locales); | |
| 1853 | - | |
| 1854 | - return $locales; | |
| 1855 | - } | |
| 1795 | + __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . | |
| 1796 | + '</div></td></tr>'; | |
| 1797 | + } | |
| 1798 | + | |
| 1799 | +	public static function locales( $type = 'date' ) { | |
| 1800 | + $locales = array( | |
| 1801 | + 'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ), | |
| 1802 | + 'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ), | |
| 1803 | + 'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ), | |
| 1804 | + 'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ), | |
| 1805 | + 'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ), | |
| 1806 | + 'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ), | |
| 1807 | + 'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ), | |
| 1808 | + 'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ), | |
| 1809 | + 'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ), | |
| 1810 | + 'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ), | |
| 1811 | + 'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ), | |
| 1812 | + 'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ), | |
| 1813 | + 'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ), | |
| 1814 | + 'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ), | |
| 1815 | + 'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ), | |
| 1816 | + 'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ), | |
| 1817 | + 'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ), | |
| 1818 | + 'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ), | |
| 1819 | + 'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ), | |
| 1820 | + 'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ), | |
| 1821 | + 'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ), | |
| 1822 | + 'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ), | |
| 1823 | + 'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ), | |
| 1824 | + 'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ), | |
| 1825 | + 'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ), | |
| 1826 | + 'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ), | |
| 1827 | + 'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ), | |
| 1828 | + 'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ), | |
| 1829 | + 'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ), | |
| 1830 | + 'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ), | |
| 1831 | + 'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ), | |
| 1832 | + 'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ), | |
| 1833 | + ); | |
| 1834 | + | |
| 1835 | +		if ( $type == 'captcha' ) { | |
| 1836 | + // remove the languages unavailable for the captcha | |
| 1837 | + $unset = array( | |
| 1838 | + '', 'af', 'sq', 'hy', 'az', 'eu', 'bs', | |
| 1839 | + 'zh-HK', 'eo', 'et', 'fo', 'fr-CH', | |
| 1840 | + 'he', 'is', 'ms', 'sr-SR', 'ta', 'tu', | |
| 1841 | + ); | |
| 1842 | +		} else { | |
| 1843 | + // remove the languages unavailable for the datepicker | |
| 1844 | + $unset = array( | |
| 1845 | + 'en', 'fil', 'fr-CA', 'de-AT', 'de-AT', | |
| 1846 | + 'de-CH', 'iw', 'hi', 'pt', 'pt-PT', | |
| 1847 | + 'es-419', 'tr', | |
| 1848 | + ); | |
| 1849 | + } | |
| 1850 | + | |
| 1851 | + $locales = array_diff_key($locales, array_flip($unset)); | |
| 1852 | +		$locales = apply_filters('frm_locales', $locales); | |
| 1853 | + | |
| 1854 | + return $locales; | |
| 1855 | + } | |
| 1856 | 1856 | } | 
| @@ -1,5 +1,5 @@ discard block | ||
| 1 | 1 | <?php | 
| 2 | -if ( ! defined('ABSPATH') ) { | |
| 2 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 3 | 3 | die( 'You are not allowed to call this page directly.' ); | 
| 4 | 4 | } | 
| 5 | 5 | |
| @@ -23,11 +23,11 @@ discard block | ||
| 23 | 23 | } | 
| 24 | 24 | |
| 25 | 25 |      public static function plugin_folder() { | 
| 26 | - return basename(self::plugin_path()); | |
| 26 | + return basename( self::plugin_path() ); | |
| 27 | 27 | } | 
| 28 | 28 | |
| 29 | 29 |      public static function plugin_path() { | 
| 30 | - return dirname(dirname(dirname(__FILE__))); | |
| 30 | + return dirname( dirname( dirname( __FILE__ ) ) ); | |
| 31 | 31 | } | 
| 32 | 32 | |
| 33 | 33 |      public static function plugin_url() { | 
| @@ -54,7 +54,7 @@ discard block | ||
| 54 | 54 | * @return string | 
| 55 | 55 | */ | 
| 56 | 56 |      public static function site_name() { | 
| 57 | -        return get_option('blogname'); | |
| 57 | + return get_option( 'blogname' ); | |
| 58 | 58 | } | 
| 59 | 59 | |
| 60 | 60 |  	public static function make_affiliate_url( $url ) { | 
| @@ -66,7 +66,7 @@ discard block | ||
| 66 | 66 | } | 
| 67 | 67 | |
| 68 | 68 |  	public static function get_affiliate() { | 
| 69 | -		$affiliate_id = apply_filters( 'frm_affiliate_link', get_option('frm_aff') ); | |
| 69 | + $affiliate_id = apply_filters( 'frm_affiliate_link', get_option( 'frm_aff' ) ); | |
| 70 | 70 | $affiliate_id = strtolower( $affiliate_id ); | 
| 71 | 71 | $allowed_affiliates = array( 'mojo' ); | 
| 72 | 72 |  		if ( ! in_array( $affiliate_id, $allowed_affiliates ) ) { | 
| @@ -85,7 +85,7 @@ discard block | ||
| 85 | 85 | */ | 
| 86 | 86 |      public static function get_settings() { | 
| 87 | 87 | global $frm_settings; | 
| 88 | -        if ( empty($frm_settings) ) { | |
| 88 | +        if ( empty( $frm_settings ) ) { | |
| 89 | 89 | $frm_settings = new FrmSettings(); | 
| 90 | 90 | } | 
| 91 | 91 | return $frm_settings; | 
| @@ -106,7 +106,7 @@ discard block | ||
| 106 | 106 | } | 
| 107 | 107 | |
| 108 | 108 |      public static function pro_is_installed() { | 
| 109 | -        return apply_filters('frm_pro_installed', false); | |
| 109 | + return apply_filters( 'frm_pro_installed', false ); | |
| 110 | 110 | } | 
| 111 | 111 | |
| 112 | 112 | /** | 
| @@ -150,7 +150,7 @@ discard block | ||
| 150 | 150 | * @return boolean | 
| 151 | 151 | */ | 
| 152 | 152 |      public static function doing_ajax() { | 
| 153 | -        return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page(); | |
| 153 | + return defined( 'DOING_AJAX' ) && DOING_AJAX && ! self::is_preview_page(); | |
| 154 | 154 | } | 
| 155 | 155 | |
| 156 | 156 | /** | 
| @@ -170,7 +170,7 @@ discard block | ||
| 170 | 170 | * @return boolean | 
| 171 | 171 | */ | 
| 172 | 172 |      public static function is_admin() { | 
| 173 | -        return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX ); | |
| 173 | + return is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ); | |
| 174 | 174 | } | 
| 175 | 175 | |
| 176 | 176 | /** | 
| @@ -196,7 +196,7 @@ discard block | ||
| 196 | 196 | * @return string | 
| 197 | 197 | */ | 
| 198 | 198 |  	public static function get_server_value( $value ) { | 
| 199 | - return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; | |
| 199 | + return isset( $_SERVER[$value] ) ? wp_strip_all_tags( $_SERVER[$value] ) : ''; | |
| 200 | 200 | } | 
| 201 | 201 | |
| 202 | 202 | /** | 
| @@ -211,14 +211,14 @@ discard block | ||
| 211 | 211 | 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', | 
| 212 | 212 | 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR', | 
| 213 | 213 |          ) as $key ) { | 
| 214 | -            if ( ! isset( $_SERVER[ $key ] ) ) { | |
| 214 | +            if ( ! isset( $_SERVER[$key] ) ) { | |
| 215 | 215 | continue; | 
| 216 | 216 | } | 
| 217 | 217 | |
| 218 | -            foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { | |
| 219 | - $ip = trim($ip); // just to be safe | |
| 218 | +            foreach ( explode( ',', $_SERVER[$key] ) as $ip ) { | |
| 219 | + $ip = trim( $ip ); // just to be safe | |
| 220 | 220 | |
| 221 | -                if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) { | |
| 221 | +                if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) !== false ) { | |
| 222 | 222 | return $ip; | 
| 223 | 223 | } | 
| 224 | 224 | } | 
| @@ -228,15 +228,15 @@ discard block | ||
| 228 | 228 | } | 
| 229 | 229 | |
| 230 | 230 |      public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { | 
| 231 | -        if ( strpos($param, '[') ) { | |
| 232 | -            $params = explode('[', $param); | |
| 231 | +        if ( strpos( $param, '[' ) ) { | |
| 232 | + $params = explode( '[', $param ); | |
| 233 | 233 | $param = $params[0]; | 
| 234 | 234 | } | 
| 235 | 235 | |
| 236 | 236 |  		if ( $src == 'get' ) { | 
| 237 | - $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); | |
| 238 | -            if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { | |
| 239 | - $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[ $param ] ) ) ); | |
| 237 | + $value = isset( $_POST[$param] ) ? stripslashes_deep( $_POST[$param] ) : ( isset( $_GET[$param] ) ? stripslashes_deep( $_GET[$param] ) : $default ); | |
| 238 | +            if ( ! isset( $_POST[$param] ) && isset( $_GET[$param] ) && ! is_array( $value ) ) { | |
| 239 | + $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[$param] ) ) ); | |
| 240 | 240 | } | 
| 241 | 241 | self::sanitize_value( $sanitize, $value ); | 
| 242 | 242 |  		} else { | 
| @@ -245,12 +245,12 @@ discard block | ||
| 245 | 245 | |
| 246 | 246 |  		if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) { | 
| 247 | 247 |              foreach ( $params as $k => $p ) { | 
| 248 | -                if ( ! $k || ! is_array($value) ) { | |
| 248 | +                if ( ! $k || ! is_array( $value ) ) { | |
| 249 | 249 | continue; | 
| 250 | 250 | } | 
| 251 | 251 | |
| 252 | - $p = trim($p, ']'); | |
| 253 | - $value = isset( $value[ $p ] ) ? $value[ $p ] : $default; | |
| 252 | + $p = trim( $p, ']' ); | |
| 253 | + $value = isset( $value[$p] ) ? $value[$p] : $default; | |
| 254 | 254 | } | 
| 255 | 255 | } | 
| 256 | 256 | |
| @@ -292,16 +292,16 @@ discard block | ||
| 292 | 292 | |
| 293 | 293 | $value = $args['default']; | 
| 294 | 294 |  		if ( $args['type'] == 'get' ) { | 
| 295 | -			if ( $_GET && isset( $_GET[ $args['param'] ] ) ) { | |
| 296 | - $value = $_GET[ $args['param'] ]; | |
| 295 | +			if ( $_GET && isset( $_GET[$args['param']] ) ) { | |
| 296 | + $value = $_GET[$args['param']]; | |
| 297 | 297 | } | 
| 298 | 298 |  		} else if ( $args['type'] == 'post' ) { | 
| 299 | -			if ( isset( $_POST[ $args['param'] ] ) ) { | |
| 300 | - $value = stripslashes_deep( maybe_unserialize( $_POST[ $args['param'] ] ) ); | |
| 299 | +			if ( isset( $_POST[$args['param']] ) ) { | |
| 300 | + $value = stripslashes_deep( maybe_unserialize( $_POST[$args['param']] ) ); | |
| 301 | 301 | } | 
| 302 | 302 |  		} else { | 
| 303 | -			if ( isset( $_REQUEST[ $args['param'] ] ) ) { | |
| 304 | - $value = $_REQUEST[ $args['param'] ]; | |
| 303 | +			if ( isset( $_REQUEST[$args['param']] ) ) { | |
| 304 | + $value = $_REQUEST[$args['param']]; | |
| 305 | 305 | } | 
| 306 | 306 | } | 
| 307 | 307 | |
| @@ -337,8 +337,8 @@ discard block | ||
| 337 | 337 |      public static function sanitize_request( $sanitize_method, &$values ) { | 
| 338 | 338 | $temp_values = $values; | 
| 339 | 339 |          foreach ( $temp_values as $k => $val ) { | 
| 340 | -            if ( isset( $sanitize_method[ $k ] ) ) { | |
| 341 | - $values[ $k ] = call_user_func( $sanitize_method[ $k ], $val ); | |
| 340 | +            if ( isset( $sanitize_method[$k] ) ) { | |
| 341 | + $values[$k] = call_user_func( $sanitize_method[$k], $val ); | |
| 342 | 342 | } | 
| 343 | 343 | } | 
| 344 | 344 | } | 
| @@ -346,7 +346,7 @@ discard block | ||
| 346 | 346 |  	public static function sanitize_array( &$values ) { | 
| 347 | 347 | $temp_values = $values; | 
| 348 | 348 |  		foreach ( $temp_values as $k => $val ) { | 
| 349 | - $values[ $k ] = wp_kses_post( $val ); | |
| 349 | + $values[$k] = wp_kses_post( $val ); | |
| 350 | 350 | } | 
| 351 | 351 | } | 
| 352 | 352 | |
| @@ -366,7 +366,7 @@ discard block | ||
| 366 | 366 | |
| 367 | 367 | $allowed_html = array(); | 
| 368 | 368 |  		foreach ( $allowed as $a ) { | 
| 369 | - $allowed_html[ $a ] = isset( $html[ $a ] ) ? $html[ $a ] : array(); | |
| 369 | + $allowed_html[$a] = isset( $html[$a] ) ? $html[$a] : array(); | |
| 370 | 370 | } | 
| 371 | 371 | |
| 372 | 372 | return wp_kses( $value, $allowed_html ); | 
| @@ -377,7 +377,7 @@ discard block | ||
| 377 | 377 | * @since 2.0 | 
| 378 | 378 | */ | 
| 379 | 379 |      public static function remove_get_action() { | 
| 380 | -        if ( ! isset($_GET) ) { | |
| 380 | +        if ( ! isset( $_GET ) ) { | |
| 381 | 381 | return; | 
| 382 | 382 | } | 
| 383 | 383 | |
| @@ -399,8 +399,8 @@ discard block | ||
| 399 | 399 | } | 
| 400 | 400 | |
| 401 | 401 | global $wp_query; | 
| 402 | -        if ( isset( $wp_query->query_vars[ $param ] ) ) { | |
| 403 | - $value = $wp_query->query_vars[ $param ]; | |
| 402 | +        if ( isset( $wp_query->query_vars[$param] ) ) { | |
| 403 | + $value = $wp_query->query_vars[$param]; | |
| 404 | 404 | } | 
| 405 | 405 | |
| 406 | 406 | return $value; | 
| @@ -429,16 +429,16 @@ discard block | ||
| 429 | 429 | * @return mixed $results The cache or query results | 
| 430 | 430 | */ | 
| 431 | 431 |      public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) { | 
| 432 | - $results = wp_cache_get($cache_key, $group); | |
| 433 | -        if ( ! self::is_empty_value( $results, false ) || empty($query) ) { | |
| 432 | + $results = wp_cache_get( $cache_key, $group ); | |
| 433 | +        if ( ! self::is_empty_value( $results, false ) || empty( $query ) ) { | |
| 434 | 434 | return $results; | 
| 435 | 435 | } | 
| 436 | 436 | |
| 437 | 437 |          if ( 'get_posts' == $type ) { | 
| 438 | - $results = get_posts($query); | |
| 438 | + $results = get_posts( $query ); | |
| 439 | 439 |          } else { | 
| 440 | 440 | global $wpdb; | 
| 441 | -            $results = $wpdb->{$type}($query); | |
| 441 | +            $results = $wpdb->{$type}( $query ); | |
| 442 | 442 | } | 
| 443 | 443 | |
| 444 | 444 |  		if ( ! self::prevent_caching() ) { | 
| @@ -462,9 +462,9 @@ discard block | ||
| 462 | 462 | } | 
| 463 | 463 | |
| 464 | 464 | // then check the transient | 
| 465 | - $results = get_transient($cache_key); | |
| 465 | + $results = get_transient( $cache_key ); | |
| 466 | 466 |          if ( $results ) { | 
| 467 | - wp_cache_set($cache_key, $results); | |
| 467 | + wp_cache_set( $cache_key, $results ); | |
| 468 | 468 | } | 
| 469 | 469 | |
| 470 | 470 | return $results; | 
| @@ -475,8 +475,8 @@ discard block | ||
| 475 | 475 | * @param string $cache_key | 
| 476 | 476 | */ | 
| 477 | 477 |  	public static function delete_cache_and_transient( $cache_key ) { | 
| 478 | - delete_transient($cache_key); | |
| 479 | - wp_cache_delete($cache_key); | |
| 478 | + delete_transient( $cache_key ); | |
| 479 | + wp_cache_delete( $cache_key ); | |
| 480 | 480 | } | 
| 481 | 481 | |
| 482 | 482 | /** | 
| @@ -490,9 +490,9 @@ discard block | ||
| 490 | 490 |  	public static function cache_delete_group( $group ) { | 
| 491 | 491 | global $wp_object_cache; | 
| 492 | 492 | |
| 493 | -        if ( isset( $wp_object_cache->cache[ $group ] ) ) { | |
| 494 | -            foreach ( $wp_object_cache->cache[ $group ] as $k => $v ) { | |
| 495 | - wp_cache_delete($k, $group); | |
| 493 | +        if ( isset( $wp_object_cache->cache[$group] ) ) { | |
| 494 | +            foreach ( $wp_object_cache->cache[$group] as $k => $v ) { | |
| 495 | + wp_cache_delete( $k, $group ); | |
| 496 | 496 | } | 
| 497 | 497 | return true; | 
| 498 | 498 | } | 
| @@ -523,29 +523,29 @@ discard block | ||
| 523 | 523 |  	public static function load_scripts( $scripts ) { | 
| 524 | 524 | _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_script' ); | 
| 525 | 525 |          foreach ( (array) $scripts as $s ) { | 
| 526 | - wp_enqueue_script($s); | |
| 526 | + wp_enqueue_script( $s ); | |
| 527 | 527 | } | 
| 528 | 528 | } | 
| 529 | 529 | |
| 530 | 530 |  	public static function load_styles( $styles ) { | 
| 531 | 531 | _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_style' ); | 
| 532 | 532 |          foreach ( (array) $styles as $s ) { | 
| 533 | - wp_enqueue_style($s); | |
| 533 | + wp_enqueue_style( $s ); | |
| 534 | 534 | } | 
| 535 | 535 | } | 
| 536 | 536 | |
| 537 | 537 |      public static function get_pages() { | 
| 538 | - return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' ) ); | |
| 538 | + return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => - 1, 'orderby' => 'title', 'order' => 'ASC' ) ); | |
| 539 | 539 | } | 
| 540 | 540 | |
| 541 | 541 |      public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { | 
| 542 | 542 | $pages = self::get_pages(); | 
| 543 | 543 | $selected = self::get_post_param( $field_name, $page_id, 'absint' ); | 
| 544 | 544 | ?> | 
| 545 | - <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown"> | |
| 545 | + <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" class="frm-pages-dropdown"> | |
| 546 | 546 | <option value=""> </option> | 
| 547 | 547 |              <?php foreach ( $pages as $page ) { ?> | 
| 548 | - <option value="<?php echo esc_attr($page->ID); ?>" <?php selected( $selected, $page->ID ) ?>> | |
| 548 | + <option value="<?php echo esc_attr( $page->ID ); ?>" <?php selected( $selected, $page->ID ) ?>> | |
| 549 | 549 | <?php echo esc_html( $truncate ? self::truncate( $page->post_title, $truncate ) : $page->post_title ); ?> | 
| 550 | 550 | </option> | 
| 551 | 551 | <?php } ?> | 
| @@ -554,7 +554,7 @@ discard block | ||
| 554 | 554 | } | 
| 555 | 555 | |
| 556 | 556 |  	public static function post_edit_link( $post_id ) { | 
| 557 | - $post = get_post($post_id); | |
| 557 | + $post = get_post( $post_id ); | |
| 558 | 558 |          if ( $post ) { | 
| 559 | 559 | $post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' ); | 
| 560 | 560 | return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>'; | 
| @@ -564,17 +564,17 @@ discard block | ||
| 564 | 564 | |
| 565 | 565 |  	public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) { | 
| 566 | 566 | ?> | 
| 567 | - <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" <?php | |
| 567 | + <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" <?php | |
| 568 | 568 | echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : ''; | 
| 569 | 569 | ?> class="frm_multiselect"> | 
| 570 | - <?php self::roles_options($capability); ?> | |
| 570 | + <?php self::roles_options( $capability ); ?> | |
| 571 | 571 | </select> | 
| 572 | 572 | <?php | 
| 573 | 573 | } | 
| 574 | 574 | |
| 575 | 575 |  	public static function roles_options( $capability ) { | 
| 576 | 576 | global $frm_vars; | 
| 577 | -        if ( isset($frm_vars['editable_roles']) ) { | |
| 577 | +        if ( isset( $frm_vars['editable_roles'] ) ) { | |
| 578 | 578 | $editable_roles = $frm_vars['editable_roles']; | 
| 579 | 579 |          } else { | 
| 580 | 580 | $editable_roles = get_editable_roles(); | 
| @@ -582,10 +582,10 @@ discard block | ||
| 582 | 582 | } | 
| 583 | 583 | |
| 584 | 584 |          foreach ( $editable_roles as $role => $details ) { | 
| 585 | - $name = translate_user_role($details['name'] ); ?> | |
| 586 | - <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option> | |
| 585 | + $name = translate_user_role( $details['name'] ); ?> | |
| 586 | + <option value="<?php echo esc_attr( $role ) ?>" <?php echo in_array( $role, (array) $capability ) ? ' selected="selected"' : ''; ?>><?php echo esc_attr( $name ) ?> </option> | |
| 587 | 587 | <?php | 
| 588 | - unset($role, $details); | |
| 588 | + unset( $role, $details ); | |
| 589 | 589 | } | 
| 590 | 590 | } | 
| 591 | 591 | |
| @@ -641,7 +641,7 @@ discard block | ||
| 641 | 641 |      public static function maybe_add_permissions() { | 
| 642 | 642 | self::force_capability( 'frm_view_entries' ); | 
| 643 | 643 | |
| 644 | -        if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) { | |
| 644 | +        if ( ! current_user_can( 'administrator' ) || current_user_can( 'frm_view_forms' ) ) { | |
| 645 | 645 | return; | 
| 646 | 646 | } | 
| 647 | 647 | |
| @@ -650,7 +650,7 @@ discard block | ||
| 650 | 650 | $frm_roles = self::frm_capabilities(); | 
| 651 | 651 |          foreach ( $frm_roles as $frm_role => $frm_role_description ) { | 
| 652 | 652 | $user->add_cap( $frm_role ); | 
| 653 | - unset($frm_role, $frm_role_description); | |
| 653 | + unset( $frm_role, $frm_role_description ); | |
| 654 | 654 | } | 
| 655 | 655 | } | 
| 656 | 656 | |
| @@ -675,12 +675,12 @@ discard block | ||
| 675 | 675 | * @param string $permission | 
| 676 | 676 | */ | 
| 677 | 677 |  	public static function permission_check( $permission, $show_message = 'show' ) { | 
| 678 | - $permission_error = self::permission_nonce_error($permission); | |
| 678 | + $permission_error = self::permission_nonce_error( $permission ); | |
| 679 | 679 |          if ( $permission_error !== false ) { | 
| 680 | 680 |              if ( 'hide' == $show_message ) { | 
| 681 | 681 | $permission_error = ''; | 
| 682 | 682 | } | 
| 683 | - wp_die($permission_error); | |
| 683 | + wp_die( $permission_error ); | |
| 684 | 684 | } | 
| 685 | 685 | } | 
| 686 | 686 | |
| @@ -697,11 +697,11 @@ discard block | ||
| 697 | 697 | } | 
| 698 | 698 | |
| 699 | 699 | $error = false; | 
| 700 | -        if ( empty($nonce_name) ) { | |
| 700 | +        if ( empty( $nonce_name ) ) { | |
| 701 | 701 | return $error; | 
| 702 | 702 | } | 
| 703 | 703 | |
| 704 | -        if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { | |
| 704 | +        if ( $_REQUEST && ( ! isset( $_REQUEST[$nonce_name] ) || ! wp_verify_nonce( $_REQUEST[$nonce_name], $nonce ) ) ) { | |
| 705 | 705 | $frm_settings = self::get_settings(); | 
| 706 | 706 | $error = $frm_settings->admin_permission; | 
| 707 | 707 | } | 
| @@ -781,7 +781,7 @@ discard block | ||
| 781 | 781 |  			} else { | 
| 782 | 782 |  				foreach ( $value as $k => $v ) { | 
| 783 | 783 |  					if ( ! is_array( $v ) ) { | 
| 784 | - $value[ $k ] = call_user_func( $original_function, $v ); | |
| 784 | + $value[$k] = call_user_func( $original_function, $v ); | |
| 785 | 785 | } | 
| 786 | 786 | } | 
| 787 | 787 | } | 
| @@ -802,11 +802,11 @@ discard block | ||
| 802 | 802 |  	public static function array_flatten( $array, $keys = 'keep' ) { | 
| 803 | 803 | $return = array(); | 
| 804 | 804 |          foreach ( $array as $key => $value ) { | 
| 805 | -            if ( is_array($value) ) { | |
| 805 | +            if ( is_array( $value ) ) { | |
| 806 | 806 | $return = array_merge( $return, self::array_flatten( $value, $keys ) ); | 
| 807 | 807 |              } else { | 
| 808 | 808 |  				if ( $keys == 'keep' ) { | 
| 809 | - $return[ $key ] = $value; | |
| 809 | + $return[$key] = $value; | |
| 810 | 810 |  				} else { | 
| 811 | 811 | $return[] = $value; | 
| 812 | 812 | } | 
| @@ -816,7 +816,7 @@ discard block | ||
| 816 | 816 | } | 
| 817 | 817 | |
| 818 | 818 |      public static function esc_textarea( $text ) { | 
| 819 | -        $safe_text = str_replace('"', '"', $text); | |
| 819 | + $safe_text = str_replace( '"', '"', $text ); | |
| 820 | 820 | $safe_text = htmlspecialchars( $safe_text, ENT_NOQUOTES ); | 
| 821 | 821 | return apply_filters( 'esc_textarea', $safe_text, $text ); | 
| 822 | 822 | } | 
| @@ -826,8 +826,8 @@ discard block | ||
| 826 | 826 | * @since 2.0 | 
| 827 | 827 | */ | 
| 828 | 828 |  	public static function use_wpautop( $content ) { | 
| 829 | -        if ( apply_filters('frm_use_wpautop', true) ) { | |
| 830 | - $content = wpautop(str_replace( '<br>', '<br />', $content)); | |
| 829 | +        if ( apply_filters( 'frm_use_wpautop', true ) ) { | |
| 830 | + $content = wpautop( str_replace( '<br>', '<br />', $content ) ); | |
| 831 | 831 | } | 
| 832 | 832 | return $content; | 
| 833 | 833 | } | 
| @@ -845,8 +845,8 @@ discard block | ||
| 845 | 845 | * @return string The base Google APIS url for the current version of jQuery UI | 
| 846 | 846 | */ | 
| 847 | 847 |      public static function jquery_ui_base_url() { | 
| 848 | -		$url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version('jquery-ui-core'); | |
| 849 | -        $url = apply_filters('frm_jquery_ui_base_url', $url); | |
| 848 | + $url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core' ); | |
| 849 | + $url = apply_filters( 'frm_jquery_ui_base_url', $url ); | |
| 850 | 850 | return $url; | 
| 851 | 851 | } | 
| 852 | 852 | |
| @@ -861,11 +861,11 @@ discard block | ||
| 861 | 861 | |
| 862 | 862 | $ver = 0; | 
| 863 | 863 | |
| 864 | -        if ( ! isset( $wp_scripts->registered[ $handle ] ) ) { | |
| 864 | +        if ( ! isset( $wp_scripts->registered[$handle] ) ) { | |
| 865 | 865 | return $ver; | 
| 866 | 866 | } | 
| 867 | 867 | |
| 868 | - $query = $wp_scripts->registered[ $handle ]; | |
| 868 | + $query = $wp_scripts->registered[$handle]; | |
| 869 | 869 |      	if ( is_object( $query ) ) { | 
| 870 | 870 | $ver = $query->ver; | 
| 871 | 871 | } | 
| @@ -878,36 +878,36 @@ discard block | ||
| 878 | 878 | } | 
| 879 | 879 | |
| 880 | 880 |  	public static function get_user_id_param( $user_id ) { | 
| 881 | -        if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) { | |
| 881 | +        if ( ! $user_id || empty( $user_id ) || is_numeric( $user_id ) ) { | |
| 882 | 882 | return $user_id; | 
| 883 | 883 | } | 
| 884 | 884 | |
| 885 | 885 |  		if ( $user_id == 'current' ) { | 
| 886 | 886 | $user_id = get_current_user_id(); | 
| 887 | 887 |  		} else { | 
| 888 | -            if ( is_email($user_id) ) { | |
| 889 | -                $user = get_user_by('email', $user_id); | |
| 888 | +            if ( is_email( $user_id ) ) { | |
| 889 | + $user = get_user_by( 'email', $user_id ); | |
| 890 | 890 |              } else { | 
| 891 | -                $user = get_user_by('login', $user_id); | |
| 891 | + $user = get_user_by( 'login', $user_id ); | |
| 892 | 892 | } | 
| 893 | 893 | |
| 894 | 894 |              if ( $user ) { | 
| 895 | 895 | $user_id = $user->ID; | 
| 896 | 896 | } | 
| 897 | - unset($user); | |
| 897 | + unset( $user ); | |
| 898 | 898 | } | 
| 899 | 899 | |
| 900 | 900 | return $user_id; | 
| 901 | 901 | } | 
| 902 | 902 | |
| 903 | 903 |  	public static function get_file_contents( $filename, $atts = array() ) { | 
| 904 | -        if ( ! is_file($filename) ) { | |
| 904 | +        if ( ! is_file( $filename ) ) { | |
| 905 | 905 | return false; | 
| 906 | 906 | } | 
| 907 | 907 | |
| 908 | - extract($atts); | |
| 908 | + extract( $atts ); | |
| 909 | 909 | ob_start(); | 
| 910 | - include($filename); | |
| 910 | + include( $filename ); | |
| 911 | 911 | $contents = ob_get_contents(); | 
| 912 | 912 | ob_end_clean(); | 
| 913 | 913 | return $contents; | 
| @@ -923,28 +923,28 @@ discard block | ||
| 923 | 923 | $key = ''; | 
| 924 | 924 | |
| 925 | 925 |          if ( ! empty( $name ) ) { | 
| 926 | - $key = sanitize_key($name); | |
| 926 | + $key = sanitize_key( $name ); | |
| 927 | 927 | } | 
| 928 | 928 | |
| 929 | 929 |  		if ( empty( $key ) ) { | 
| 930 | - $max_slug_value = pow(36, $num_chars); | |
| 930 | + $max_slug_value = pow( 36, $num_chars ); | |
| 931 | 931 | $min_slug_value = 37; // we want to have at least 2 characters in the slug | 
| 932 | - $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); | |
| 932 | + $key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 ); | |
| 933 | 933 | } | 
| 934 | 934 | |
| 935 | -		if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) { | |
| 935 | +		if ( is_numeric( $key ) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) { | |
| 936 | 936 | $key = $key . 'a'; | 
| 937 | 937 | } | 
| 938 | 938 | |
| 939 | 939 | $key_check = FrmDb::get_var( $table_name, array( $column => $key, 'ID !' => $id ), $column ); | 
| 940 | 940 | |
| 941 | -        if ( $key_check || is_numeric($key_check) ) { | |
| 941 | +        if ( $key_check || is_numeric( $key_check ) ) { | |
| 942 | 942 | $suffix = 2; | 
| 943 | 943 |  			do { | 
| 944 | 944 | $alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix; | 
| 945 | 945 | $key_check = FrmDb::get_var( $table_name, array( $column => $alt_post_name, 'ID !' => $id ), $column ); | 
| 946 | - $suffix++; | |
| 947 | - } while ($key_check || is_numeric($key_check)); | |
| 946 | + $suffix ++; | |
| 947 | + } while ( $key_check || is_numeric( $key_check ) ); | |
| 948 | 948 | $key = $alt_post_name; | 
| 949 | 949 | } | 
| 950 | 950 | return $key; | 
| @@ -960,32 +960,32 @@ discard block | ||
| 960 | 960 | return false; | 
| 961 | 961 | } | 
| 962 | 962 | |
| 963 | -        if ( empty($post_values) ) { | |
| 964 | - $post_values = stripslashes_deep($_POST); | |
| 963 | +        if ( empty( $post_values ) ) { | |
| 964 | + $post_values = stripslashes_deep( $_POST ); | |
| 965 | 965 | } | 
| 966 | 966 | |
| 967 | 967 | $values = array( 'id' => $record->id, 'fields' => array() ); | 
| 968 | 968 | |
| 969 | 969 |  		foreach ( array( 'name', 'description' ) as $var ) { | 
| 970 | -            $default_val = isset($record->{$var}) ? $record->{$var} : ''; | |
| 971 | - $values[ $var ] = self::get_param( $var, $default_val ); | |
| 972 | - unset($var, $default_val); | |
| 970 | +            $default_val = isset( $record->{$var}) ? $record->{$var} : ''; | |
| 971 | + $values[$var] = self::get_param( $var, $default_val ); | |
| 972 | + unset( $var, $default_val ); | |
| 973 | 973 | } | 
| 974 | 974 | |
| 975 | - $values['description'] = self::use_wpautop($values['description']); | |
| 975 | + $values['description'] = self::use_wpautop( $values['description'] ); | |
| 976 | 976 | $frm_settings = self::get_settings(); | 
| 977 | -        $is_form_builder = self::is_admin_page('formidable' ); | |
| 977 | + $is_form_builder = self::is_admin_page( 'formidable' ); | |
| 978 | 978 | |
| 979 | 979 |          foreach ( (array) $fields as $field ) { | 
| 980 | 980 | // Make sure to filter default values (for placeholder text), but not on the form builder page | 
| 981 | 981 |              if ( ! $is_form_builder ) { | 
| 982 | -                $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true ); | |
| 982 | + $field->default_value = apply_filters( 'frm_get_default_value', $field->default_value, $field, true ); | |
| 983 | 983 | } | 
| 984 | 984 | $parent_form_id = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id; | 
| 985 | -			self::fill_field_defaults($field, $record, $values, compact('default', 'post_values', 'frm_settings', 'parent_form_id' ) ); | |
| 985 | + self::fill_field_defaults( $field, $record, $values, compact( 'default', 'post_values', 'frm_settings', 'parent_form_id' ) ); | |
| 986 | 986 | } | 
| 987 | 987 | |
| 988 | - self::fill_form_opts($record, $table, $post_values, $values); | |
| 988 | + self::fill_form_opts( $record, $table, $post_values, $values ); | |
| 989 | 989 | |
| 990 | 990 |          if ( $table == 'entries' ) { | 
| 991 | 991 | $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); | 
| @@ -1002,8 +1002,8 @@ discard block | ||
| 1002 | 1002 |          if ( $args['default'] ) { | 
| 1003 | 1003 | $meta_value = $field->default_value; | 
| 1004 | 1004 |          } else { | 
| 1005 | -            if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) { | |
| 1006 | -                if ( ! isset($field->field_options['custom_field']) ) { | |
| 1005 | +            if ( $record->post_id && self::pro_is_installed() && isset( $field->field_options['post_field'] ) && $field->field_options['post_field'] ) { | |
| 1006 | +                if ( ! isset( $field->field_options['custom_field'] ) ) { | |
| 1007 | 1007 | $field->field_options['custom_field'] = ''; | 
| 1008 | 1008 | } | 
| 1009 | 1009 | $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 ) ); | 
| @@ -1012,8 +1012,8 @@ discard block | ||
| 1012 | 1012 | } | 
| 1013 | 1013 | } | 
| 1014 | 1014 | |
| 1015 | - $field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type; | |
| 1016 | - $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; | |
| 1015 | + $field_type = isset( $post_values['field_options']['type_' . $field->id] ) ? $post_values['field_options']['type_' . $field->id] : $field->type; | |
| 1016 | + $new_value = isset( $post_values['item_meta'][$field->id] ) ? maybe_unserialize( $post_values['item_meta'][$field->id] ) : $meta_value; | |
| 1017 | 1017 | |
| 1018 | 1018 | $field_array = array( | 
| 1019 | 1019 | 'id' => $field->id, | 
| @@ -1021,7 +1021,7 @@ discard block | ||
| 1021 | 1021 | 'default_value' => $field->default_value, | 
| 1022 | 1022 | 'name' => $field->name, | 
| 1023 | 1023 | 'description' => $field->description, | 
| 1024 | -            'type'          => apply_filters('frm_field_type', $field_type, $field, $new_value), | |
| 1024 | + 'type' => apply_filters( 'frm_field_type', $field_type, $field, $new_value ), | |
| 1025 | 1025 | 'options' => $field->options, | 
| 1026 | 1026 | 'required' => $field->required, | 
| 1027 | 1027 | 'field_key' => $field->field_key, | 
| @@ -1031,38 +1031,38 @@ discard block | ||
| 1031 | 1031 | ); | 
| 1032 | 1032 | |
| 1033 | 1033 | $args['field_type'] = $field_type; | 
| 1034 | - self::fill_field_opts($field, $field_array, $args); | |
| 1034 | + self::fill_field_opts( $field, $field_array, $args ); | |
| 1035 | 1035 | |
| 1036 | -        $field_array = apply_filters('frm_setup_edit_fields_vars', $field_array, $field, $values['id']); | |
| 1036 | + $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'] ); | |
| 1037 | 1037 | |
| 1038 | -        if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) { | |
| 1038 | +        if ( ! isset( $field_array['unique'] ) || ! $field_array['unique'] ) { | |
| 1039 | 1039 | $field_array['unique_msg'] = ''; | 
| 1040 | 1040 | } | 
| 1041 | 1041 | |
| 1042 | 1042 | $field_array = array_merge( $field->field_options, $field_array ); | 
| 1043 | 1043 | |
| 1044 | - $values['fields'][ $field->id ] = $field_array; | |
| 1044 | + $values['fields'][$field->id] = $field_array; | |
| 1045 | 1045 | } | 
| 1046 | 1046 | |
| 1047 | 1047 |  	private static function fill_field_opts( $field, array &$field_array, $args ) { | 
| 1048 | 1048 | $post_values = $args['post_values']; | 
| 1049 | - $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); | |
| 1049 | + $opt_defaults = FrmFieldsHelper::get_default_field_opts( $field_array['type'], $field, true ); | |
| 1050 | 1050 | |
| 1051 | 1051 |          foreach ( $opt_defaults as $opt => $default_opt ) { | 
| 1052 | - $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 ); | |
| 1053 | -            if ( $opt == 'blank' && $field_array[ $opt ] == '' ) { | |
| 1054 | - $field_array[ $opt ] = $args['frm_settings']->blank_msg; | |
| 1055 | -            } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) { | |
| 1052 | + $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 ); | |
| 1053 | +            if ( $opt == 'blank' && $field_array[$opt] == '' ) { | |
| 1054 | + $field_array[$opt] = $args['frm_settings']->blank_msg; | |
| 1055 | +            } else if ( $opt == 'invalid' && $field_array[$opt] == '' ) { | |
| 1056 | 1056 |                  if ( $args['field_type'] == 'captcha' ) { | 
| 1057 | - $field_array[ $opt ] = $args['frm_settings']->re_msg; | |
| 1057 | + $field_array[$opt] = $args['frm_settings']->re_msg; | |
| 1058 | 1058 |                  } else { | 
| 1059 | - $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] ); | |
| 1059 | + $field_array[$opt] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] ); | |
| 1060 | 1060 | } | 
| 1061 | 1061 | } | 
| 1062 | 1062 | } | 
| 1063 | 1063 | |
| 1064 | 1064 |          if ( $field_array['custom_html'] == '' ) { | 
| 1065 | - $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']); | |
| 1065 | + $field_array['custom_html'] = FrmFieldsHelper::get_default_html( $args['field_type'] ); | |
| 1066 | 1066 | } | 
| 1067 | 1067 | } | 
| 1068 | 1068 | |
| @@ -1081,18 +1081,18 @@ discard block | ||
| 1081 | 1081 | return; | 
| 1082 | 1082 | } | 
| 1083 | 1083 | |
| 1084 | - $values['form_name'] = isset($record->form_id) ? $form->name : ''; | |
| 1084 | + $values['form_name'] = isset( $record->form_id ) ? $form->name : ''; | |
| 1085 | 1085 | $values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0; | 
| 1086 | 1086 | |
| 1087 | -        if ( ! is_array($form->options) ) { | |
| 1087 | +        if ( ! is_array( $form->options ) ) { | |
| 1088 | 1088 | return; | 
| 1089 | 1089 | } | 
| 1090 | 1090 | |
| 1091 | 1091 |          foreach ( $form->options as $opt => $value ) { | 
| 1092 | - $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; | |
| 1092 | + $values[$opt] = isset( $post_values[$opt] ) ? maybe_unserialize( $post_values[$opt] ) : $value; | |
| 1093 | 1093 | } | 
| 1094 | 1094 | |
| 1095 | - self::fill_form_defaults($post_values, $values); | |
| 1095 | + self::fill_form_defaults( $post_values, $values ); | |
| 1096 | 1096 | } | 
| 1097 | 1097 | |
| 1098 | 1098 | /** | 
| @@ -1102,23 +1102,23 @@ discard block | ||
| 1102 | 1102 | $form_defaults = FrmFormsHelper::get_default_opts(); | 
| 1103 | 1103 | |
| 1104 | 1104 |          foreach ( $form_defaults as $opt => $default ) { | 
| 1105 | -            if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { | |
| 1106 | - $values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default; | |
| 1105 | +            if ( ! isset( $values[$opt] ) || $values[$opt] == '' ) { | |
| 1106 | + $values[$opt] = ( $post_values && isset( $post_values['options'][$opt] ) ) ? $post_values['options'][$opt] : $default; | |
| 1107 | 1107 | } | 
| 1108 | 1108 | |
| 1109 | - unset($opt, $defaut); | |
| 1109 | + unset( $opt, $defaut ); | |
| 1110 | 1110 | } | 
| 1111 | 1111 | |
| 1112 | -        if ( ! isset($values['custom_style']) ) { | |
| 1112 | +        if ( ! isset( $values['custom_style'] ) ) { | |
| 1113 | 1113 | $frm_settings = self::get_settings(); | 
| 1114 | 1114 | $values['custom_style'] = ( $post_values && isset( $post_values['options']['custom_style'] ) ) ? absint( $_POST['options']['custom_style'] ) : ( $frm_settings->load_style != 'none' ); | 
| 1115 | 1115 | } | 
| 1116 | 1116 | |
| 1117 | 1117 |  		foreach ( array( 'before', 'after', 'submit' ) as $h ) { | 
| 1118 | -			if ( ! isset( $values[ $h . '_html' ] ) ) { | |
| 1119 | - $values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) ); | |
| 1118 | +			if ( ! isset( $values[$h . '_html'] ) ) { | |
| 1119 | + $values[$h . '_html'] = ( isset( $post_values['options'][$h . '_html'] ) ? $post_values['options'][$h . '_html'] : FrmFormsHelper::get_default_html( $h ) ); | |
| 1120 | 1120 | } | 
| 1121 | - unset($h); | |
| 1121 | + unset( $h ); | |
| 1122 | 1122 | } | 
| 1123 | 1123 | } | 
| 1124 | 1124 | |
| @@ -1134,9 +1134,9 @@ discard block | ||
| 1134 | 1134 | } | 
| 1135 | 1135 | ?> | 
| 1136 | 1136 | <li> | 
| 1137 | - <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> | |
| 1138 | - <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> | |
| 1139 | - <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> | |
| 1137 | + <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> | |
| 1138 | + <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> | |
| 1139 | + <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> | |
| 1140 | 1140 | </li> | 
| 1141 | 1141 | <?php | 
| 1142 | 1142 | } | 
| @@ -1164,7 +1164,7 @@ discard block | ||
| 1164 | 1164 | return ''; | 
| 1165 | 1165 |          } else if ( $length <= 10 ) { | 
| 1166 | 1166 | $sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) ); | 
| 1167 | - return $sub . (($length < $original_len) ? $continue : ''); | |
| 1167 | + return $sub . ( ( $length < $original_len ) ? $continue : '' ); | |
| 1168 | 1168 | } | 
| 1169 | 1169 | |
| 1170 | 1170 | $sub = ''; | 
| @@ -1173,23 +1173,23 @@ discard block | ||
| 1173 | 1173 | $words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) ); | 
| 1174 | 1174 | |
| 1175 | 1175 |  		foreach ( $words as $word ) { | 
| 1176 | - $part = (($sub != '') ? ' ' : '') . $word; | |
| 1176 | + $part = ( ( $sub != '' ) ? ' ' : '' ) . $word; | |
| 1177 | 1177 | $total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) ); | 
| 1178 | -            if ( $total_len > $length && str_word_count($sub) ) { | |
| 1178 | +            if ( $total_len > $length && str_word_count( $sub ) ) { | |
| 1179 | 1179 | break; | 
| 1180 | 1180 | } | 
| 1181 | 1181 | |
| 1182 | 1182 | $sub .= $part; | 
| 1183 | 1183 | $len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) ); | 
| 1184 | 1184 | |
| 1185 | -            if ( str_word_count($sub) > $minword && $total_len >= $length ) { | |
| 1185 | +            if ( str_word_count( $sub ) > $minword && $total_len >= $length ) { | |
| 1186 | 1186 | break; | 
| 1187 | 1187 | } | 
| 1188 | 1188 | |
| 1189 | - unset($total_len, $word); | |
| 1189 | + unset( $total_len, $word ); | |
| 1190 | 1190 | } | 
| 1191 | 1191 | |
| 1192 | - return $sub . (($len < $original_len) ? $continue : ''); | |
| 1192 | + return $sub . ( ( $len < $original_len ) ? $continue : '' ); | |
| 1193 | 1193 | } | 
| 1194 | 1194 | |
| 1195 | 1195 |  	public static function mb_function( $function_names, $args ) { | 
| @@ -1202,17 +1202,17 @@ discard block | ||
| 1202 | 1202 | } | 
| 1203 | 1203 | |
| 1204 | 1204 |  	public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) { | 
| 1205 | -        if ( empty($date) ) { | |
| 1205 | +        if ( empty( $date ) ) { | |
| 1206 | 1206 | return $date; | 
| 1207 | 1207 | } | 
| 1208 | 1208 | |
| 1209 | -        if ( empty($date_format) ) { | |
| 1210 | -            $date_format = get_option('date_format'); | |
| 1209 | +        if ( empty( $date_format ) ) { | |
| 1210 | + $date_format = get_option( 'date_format' ); | |
| 1211 | 1211 | } | 
| 1212 | 1212 | |
| 1213 | -        if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) { | |
| 1213 | +        if ( preg_match( '/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date ) && self::pro_is_installed() ) { | |
| 1214 | 1214 | $frmpro_settings = new FrmProSettings(); | 
| 1215 | - $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d'); | |
| 1215 | + $date = FrmProAppHelper::convert_date( $date, $frmpro_settings->date_format, 'Y-m-d' ); | |
| 1216 | 1216 | } | 
| 1217 | 1217 | |
| 1218 | 1218 | $formatted = self::get_localized_date( $date_format, $date ); | 
| @@ -1227,7 +1227,7 @@ discard block | ||
| 1227 | 1227 | |
| 1228 | 1228 |  	private static function add_time_to_date( $time_format, $date ) { | 
| 1229 | 1229 |  		if ( empty( $time_format ) ) { | 
| 1230 | -			$time_format = get_option('time_format'); | |
| 1230 | + $time_format = get_option( 'time_format' ); | |
| 1231 | 1231 | } | 
| 1232 | 1232 | |
| 1233 | 1233 | $trimmed_format = trim( $time_format ); | 
| @@ -1273,10 +1273,10 @@ discard block | ||
| 1273 | 1273 | $time_strings = self::get_time_strings(); | 
| 1274 | 1274 | |
| 1275 | 1275 |  		foreach ( $time_strings as $k => $v ) { | 
| 1276 | -			if ( $diff[ $k ] ) { | |
| 1277 | - $time_strings[ $k ] = $diff[ $k ] . ' ' . ( $diff[ $k ] > 1 ? $v[1] : $v[0] ); | |
| 1276 | +			if ( $diff[$k] ) { | |
| 1277 | + $time_strings[$k] = $diff[$k] . ' ' . ( $diff[$k] > 1 ? $v[1] : $v[0] ); | |
| 1278 | 1278 |  			} else { | 
| 1279 | - unset( $time_strings[ $k ] ); | |
| 1279 | + unset( $time_strings[$k] ); | |
| 1280 | 1280 | } | 
| 1281 | 1281 | } | 
| 1282 | 1282 | |
| @@ -1314,7 +1314,7 @@ discard block | ||
| 1314 | 1314 | */ | 
| 1315 | 1315 |  	public static function esc_like( $term ) { | 
| 1316 | 1316 | global $wpdb; | 
| 1317 | -        if ( method_exists($wpdb, 'esc_like') ) { | |
| 1317 | +        if ( method_exists( $wpdb, 'esc_like' ) ) { | |
| 1318 | 1318 | // WP 4.0 | 
| 1319 | 1319 | $term = $wpdb->esc_like( $term ); | 
| 1320 | 1320 |          } else { | 
| @@ -1328,17 +1328,17 @@ discard block | ||
| 1328 | 1328 | * @param string $order_query | 
| 1329 | 1329 | */ | 
| 1330 | 1330 |  	public static function esc_order( $order_query ) { | 
| 1331 | -        if ( empty($order_query) ) { | |
| 1331 | +        if ( empty( $order_query ) ) { | |
| 1332 | 1332 | return ''; | 
| 1333 | 1333 | } | 
| 1334 | 1334 | |
| 1335 | 1335 | // remove ORDER BY before santizing | 
| 1336 | - $order_query = strtolower($order_query); | |
| 1337 | -        if ( strpos($order_query, 'order by') !== false ) { | |
| 1338 | -            $order_query = str_replace('order by', '', $order_query); | |
| 1336 | + $order_query = strtolower( $order_query ); | |
| 1337 | +        if ( strpos( $order_query, 'order by' ) !== false ) { | |
| 1338 | + $order_query = str_replace( 'order by', '', $order_query ); | |
| 1339 | 1339 | } | 
| 1340 | 1340 | |
| 1341 | -        $order_query = explode(' ', trim($order_query)); | |
| 1341 | + $order_query = explode( ' ', trim( $order_query ) ); | |
| 1342 | 1342 | |
| 1343 | 1343 | $order_fields = array( | 
| 1344 | 1344 | 'id', 'form_key', 'name', 'description', | 
| @@ -1346,13 +1346,13 @@ discard block | ||
| 1346 | 1346 | 'default_template', 'status', 'created_at', | 
| 1347 | 1347 | ); | 
| 1348 | 1348 | |
| 1349 | - $order = trim(trim(reset($order_query), ',')); | |
| 1350 | -        if ( ! in_array($order, $order_fields) ) { | |
| 1349 | + $order = trim( trim( reset( $order_query ), ',' ) ); | |
| 1350 | +        if ( ! in_array( $order, $order_fields ) ) { | |
| 1351 | 1351 | return ''; | 
| 1352 | 1352 | } | 
| 1353 | 1353 | |
| 1354 | 1354 | $order_by = ''; | 
| 1355 | -        if ( count($order_query) > 1 ) { | |
| 1355 | +        if ( count( $order_query ) > 1 ) { | |
| 1356 | 1356 | $order_by = end( $order_query ); | 
| 1357 | 1357 | self::esc_order_by( $order_by ); | 
| 1358 | 1358 | } | 
| @@ -1374,23 +1374,23 @@ discard block | ||
| 1374 | 1374 | * @param string $limit | 
| 1375 | 1375 | */ | 
| 1376 | 1376 |  	public static function esc_limit( $limit ) { | 
| 1377 | -        if ( empty($limit) ) { | |
| 1377 | +        if ( empty( $limit ) ) { | |
| 1378 | 1378 | return ''; | 
| 1379 | 1379 | } | 
| 1380 | 1380 | |
| 1381 | -        $limit = trim(str_replace(' limit', '', strtolower($limit))); | |
| 1382 | -        if ( is_numeric($limit) ) { | |
| 1381 | + $limit = trim( str_replace( ' limit', '', strtolower( $limit ) ) ); | |
| 1382 | +        if ( is_numeric( $limit ) ) { | |
| 1383 | 1383 | return ' LIMIT ' . $limit; | 
| 1384 | 1384 | } | 
| 1385 | 1385 | |
| 1386 | -        $limit = explode(',', trim($limit)); | |
| 1386 | + $limit = explode( ',', trim( $limit ) ); | |
| 1387 | 1387 |          foreach ( $limit as $k => $l ) { | 
| 1388 | 1388 |              if ( is_numeric( $l ) ) { | 
| 1389 | - $limit[ $k ] = $l; | |
| 1389 | + $limit[$k] = $l; | |
| 1390 | 1390 | } | 
| 1391 | 1391 | } | 
| 1392 | 1392 | |
| 1393 | -        $limit = implode(',', $limit); | |
| 1393 | + $limit = implode( ',', $limit ); | |
| 1394 | 1394 | return ' LIMIT ' . $limit; | 
| 1395 | 1395 | } | 
| 1396 | 1396 | |
| @@ -1399,12 +1399,12 @@ discard block | ||
| 1399 | 1399 | * @since 2.0 | 
| 1400 | 1400 | */ | 
| 1401 | 1401 |      public static function prepare_array_values( $array, $type = '%s' ) { | 
| 1402 | - $placeholders = array_fill(0, count($array), $type); | |
| 1403 | -        return implode(', ', $placeholders); | |
| 1402 | + $placeholders = array_fill( 0, count( $array ), $type ); | |
| 1403 | + return implode( ', ', $placeholders ); | |
| 1404 | 1404 | } | 
| 1405 | 1405 | |
| 1406 | 1406 |      public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) { | 
| 1407 | -        if ( empty($where) ) { | |
| 1407 | +        if ( empty( $where ) ) { | |
| 1408 | 1408 | return ''; | 
| 1409 | 1409 | } | 
| 1410 | 1410 | |
| @@ -1450,7 +1450,7 @@ discard block | ||
| 1450 | 1450 | |
| 1451 | 1451 |      public static function get_referer_info() { | 
| 1452 | 1452 | _deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::get_server_value' ); | 
| 1453 | -        return self::get_server_value('HTTP_REFERER'); | |
| 1453 | + return self::get_server_value( 'HTTP_REFERER' ); | |
| 1454 | 1454 | } | 
| 1455 | 1455 | |
| 1456 | 1456 | /** | 
| @@ -1459,19 +1459,19 @@ discard block | ||
| 1459 | 1459 |  	public static function json_to_array( $json_vars ) { | 
| 1460 | 1460 | $vars = array(); | 
| 1461 | 1461 |          foreach ( $json_vars as $jv ) { | 
| 1462 | -            $jv_name = explode('[', $jv['name']); | |
| 1463 | - $last = count($jv_name) - 1; | |
| 1462 | + $jv_name = explode( '[', $jv['name'] ); | |
| 1463 | + $last = count( $jv_name ) - 1; | |
| 1464 | 1464 |              foreach ( $jv_name as $p => $n ) { | 
| 1465 | - $name = trim($n, ']'); | |
| 1466 | -                if ( ! isset($l1) ) { | |
| 1465 | + $name = trim( $n, ']' ); | |
| 1466 | +                if ( ! isset( $l1 ) ) { | |
| 1467 | 1467 | $l1 = $name; | 
| 1468 | 1468 | } | 
| 1469 | 1469 | |
| 1470 | -                if ( ! isset($l2) ) { | |
| 1470 | +                if ( ! isset( $l2 ) ) { | |
| 1471 | 1471 | $l2 = $name; | 
| 1472 | 1472 | } | 
| 1473 | 1473 | |
| 1474 | -                if ( ! isset($l3) ) { | |
| 1474 | +                if ( ! isset( $l3 ) ) { | |
| 1475 | 1475 | $l3 = $name; | 
| 1476 | 1476 | } | 
| 1477 | 1477 | |
| @@ -1485,24 +1485,24 @@ discard block | ||
| 1485 | 1485 | |
| 1486 | 1486 | case 1: | 
| 1487 | 1487 | $l2 = $name; | 
| 1488 | - self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); | |
| 1488 | + self::add_value_to_array( $name, $l2, $this_val, $vars[$l1] ); | |
| 1489 | 1489 | break; | 
| 1490 | 1490 | |
| 1491 | 1491 | case 2: | 
| 1492 | 1492 | $l3 = $name; | 
| 1493 | - self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); | |
| 1493 | + self::add_value_to_array( $name, $l3, $this_val, $vars[$l1][$l2] ); | |
| 1494 | 1494 | break; | 
| 1495 | 1495 | |
| 1496 | 1496 | case 3: | 
| 1497 | 1497 | $l4 = $name; | 
| 1498 | - self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); | |
| 1498 | + self::add_value_to_array( $name, $l4, $this_val, $vars[$l1][$l2][$l3] ); | |
| 1499 | 1499 | break; | 
| 1500 | 1500 | } | 
| 1501 | 1501 | |
| 1502 | - unset($this_val, $n); | |
| 1502 | + unset( $this_val, $n ); | |
| 1503 | 1503 | } | 
| 1504 | 1504 | |
| 1505 | - unset($last, $jv); | |
| 1505 | + unset( $last, $jv ); | |
| 1506 | 1506 | } | 
| 1507 | 1507 | |
| 1508 | 1508 | return $vars; | 
| @@ -1515,8 +1515,8 @@ discard block | ||
| 1515 | 1515 |      public static function add_value_to_array( $name, $l1, $val, &$vars ) { | 
| 1516 | 1516 |          if ( $name == '' ) { | 
| 1517 | 1517 | $vars[] = $val; | 
| 1518 | -        } else if ( ! isset( $vars[ $l1 ] ) ) { | |
| 1519 | - $vars[ $l1 ] = $val; | |
| 1518 | +        } else if ( ! isset( $vars[$l1] ) ) { | |
| 1519 | + $vars[$l1] = $val; | |
| 1520 | 1520 | } | 
| 1521 | 1521 | } | 
| 1522 | 1522 | |
| @@ -1531,7 +1531,7 @@ discard block | ||
| 1531 | 1531 | '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() ) ), | 
| 1532 | 1532 | ); | 
| 1533 | 1533 | |
| 1534 | -        if ( ! isset( $tooltips[ $name ] ) ) { | |
| 1534 | +        if ( ! isset( $tooltips[$name] ) ) { | |
| 1535 | 1535 | return; | 
| 1536 | 1536 | } | 
| 1537 | 1537 | |
| @@ -1541,7 +1541,7 @@ discard block | ||
| 1541 | 1541 | echo ' class="frm_help"'; | 
| 1542 | 1542 | } | 
| 1543 | 1543 | |
| 1544 | - echo ' title="' . esc_attr( $tooltips[ $name ] ); | |
| 1544 | + echo ' title="' . esc_attr( $tooltips[$name] ); | |
| 1545 | 1545 | |
| 1546 | 1546 |          if ( 'open' != $class ) { | 
| 1547 | 1547 | echo '"'; | 
| @@ -1593,13 +1593,13 @@ discard block | ||
| 1593 | 1593 | } | 
| 1594 | 1594 | |
| 1595 | 1595 |  	private static function prepare_action_slashes( $val, $key, &$post_content ) { | 
| 1596 | -		if ( ! isset( $post_content[ $key ] ) ) { | |
| 1596 | +		if ( ! isset( $post_content[$key] ) ) { | |
| 1597 | 1597 | return; | 
| 1598 | 1598 | } | 
| 1599 | 1599 | |
| 1600 | 1600 |  		if ( is_array( $val ) ) { | 
| 1601 | 1601 |  			foreach ( $val as $k1 => $v1 ) { | 
| 1602 | - self::prepare_action_slashes( $v1, $k1, $post_content[ $key ] ); | |
| 1602 | + self::prepare_action_slashes( $v1, $k1, $post_content[$key] ); | |
| 1603 | 1603 | unset( $k1, $v1 ); | 
| 1604 | 1604 | } | 
| 1605 | 1605 |  		} else { | 
| @@ -1607,7 +1607,7 @@ discard block | ||
| 1607 | 1607 | $val = stripslashes( $val ); | 
| 1608 | 1608 | |
| 1609 | 1609 | // Add backslashes before double quotes and forward slashes only | 
| 1610 | - $post_content[ $key ] = addcslashes( $val, '"\\/' ); | |
| 1610 | + $post_content[$key] = addcslashes( $val, '"\\/' ); | |
| 1611 | 1611 | } | 
| 1612 | 1612 | } | 
| 1613 | 1613 | |
| @@ -1624,7 +1624,7 @@ discard block | ||
| 1624 | 1624 | $settings['post_content'] = FrmAppHelper::prepare_and_encode( $settings['post_content'] ); | 
| 1625 | 1625 | |
| 1626 | 1626 |  		if ( empty( $settings['ID'] ) ) { | 
| 1627 | - unset( $settings['ID']); | |
| 1627 | + unset( $settings['ID'] ); | |
| 1628 | 1628 | } | 
| 1629 | 1629 | |
| 1630 | 1630 | // delete all caches for this group | 
| @@ -1658,17 +1658,17 @@ discard block | ||
| 1658 | 1658 | } | 
| 1659 | 1659 | |
| 1660 | 1660 |  	public static function maybe_json_decode( $string ) { | 
| 1661 | -        if ( is_array($string) ) { | |
| 1661 | +        if ( is_array( $string ) ) { | |
| 1662 | 1662 | return $string; | 
| 1663 | 1663 | } | 
| 1664 | 1664 | |
| 1665 | - $new_string = json_decode($string, true); | |
| 1666 | -        if ( function_exists('json_last_error') ) { | |
| 1665 | + $new_string = json_decode( $string, true ); | |
| 1666 | +        if ( function_exists( 'json_last_error' ) ) { | |
| 1667 | 1667 | // php 5.3+ | 
| 1668 | 1668 |              if ( json_last_error() == JSON_ERROR_NONE ) { | 
| 1669 | 1669 | $string = $new_string; | 
| 1670 | 1670 | } | 
| 1671 | -        } else if ( isset($new_string) ) { | |
| 1671 | +        } else if ( isset( $new_string ) ) { | |
| 1672 | 1672 | // php < 5.3 fallback | 
| 1673 | 1673 | $string = $new_string; | 
| 1674 | 1674 | } | 
| @@ -1684,11 +1684,11 @@ discard block | ||
| 1684 | 1684 |  	public static function maybe_highlight_menu( $post_type ) { | 
| 1685 | 1685 | global $post, $pagenow; | 
| 1686 | 1686 | |
| 1687 | -        if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) { | |
| 1687 | +        if ( isset( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] != $post_type ) { | |
| 1688 | 1688 | return; | 
| 1689 | 1689 | } | 
| 1690 | 1690 | |
| 1691 | -        if ( is_object($post) && $post->post_type != $post_type ) { | |
| 1691 | +        if ( is_object( $post ) && $post->post_type != $post_type ) { | |
| 1692 | 1692 | return; | 
| 1693 | 1693 | } | 
| 1694 | 1694 | |
| @@ -1786,11 +1786,11 @@ discard block | ||
| 1786 | 1786 | $frm_version = self::plugin_version(); | 
| 1787 | 1787 | |
| 1788 | 1788 | // check if Formidable meets minimum requirements | 
| 1789 | -        if ( version_compare($frm_version, $min_version, '>=') ) { | |
| 1789 | +        if ( version_compare( $frm_version, $min_version, '>=' ) ) { | |
| 1790 | 1790 | return; | 
| 1791 | 1791 | } | 
| 1792 | 1792 | |
| 1793 | -        $wp_list_table = _get_list_table('WP_Plugins_List_Table'); | |
| 1793 | + $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); | |
| 1794 | 1794 | 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">' . | 
| 1795 | 1795 | __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . | 
| 1796 | 1796 | '</div></td></tr>'; | 
| @@ -1798,38 +1798,38 @@ discard block | ||
| 1798 | 1798 | |
| 1799 | 1799 |      public static function locales( $type = 'date' ) { | 
| 1800 | 1800 | $locales = array( | 
| 1801 | - 'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ), | |
| 1802 | - 'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ), | |
| 1803 | - 'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ), | |
| 1801 | + 'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ), | |
| 1802 | + 'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ), | |
| 1803 | + 'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ), | |
| 1804 | 1804 | 'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ), | 
| 1805 | - 'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ), | |
| 1806 | - 'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ), | |
| 1805 | + 'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ), | |
| 1806 | + 'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ), | |
| 1807 | 1807 | 'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ), | 
| 1808 | - 'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ), | |
| 1809 | - 'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ), | |
| 1808 | + 'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ), | |
| 1809 | + 'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ), | |
| 1810 | 1810 | 'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ), | 
| 1811 | - 'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ), | |
| 1811 | + 'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ), | |
| 1812 | 1812 | 'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ), | 
| 1813 | - 'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ), | |
| 1813 | + 'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ), | |
| 1814 | 1814 | 'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ), | 
| 1815 | - 'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ), | |
| 1815 | + 'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ), | |
| 1816 | 1816 | 'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ), | 
| 1817 | - 'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ), | |
| 1818 | - 'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ), | |
| 1819 | - 'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ), | |
| 1820 | - 'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ), | |
| 1821 | - 'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ), | |
| 1817 | + 'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ), | |
| 1818 | + 'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ), | |
| 1819 | + 'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ), | |
| 1820 | + 'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ), | |
| 1821 | + 'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ), | |
| 1822 | 1822 | 'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ), | 
| 1823 | - 'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ), | |
| 1823 | + 'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ), | |
| 1824 | 1824 | 'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ), | 
| 1825 | 1825 | 'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ), | 
| 1826 | - 'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ), | |
| 1826 | + 'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ), | |
| 1827 | 1827 | 'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ), | 
| 1828 | - 'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ), | |
| 1828 | + 'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ), | |
| 1829 | 1829 | 'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ), | 
| 1830 | - 'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ), | |
| 1831 | - 'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ), | |
| 1832 | - 'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ), | |
| 1830 | + 'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ), | |
| 1831 | + 'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ), | |
| 1832 | + 'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ), | |
| 1833 | 1833 | ); | 
| 1834 | 1834 | |
| 1835 | 1835 |          if ( $type == 'captcha' ) { | 
| @@ -1848,8 +1848,8 @@ discard block | ||
| 1848 | 1848 | ); | 
| 1849 | 1849 | } | 
| 1850 | 1850 | |
| 1851 | - $locales = array_diff_key($locales, array_flip($unset)); | |
| 1852 | -        $locales = apply_filters('frm_locales', $locales); | |
| 1851 | + $locales = array_diff_key( $locales, array_flip( $unset ) ); | |
| 1852 | + $locales = apply_filters( 'frm_locales', $locales ); | |
| 1853 | 1853 | |
| 1854 | 1854 | return $locales; | 
| 1855 | 1855 | } | 
| @@ -61,6 +61,9 @@ discard block | ||
| 61 | 61 | return $wpdb->update( $wpdb->prefix .'frm_item_metas', array( 'meta_value' => $meta_value ), $where_values ); | 
| 62 | 62 | } | 
| 63 | 63 | |
| 64 | + /** | |
| 65 | + * @param integer $entry_id | |
| 66 | + */ | |
| 64 | 67 |  	public static function update_entry_metas( $entry_id, $values ) { | 
| 65 | 68 | global $wpdb; | 
| 66 | 69 | |
| @@ -286,6 +289,7 @@ discard block | ||
| 286 | 289 | * @param string|array $where | 
| 287 | 290 | * @param string $order_by | 
| 288 | 291 | * @param string $limit | 
| 292 | + * @param boolean $unique | |
| 289 | 293 | */ | 
| 290 | 294 |  	private static function get_ids_query( $where, $order_by, $limit, $unique, $args, array &$query ) { | 
| 291 | 295 | global $wpdb; | 
| @@ -5,25 +5,25 @@ discard block | ||
| 5 | 5 | |
| 6 | 6 |  class FrmEntryMeta { | 
| 7 | 7 | |
| 8 | - /** | |
| 9 | - * @param string $meta_key | |
| 10 | - */ | |
| 8 | + /** | |
| 9 | + * @param string $meta_key | |
| 10 | + */ | |
| 11 | 11 |  	public static function add_entry_meta( $entry_id, $field_id, $meta_key = null, $meta_value ) { | 
| 12 | - global $wpdb; | |
| 12 | + global $wpdb; | |
| 13 | 13 | |
| 14 | -        if ( FrmAppHelper::is_empty_value( $meta_value ) ) { | |
| 15 | - // don't save blank fields | |
| 16 | - return; | |
| 17 | - } | |
| 14 | +		if ( FrmAppHelper::is_empty_value( $meta_value ) ) { | |
| 15 | + // don't save blank fields | |
| 16 | + return; | |
| 17 | + } | |
| 18 | 18 | |
| 19 | - $new_values = array( | |
| 19 | + $new_values = array( | |
| 20 | 20 | 'meta_value' => is_array( $meta_value ) ? serialize( array_filter( $meta_value, 'FrmAppHelper::is_not_empty_value' ) ) : trim( $meta_value ), | 
| 21 | - 'item_id' => $entry_id, | |
| 22 | - 'field_id' => $field_id, | |
| 23 | -            'created_at'    => current_time('mysql', 1), | |
| 24 | - ); | |
| 21 | + 'item_id' => $entry_id, | |
| 22 | + 'field_id' => $field_id, | |
| 23 | +			'created_at'    => current_time('mysql', 1), | |
| 24 | + ); | |
| 25 | 25 | |
| 26 | -        $new_values = apply_filters('frm_add_entry_meta', $new_values); | |
| 26 | +		$new_values = apply_filters('frm_add_entry_meta', $new_values); | |
| 27 | 27 | |
| 28 | 28 | $query_results = $wpdb->insert( $wpdb->prefix . 'frm_item_metas', $new_values ); | 
| 29 | 29 | |
| @@ -34,40 +34,40 @@ discard block | ||
| 34 | 34 | $id = 0; | 
| 35 | 35 | } | 
| 36 | 36 | |
| 37 | - return $id; | |
| 38 | - } | |
| 37 | + return $id; | |
| 38 | + } | |
| 39 | 39 | |
| 40 | - /** | |
| 41 | - * @param string $meta_key | |
| 42 | - */ | |
| 40 | + /** | |
| 41 | + * @param string $meta_key | |
| 42 | + */ | |
| 43 | 43 |  	public static function update_entry_meta( $entry_id, $field_id, $meta_key = null, $meta_value ) { | 
| 44 | -        if ( ! $field_id ) { | |
| 45 | - return false; | |
| 46 | - } | |
| 44 | +		if ( ! $field_id ) { | |
| 45 | + return false; | |
| 46 | + } | |
| 47 | 47 | |
| 48 | - global $wpdb; | |
| 48 | + global $wpdb; | |
| 49 | 49 | |
| 50 | - $values = $where_values = array( 'item_id' => $entry_id, 'field_id' => $field_id ); | |
| 51 | - $values['meta_value'] = $meta_value; | |
| 52 | -        $values = apply_filters('frm_update_entry_meta', $values); | |
| 50 | + $values = $where_values = array( 'item_id' => $entry_id, 'field_id' => $field_id ); | |
| 51 | + $values['meta_value'] = $meta_value; | |
| 52 | +		$values = apply_filters('frm_update_entry_meta', $values); | |
| 53 | 53 |  		if ( is_array($values['meta_value']) ) { | 
| 54 | 54 | $values['meta_value'] = array_filter( $values['meta_value'], 'FrmAppHelper::is_not_empty_value' ); | 
| 55 | 55 | } | 
| 56 | - $meta_value = maybe_serialize($values['meta_value']); | |
| 56 | + $meta_value = maybe_serialize($values['meta_value']); | |
| 57 | 57 | |
| 58 | - wp_cache_delete( $entry_id, 'frm_entry'); | |
| 58 | + wp_cache_delete( $entry_id, 'frm_entry'); | |
| 59 | 59 | self::clear_cache(); | 
| 60 | 60 | |
| 61 | 61 | return $wpdb->update( $wpdb->prefix . 'frm_item_metas', array( 'meta_value' => $meta_value ), $where_values ); | 
| 62 | - } | |
| 62 | + } | |
| 63 | 63 | |
| 64 | 64 |  	public static function update_entry_metas( $entry_id, $values ) { | 
| 65 | - global $wpdb; | |
| 65 | + global $wpdb; | |
| 66 | 66 | |
| 67 | 67 | $prev_values = FrmDb::get_col( $wpdb->prefix . 'frm_item_metas', array( 'item_id' => $entry_id, 'field_id !' => 0 ), 'field_id' ); | 
| 68 | 68 | |
| 69 | -        foreach ( $values as $field_id => $meta_value ) { | |
| 70 | - // set the value for the file upload field and add new tags (in Pro version) | |
| 69 | +		foreach ( $values as $field_id => $meta_value ) { | |
| 70 | + // set the value for the file upload field and add new tags (in Pro version) | |
| 71 | 71 | $meta_value = apply_filters( 'frm_prepare_data_before_db', $meta_value, $field_id, $entry_id ); | 
| 72 | 72 | |
| 73 | 73 |  			if ( $prev_values && in_array($field_id, $prev_values) ) { | 
| @@ -85,39 +85,39 @@ discard block | ||
| 85 | 85 | } | 
| 86 | 86 | } | 
| 87 | 87 | |
| 88 | -        if ( empty($prev_values) ) { | |
| 89 | - return; | |
| 90 | - } | |
| 88 | +		if ( empty($prev_values) ) { | |
| 89 | + return; | |
| 90 | + } | |
| 91 | 91 | |
| 92 | - $prev_values = array_diff($prev_values, array_keys($values)); | |
| 92 | + $prev_values = array_diff($prev_values, array_keys($values)); | |
| 93 | 93 | |
| 94 | -        if ( empty($prev_values) ) { | |
| 95 | - return; | |
| 96 | - } | |
| 94 | +		if ( empty($prev_values) ) { | |
| 95 | + return; | |
| 96 | + } | |
| 97 | 97 | |
| 98 | 98 | // prepare the query | 
| 99 | 99 | $where = array( 'item_id' => $entry_id, 'field_id' => $prev_values ); | 
| 100 | 100 | FrmDb::get_where_clause_and_values( $where ); | 
| 101 | 101 | |
| 102 | - // Delete any leftovers | |
| 103 | - $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas ' . $where['where'], $where['values'] ) ); | |
| 102 | + // Delete any leftovers | |
| 103 | + $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas ' . $where['where'], $where['values'] ) ); | |
| 104 | 104 | self::clear_cache(); | 
| 105 | - } | |
| 105 | + } | |
| 106 | 106 | |
| 107 | 107 |  	public static function duplicate_entry_metas( $old_id, $new_id ) { | 
| 108 | - $metas = self::get_entry_meta_info($old_id); | |
| 109 | -        foreach ( $metas as $meta ) { | |
| 110 | - self::add_entry_meta($new_id, $meta->field_id, null, $meta->meta_value); | |
| 111 | - unset($meta); | |
| 112 | - } | |
| 108 | + $metas = self::get_entry_meta_info($old_id); | |
| 109 | +		foreach ( $metas as $meta ) { | |
| 110 | + self::add_entry_meta($new_id, $meta->field_id, null, $meta->meta_value); | |
| 111 | + unset($meta); | |
| 112 | + } | |
| 113 | 113 | self::clear_cache(); | 
| 114 | - } | |
| 114 | + } | |
| 115 | 115 | |
| 116 | 116 |  	public static function delete_entry_meta( $entry_id, $field_id ) { | 
| 117 | - global $wpdb; | |
| 117 | + global $wpdb; | |
| 118 | 118 | self::clear_cache(); | 
| 119 | -        return $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}frm_item_metas WHERE field_id=%d AND item_id=%d", $field_id, $entry_id)); | |
| 120 | - } | |
| 119 | +		return $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}frm_item_metas WHERE field_id=%d AND item_id=%d", $field_id, $entry_id)); | |
| 120 | + } | |
| 121 | 121 | |
| 122 | 122 | /** | 
| 123 | 123 | * Clear entry meta caching | 
| @@ -142,7 +142,7 @@ discard block | ||
| 142 | 142 | } | 
| 143 | 143 | |
| 144 | 144 |  	public static function get_entry_meta_by_field( $entry_id, $field_id ) { | 
| 145 | - global $wpdb; | |
| 145 | + global $wpdb; | |
| 146 | 146 | |
| 147 | 147 |  		if ( is_object( $entry_id ) ) { | 
| 148 | 148 | $entry = $entry_id; | 
| @@ -155,24 +155,24 @@ discard block | ||
| 155 | 155 | |
| 156 | 156 |  		if ( $cached && isset( $cached->metas ) && isset( $cached->metas[ $field_id ] ) ) { | 
| 157 | 157 | $result = $cached->metas[ $field_id ]; | 
| 158 | - return stripslashes_deep($result); | |
| 159 | - } | |
| 158 | + return stripslashes_deep($result); | |
| 159 | + } | |
| 160 | 160 | |
| 161 | 161 | $get_table = $wpdb->prefix . 'frm_item_metas'; | 
| 162 | 162 | $query = array( 'item_id' => $entry_id ); | 
| 163 | -        if ( is_numeric($field_id) ) { | |
| 163 | +		if ( is_numeric($field_id) ) { | |
| 164 | 164 | $query['field_id'] = $field_id; | 
| 165 | -        } else { | |
| 165 | +		} else { | |
| 166 | 166 | $get_table .= ' it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON it.field_id=fi.id'; | 
| 167 | 167 | $query['fi.field_key'] = $field_id; | 
| 168 | - } | |
| 168 | + } | |
| 169 | 169 | |
| 170 | 170 | $result = FrmDb::get_var( $get_table, $query, 'meta_value' ); | 
| 171 | - $result = maybe_unserialize($result); | |
| 172 | - $result = stripslashes_deep($result); | |
| 171 | + $result = maybe_unserialize($result); | |
| 172 | + $result = stripslashes_deep($result); | |
| 173 | 173 | |
| 174 | - return $result; | |
| 175 | - } | |
| 174 | + return $result; | |
| 175 | + } | |
| 176 | 176 | |
| 177 | 177 |  	public static function get_entry_meta( $entry_id, $field_id ) { | 
| 178 | 178 | _deprecated_function( __FUNCTION__, '2.0', 'FrmEntryMeta::get_entry_meta_by_field' ); | 
| @@ -180,117 +180,117 @@ discard block | ||
| 180 | 180 | } | 
| 181 | 181 | |
| 182 | 182 |  	public static function get_entry_metas( $entry_id ) { | 
| 183 | - _deprecated_function( __FUNCTION__, '1.07.10'); | |
| 183 | + _deprecated_function( __FUNCTION__, '1.07.10'); | |
| 184 | 184 | |
| 185 | - global $wpdb; | |
| 185 | + global $wpdb; | |
| 186 | 186 | return FrmDb::get_col( $wpdb->prefix . 'frm_item_metas', array( 'item_id' => $entry_id ), 'meta_value' ); | 
| 187 | - } | |
| 187 | + } | |
| 188 | 188 | |
| 189 | -    public static function get_entry_metas_for_field( $field_id, $order = '', $limit = '', $args = array() ) { | |
| 189 | +	public static function get_entry_metas_for_field( $field_id, $order = '', $limit = '', $args = array() ) { | |
| 190 | 190 | $defaults = array( 'value' => false, 'unique' => false, 'stripslashes' => true, 'is_draft' => false ); | 
| 191 | - $args = wp_parse_args( $args, $defaults ); | |
| 191 | + $args = wp_parse_args( $args, $defaults ); | |
| 192 | 192 | |
| 193 | - $query = array(); | |
| 194 | - self::meta_field_query($field_id, $order, $limit, $args, $query); | |
| 195 | -        $query = implode(' ', $query); | |
| 193 | + $query = array(); | |
| 194 | + self::meta_field_query($field_id, $order, $limit, $args, $query); | |
| 195 | +		$query = implode(' ', $query); | |
| 196 | 196 | |
| 197 | 197 | $cache_key = 'entry_metas_for_field_' . $field_id . $order . $limit . maybe_serialize( $args ); | 
| 198 | - $values = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, 'get_col'); | |
| 198 | + $values = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, 'get_col'); | |
| 199 | 199 | |
| 200 | -        if ( ! $args['stripslashes'] ) { | |
| 201 | - return $values; | |
| 202 | - } | |
| 200 | +		if ( ! $args['stripslashes'] ) { | |
| 201 | + return $values; | |
| 202 | + } | |
| 203 | 203 | |
| 204 | 204 |  		foreach ( $values as $k => $v ) { | 
| 205 | 205 | $values[ $k ] = maybe_unserialize( $v ); | 
| 206 | - unset($k, $v); | |
| 207 | - } | |
| 206 | + unset($k, $v); | |
| 207 | + } | |
| 208 | 208 | |
| 209 | - return stripslashes_deep($values); | |
| 210 | - } | |
| 209 | + return stripslashes_deep($values); | |
| 210 | + } | |
| 211 | 211 | |
| 212 | - /** | |
| 213 | - * @param string $order | |
| 214 | - * @param string $limit | |
| 215 | - */ | |
| 212 | + /** | |
| 213 | + * @param string $order | |
| 214 | + * @param string $limit | |
| 215 | + */ | |
| 216 | 216 |  	private static function meta_field_query( $field_id, $order, $limit, $args, array &$query ) { | 
| 217 | - global $wpdb; | |
| 218 | - $query[] = 'SELECT'; | |
| 219 | - $query[] = $args['unique'] ? 'DISTINCT(em.meta_value)' : 'em.meta_value'; | |
| 217 | + global $wpdb; | |
| 218 | + $query[] = 'SELECT'; | |
| 219 | + $query[] = $args['unique'] ? 'DISTINCT(em.meta_value)' : 'em.meta_value'; | |
| 220 | 220 | $query[] = 'FROM ' . $wpdb->prefix . 'frm_item_metas em '; | 
| 221 | 221 | |
| 222 | -        if ( ! $args['is_draft'] ) { | |
| 222 | +		if ( ! $args['is_draft'] ) { | |
| 223 | 223 | $query[] = 'INNER JOIN ' . $wpdb->prefix . 'frm_items e ON (e.id=em.item_id)'; | 
| 224 | - } | |
| 224 | + } | |
| 225 | 225 | |
| 226 | -        if ( is_numeric($field_id) ) { | |
| 227 | -            $query[] = $wpdb->prepare('WHERE em.field_id=%d', $field_id); | |
| 228 | -        } else { | |
| 226 | +		if ( is_numeric($field_id) ) { | |
| 227 | +			$query[] = $wpdb->prepare('WHERE em.field_id=%d', $field_id); | |
| 228 | +		} else { | |
| 229 | 229 | $query[] = $wpdb->prepare( 'LEFT JOIN ' . $wpdb->prefix . 'frm_fields fi ON (em.field_id = fi.id) WHERE fi.field_key=%s', $field_id ); | 
| 230 | - } | |
| 230 | + } | |
| 231 | 231 | |
| 232 | -        if ( ! $args['is_draft'] ) { | |
| 233 | - $query[] = 'AND e.is_draft=0'; | |
| 234 | - } | |
| 232 | +		if ( ! $args['is_draft'] ) { | |
| 233 | + $query[] = 'AND e.is_draft=0'; | |
| 234 | + } | |
| 235 | 235 | |
| 236 | -        if ( $args['value'] ) { | |
| 237 | -            $query[] = $wpdb->prepare(' AND meta_value=%s', $args['value']); | |
| 238 | - } | |
| 239 | - $query[] = $order . $limit; | |
| 240 | - } | |
| 236 | +		if ( $args['value'] ) { | |
| 237 | +			$query[] = $wpdb->prepare(' AND meta_value=%s', $args['value']); | |
| 238 | + } | |
| 239 | + $query[] = $order . $limit; | |
| 240 | + } | |
| 241 | 241 | |
| 242 | 242 |  	public static function get_entry_meta_info( $entry_id ) { | 
| 243 | 243 | return FrmDb::get_results( 'frm_item_metas', array( 'item_id' => $entry_id ) ); | 
| 244 | - } | |
| 244 | + } | |
| 245 | 245 | |
| 246 | 246 |  	public static function getAll( $where = array(), $order_by = '', $limit = '', $stripslashes = false ) { | 
| 247 | - global $wpdb; | |
| 248 | - $query = 'SELECT it.*, fi.type as field_type, fi.field_key as field_key, | |
| 247 | + global $wpdb; | |
| 248 | + $query = 'SELECT it.*, fi.type as field_type, fi.field_key as field_key, | |
| 249 | 249 | fi.required as required, fi.form_id as field_form_id, fi.name as field_name, fi.options as fi_options | 
| 250 | 250 | FROM ' . $wpdb->prefix . 'frm_item_metas it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON it.field_id=fi.id' . | 
| 251 | -            FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit; | |
| 251 | +			FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit; | |
| 252 | 252 | |
| 253 | 253 | $cache_key = 'all_' . maybe_serialize( $where ) . $order_by . $limit; | 
| 254 | - $results = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, ($limit == ' LIMIT 1' ? 'get_row' : 'get_results')); | |
| 254 | + $results = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, ($limit == ' LIMIT 1' ? 'get_row' : 'get_results')); | |
| 255 | 255 | |
| 256 | -        if ( ! $results || ! $stripslashes ) { | |
| 257 | - return $results; | |
| 258 | - } | |
| 256 | +		if ( ! $results || ! $stripslashes ) { | |
| 257 | + return $results; | |
| 258 | + } | |
| 259 | 259 | |
| 260 | -        foreach ( $results as $k => $result ) { | |
| 260 | +		foreach ( $results as $k => $result ) { | |
| 261 | 261 | $results[ $k ]->meta_value = stripslashes_deep( maybe_unserialize( $result->meta_value ) ); | 
| 262 | - unset($k, $result); | |
| 263 | - } | |
| 262 | + unset($k, $result); | |
| 263 | + } | |
| 264 | 264 | |
| 265 | - return $results; | |
| 266 | - } | |
| 265 | + return $results; | |
| 266 | + } | |
| 267 | 267 | |
| 268 | -    public static function getEntryIds( $where = array(), $order_by = '', $limit = '', $unique = true, $args = array() ) { | |
| 268 | +	public static function getEntryIds( $where = array(), $order_by = '', $limit = '', $unique = true, $args = array() ) { | |
| 269 | 269 | $defaults = array( | 
| 270 | 270 | 'is_draft' => false, | 
| 271 | 271 | 'user_id' => '', | 
| 272 | 272 | 'group_by' => '', | 
| 273 | 273 | ); | 
| 274 | - $args = wp_parse_args($args, $defaults); | |
| 274 | + $args = wp_parse_args($args, $defaults); | |
| 275 | 275 | |
| 276 | - $query = array(); | |
| 277 | - self::get_ids_query($where, $order_by, $limit, $unique, $args, $query ); | |
| 278 | -        $query = implode(' ', $query); | |
| 276 | + $query = array(); | |
| 277 | + self::get_ids_query($where, $order_by, $limit, $unique, $args, $query ); | |
| 278 | +		$query = implode(' ', $query); | |
| 279 | 279 | |
| 280 | 280 | $cache_key = 'ids_' . maybe_serialize( $where ) . $order_by . 'l'. $limit . 'u'. $unique . maybe_serialize( $args ); | 
| 281 | - $results = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, ($limit == ' LIMIT 1' ? 'get_var' : 'get_col')); | |
| 281 | + $results = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, ($limit == ' LIMIT 1' ? 'get_var' : 'get_col')); | |
| 282 | 282 | |
| 283 | - return $results; | |
| 284 | - } | |
| 283 | + return $results; | |
| 284 | + } | |
| 285 | 285 | |
| 286 | - /** | |
| 287 | - * @param string|array $where | |
| 288 | - * @param string $order_by | |
| 289 | - * @param string $limit | |
| 290 | - */ | |
| 286 | + /** | |
| 287 | + * @param string|array $where | |
| 288 | + * @param string $order_by | |
| 289 | + * @param string $limit | |
| 290 | + */ | |
| 291 | 291 |  	private static function get_ids_query( $where, $order_by, $limit, $unique, $args, array &$query ) { | 
| 292 | - global $wpdb; | |
| 293 | - $query[] = 'SELECT'; | |
| 292 | + global $wpdb; | |
| 293 | + $query[] = 'SELECT'; | |
| 294 | 294 | |
| 295 | 295 | $defaults = array( 'return_parent_id' => false ); | 
| 296 | 296 | $args = array_merge( $defaults, $args ); | 
| @@ -304,88 +304,88 @@ discard block | ||
| 304 | 304 | $query[] = 'FROM ' . $wpdb->prefix . 'frm_item_metas it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON it.field_id=fi.id'; | 
| 305 | 305 | |
| 306 | 306 | $query[] = 'INNER JOIN ' . $wpdb->prefix . 'frm_items e ON (e.id=it.item_id)'; | 
| 307 | -        if ( is_array($where) ) { | |
| 308 | -            if ( ! $args['is_draft'] ) { | |
| 309 | - $where['e.is_draft'] = 0; | |
| 310 | -            } else if ( $args['is_draft'] == 1 ) { | |
| 311 | - $where['e.is_draft'] = 1; | |
| 312 | - } | |
| 313 | - | |
| 314 | -            if ( ! empty($args['user_id']) ) { | |
| 315 | - $where['e.user_id'] = $args['user_id']; | |
| 316 | - } | |
| 317 | -            $query[] = FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit; | |
| 307 | +		if ( is_array($where) ) { | |
| 308 | +			if ( ! $args['is_draft'] ) { | |
| 309 | + $where['e.is_draft'] = 0; | |
| 310 | +			} else if ( $args['is_draft'] == 1 ) { | |
| 311 | + $where['e.is_draft'] = 1; | |
| 312 | + } | |
| 313 | + | |
| 314 | +			if ( ! empty($args['user_id']) ) { | |
| 315 | + $where['e.user_id'] = $args['user_id']; | |
| 316 | + } | |
| 317 | +			$query[] = FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit; | |
| 318 | 318 | |
| 319 | 319 |  			if ( $args['group_by'] ) { | 
| 320 | 320 | $query[] = ' GROUP BY ' . sanitize_text_field( $args['group_by'] ); | 
| 321 | 321 | } | 
| 322 | - return; | |
| 323 | - } | |
| 322 | + return; | |
| 323 | + } | |
| 324 | 324 | |
| 325 | 325 | $draft_where = $user_where = ''; | 
| 326 | -        if ( ! $args['is_draft'] ) { | |
| 326 | +		if ( ! $args['is_draft'] ) { | |
| 327 | 327 | $draft_where = $wpdb->prepare( ' AND e.is_draft=%d', 0 ); | 
| 328 | -        } else if ( $args['is_draft'] == 1 ) { | |
| 328 | +		} else if ( $args['is_draft'] == 1 ) { | |
| 329 | 329 | $draft_where = $wpdb->prepare( ' AND e.is_draft=%d', 1 ); | 
| 330 | - } | |
| 330 | + } | |
| 331 | 331 | |
| 332 | -        if ( ! empty($args['user_id']) ) { | |
| 333 | -            $user_where = $wpdb->prepare(' AND e.user_id=%d', $args['user_id']); | |
| 334 | - } | |
| 332 | +		if ( ! empty($args['user_id']) ) { | |
| 333 | +			$user_where = $wpdb->prepare(' AND e.user_id=%d', $args['user_id']); | |
| 334 | + } | |
| 335 | 335 | |
| 336 | -        if ( strpos($where, ' GROUP BY ') ) { | |
| 337 | - // don't inject WHERE filtering after GROUP BY | |
| 338 | -            $parts = explode(' GROUP BY ', $where); | |
| 339 | - $where = $parts[0]; | |
| 340 | - $where .= $draft_where . $user_where; | |
| 336 | +		if ( strpos($where, ' GROUP BY ') ) { | |
| 337 | + // don't inject WHERE filtering after GROUP BY | |
| 338 | +			$parts = explode(' GROUP BY ', $where); | |
| 339 | + $where = $parts[0]; | |
| 340 | + $where .= $draft_where . $user_where; | |
| 341 | 341 | $where .= ' GROUP BY ' . $parts[1]; | 
| 342 | -        } else { | |
| 343 | - $where .= $draft_where . $user_where; | |
| 344 | - } | |
| 342 | +		} else { | |
| 343 | + $where .= $draft_where . $user_where; | |
| 344 | + } | |
| 345 | 345 | |
| 346 | 346 | // The query has already been prepared | 
| 347 | 347 |  		$query[] = FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit; | 
| 348 | - } | |
| 348 | + } | |
| 349 | 349 | |
| 350 | -    public static function search_entry_metas( $search, $field_id = '', $operator ) { | |
| 350 | +	public static function search_entry_metas( $search, $field_id = '', $operator ) { | |
| 351 | 351 | $cache_key = 'search_' . maybe_serialize( $search ) . $field_id . $operator; | 
| 352 | - $results = wp_cache_get($cache_key, 'frm_entry'); | |
| 353 | -        if ( false !== $results ) { | |
| 354 | - return $results; | |
| 355 | - } | |
| 352 | + $results = wp_cache_get($cache_key, 'frm_entry'); | |
| 353 | +		if ( false !== $results ) { | |
| 354 | + return $results; | |
| 355 | + } | |
| 356 | 356 | |
| 357 | - global $wpdb; | |
| 357 | + global $wpdb; | |
| 358 | 358 |  		if ( is_array( $search ) ) { | 
| 359 | - $where = ''; | |
| 359 | + $where = ''; | |
| 360 | 360 |  			foreach ( $search as $field => $value ) { | 
| 361 | 361 |  				if ( $value <= 0 || ! in_array( $field, array( 'year', 'month', 'day' ) ) ) { | 
| 362 | - continue; | |
| 363 | - } | |
| 362 | + continue; | |
| 363 | + } | |
| 364 | 364 | |
| 365 | -                switch ( $field ) { | |
| 366 | - case 'year': | |
| 365 | +				switch ( $field ) { | |
| 366 | + case 'year': | |
| 367 | 367 | $value = '%' . $value; | 
| 368 | - break; | |
| 369 | - case 'month': | |
| 370 | - $value .= '%'; | |
| 371 | - break; | |
| 372 | - case 'day': | |
| 368 | + break; | |
| 369 | + case 'month': | |
| 370 | + $value .= '%'; | |
| 371 | + break; | |
| 372 | + case 'day': | |
| 373 | 373 | $value = '%' . $value . '%'; | 
| 374 | - } | |
| 374 | + } | |
| 375 | 375 |  				$where .= $wpdb->prepare(' meta_value ' . $operator . ' %s and', $value ); | 
| 376 | - } | |
| 377 | -            $where .= $wpdb->prepare(' field_id=%d', $field_id); | |
| 376 | + } | |
| 377 | +			$where .= $wpdb->prepare(' field_id=%d', $field_id); | |
| 378 | 378 | $query = 'SELECT DISTINCT item_id FROM ' . $wpdb->prefix . 'frm_item_metas' . FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ); | 
| 379 | -        } else { | |
| 379 | +		} else { | |
| 380 | 380 |  			if ( $operator == 'LIKE' ) { | 
| 381 | - $search = '%' . $search . '%'; | |
| 381 | + $search = '%' . $search . '%'; | |
| 382 | 382 | } | 
| 383 | -            $query = $wpdb->prepare("SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas WHERE meta_value {$operator} %s and field_id = %d", $search, $field_id); | |
| 384 | - } | |
| 383 | +			$query = $wpdb->prepare("SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas WHERE meta_value {$operator} %s and field_id = %d", $search, $field_id); | |
| 384 | + } | |
| 385 | 385 | |
| 386 | - $results = $wpdb->get_col($query, 0); | |
| 387 | - wp_cache_set($cache_key, $results, 'frm_entry', 300); | |
| 386 | + $results = $wpdb->get_col($query, 0); | |
| 387 | + wp_cache_set($cache_key, $results, 'frm_entry', 300); | |
| 388 | 388 | |
| 389 | - return $results; | |
| 390 | - } | |
| 389 | + return $results; | |
| 390 | + } | |
| 391 | 391 | } | 
| @@ -1,5 +1,5 @@ discard block | ||
| 1 | 1 | <?php | 
| 2 | -if ( ! defined('ABSPATH') ) { | |
| 2 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 3 | 3 | die( 'You are not allowed to call this page directly.' ); | 
| 4 | 4 | } | 
| 5 | 5 | |
| @@ -20,10 +20,10 @@ discard block | ||
| 20 | 20 | 'meta_value' => is_array( $meta_value ) ? serialize( array_filter( $meta_value, 'FrmAppHelper::is_not_empty_value' ) ) : trim( $meta_value ), | 
| 21 | 21 | 'item_id' => $entry_id, | 
| 22 | 22 | 'field_id' => $field_id, | 
| 23 | -            'created_at'    => current_time('mysql', 1), | |
| 23 | + 'created_at' => current_time( 'mysql', 1 ), | |
| 24 | 24 | ); | 
| 25 | 25 | |
| 26 | -        $new_values = apply_filters('frm_add_entry_meta', $new_values); | |
| 26 | + $new_values = apply_filters( 'frm_add_entry_meta', $new_values ); | |
| 27 | 27 | |
| 28 | 28 | $query_results = $wpdb->insert( $wpdb->prefix . 'frm_item_metas', $new_values ); | 
| 29 | 29 | |
| @@ -49,13 +49,13 @@ discard block | ||
| 49 | 49 | |
| 50 | 50 | $values = $where_values = array( 'item_id' => $entry_id, 'field_id' => $field_id ); | 
| 51 | 51 | $values['meta_value'] = $meta_value; | 
| 52 | -        $values = apply_filters('frm_update_entry_meta', $values); | |
| 53 | -		if ( is_array($values['meta_value']) ) { | |
| 52 | + $values = apply_filters( 'frm_update_entry_meta', $values ); | |
| 53 | +		if ( is_array( $values['meta_value'] ) ) { | |
| 54 | 54 | $values['meta_value'] = array_filter( $values['meta_value'], 'FrmAppHelper::is_not_empty_value' ); | 
| 55 | 55 | } | 
| 56 | - $meta_value = maybe_serialize($values['meta_value']); | |
| 56 | + $meta_value = maybe_serialize( $values['meta_value'] ); | |
| 57 | 57 | |
| 58 | - wp_cache_delete( $entry_id, 'frm_entry'); | |
| 58 | + wp_cache_delete( $entry_id, 'frm_entry' ); | |
| 59 | 59 | self::clear_cache(); | 
| 60 | 60 | |
| 61 | 61 | return $wpdb->update( $wpdb->prefix . 'frm_item_metas', array( 'meta_value' => $meta_value ), $where_values ); | 
| @@ -70,11 +70,11 @@ discard block | ||
| 70 | 70 | // set the value for the file upload field and add new tags (in Pro version) | 
| 71 | 71 | $meta_value = apply_filters( 'frm_prepare_data_before_db', $meta_value, $field_id, $entry_id ); | 
| 72 | 72 | |
| 73 | -			if ( $prev_values && in_array($field_id, $prev_values) ) { | |
| 73 | +			if ( $prev_values && in_array( $field_id, $prev_values ) ) { | |
| 74 | 74 | |
| 75 | 75 |  				if ( ( is_array( $meta_value ) && empty( $meta_value ) ) || ( ! is_array( $meta_value ) && trim( $meta_value ) == '' ) ) { | 
| 76 | 76 | // remove blank fields | 
| 77 | - unset( $values[ $field_id ] ); | |
| 77 | + unset( $values[$field_id] ); | |
| 78 | 78 |  				} else { | 
| 79 | 79 | // if value exists, then update it | 
| 80 | 80 | self::update_entry_meta( $entry_id, $field_id, '', $meta_value ); | 
| @@ -85,13 +85,13 @@ discard block | ||
| 85 | 85 | } | 
| 86 | 86 | } | 
| 87 | 87 | |
| 88 | -        if ( empty($prev_values) ) { | |
| 88 | +        if ( empty( $prev_values ) ) { | |
| 89 | 89 | return; | 
| 90 | 90 | } | 
| 91 | 91 | |
| 92 | - $prev_values = array_diff($prev_values, array_keys($values)); | |
| 92 | + $prev_values = array_diff( $prev_values, array_keys( $values ) ); | |
| 93 | 93 | |
| 94 | -        if ( empty($prev_values) ) { | |
| 94 | +        if ( empty( $prev_values ) ) { | |
| 95 | 95 | return; | 
| 96 | 96 | } | 
| 97 | 97 | |
| @@ -105,10 +105,10 @@ discard block | ||
| 105 | 105 | } | 
| 106 | 106 | |
| 107 | 107 |  	public static function duplicate_entry_metas( $old_id, $new_id ) { | 
| 108 | - $metas = self::get_entry_meta_info($old_id); | |
| 108 | + $metas = self::get_entry_meta_info( $old_id ); | |
| 109 | 109 |          foreach ( $metas as $meta ) { | 
| 110 | - self::add_entry_meta($new_id, $meta->field_id, null, $meta->meta_value); | |
| 111 | - unset($meta); | |
| 110 | + self::add_entry_meta( $new_id, $meta->field_id, null, $meta->meta_value ); | |
| 111 | + unset( $meta ); | |
| 112 | 112 | } | 
| 113 | 113 | self::clear_cache(); | 
| 114 | 114 | } | 
| @@ -116,7 +116,7 @@ discard block | ||
| 116 | 116 |  	public static function delete_entry_meta( $entry_id, $field_id ) { | 
| 117 | 117 | global $wpdb; | 
| 118 | 118 | self::clear_cache(); | 
| 119 | -        return $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}frm_item_metas WHERE field_id=%d AND item_id=%d", $field_id, $entry_id)); | |
| 119 | +        return $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_item_metas WHERE field_id=%d AND item_id=%d", $field_id, $entry_id ) ); | |
| 120 | 120 | } | 
| 121 | 121 | |
| 122 | 122 | /** | 
| @@ -135,7 +135,7 @@ discard block | ||
| 135 | 135 | */ | 
| 136 | 136 |  	public static function get_meta_value( $entry, $field_id ) { | 
| 137 | 137 |  		if ( isset( $entry->metas ) ) { | 
| 138 | - return isset( $entry->metas[ $field_id ] ) ? $entry->metas[ $field_id ] : false; | |
| 138 | + return isset( $entry->metas[$field_id] ) ? $entry->metas[$field_id] : false; | |
| 139 | 139 |  		} else { | 
| 140 | 140 | return self::get_entry_meta_by_field( $entry->id, $field_id ); | 
| 141 | 141 | } | 
| @@ -153,14 +153,14 @@ discard block | ||
| 153 | 153 | $cached = FrmAppHelper::check_cache( $entry_id, 'frm_entry' ); | 
| 154 | 154 | } | 
| 155 | 155 | |
| 156 | -		if ( $cached && isset( $cached->metas ) && isset( $cached->metas[ $field_id ] ) ) { | |
| 157 | - $result = $cached->metas[ $field_id ]; | |
| 158 | - return stripslashes_deep($result); | |
| 156 | +		if ( $cached && isset( $cached->metas ) && isset( $cached->metas[$field_id] ) ) { | |
| 157 | + $result = $cached->metas[$field_id]; | |
| 158 | + return stripslashes_deep( $result ); | |
| 159 | 159 | } | 
| 160 | 160 | |
| 161 | 161 | $get_table = $wpdb->prefix . 'frm_item_metas'; | 
| 162 | 162 | $query = array( 'item_id' => $entry_id ); | 
| 163 | -        if ( is_numeric($field_id) ) { | |
| 163 | +        if ( is_numeric( $field_id ) ) { | |
| 164 | 164 | $query['field_id'] = $field_id; | 
| 165 | 165 |          } else { | 
| 166 | 166 | $get_table .= ' it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON it.field_id=fi.id'; | 
| @@ -168,8 +168,8 @@ discard block | ||
| 168 | 168 | } | 
| 169 | 169 | |
| 170 | 170 | $result = FrmDb::get_var( $get_table, $query, 'meta_value' ); | 
| 171 | - $result = maybe_unserialize($result); | |
| 172 | - $result = stripslashes_deep($result); | |
| 171 | + $result = maybe_unserialize( $result ); | |
| 172 | + $result = stripslashes_deep( $result ); | |
| 173 | 173 | |
| 174 | 174 | return $result; | 
| 175 | 175 | } | 
| @@ -180,7 +180,7 @@ discard block | ||
| 180 | 180 | } | 
| 181 | 181 | |
| 182 | 182 |  	public static function get_entry_metas( $entry_id ) { | 
| 183 | - _deprecated_function( __FUNCTION__, '1.07.10'); | |
| 183 | + _deprecated_function( __FUNCTION__, '1.07.10' ); | |
| 184 | 184 | |
| 185 | 185 | global $wpdb; | 
| 186 | 186 | return FrmDb::get_col( $wpdb->prefix . 'frm_item_metas', array( 'item_id' => $entry_id ), 'meta_value' ); | 
| @@ -191,22 +191,22 @@ discard block | ||
| 191 | 191 | $args = wp_parse_args( $args, $defaults ); | 
| 192 | 192 | |
| 193 | 193 | $query = array(); | 
| 194 | - self::meta_field_query($field_id, $order, $limit, $args, $query); | |
| 195 | -        $query = implode(' ', $query); | |
| 194 | + self::meta_field_query( $field_id, $order, $limit, $args, $query ); | |
| 195 | + $query = implode( ' ', $query ); | |
| 196 | 196 | |
| 197 | 197 | $cache_key = 'entry_metas_for_field_' . $field_id . $order . $limit . maybe_serialize( $args ); | 
| 198 | - $values = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, 'get_col'); | |
| 198 | + $values = FrmAppHelper::check_cache( $cache_key, 'frm_entry', $query, 'get_col' ); | |
| 199 | 199 | |
| 200 | 200 |          if ( ! $args['stripslashes'] ) { | 
| 201 | 201 | return $values; | 
| 202 | 202 | } | 
| 203 | 203 | |
| 204 | 204 |  		foreach ( $values as $k => $v ) { | 
| 205 | - $values[ $k ] = maybe_unserialize( $v ); | |
| 206 | - unset($k, $v); | |
| 205 | + $values[$k] = maybe_unserialize( $v ); | |
| 206 | + unset( $k, $v ); | |
| 207 | 207 | } | 
| 208 | 208 | |
| 209 | - return stripslashes_deep($values); | |
| 209 | + return stripslashes_deep( $values ); | |
| 210 | 210 | } | 
| 211 | 211 | |
| 212 | 212 | /** | 
| @@ -223,8 +223,8 @@ discard block | ||
| 223 | 223 | $query[] = 'INNER JOIN ' . $wpdb->prefix . 'frm_items e ON (e.id=em.item_id)'; | 
| 224 | 224 | } | 
| 225 | 225 | |
| 226 | -        if ( is_numeric($field_id) ) { | |
| 227 | -            $query[] = $wpdb->prepare('WHERE em.field_id=%d', $field_id); | |
| 226 | +        if ( is_numeric( $field_id ) ) { | |
| 227 | + $query[] = $wpdb->prepare( 'WHERE em.field_id=%d', $field_id ); | |
| 228 | 228 |          } else { | 
| 229 | 229 | $query[] = $wpdb->prepare( 'LEFT JOIN ' . $wpdb->prefix . 'frm_fields fi ON (em.field_id = fi.id) WHERE fi.field_key=%s', $field_id ); | 
| 230 | 230 | } | 
| @@ -234,7 +234,7 @@ discard block | ||
| 234 | 234 | } | 
| 235 | 235 | |
| 236 | 236 |          if ( $args['value'] ) { | 
| 237 | -            $query[] = $wpdb->prepare(' AND meta_value=%s', $args['value']); | |
| 237 | + $query[] = $wpdb->prepare( ' AND meta_value=%s', $args['value'] ); | |
| 238 | 238 | } | 
| 239 | 239 | $query[] = $order . $limit; | 
| 240 | 240 | } | 
| @@ -248,18 +248,18 @@ discard block | ||
| 248 | 248 | $query = 'SELECT it.*, fi.type as field_type, fi.field_key as field_key, | 
| 249 | 249 | fi.required as required, fi.form_id as field_form_id, fi.name as field_name, fi.options as fi_options | 
| 250 | 250 | FROM ' . $wpdb->prefix . 'frm_item_metas it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON it.field_id=fi.id' . | 
| 251 | -            FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit; | |
| 251 | + FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit; | |
| 252 | 252 | |
| 253 | 253 | $cache_key = 'all_' . maybe_serialize( $where ) . $order_by . $limit; | 
| 254 | - $results = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, ($limit == ' LIMIT 1' ? 'get_row' : 'get_results')); | |
| 254 | + $results = FrmAppHelper::check_cache( $cache_key, 'frm_entry', $query, ( $limit == ' LIMIT 1' ? 'get_row' : 'get_results' ) ); | |
| 255 | 255 | |
| 256 | 256 |          if ( ! $results || ! $stripslashes ) { | 
| 257 | 257 | return $results; | 
| 258 | 258 | } | 
| 259 | 259 | |
| 260 | 260 |          foreach ( $results as $k => $result ) { | 
| 261 | - $results[ $k ]->meta_value = stripslashes_deep( maybe_unserialize( $result->meta_value ) ); | |
| 262 | - unset($k, $result); | |
| 261 | + $results[$k]->meta_value = stripslashes_deep( maybe_unserialize( $result->meta_value ) ); | |
| 262 | + unset( $k, $result ); | |
| 263 | 263 | } | 
| 264 | 264 | |
| 265 | 265 | return $results; | 
| @@ -271,14 +271,14 @@ discard block | ||
| 271 | 271 | 'user_id' => '', | 
| 272 | 272 | 'group_by' => '', | 
| 273 | 273 | ); | 
| 274 | - $args = wp_parse_args($args, $defaults); | |
| 274 | + $args = wp_parse_args( $args, $defaults ); | |
| 275 | 275 | |
| 276 | 276 | $query = array(); | 
| 277 | - self::get_ids_query($where, $order_by, $limit, $unique, $args, $query ); | |
| 278 | -        $query = implode(' ', $query); | |
| 277 | + self::get_ids_query( $where, $order_by, $limit, $unique, $args, $query ); | |
| 278 | + $query = implode( ' ', $query ); | |
| 279 | 279 | |
| 280 | 280 | $cache_key = 'ids_' . maybe_serialize( $where ) . $order_by . 'l' . $limit . 'u' . $unique . maybe_serialize( $args ); | 
| 281 | - $results = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, ($limit == ' LIMIT 1' ? 'get_var' : 'get_col')); | |
| 281 | + $results = FrmAppHelper::check_cache( $cache_key, 'frm_entry', $query, ( $limit == ' LIMIT 1' ? 'get_var' : 'get_col' ) ); | |
| 282 | 282 | |
| 283 | 283 | return $results; | 
| 284 | 284 | } | 
| @@ -304,17 +304,17 @@ discard block | ||
| 304 | 304 | $query[] = 'FROM ' . $wpdb->prefix . 'frm_item_metas it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON it.field_id=fi.id'; | 
| 305 | 305 | |
| 306 | 306 | $query[] = 'INNER JOIN ' . $wpdb->prefix . 'frm_items e ON (e.id=it.item_id)'; | 
| 307 | -        if ( is_array($where) ) { | |
| 307 | +        if ( is_array( $where ) ) { | |
| 308 | 308 |              if ( ! $args['is_draft'] ) { | 
| 309 | 309 | $where['e.is_draft'] = 0; | 
| 310 | 310 |              } else if ( $args['is_draft'] == 1 ) { | 
| 311 | 311 | $where['e.is_draft'] = 1; | 
| 312 | 312 | } | 
| 313 | 313 | |
| 314 | -            if ( ! empty($args['user_id']) ) { | |
| 314 | +            if ( ! empty( $args['user_id'] ) ) { | |
| 315 | 315 | $where['e.user_id'] = $args['user_id']; | 
| 316 | 316 | } | 
| 317 | -            $query[] = FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit; | |
| 317 | + $query[] = FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit; | |
| 318 | 318 | |
| 319 | 319 |  			if ( $args['group_by'] ) { | 
| 320 | 320 | $query[] = ' GROUP BY ' . sanitize_text_field( $args['group_by'] ); | 
| @@ -329,13 +329,13 @@ discard block | ||
| 329 | 329 | $draft_where = $wpdb->prepare( ' AND e.is_draft=%d', 1 ); | 
| 330 | 330 | } | 
| 331 | 331 | |
| 332 | -        if ( ! empty($args['user_id']) ) { | |
| 333 | -            $user_where = $wpdb->prepare(' AND e.user_id=%d', $args['user_id']); | |
| 332 | +        if ( ! empty( $args['user_id'] ) ) { | |
| 333 | + $user_where = $wpdb->prepare( ' AND e.user_id=%d', $args['user_id'] ); | |
| 334 | 334 | } | 
| 335 | 335 | |
| 336 | -        if ( strpos($where, ' GROUP BY ') ) { | |
| 336 | +        if ( strpos( $where, ' GROUP BY ' ) ) { | |
| 337 | 337 | // don't inject WHERE filtering after GROUP BY | 
| 338 | -            $parts = explode(' GROUP BY ', $where); | |
| 338 | + $parts = explode( ' GROUP BY ', $where ); | |
| 339 | 339 | $where = $parts[0]; | 
| 340 | 340 | $where .= $draft_where . $user_where; | 
| 341 | 341 | $where .= ' GROUP BY ' . $parts[1]; | 
| @@ -344,12 +344,12 @@ discard block | ||
| 344 | 344 | } | 
| 345 | 345 | |
| 346 | 346 | // The query has already been prepared | 
| 347 | -		$query[] = FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit; | |
| 347 | + $query[] = FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit; | |
| 348 | 348 | } | 
| 349 | 349 | |
| 350 | 350 |      public static function search_entry_metas( $search, $field_id = '', $operator ) { | 
| 351 | 351 | $cache_key = 'search_' . maybe_serialize( $search ) . $field_id . $operator; | 
| 352 | - $results = wp_cache_get($cache_key, 'frm_entry'); | |
| 352 | + $results = wp_cache_get( $cache_key, 'frm_entry' ); | |
| 353 | 353 |          if ( false !== $results ) { | 
| 354 | 354 | return $results; | 
| 355 | 355 | } | 
| @@ -372,19 +372,19 @@ discard block | ||
| 372 | 372 | case 'day': | 
| 373 | 373 | $value = '%' . $value . '%'; | 
| 374 | 374 | } | 
| 375 | -				$where .= $wpdb->prepare(' meta_value ' . $operator . ' %s and', $value ); | |
| 375 | + $where .= $wpdb->prepare( ' meta_value ' . $operator . ' %s and', $value ); | |
| 376 | 376 | } | 
| 377 | -            $where .= $wpdb->prepare(' field_id=%d', $field_id); | |
| 377 | + $where .= $wpdb->prepare( ' field_id=%d', $field_id ); | |
| 378 | 378 | $query = 'SELECT DISTINCT item_id FROM ' . $wpdb->prefix . 'frm_item_metas' . FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ); | 
| 379 | 379 |          } else { | 
| 380 | 380 |  			if ( $operator == 'LIKE' ) { | 
| 381 | 381 | $search = '%' . $search . '%'; | 
| 382 | 382 | } | 
| 383 | -            $query = $wpdb->prepare("SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas WHERE meta_value {$operator} %s and field_id = %d", $search, $field_id); | |
| 383 | +            $query = $wpdb->prepare( "SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas WHERE meta_value {$operator} %s and field_id = %d", $search, $field_id ); | |
| 384 | 384 | } | 
| 385 | 385 | |
| 386 | - $results = $wpdb->get_col($query, 0); | |
| 387 | - wp_cache_set($cache_key, $results, 'frm_entry', 300); | |
| 386 | + $results = $wpdb->get_col( $query, 0 ); | |
| 387 | + wp_cache_set( $cache_key, $results, 'frm_entry', 300 ); | |
| 388 | 388 | |
| 389 | 389 | return $results; | 
| 390 | 390 | } | 
| @@ -4,7 +4,7 @@ | ||
| 4 | 4 | public $id = 0; // the id of the post | 
| 5 | 5 | |
| 6 | 6 | /** | 
| 7 | - * @param int|string $id The id of the stylsheet or 'default' | |
| 7 | + * @param integer $id The id of the stylsheet or 'default' | |
| 8 | 8 | */ | 
| 9 | 9 |  	public function __construct( $id = 0 ) { | 
| 10 | 10 | $this->id = $id; | 
| @@ -1,52 +1,52 @@ discard block | ||
| 1 | 1 | <?php | 
| 2 | 2 |  class FrmStyle { | 
| 3 | - public $number = false; // Unique ID number of the current instance. | |
| 3 | + public $number = false; // Unique ID number of the current instance. | |
| 4 | 4 | public $id = 0; // the id of the post | 
| 5 | 5 | |
| 6 | 6 | /** | 
| 7 | 7 | * @param int|string $id The id of the stylsheet or 'default' | 
| 8 | 8 | */ | 
| 9 | 9 |  	public function __construct( $id = 0 ) { | 
| 10 | - $this->id = $id; | |
| 11 | - } | |
| 10 | + $this->id = $id; | |
| 11 | + } | |
| 12 | 12 | |
| 13 | -    public function get_new() { | |
| 13 | +	public function get_new() { | |
| 14 | 14 | $this->id = 0; | 
| 15 | 15 | |
| 16 | - $max_slug_value = pow(36, 6); | |
| 17 | - $min_slug_value = 37; // we want to have at least 2 characters in the slug | |
| 18 | - $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); | |
| 19 | - | |
| 20 | - $style = array( | |
| 21 | - 'post_type' => FrmStylesController::$post_type, | |
| 22 | - 'ID' => '', | |
| 23 | - 'post_title' => __( 'New Style', 'formidable' ), | |
| 24 | - 'post_name' => $key, | |
| 25 | - 'post_content' => $this->get_defaults(), | |
| 26 | - 'menu_order' => '', | |
| 27 | - 'post_status' => 'publish', | |
| 28 | - ); | |
| 16 | + $max_slug_value = pow(36, 6); | |
| 17 | + $min_slug_value = 37; // we want to have at least 2 characters in the slug | |
| 18 | + $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); | |
| 19 | + | |
| 20 | + $style = array( | |
| 21 | + 'post_type' => FrmStylesController::$post_type, | |
| 22 | + 'ID' => '', | |
| 23 | + 'post_title' => __( 'New Style', 'formidable' ), | |
| 24 | + 'post_name' => $key, | |
| 25 | + 'post_content' => $this->get_defaults(), | |
| 26 | + 'menu_order' => '', | |
| 27 | + 'post_status' => 'publish', | |
| 28 | + ); | |
| 29 | 29 | |
| 30 | - return (object) $style; | |
| 31 | - } | |
| 30 | + return (object) $style; | |
| 31 | + } | |
| 32 | 32 | |
| 33 | 33 |  	public function save( $settings ) { | 
| 34 | 34 | return FrmAppHelper::save_settings( $settings, 'frm_styles' ); | 
| 35 | - } | |
| 35 | + } | |
| 36 | 36 | |
| 37 | 37 |  	public function duplicate( $id ) { | 
| 38 | - // duplicating is a pro feature | |
| 39 | - } | |
| 38 | + // duplicating is a pro feature | |
| 39 | + } | |
| 40 | 40 | |
| 41 | -    public function update( $id = 'default' ) { | |
| 41 | +	public function update( $id = 'default' ) { | |
| 42 | 42 | $all_instances = $this->get_all(); | 
| 43 | 43 | |
| 44 | 44 |   		if ( empty($id) ) { | 
| 45 | - $new_style = (array) $this->get_new(); | |
| 46 | - $all_instances[] = $new_style; | |
| 45 | + $new_style = (array) $this->get_new(); | |
| 46 | + $all_instances[] = $new_style; | |
| 47 | 47 | } | 
| 48 | 48 | |
| 49 | - $action_ids = array(); | |
| 49 | + $action_ids = array(); | |
| 50 | 50 | |
| 51 | 51 |   		foreach ( $all_instances as $number => $new_instance ) { | 
| 52 | 52 | $new_instance = stripslashes_deep( (array) $new_instance); | 
| @@ -54,40 +54,40 @@ discard block | ||
| 54 | 54 |   			if ( $id != $this->id || ! $_POST || ! isset($_POST['frm_style_setting']) ) { | 
| 55 | 55 | $all_instances[ $number ] = $new_instance; | 
| 56 | 56 | |
| 57 | - 			    if ( $new_instance['menu_order'] && $_POST && empty($_POST['prev_menu_order']) && isset($_POST['frm_style_setting']['menu_order']) ) { | |
| 58 | - // this style was set to default, so remove default setting on previous default style | |
| 59 | - $new_instance['menu_order'] = 0; | |
| 60 | - $action_ids[] = $this->save($new_instance); | |
| 61 | - } | |
| 57 | + 				if ( $new_instance['menu_order'] && $_POST && empty($_POST['prev_menu_order']) && isset($_POST['frm_style_setting']['menu_order']) ) { | |
| 58 | + // this style was set to default, so remove default setting on previous default style | |
| 59 | + $new_instance['menu_order'] = 0; | |
| 60 | + $action_ids[] = $this->save($new_instance); | |
| 61 | + } | |
| 62 | 62 | |
| 63 | - // don't continue if not saving this style | |
| 64 | - continue; | |
| 63 | + // don't continue if not saving this style | |
| 64 | + continue; | |
| 65 | 65 | } | 
| 66 | 66 | |
| 67 | 67 | $new_instance['post_title'] = sanitize_text_field( $_POST['frm_style_setting']['post_title'] ); | 
| 68 | 68 | $new_instance['post_content'] = $_POST['frm_style_setting']['post_content']; | 
| 69 | 69 | $new_instance['post_type'] = FrmStylesController::$post_type; | 
| 70 | - $new_instance['post_status'] = 'publish'; | |
| 70 | + $new_instance['post_status'] = 'publish'; | |
| 71 | 71 | $new_instance['menu_order'] = isset( $_POST['frm_style_setting']['menu_order'] ) ? absint( $_POST['frm_style_setting']['menu_order'] ) : 0; | 
| 72 | 72 | |
| 73 | -            if ( empty($id) ) { | |
| 74 | - $new_instance['post_name'] = $new_instance['post_title']; | |
| 75 | - } | |
| 73 | +			if ( empty($id) ) { | |
| 74 | + $new_instance['post_name'] = $new_instance['post_title']; | |
| 75 | + } | |
| 76 | 76 | |
| 77 | - $default_settings = $this->get_defaults(); | |
| 77 | + $default_settings = $this->get_defaults(); | |
| 78 | 78 | |
| 79 | -            foreach ( $default_settings as $setting => $default ) { | |
| 79 | +			foreach ( $default_settings as $setting => $default ) { | |
| 80 | 80 |  				if ( strpos( $setting, 'color' ) !== false || in_array( $setting, array( 'error_bg', 'error_border', 'error_text' ) ) ) { | 
| 81 | - //if is a color | |
| 81 | + //if is a color | |
| 82 | 82 | $new_instance['post_content'][ $setting ] = str_replace( '#', '', $new_instance['post_content'][ $setting ] ); | 
| 83 | 83 |  				} else if ( in_array( $setting, array( 'submit_style', 'important_style', 'auto_width' ) ) && ! isset( $new_instance['post_content'][ $setting ] ) ) { | 
| 84 | 84 | $new_instance['post_content'][ $setting ] = 0; | 
| 85 | - } | |
| 86 | - } | |
| 85 | + } | |
| 86 | + } | |
| 87 | 87 | |
| 88 | 88 | $all_instances[ $number ] = $new_instance; | 
| 89 | 89 | |
| 90 | - $action_ids[] = $this->save($new_instance); | |
| 90 | + $action_ids[] = $this->save($new_instance); | |
| 91 | 91 | |
| 92 | 92 | } | 
| 93 | 93 | |
| @@ -96,75 +96,75 @@ discard block | ||
| 96 | 96 | return $action_ids; | 
| 97 | 97 | } | 
| 98 | 98 | |
| 99 | - /** | |
| 100 | - * Create static css file | |
| 101 | - */ | |
| 99 | + /** | |
| 100 | + * Create static css file | |
| 101 | + */ | |
| 102 | 102 |  	public function save_settings( $styles ) { | 
| 103 | 103 | $filename = FrmAppHelper::plugin_path() . '/css/custom_theme.css.php'; | 
| 104 | 104 |  		update_option( 'frm_last_style_update', date('njGi') ); | 
| 105 | 105 | |
| 106 | -        if ( ! is_file($filename) ) { | |
| 107 | - return; | |
| 108 | - } | |
| 106 | +		if ( ! is_file($filename) ) { | |
| 107 | + return; | |
| 108 | + } | |
| 109 | 109 | |
| 110 | - $defaults = $this->get_defaults(); | |
| 111 | - $uploads = wp_upload_dir(); | |
| 110 | + $defaults = $this->get_defaults(); | |
| 111 | + $uploads = wp_upload_dir(); | |
| 112 | 112 | $target_path = $uploads['basedir'] . '/formidable'; | 
| 113 | 113 | $needed_dirs = array( $target_path, $target_path . '/css' ); | 
| 114 | - $dirs_exist = true; | |
| 114 | + $dirs_exist = true; | |
| 115 | 115 | |
| 116 | - $saving = true; | |
| 116 | + $saving = true; | |
| 117 | 117 | $css = '/* ' . __( 'WARNING: Any changes made to this file will be lost when your Formidable settings are updated', 'formidable' ) . ' */' . "\n"; | 
| 118 | 118 | |
| 119 | - ob_start(); | |
| 120 | - $frm_style = $this; | |
| 121 | - include($filename); | |
| 119 | + ob_start(); | |
| 120 | + $frm_style = $this; | |
| 121 | + include($filename); | |
| 122 | 122 | $css .= preg_replace( '/\/\*(.|\s)*?\*\//', '', str_replace( array( "\r\n", "\r", "\n", "\t", ' ' ), '', ob_get_contents() ) ); | 
| 123 | - ob_end_clean(); | |
| 123 | + ob_end_clean(); | |
| 124 | 124 | |
| 125 | - $access_type = get_filesystem_method(); | |
| 126 | -        if ( $access_type === 'direct' ) { | |
| 125 | + $access_type = get_filesystem_method(); | |
| 126 | +		if ( $access_type === 'direct' ) { | |
| 127 | 127 | $creds = request_filesystem_credentials( site_url() . '/wp-admin/', '', false, false, array() ); | 
| 128 | 128 |  		} else { | 
| 129 | 129 | $creds = $this->get_ftp_creds( $access_type ); | 
| 130 | 130 | } | 
| 131 | 131 | |
| 132 | 132 |  		if ( ! empty( $creds ) ) { | 
| 133 | - // initialize the API | |
| 134 | -        	if ( ! WP_Filesystem( $creds ) ) { | |
| 135 | - // any problems and we exit | |
| 136 | - $dirs_exist = false; | |
| 133 | + // initialize the API | |
| 134 | +			if ( ! WP_Filesystem( $creds ) ) { | |
| 135 | + // any problems and we exit | |
| 136 | + $dirs_exist = false; | |
| 137 | 137 | } | 
| 138 | 138 | |
| 139 | -            if ( $dirs_exist ) { | |
| 140 | - global $wp_filesystem; | |
| 139 | +			if ( $dirs_exist ) { | |
| 140 | + global $wp_filesystem; | |
| 141 | 141 | |
| 142 | -            	$chmod_dir = defined('FS_CHMOD_DIR') ? FS_CHMOD_DIR : ( fileperms( ABSPATH ) & 0777 | 0755 ); | |
| 143 | -            	$chmod_file = defined('FS_CHMOD_FILE') ? FS_CHMOD_FILE : ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 ); | |
| 142 | +				$chmod_dir = defined('FS_CHMOD_DIR') ? FS_CHMOD_DIR : ( fileperms( ABSPATH ) & 0777 | 0755 ); | |
| 143 | +				$chmod_file = defined('FS_CHMOD_FILE') ? FS_CHMOD_FILE : ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 ); | |
| 144 | 144 | |
| 145 | - // Create the directories if need be: | |
| 146 | -            	foreach ( $needed_dirs as $_dir ) { | |
| 147 | - // Only check to see if the Dir exists upon creation failure. Less I/O this way. | |
| 148 | -            		if ( ! $wp_filesystem->mkdir( $_dir, $chmod_dir ) && ! $wp_filesystem->is_dir( $_dir ) ) { | |
| 149 | - $dirs_exist = false; | |
| 150 | - } | |
| 151 | - } | |
| 145 | + // Create the directories if need be: | |
| 146 | +				foreach ( $needed_dirs as $_dir ) { | |
| 147 | + // Only check to see if the Dir exists upon creation failure. Less I/O this way. | |
| 148 | +					if ( ! $wp_filesystem->mkdir( $_dir, $chmod_dir ) && ! $wp_filesystem->is_dir( $_dir ) ) { | |
| 149 | + $dirs_exist = false; | |
| 150 | + } | |
| 151 | + } | |
| 152 | 152 | |
| 153 | 153 | $index_path = $target_path . '/index.php'; | 
| 154 | - $wp_filesystem->put_contents( $index_path, "<?php\n// Silence is golden.\n?>", $chmod_file ); | |
| 154 | + $wp_filesystem->put_contents( $index_path, "<?php\n// Silence is golden.\n?>", $chmod_file ); | |
| 155 | 155 | |
| 156 | - // only write the file if the folders exist | |
| 157 | -                if ( $dirs_exist ) { | |
| 156 | + // only write the file if the folders exist | |
| 157 | +				if ( $dirs_exist ) { | |
| 158 | 158 | $css_file = $target_path . '/css/formidablepro.css'; | 
| 159 | - $wp_filesystem->put_contents( $css_file, $css, $chmod_file ); | |
| 160 | - } | |
| 161 | - } | |
| 162 | - } | |
| 159 | + $wp_filesystem->put_contents( $css_file, $css, $chmod_file ); | |
| 160 | + } | |
| 161 | + } | |
| 162 | + } | |
| 163 | 163 | |
| 164 | -        update_option('frmpro_css', $css); | |
| 164 | +		update_option('frmpro_css', $css); | |
| 165 | 165 | |
| 166 | -        delete_transient('frmpro_css'); | |
| 167 | -        set_transient('frmpro_css', $css); | |
| 166 | +		delete_transient('frmpro_css'); | |
| 167 | +		set_transient('frmpro_css', $css); | |
| 168 | 168 | } | 
| 169 | 169 | |
| 170 | 170 |  	private function get_ftp_creds( $type ) { | 
| @@ -218,271 +218,271 @@ discard block | ||
| 218 | 218 | } | 
| 219 | 219 | |
| 220 | 220 |  	public function destroy( $id ) { | 
| 221 | - return wp_delete_post($id); | |
| 222 | - } | |
| 221 | + return wp_delete_post($id); | |
| 222 | + } | |
| 223 | 223 | |
| 224 | -    public function get_one() { | |
| 225 | -        if ( 'default' == $this->id ) { | |
| 226 | - $style = $this->get_default_style(); | |
| 227 | -            if ( $style ) { | |
| 228 | - $this->id = $style->ID; | |
| 229 | -            } else { | |
| 230 | - $this->id = 0; | |
| 231 | - } | |
| 232 | - return $style; | |
| 233 | - } | |
| 224 | +	public function get_one() { | |
| 225 | +		if ( 'default' == $this->id ) { | |
| 226 | + $style = $this->get_default_style(); | |
| 227 | +			if ( $style ) { | |
| 228 | + $this->id = $style->ID; | |
| 229 | +			} else { | |
| 230 | + $this->id = 0; | |
| 231 | + } | |
| 232 | + return $style; | |
| 233 | + } | |
| 234 | 234 | |
| 235 | - $style = get_post($this->id); | |
| 235 | + $style = get_post($this->id); | |
| 236 | 236 | |
| 237 | -        if ( ! $style ) { | |
| 238 | - return $style; | |
| 239 | - } | |
| 237 | +		if ( ! $style ) { | |
| 238 | + return $style; | |
| 239 | + } | |
| 240 | 240 | |
| 241 | - $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content); | |
| 241 | + $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content); | |
| 242 | 242 | |
| 243 | - $default_values = $this->get_defaults(); | |
| 243 | + $default_values = $this->get_defaults(); | |
| 244 | 244 | |
| 245 | - // fill default values | |
| 246 | - $style->post_content = $this->override_defaults($style->post_content); | |
| 247 | - $style->post_content = wp_parse_args( $style->post_content, $default_values); | |
| 245 | + // fill default values | |
| 246 | + $style->post_content = $this->override_defaults($style->post_content); | |
| 247 | + $style->post_content = wp_parse_args( $style->post_content, $default_values); | |
| 248 | 248 | |
| 249 | - return $style; | |
| 250 | - } | |
| 249 | + return $style; | |
| 250 | + } | |
| 251 | 251 | |
| 252 | -    public function get_all( $orderby = 'title', $order = 'ASC', $limit = 99 ) { | |
| 253 | - $post_atts = array( | |
| 252 | +	public function get_all( $orderby = 'title', $order = 'ASC', $limit = 99 ) { | |
| 253 | + $post_atts = array( | |
| 254 | 254 | 'post_type' => FrmStylesController::$post_type, | 
| 255 | 255 | 'post_status' => 'publish', | 
| 256 | 256 | 'numberposts' => $limit, | 
| 257 | 257 | 'orderby' => $orderby, | 
| 258 | 258 | 'order' => $order, | 
| 259 | - ); | |
| 259 | + ); | |
| 260 | 260 | |
| 261 | - $temp_styles = FrmAppHelper::check_cache(serialize($post_atts), 'frm_styles', $post_atts, 'get_posts'); | |
| 261 | + $temp_styles = FrmAppHelper::check_cache(serialize($post_atts), 'frm_styles', $post_atts, 'get_posts'); | |
| 262 | 262 | |
| 263 | -        if ( empty($temp_styles) ) { | |
| 264 | - global $wpdb; | |
| 265 | - // make sure there wasn't a conflict with the query | |
| 263 | +		if ( empty($temp_styles) ) { | |
| 264 | + global $wpdb; | |
| 265 | + // make sure there wasn't a conflict with the query | |
| 266 | 266 | $query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->posts . ' WHERE post_type=%s AND post_status=%s ORDER BY post_title ASC LIMIT 99', FrmStylesController::$post_type, 'publish' ); | 
| 267 | -            $temp_styles = FrmAppHelper::check_cache('frm_backup_style_check', 'frm_styles', $query, 'get_results'); | |
| 268 | - | |
| 269 | -            if ( empty($temp_styles) ) { | |
| 270 | - // create a new style if there are none | |
| 271 | - $new = $this->get_new(); | |
| 272 | - $new->post_title = $new->post_name = __( 'Formidable Style', 'formidable' ); | |
| 273 | - $new->menu_order = 1; | |
| 274 | - $new = $this->save( (array) $new); | |
| 275 | -         		$this->update('default'); | |
| 276 | - | |
| 277 | - $post_atts['include'] = $new; | |
| 278 | - | |
| 279 | - $temp_styles = get_posts( $post_atts ); | |
| 280 | - } | |
| 281 | - } | |
| 282 | - | |
| 283 | - $default_values = $this->get_defaults(); | |
| 284 | - $default_style = false; | |
| 285 | - | |
| 286 | - $styles = array(); | |
| 287 | -        foreach ( $temp_styles as $style ) { | |
| 288 | - $this->id = $style->ID; | |
| 289 | -            if ( $style->menu_order ) { | |
| 290 | -                if ( $default_style ) { | |
| 291 | - // only return one default | |
| 292 | - $style->menu_order = 0; | |
| 293 | -                } else { | |
| 294 | - // check for a default style | |
| 295 | - $default_style = $style->ID; | |
| 296 | - } | |
| 297 | - } | |
| 298 | - | |
| 299 | - $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content); | |
| 300 | - | |
| 301 | - // fill default values | |
| 302 | - $style->post_content = $this->override_defaults($style->post_content); | |
| 303 | - $style->post_content = wp_parse_args( $style->post_content, $default_values); | |
| 267 | +			$temp_styles = FrmAppHelper::check_cache('frm_backup_style_check', 'frm_styles', $query, 'get_results'); | |
| 268 | + | |
| 269 | +			if ( empty($temp_styles) ) { | |
| 270 | + // create a new style if there are none | |
| 271 | + $new = $this->get_new(); | |
| 272 | + $new->post_title = $new->post_name = __( 'Formidable Style', 'formidable' ); | |
| 273 | + $new->menu_order = 1; | |
| 274 | + $new = $this->save( (array) $new); | |
| 275 | +		 		$this->update('default'); | |
| 276 | + | |
| 277 | + $post_atts['include'] = $new; | |
| 278 | + | |
| 279 | + $temp_styles = get_posts( $post_atts ); | |
| 280 | + } | |
| 281 | + } | |
| 282 | + | |
| 283 | + $default_values = $this->get_defaults(); | |
| 284 | + $default_style = false; | |
| 285 | + | |
| 286 | + $styles = array(); | |
| 287 | +		foreach ( $temp_styles as $style ) { | |
| 288 | + $this->id = $style->ID; | |
| 289 | +			if ( $style->menu_order ) { | |
| 290 | +				if ( $default_style ) { | |
| 291 | + // only return one default | |
| 292 | + $style->menu_order = 0; | |
| 293 | +				} else { | |
| 294 | + // check for a default style | |
| 295 | + $default_style = $style->ID; | |
| 296 | + } | |
| 297 | + } | |
| 298 | + | |
| 299 | + $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content); | |
| 300 | + | |
| 301 | + // fill default values | |
| 302 | + $style->post_content = $this->override_defaults($style->post_content); | |
| 303 | + $style->post_content = wp_parse_args( $style->post_content, $default_values); | |
| 304 | 304 | |
| 305 | 305 | $styles[ $style->ID ] = $style; | 
| 306 | - } | |
| 306 | + } | |
| 307 | 307 | |
| 308 | -        if ( ! $default_style ) { | |
| 309 | - $default_style = reset($styles); | |
| 308 | +		if ( ! $default_style ) { | |
| 309 | + $default_style = reset($styles); | |
| 310 | 310 | $styles[ $default_style->ID ]->menu_order = 1; | 
| 311 | - } | |
| 311 | + } | |
| 312 | 312 | |
| 313 | - return $styles; | |
| 314 | - } | |
| 313 | + return $styles; | |
| 314 | + } | |
| 315 | 315 | |
| 316 | 316 |  	public function get_default_style( $styles = null ) { | 
| 317 | -        if ( ! isset($styles) ) { | |
| 317 | +		if ( ! isset($styles) ) { | |
| 318 | 318 | $styles = $this->get_all( 'menu_order', 'DESC', 1 ); | 
| 319 | - } | |
| 319 | + } | |
| 320 | 320 | |
| 321 | -        foreach ( $styles as $style ) { | |
| 322 | -            if ( $style->menu_order ) { | |
| 323 | - return $style; | |
| 324 | - } | |
| 325 | - } | |
| 326 | - } | |
| 321 | +		foreach ( $styles as $style ) { | |
| 322 | +			if ( $style->menu_order ) { | |
| 323 | + return $style; | |
| 324 | + } | |
| 325 | + } | |
| 326 | + } | |
| 327 | 327 | |
| 328 | 328 |  	public function override_defaults( $settings ) { | 
| 329 | -	    if ( ! is_array($settings) ) { | |
| 330 | - return $settings; | |
| 331 | - } | |
| 332 | - | |
| 333 | - $settings['line_height'] = ( ! isset($settings['field_height']) || $settings['field_height'] == '' || $settings['field_height'] == 'auto') ? 'normal' : $settings['field_height']; | |
| 334 | - | |
| 335 | -	    if ( ! isset($settings['form_desc_size']) && isset($settings['description_font_size']) ) { | |
| 336 | - $settings['form_desc_size'] = $settings['description_font_size']; | |
| 337 | - $settings['form_desc_color'] = $settings['description_color']; | |
| 338 | - $settings['title_color'] = $settings['label_color']; | |
| 339 | - } | |
| 340 | - | |
| 341 | -	    if ( ! isset($settings['section_color']) && isset($settings['label_color']) ) { | |
| 342 | - $settings['section_color'] = $settings['label_color']; | |
| 343 | - $settings['section_border_color'] = $settings['border_color']; | |
| 344 | - } | |
| 345 | - | |
| 346 | -	    if ( ! isset($settings['submit_hover_bg_color']) && isset($settings['submit_bg_color']) ) { | |
| 347 | - $settings['submit_hover_bg_color'] = $settings['submit_bg_color']; | |
| 348 | - $settings['submit_hover_color'] = $settings['submit_text_color']; | |
| 349 | - $settings['submit_hover_border_color'] = $settings['submit_border_color']; | |
| 350 | - | |
| 351 | - $settings['submit_active_bg_color'] = $settings['submit_bg_color']; | |
| 352 | - $settings['submit_active_color'] = $settings['submit_text_color']; | |
| 353 | - $settings['submit_active_border_color'] = $settings['submit_border_color']; | |
| 354 | - } | |
| 355 | - | |
| 356 | - return $settings; | |
| 329 | +		if ( ! is_array($settings) ) { | |
| 330 | + return $settings; | |
| 331 | + } | |
| 332 | + | |
| 333 | + $settings['line_height'] = ( ! isset($settings['field_height']) || $settings['field_height'] == '' || $settings['field_height'] == 'auto') ? 'normal' : $settings['field_height']; | |
| 334 | + | |
| 335 | +		if ( ! isset($settings['form_desc_size']) && isset($settings['description_font_size']) ) { | |
| 336 | + $settings['form_desc_size'] = $settings['description_font_size']; | |
| 337 | + $settings['form_desc_color'] = $settings['description_color']; | |
| 338 | + $settings['title_color'] = $settings['label_color']; | |
| 339 | + } | |
| 340 | + | |
| 341 | +		if ( ! isset($settings['section_color']) && isset($settings['label_color']) ) { | |
| 342 | + $settings['section_color'] = $settings['label_color']; | |
| 343 | + $settings['section_border_color'] = $settings['border_color']; | |
| 344 | + } | |
| 345 | + | |
| 346 | +		if ( ! isset($settings['submit_hover_bg_color']) && isset($settings['submit_bg_color']) ) { | |
| 347 | + $settings['submit_hover_bg_color'] = $settings['submit_bg_color']; | |
| 348 | + $settings['submit_hover_color'] = $settings['submit_text_color']; | |
| 349 | + $settings['submit_hover_border_color'] = $settings['submit_border_color']; | |
| 350 | + | |
| 351 | + $settings['submit_active_bg_color'] = $settings['submit_bg_color']; | |
| 352 | + $settings['submit_active_color'] = $settings['submit_text_color']; | |
| 353 | + $settings['submit_active_border_color'] = $settings['submit_border_color']; | |
| 354 | + } | |
| 355 | + | |
| 356 | + return $settings; | |
| 357 | 357 | } | 
| 358 | 358 | |
| 359 | 359 |  	public function get_defaults() { | 
| 360 | - return array( | |
| 361 | - 'theme_css' => 'ui-lightness', | |
| 362 | - 'theme_name' => 'UI Lightness', | |
| 360 | + return array( | |
| 361 | + 'theme_css' => 'ui-lightness', | |
| 362 | + 'theme_name' => 'UI Lightness', | |
| 363 | 363 | |
| 364 | 364 | 'center_form' => '', | 
| 365 | - 'form_width' => '100%', | |
| 366 | - 'form_align' => 'left', | |
| 367 | - 'direction' => is_rtl() ? 'rtl' : 'ltr', | |
| 368 | - 'fieldset' => '0px', | |
| 369 | - 'fieldset_color' => '000000', | |
| 370 | - 'fieldset_padding' => '0 0 15px 0', | |
| 371 | - 'fieldset_bg_color' => '', | |
| 372 | - | |
| 373 | - 'title_size' => '20px', | |
| 374 | - 'title_color' => '444444', | |
| 365 | + 'form_width' => '100%', | |
| 366 | + 'form_align' => 'left', | |
| 367 | + 'direction' => is_rtl() ? 'rtl' : 'ltr', | |
| 368 | + 'fieldset' => '0px', | |
| 369 | + 'fieldset_color' => '000000', | |
| 370 | + 'fieldset_padding' => '0 0 15px 0', | |
| 371 | + 'fieldset_bg_color' => '', | |
| 372 | + | |
| 373 | + 'title_size' => '20px', | |
| 374 | + 'title_color' => '444444', | |
| 375 | 375 | 'title_margin_top' => '10px', | 
| 376 | 376 | 'title_margin_bottom' => '10px', | 
| 377 | - 'form_desc_size' => '14px', | |
| 378 | - 'form_desc_color' => '666666', | |
| 377 | + 'form_desc_size' => '14px', | |
| 378 | + 'form_desc_color' => '666666', | |
| 379 | 379 | 'form_desc_margin_top' => '10px', | 
| 380 | 380 | 'form_desc_margin_bottom' => '25px', | 
| 381 | 381 | |
| 382 | - 'font' => '"Lucida Grande","Lucida Sans Unicode",Tahoma,sans-serif', | |
| 383 | - 'font_size' => '14px', | |
| 384 | - 'label_color' => '444444', | |
| 385 | - 'weight' => 'bold', | |
| 386 | - 'position' => 'none', | |
| 387 | - 'align' => 'left', | |
| 388 | - 'width' => '150px', | |
| 389 | - 'required_color' => 'B94A48', | |
| 390 | - 'required_weight' => 'bold', | |
| 391 | - 'label_padding' => '0 0 3px 0', | |
| 392 | - | |
| 393 | - 'description_font_size' => '12px', | |
| 394 | - 'description_color' => '666666', | |
| 395 | - 'description_weight' => 'normal', | |
| 396 | - 'description_style' => 'normal', | |
| 397 | - 'description_align' => 'left', | |
| 398 | - | |
| 399 | - 'field_font_size' => '14px', | |
| 400 | - 'field_height' => '32px', | |
| 401 | - 'line_height' => 'normal', | |
| 402 | - 'field_width' => '100%', | |
| 403 | - 'auto_width' => false, | |
| 404 | - 'field_pad' => '6px 10px', | |
| 405 | - 'field_margin' => '20px', | |
| 382 | + 'font' => '"Lucida Grande","Lucida Sans Unicode",Tahoma,sans-serif', | |
| 383 | + 'font_size' => '14px', | |
| 384 | + 'label_color' => '444444', | |
| 385 | + 'weight' => 'bold', | |
| 386 | + 'position' => 'none', | |
| 387 | + 'align' => 'left', | |
| 388 | + 'width' => '150px', | |
| 389 | + 'required_color' => 'B94A48', | |
| 390 | + 'required_weight' => 'bold', | |
| 391 | + 'label_padding' => '0 0 3px 0', | |
| 392 | + | |
| 393 | + 'description_font_size' => '12px', | |
| 394 | + 'description_color' => '666666', | |
| 395 | + 'description_weight' => 'normal', | |
| 396 | + 'description_style' => 'normal', | |
| 397 | + 'description_align' => 'left', | |
| 398 | + | |
| 399 | + 'field_font_size' => '14px', | |
| 400 | + 'field_height' => '32px', | |
| 401 | + 'line_height' => 'normal', | |
| 402 | + 'field_width' => '100%', | |
| 403 | + 'auto_width' => false, | |
| 404 | + 'field_pad' => '6px 10px', | |
| 405 | + 'field_margin' => '20px', | |
| 406 | 406 | 'field_weight' => 'normal', | 
| 407 | - 'text_color' => '555555', | |
| 408 | - //'border_color_hv' => 'cccccc', | |
| 409 | - 'border_color' => 'cccccc', | |
| 410 | - 'field_border_width' => '1px', | |
| 411 | - 'field_border_style' => 'solid', | |
| 412 | - | |
| 413 | - 'bg_color' => 'ffffff', | |
| 414 | - //'bg_color_hv' => 'ffffff', | |
| 407 | + 'text_color' => '555555', | |
| 408 | + //'border_color_hv' => 'cccccc', | |
| 409 | + 'border_color' => 'cccccc', | |
| 410 | + 'field_border_width' => '1px', | |
| 411 | + 'field_border_style' => 'solid', | |
| 412 | + | |
| 413 | + 'bg_color' => 'ffffff', | |
| 414 | + //'bg_color_hv' => 'ffffff', | |
| 415 | 415 | 'remove_box_shadow' => '', | 
| 416 | - 'bg_color_active' => 'ffffff', | |
| 416 | + 'bg_color_active' => 'ffffff', | |
| 417 | 417 | 'border_color_active' => '66afe9', | 
| 418 | 418 | 'remove_box_shadow_active' => '', | 
| 419 | - 'text_color_error' => '444444', | |
| 420 | - 'bg_color_error' => 'ffffff', | |
| 419 | + 'text_color_error' => '444444', | |
| 420 | + 'bg_color_error' => 'ffffff', | |
| 421 | 421 | 'border_color_error' => 'B94A48', | 
| 422 | 422 | 'border_width_error' => '1px', | 
| 423 | 423 | 'border_style_error' => 'solid', | 
| 424 | - 'bg_color_disabled' => 'ffffff', | |
| 425 | - 'border_color_disabled' => 'E5E5E5', | |
| 426 | - 'text_color_disabled' => 'A1A1A1', | |
| 427 | - | |
| 428 | - 'radio_align' => 'block', | |
| 429 | - 'check_align' => 'block', | |
| 430 | - 'check_font_size' => '13px', | |
| 431 | - 'check_label_color' => '444444', | |
| 432 | - 'check_weight' => 'normal', | |
| 433 | - | |
| 434 | - 'section_font_size' => '18px', | |
| 435 | - 'section_color' => '444444', | |
| 436 | - 'section_weight' => 'bold', | |
| 437 | - 'section_pad' => '15px 0 3px 0', | |
| 438 | - 'section_mar_top' => '15px', | |
| 424 | + 'bg_color_disabled' => 'ffffff', | |
| 425 | + 'border_color_disabled' => 'E5E5E5', | |
| 426 | + 'text_color_disabled' => 'A1A1A1', | |
| 427 | + | |
| 428 | + 'radio_align' => 'block', | |
| 429 | + 'check_align' => 'block', | |
| 430 | + 'check_font_size' => '13px', | |
| 431 | + 'check_label_color' => '444444', | |
| 432 | + 'check_weight' => 'normal', | |
| 433 | + | |
| 434 | + 'section_font_size' => '18px', | |
| 435 | + 'section_color' => '444444', | |
| 436 | + 'section_weight' => 'bold', | |
| 437 | + 'section_pad' => '15px 0 3px 0', | |
| 438 | + 'section_mar_top' => '15px', | |
| 439 | 439 | 'section_mar_bottom' => '12px', | 
| 440 | - 'section_bg_color' => '', | |
| 441 | - 'section_border_color' => 'e8e8e8', | |
| 442 | - 'section_border_width' => '2px', | |
| 443 | - 'section_border_style' => 'solid', | |
| 444 | - 'section_border_loc' => '-top', | |
| 445 | - 'collapse_icon' => '6', | |
| 446 | - 'collapse_pos' => 'after', | |
| 447 | - 'repeat_icon' => '1', | |
| 448 | - | |
| 449 | - 'submit_style' => false, | |
| 450 | - 'submit_font_size' => '14px', | |
| 451 | - 'submit_width' => 'auto', | |
| 452 | - 'submit_height' => 'auto', | |
| 453 | - 'submit_bg_color' => 'ffffff', | |
| 454 | - 'submit_border_color' => 'cccccc', | |
| 455 | - 'submit_border_width' => '1px', | |
| 456 | - 'submit_text_color' => '444444', | |
| 457 | - 'submit_weight' => 'normal', | |
| 458 | - 'submit_border_radius' => '4px', | |
| 459 | - 'submit_bg_img' => '', | |
| 460 | - 'submit_margin' => '10px', | |
| 461 | - 'submit_padding' => '6px 11px', | |
| 462 | - 'submit_shadow_color' => 'eeeeee', | |
| 463 | - 'submit_hover_bg_color' => 'efefef', | |
| 464 | - 'submit_hover_color' => '444444', | |
| 465 | - 'submit_hover_border_color' => 'cccccc', | |
| 466 | - 'submit_active_bg_color' => 'efefef', | |
| 467 | - 'submit_active_color' => '444444', | |
| 468 | - 'submit_active_border_color' => 'cccccc', | |
| 469 | - | |
| 470 | - 'border_radius' => '4px', | |
| 471 | - 'error_bg' => 'F2DEDE', | |
| 472 | - 'error_border' => 'EBCCD1', | |
| 473 | - 'error_text' => 'B94A48', | |
| 474 | - 'error_font_size' => '14px', | |
| 475 | - | |
| 476 | - 'success_bg_color' => 'DFF0D8', | |
| 477 | - 'success_border_color' => 'D6E9C6', | |
| 478 | - 'success_text_color' => '468847', | |
| 479 | - 'success_font_size' => '14px', | |
| 480 | - | |
| 481 | - 'important_style' => false, | |
| 482 | - | |
| 483 | - 'custom_css' => '', | |
| 484 | - ); | |
| 485 | - } | |
| 440 | + 'section_bg_color' => '', | |
| 441 | + 'section_border_color' => 'e8e8e8', | |
| 442 | + 'section_border_width' => '2px', | |
| 443 | + 'section_border_style' => 'solid', | |
| 444 | + 'section_border_loc' => '-top', | |
| 445 | + 'collapse_icon' => '6', | |
| 446 | + 'collapse_pos' => 'after', | |
| 447 | + 'repeat_icon' => '1', | |
| 448 | + | |
| 449 | + 'submit_style' => false, | |
| 450 | + 'submit_font_size' => '14px', | |
| 451 | + 'submit_width' => 'auto', | |
| 452 | + 'submit_height' => 'auto', | |
| 453 | + 'submit_bg_color' => 'ffffff', | |
| 454 | + 'submit_border_color' => 'cccccc', | |
| 455 | + 'submit_border_width' => '1px', | |
| 456 | + 'submit_text_color' => '444444', | |
| 457 | + 'submit_weight' => 'normal', | |
| 458 | + 'submit_border_radius' => '4px', | |
| 459 | + 'submit_bg_img' => '', | |
| 460 | + 'submit_margin' => '10px', | |
| 461 | + 'submit_padding' => '6px 11px', | |
| 462 | + 'submit_shadow_color' => 'eeeeee', | |
| 463 | + 'submit_hover_bg_color' => 'efefef', | |
| 464 | + 'submit_hover_color' => '444444', | |
| 465 | + 'submit_hover_border_color' => 'cccccc', | |
| 466 | + 'submit_active_bg_color' => 'efefef', | |
| 467 | + 'submit_active_color' => '444444', | |
| 468 | + 'submit_active_border_color' => 'cccccc', | |
| 469 | + | |
| 470 | + 'border_radius' => '4px', | |
| 471 | + 'error_bg' => 'F2DEDE', | |
| 472 | + 'error_border' => 'EBCCD1', | |
| 473 | + 'error_text' => 'B94A48', | |
| 474 | + 'error_font_size' => '14px', | |
| 475 | + | |
| 476 | + 'success_bg_color' => 'DFF0D8', | |
| 477 | + 'success_border_color' => 'D6E9C6', | |
| 478 | + 'success_text_color' => '468847', | |
| 479 | + 'success_font_size' => '14px', | |
| 480 | + | |
| 481 | + 'important_style' => false, | |
| 482 | + | |
| 483 | + 'custom_css' => '', | |
| 484 | + ); | |
| 485 | + } | |
| 486 | 486 | |
| 487 | 487 |  	public function get_field_name( $field_name, $post_field = 'post_content' ) { | 
| 488 | 488 | return 'frm_style_setting' . ( empty( $post_field ) ? '' : '[' . $post_field . ']' ) . '[' . $field_name . ']'; | 
| @@ -1,6 +1,6 @@ discard block | ||
| 1 | 1 | <?php | 
| 2 | 2 |  class FrmStyle { | 
| 3 | - public $number = false; // Unique ID number of the current instance. | |
| 3 | + public $number = false; // Unique ID number of the current instance. | |
| 4 | 4 | public $id = 0; // the id of the post | 
| 5 | 5 | |
| 6 | 6 | /** | 
| @@ -13,9 +13,9 @@ discard block | ||
| 13 | 13 |      public function get_new() { | 
| 14 | 14 | $this->id = 0; | 
| 15 | 15 | |
| 16 | - $max_slug_value = pow(36, 6); | |
| 16 | + $max_slug_value = pow( 36, 6 ); | |
| 17 | 17 | $min_slug_value = 37; // we want to have at least 2 characters in the slug | 
| 18 | - $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); | |
| 18 | + $key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 ); | |
| 19 | 19 | |
| 20 | 20 | $style = array( | 
| 21 | 21 | 'post_type' => FrmStylesController::$post_type, | 
| @@ -41,7 +41,7 @@ discard block | ||
| 41 | 41 |      public function update( $id = 'default' ) { | 
| 42 | 42 | $all_instances = $this->get_all(); | 
| 43 | 43 | |
| 44 | - 		if ( empty($id) ) { | |
| 44 | + 		if ( empty( $id ) ) { | |
| 45 | 45 | $new_style = (array) $this->get_new(); | 
| 46 | 46 | $all_instances[] = $new_style; | 
| 47 | 47 | } | 
| @@ -49,15 +49,15 @@ discard block | ||
| 49 | 49 | $action_ids = array(); | 
| 50 | 50 | |
| 51 | 51 |   		foreach ( $all_instances as $number => $new_instance ) { | 
| 52 | - $new_instance = stripslashes_deep( (array) $new_instance); | |
| 52 | + $new_instance = stripslashes_deep( (array) $new_instance ); | |
| 53 | 53 | $this->id = $new_instance['ID']; | 
| 54 | - 			if ( $id != $this->id || ! $_POST || ! isset($_POST['frm_style_setting']) ) { | |
| 55 | - $all_instances[ $number ] = $new_instance; | |
| 54 | + 			if ( $id != $this->id || ! $_POST || ! isset( $_POST['frm_style_setting'] ) ) { | |
| 55 | + $all_instances[$number] = $new_instance; | |
| 56 | 56 | |
| 57 | - 			    if ( $new_instance['menu_order'] && $_POST && empty($_POST['prev_menu_order']) && isset($_POST['frm_style_setting']['menu_order']) ) { | |
| 57 | + 			    if ( $new_instance['menu_order'] && $_POST && empty( $_POST['prev_menu_order'] ) && isset( $_POST['frm_style_setting']['menu_order'] ) ) { | |
| 58 | 58 | // this style was set to default, so remove default setting on previous default style | 
| 59 | 59 | $new_instance['menu_order'] = 0; | 
| 60 | - $action_ids[] = $this->save($new_instance); | |
| 60 | + $action_ids[] = $this->save( $new_instance ); | |
| 61 | 61 | } | 
| 62 | 62 | |
| 63 | 63 | // don't continue if not saving this style | 
| @@ -67,10 +67,10 @@ discard block | ||
| 67 | 67 | $new_instance['post_title'] = sanitize_text_field( $_POST['frm_style_setting']['post_title'] ); | 
| 68 | 68 | $new_instance['post_content'] = $_POST['frm_style_setting']['post_content']; | 
| 69 | 69 | $new_instance['post_type'] = FrmStylesController::$post_type; | 
| 70 | - $new_instance['post_status'] = 'publish'; | |
| 70 | + $new_instance['post_status'] = 'publish'; | |
| 71 | 71 | $new_instance['menu_order'] = isset( $_POST['frm_style_setting']['menu_order'] ) ? absint( $_POST['frm_style_setting']['menu_order'] ) : 0; | 
| 72 | 72 | |
| 73 | -            if ( empty($id) ) { | |
| 73 | +            if ( empty( $id ) ) { | |
| 74 | 74 | $new_instance['post_name'] = $new_instance['post_title']; | 
| 75 | 75 | } | 
| 76 | 76 | |
| @@ -79,19 +79,19 @@ discard block | ||
| 79 | 79 |              foreach ( $default_settings as $setting => $default ) { | 
| 80 | 80 |  				if ( strpos( $setting, 'color' ) !== false || in_array( $setting, array( 'error_bg', 'error_border', 'error_text' ) ) ) { | 
| 81 | 81 | //if is a color | 
| 82 | - $new_instance['post_content'][ $setting ] = str_replace( '#', '', $new_instance['post_content'][ $setting ] ); | |
| 83 | -				} else if ( in_array( $setting, array( 'submit_style', 'important_style', 'auto_width' ) ) && ! isset( $new_instance['post_content'][ $setting ] ) ) { | |
| 84 | - $new_instance['post_content'][ $setting ] = 0; | |
| 82 | + $new_instance['post_content'][$setting] = str_replace( '#', '', $new_instance['post_content'][$setting] ); | |
| 83 | +				} else if ( in_array( $setting, array( 'submit_style', 'important_style', 'auto_width' ) ) && ! isset( $new_instance['post_content'][$setting] ) ) { | |
| 84 | + $new_instance['post_content'][$setting] = 0; | |
| 85 | 85 | } | 
| 86 | 86 | } | 
| 87 | 87 | |
| 88 | - $all_instances[ $number ] = $new_instance; | |
| 88 | + $all_instances[$number] = $new_instance; | |
| 89 | 89 | |
| 90 | - $action_ids[] = $this->save($new_instance); | |
| 90 | + $action_ids[] = $this->save( $new_instance ); | |
| 91 | 91 | |
| 92 | 92 | } | 
| 93 | 93 | |
| 94 | - $this->save_settings($all_instances); | |
| 94 | + $this->save_settings( $all_instances ); | |
| 95 | 95 | |
| 96 | 96 | return $action_ids; | 
| 97 | 97 | } | 
| @@ -101,9 +101,9 @@ discard block | ||
| 101 | 101 | */ | 
| 102 | 102 |  	public function save_settings( $styles ) { | 
| 103 | 103 | $filename = FrmAppHelper::plugin_path() . '/css/custom_theme.css.php'; | 
| 104 | -		update_option( 'frm_last_style_update', date('njGi') ); | |
| 104 | + update_option( 'frm_last_style_update', date( 'njGi' ) ); | |
| 105 | 105 | |
| 106 | -        if ( ! is_file($filename) ) { | |
| 106 | +        if ( ! is_file( $filename ) ) { | |
| 107 | 107 | return; | 
| 108 | 108 | } | 
| 109 | 109 | |
| @@ -118,7 +118,7 @@ discard block | ||
| 118 | 118 | |
| 119 | 119 | ob_start(); | 
| 120 | 120 | $frm_style = $this; | 
| 121 | - include($filename); | |
| 121 | + include( $filename ); | |
| 122 | 122 | $css .= preg_replace( '/\/\*(.|\s)*?\*\//', '', str_replace( array( "\r\n", "\r", "\n", "\t", ' ' ), '', ob_get_contents() ) ); | 
| 123 | 123 | ob_end_clean(); | 
| 124 | 124 | |
| @@ -139,8 +139,8 @@ discard block | ||
| 139 | 139 |              if ( $dirs_exist ) { | 
| 140 | 140 | global $wp_filesystem; | 
| 141 | 141 | |
| 142 | -            	$chmod_dir = defined('FS_CHMOD_DIR') ? FS_CHMOD_DIR : ( fileperms( ABSPATH ) & 0777 | 0755 ); | |
| 143 | -            	$chmod_file = defined('FS_CHMOD_FILE') ? FS_CHMOD_FILE : ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 ); | |
| 142 | + $chmod_dir = defined( 'FS_CHMOD_DIR' ) ? FS_CHMOD_DIR : ( fileperms( ABSPATH ) & 0777 | 0755 ); | |
| 143 | + $chmod_file = defined( 'FS_CHMOD_FILE' ) ? FS_CHMOD_FILE : ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 ); | |
| 144 | 144 | |
| 145 | 145 | // Create the directories if need be: | 
| 146 | 146 |              	foreach ( $needed_dirs as $_dir ) { | 
| @@ -161,22 +161,22 @@ discard block | ||
| 161 | 161 | } | 
| 162 | 162 | } | 
| 163 | 163 | |
| 164 | -        update_option('frmpro_css', $css); | |
| 164 | + update_option( 'frmpro_css', $css ); | |
| 165 | 165 | |
| 166 | -        delete_transient('frmpro_css'); | |
| 167 | -        set_transient('frmpro_css', $css); | |
| 166 | + delete_transient( 'frmpro_css' ); | |
| 167 | + set_transient( 'frmpro_css', $css ); | |
| 168 | 168 | } | 
| 169 | 169 | |
| 170 | 170 |  	private function get_ftp_creds( $type ) { | 
| 171 | 171 | $credentials = get_option( 'ftp_credentials', array( 'hostname' => '', 'username' => '' ) ); | 
| 172 | 172 | |
| 173 | -		$credentials['hostname'] = defined('FTP_HOST') ? FTP_HOST : $credentials['hostname']; | |
| 174 | -		$credentials['username'] = defined('FTP_USER') ? FTP_USER : $credentials['username']; | |
| 175 | -		$credentials['password'] = defined('FTP_PASS') ? FTP_PASS : ''; | |
| 173 | + $credentials['hostname'] = defined( 'FTP_HOST' ) ? FTP_HOST : $credentials['hostname']; | |
| 174 | + $credentials['username'] = defined( 'FTP_USER' ) ? FTP_USER : $credentials['username']; | |
| 175 | + $credentials['password'] = defined( 'FTP_PASS' ) ? FTP_PASS : ''; | |
| 176 | 176 | |
| 177 | 177 | // Check to see if we are setting the public/private keys for ssh | 
| 178 | -		$credentials['public_key'] = defined('FTP_PUBKEY') ? FTP_PUBKEY : ''; | |
| 179 | -		$credentials['private_key'] = defined('FTP_PRIKEY') ? FTP_PRIKEY : ''; | |
| 178 | + $credentials['public_key'] = defined( 'FTP_PUBKEY' ) ? FTP_PUBKEY : ''; | |
| 179 | + $credentials['private_key'] = defined( 'FTP_PRIKEY' ) ? FTP_PRIKEY : ''; | |
| 180 | 180 | |
| 181 | 181 | // Sanitize the hostname, Some people might pass in odd-data: | 
| 182 | 182 | $credentials['hostname'] = preg_replace( '|\w+://|', '', $credentials['hostname'] ); //Strip any schemes off | 
| @@ -218,7 +218,7 @@ discard block | ||
| 218 | 218 | } | 
| 219 | 219 | |
| 220 | 220 |  	public function destroy( $id ) { | 
| 221 | - return wp_delete_post($id); | |
| 221 | + return wp_delete_post( $id ); | |
| 222 | 222 | } | 
| 223 | 223 | |
| 224 | 224 |      public function get_one() { | 
| @@ -232,19 +232,19 @@ discard block | ||
| 232 | 232 | return $style; | 
| 233 | 233 | } | 
| 234 | 234 | |
| 235 | - $style = get_post($this->id); | |
| 235 | + $style = get_post( $this->id ); | |
| 236 | 236 | |
| 237 | 237 |          if ( ! $style ) { | 
| 238 | 238 | return $style; | 
| 239 | 239 | } | 
| 240 | 240 | |
| 241 | - $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content); | |
| 241 | + $style->post_content = FrmAppHelper::maybe_json_decode( $style->post_content ); | |
| 242 | 242 | |
| 243 | 243 | $default_values = $this->get_defaults(); | 
| 244 | 244 | |
| 245 | 245 | // fill default values | 
| 246 | - $style->post_content = $this->override_defaults($style->post_content); | |
| 247 | - $style->post_content = wp_parse_args( $style->post_content, $default_values); | |
| 246 | + $style->post_content = $this->override_defaults( $style->post_content ); | |
| 247 | + $style->post_content = wp_parse_args( $style->post_content, $default_values ); | |
| 248 | 248 | |
| 249 | 249 | return $style; | 
| 250 | 250 | } | 
| @@ -258,21 +258,21 @@ discard block | ||
| 258 | 258 | 'order' => $order, | 
| 259 | 259 | ); | 
| 260 | 260 | |
| 261 | - $temp_styles = FrmAppHelper::check_cache(serialize($post_atts), 'frm_styles', $post_atts, 'get_posts'); | |
| 261 | + $temp_styles = FrmAppHelper::check_cache( serialize( $post_atts ), 'frm_styles', $post_atts, 'get_posts' ); | |
| 262 | 262 | |
| 263 | -        if ( empty($temp_styles) ) { | |
| 263 | +        if ( empty( $temp_styles ) ) { | |
| 264 | 264 | global $wpdb; | 
| 265 | 265 | // make sure there wasn't a conflict with the query | 
| 266 | 266 | $query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->posts . ' WHERE post_type=%s AND post_status=%s ORDER BY post_title ASC LIMIT 99', FrmStylesController::$post_type, 'publish' ); | 
| 267 | -            $temp_styles = FrmAppHelper::check_cache('frm_backup_style_check', 'frm_styles', $query, 'get_results'); | |
| 267 | + $temp_styles = FrmAppHelper::check_cache( 'frm_backup_style_check', 'frm_styles', $query, 'get_results' ); | |
| 268 | 268 | |
| 269 | -            if ( empty($temp_styles) ) { | |
| 269 | +            if ( empty( $temp_styles ) ) { | |
| 270 | 270 | // create a new style if there are none | 
| 271 | 271 | $new = $this->get_new(); | 
| 272 | 272 | $new->post_title = $new->post_name = __( 'Formidable Style', 'formidable' ); | 
| 273 | 273 | $new->menu_order = 1; | 
| 274 | - $new = $this->save( (array) $new); | |
| 275 | -         		$this->update('default'); | |
| 274 | + $new = $this->save( (array) $new ); | |
| 275 | + $this->update( 'default' ); | |
| 276 | 276 | |
| 277 | 277 | $post_atts['include'] = $new; | 
| 278 | 278 | |
| @@ -296,25 +296,25 @@ discard block | ||
| 296 | 296 | } | 
| 297 | 297 | } | 
| 298 | 298 | |
| 299 | - $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content); | |
| 299 | + $style->post_content = FrmAppHelper::maybe_json_decode( $style->post_content ); | |
| 300 | 300 | |
| 301 | 301 | // fill default values | 
| 302 | - $style->post_content = $this->override_defaults($style->post_content); | |
| 303 | - $style->post_content = wp_parse_args( $style->post_content, $default_values); | |
| 302 | + $style->post_content = $this->override_defaults( $style->post_content ); | |
| 303 | + $style->post_content = wp_parse_args( $style->post_content, $default_values ); | |
| 304 | 304 | |
| 305 | - $styles[ $style->ID ] = $style; | |
| 305 | + $styles[$style->ID] = $style; | |
| 306 | 306 | } | 
| 307 | 307 | |
| 308 | 308 |          if ( ! $default_style ) { | 
| 309 | - $default_style = reset($styles); | |
| 310 | - $styles[ $default_style->ID ]->menu_order = 1; | |
| 309 | + $default_style = reset( $styles ); | |
| 310 | + $styles[$default_style->ID]->menu_order = 1; | |
| 311 | 311 | } | 
| 312 | 312 | |
| 313 | 313 | return $styles; | 
| 314 | 314 | } | 
| 315 | 315 | |
| 316 | 316 |  	public function get_default_style( $styles = null ) { | 
| 317 | -        if ( ! isset($styles) ) { | |
| 317 | +        if ( ! isset( $styles ) ) { | |
| 318 | 318 | $styles = $this->get_all( 'menu_order', 'DESC', 1 ); | 
| 319 | 319 | } | 
| 320 | 320 | |
| @@ -326,24 +326,24 @@ discard block | ||
| 326 | 326 | } | 
| 327 | 327 | |
| 328 | 328 |  	public function override_defaults( $settings ) { | 
| 329 | -	    if ( ! is_array($settings) ) { | |
| 329 | +	    if ( ! is_array( $settings ) ) { | |
| 330 | 330 | return $settings; | 
| 331 | 331 | } | 
| 332 | 332 | |
| 333 | - $settings['line_height'] = ( ! isset($settings['field_height']) || $settings['field_height'] == '' || $settings['field_height'] == 'auto') ? 'normal' : $settings['field_height']; | |
| 333 | + $settings['line_height'] = ( ! isset( $settings['field_height'] ) || $settings['field_height'] == '' || $settings['field_height'] == 'auto' ) ? 'normal' : $settings['field_height']; | |
| 334 | 334 | |
| 335 | -	    if ( ! isset($settings['form_desc_size']) && isset($settings['description_font_size']) ) { | |
| 335 | +	    if ( ! isset( $settings['form_desc_size'] ) && isset( $settings['description_font_size'] ) ) { | |
| 336 | 336 | $settings['form_desc_size'] = $settings['description_font_size']; | 
| 337 | 337 | $settings['form_desc_color'] = $settings['description_color']; | 
| 338 | 338 | $settings['title_color'] = $settings['label_color']; | 
| 339 | 339 | } | 
| 340 | 340 | |
| 341 | -	    if ( ! isset($settings['section_color']) && isset($settings['label_color']) ) { | |
| 341 | +	    if ( ! isset( $settings['section_color'] ) && isset( $settings['label_color'] ) ) { | |
| 342 | 342 | $settings['section_color'] = $settings['label_color']; | 
| 343 | 343 | $settings['section_border_color'] = $settings['border_color']; | 
| 344 | 344 | } | 
| 345 | 345 | |
| 346 | -	    if ( ! isset($settings['submit_hover_bg_color']) && isset($settings['submit_bg_color']) ) { | |
| 346 | +	    if ( ! isset( $settings['submit_hover_bg_color'] ) && isset( $settings['submit_bg_color'] ) ) { | |
| 347 | 347 | $settings['submit_hover_bg_color'] = $settings['submit_bg_color']; | 
| 348 | 348 | $settings['submit_hover_color'] = $settings['submit_text_color']; | 
| 349 | 349 | $settings['submit_hover_border_color'] = $settings['submit_border_color']; | 
| @@ -143,8 +143,8 @@ | ||
| 143 | 143 | add_action( 'wp_ajax_frm_deauthorize', 'FrmAppController::deauthorize' ); | 
| 144 | 144 | |
| 145 | 145 | // Addons Controller | 
| 146 | -		add_action('wp_ajax_frm_addon_activate', 'FrmAddon::activate' ); | |
| 147 | -		add_action('wp_ajax_frm_addon_deactivate', 'FrmAddon::deactivate' ); | |
| 146 | + add_action( 'wp_ajax_frm_addon_activate', 'FrmAddon::activate' ); | |
| 147 | + add_action( 'wp_ajax_frm_addon_deactivate', 'FrmAddon::deactivate' ); | |
| 148 | 148 | |
| 149 | 149 | // Fields Controller | 
| 150 | 150 | add_action( 'wp_ajax_frm_load_field', 'FrmFieldsController::load_field' ); | 
| @@ -1,91 +1,91 @@ discard block | ||
| 1 | 1 | <?php | 
| 2 | 2 | |
| 3 | 3 |  class FrmHooksController { | 
| 4 | - /** | |
| 5 | - * Trigger plugin-wide hook loading | |
| 6 | - */ | |
| 7 | -    public static function trigger_load_hook( $hooks = 'load_hooks' ) { | |
| 8 | - $controllers = apply_filters( 'frm_load_controllers', array( 'FrmHooksController' ) ); | |
| 9 | - | |
| 10 | - $trigger_hooks = $hooks; | |
| 11 | - $hooks = (array) $hooks; | |
| 12 | - | |
| 13 | -        if ( 'load_hooks' == $trigger_hooks ) { | |
| 14 | -            if ( is_admin() ) { | |
| 15 | - $hooks[] = 'load_admin_hooks'; | |
| 16 | -                if ( defined( 'DOING_AJAX' ) ) { | |
| 17 | - $hooks[] = 'load_ajax_hooks'; | |
| 18 | - $hooks[] = 'load_form_hooks'; | |
| 19 | - } | |
| 20 | - } | |
| 21 | - | |
| 22 | -            if ( is_multisite() ) { | |
| 23 | - $hooks[] = 'load_multisite_hooks'; | |
| 24 | - } | |
| 25 | -        } else { | |
| 26 | - // Make sure the hooks are only triggered once | |
| 27 | - add_filter( 'frm' . str_replace( 'load', '', $trigger_hooks ) . '_loaded', '__return_true' ); | |
| 28 | - } | |
| 29 | - unset( $trigger_hooks ); | |
| 30 | - | |
| 31 | - // Instansiate Controllers | |
| 32 | -        foreach ( $controllers as $c ) { | |
| 33 | -            foreach ( $hooks as $hook ) { | |
| 4 | + /** | |
| 5 | + * Trigger plugin-wide hook loading | |
| 6 | + */ | |
| 7 | +	public static function trigger_load_hook( $hooks = 'load_hooks' ) { | |
| 8 | + $controllers = apply_filters( 'frm_load_controllers', array( 'FrmHooksController' ) ); | |
| 9 | + | |
| 10 | + $trigger_hooks = $hooks; | |
| 11 | + $hooks = (array) $hooks; | |
| 12 | + | |
| 13 | +		if ( 'load_hooks' == $trigger_hooks ) { | |
| 14 | +			if ( is_admin() ) { | |
| 15 | + $hooks[] = 'load_admin_hooks'; | |
| 16 | +				if ( defined( 'DOING_AJAX' ) ) { | |
| 17 | + $hooks[] = 'load_ajax_hooks'; | |
| 18 | + $hooks[] = 'load_form_hooks'; | |
| 19 | + } | |
| 20 | + } | |
| 21 | + | |
| 22 | +			if ( is_multisite() ) { | |
| 23 | + $hooks[] = 'load_multisite_hooks'; | |
| 24 | + } | |
| 25 | +		} else { | |
| 26 | + // Make sure the hooks are only triggered once | |
| 27 | + add_filter( 'frm' . str_replace( 'load', '', $trigger_hooks ) . '_loaded', '__return_true' ); | |
| 28 | + } | |
| 29 | + unset( $trigger_hooks ); | |
| 30 | + | |
| 31 | + // Instansiate Controllers | |
| 32 | +		foreach ( $controllers as $c ) { | |
| 33 | +			foreach ( $hooks as $hook ) { | |
| 34 | 34 | call_user_func( array( $c, $hook ) ); | 
| 35 | 35 | unset( $hook ); | 
| 36 | - } | |
| 36 | + } | |
| 37 | 37 | unset( $c ); | 
| 38 | - } | |
| 38 | + } | |
| 39 | 39 | |
| 40 | - } | |
| 40 | + } | |
| 41 | 41 | |
| 42 | -    public static function trigger_load_form_hooks() { | |
| 43 | - self::trigger_load_hook( 'load_form_hooks' ); | |
| 44 | - } | |
| 42 | +	public static function trigger_load_form_hooks() { | |
| 43 | + self::trigger_load_hook( 'load_form_hooks' ); | |
| 44 | + } | |
| 45 | 45 | |
| 46 | 46 |  	public static function load_hooks() { | 
| 47 | -        if ( ! is_admin() ) { | |
| 48 | - add_filter( 'the_content', 'FrmAppController::page_route', 10 ); | |
| 49 | - } | |
| 50 | - | |
| 51 | - add_action( 'plugins_loaded', 'FrmAppController::load_lang' ); | |
| 52 | - add_filter( 'widget_text', 'FrmAppController::widget_text_filter', 8 ); | |
| 53 | - | |
| 54 | - // Entries controller | |
| 55 | - add_action( 'wp_loaded', 'FrmEntriesController::process_entry', 10, 0 ); | |
| 56 | - add_filter( 'frm_redirect_url', 'FrmEntriesController::delete_entry_before_redirect', 50, 3 ); | |
| 57 | - add_action( 'frm_after_entry_processed', 'FrmEntriesController::delete_entry_after_save', 100 ); | |
| 58 | - add_filter( 'frm_email_value', 'FrmEntriesController::filter_email_value', 10, 3 ); | |
| 59 | - add_filter( 'frmpro_fields_replace_shortcodes', 'FrmEntriesController::filter_shortcode_value', 10, 4 ); | |
| 60 | - | |
| 61 | - // Form Actions Controller | |
| 62 | - add_action( 'init', 'FrmFormActionsController::register_post_types', 1 ); | |
| 47 | +		if ( ! is_admin() ) { | |
| 48 | + add_filter( 'the_content', 'FrmAppController::page_route', 10 ); | |
| 49 | + } | |
| 50 | + | |
| 51 | + add_action( 'plugins_loaded', 'FrmAppController::load_lang' ); | |
| 52 | + add_filter( 'widget_text', 'FrmAppController::widget_text_filter', 8 ); | |
| 53 | + | |
| 54 | + // Entries controller | |
| 55 | + add_action( 'wp_loaded', 'FrmEntriesController::process_entry', 10, 0 ); | |
| 56 | + add_filter( 'frm_redirect_url', 'FrmEntriesController::delete_entry_before_redirect', 50, 3 ); | |
| 57 | + add_action( 'frm_after_entry_processed', 'FrmEntriesController::delete_entry_after_save', 100 ); | |
| 58 | + add_filter( 'frm_email_value', 'FrmEntriesController::filter_email_value', 10, 3 ); | |
| 59 | + add_filter( 'frmpro_fields_replace_shortcodes', 'FrmEntriesController::filter_shortcode_value', 10, 4 ); | |
| 60 | + | |
| 61 | + // Form Actions Controller | |
| 62 | + add_action( 'init', 'FrmFormActionsController::register_post_types', 1 ); | |
| 63 | 63 | add_action( 'frm_after_create_entry', 'FrmFormActionsController::trigger_create_actions', 20, 3 ); | 
| 64 | 64 | |
| 65 | - // Forms Controller | |
| 66 | - add_action( 'widgets_init', 'FrmFormsController::register_widgets' ); | |
| 65 | + // Forms Controller | |
| 66 | + add_action( 'widgets_init', 'FrmFormsController::register_widgets' ); | |
| 67 | 67 | add_action( 'init', 'FrmFormsController::front_head' ); | 
| 68 | - add_filter( 'frm_content', 'FrmFormsController::filter_content', 10, 3 ); | |
| 69 | - add_filter( 'frm_replace_content_shortcodes', 'FrmFormsController::replace_content_shortcodes', 20, 3 ); | |
| 70 | - add_action( 'admin_bar_init', 'FrmFormsController::admin_bar_css' ); | |
| 68 | + add_filter( 'frm_content', 'FrmFormsController::filter_content', 10, 3 ); | |
| 69 | + add_filter( 'frm_replace_content_shortcodes', 'FrmFormsController::replace_content_shortcodes', 20, 3 ); | |
| 70 | + add_action( 'admin_bar_init', 'FrmFormsController::admin_bar_css' ); | |
| 71 | 71 | add_action( 'wp_footer', 'FrmFormsController::footer_js', 1, 0 ); | 
| 72 | 72 | |
| 73 | 73 | add_action( 'wp_scheduled_delete', 'FrmForm::scheduled_delete' ); | 
| 74 | 74 | |
| 75 | - // Form Shortcodes | |
| 76 | - add_shortcode( 'formidable', 'FrmFormsController::get_form_shortcode' ); | |
| 75 | + // Form Shortcodes | |
| 76 | + add_shortcode( 'formidable', 'FrmFormsController::get_form_shortcode' ); | |
| 77 | 77 | |
| 78 | - // Styles Controller | |
| 79 | - add_action( 'init', 'FrmStylesController::register_post_types', 0 ); | |
| 80 | - add_filter( 'frm_get_style_opts', 'FrmStylesController::get_style_opts' ); | |
| 81 | - add_filter( 'frm_add_form_style_class', 'FrmStylesController::get_form_style_class', 10, 2 ); | |
| 82 | - add_filter( 'frm_show_entry_styles', 'FrmStylesController::show_entry_styles' ); | |
| 83 | - } | |
| 78 | + // Styles Controller | |
| 79 | + add_action( 'init', 'FrmStylesController::register_post_types', 0 ); | |
| 80 | + add_filter( 'frm_get_style_opts', 'FrmStylesController::get_style_opts' ); | |
| 81 | + add_filter( 'frm_add_form_style_class', 'FrmStylesController::get_form_style_class', 10, 2 ); | |
| 82 | + add_filter( 'frm_show_entry_styles', 'FrmStylesController::show_entry_styles' ); | |
| 83 | + } | |
| 84 | 84 | |
| 85 | 85 |  	public static function load_admin_hooks() { | 
| 86 | - add_action( 'admin_menu', 'FrmAppController::menu', 1 ); | |
| 87 | - add_action( 'admin_enqueue_scripts', 'FrmAppController::load_wp_admin_style' ); | |
| 88 | - add_action( 'admin_notices', 'FrmAppController::pro_get_started_headline' ); | |
| 86 | + add_action( 'admin_menu', 'FrmAppController::menu', 1 ); | |
| 87 | + add_action( 'admin_enqueue_scripts', 'FrmAppController::load_wp_admin_style' ); | |
| 88 | + add_action( 'admin_notices', 'FrmAppController::pro_get_started_headline' ); | |
| 89 | 89 | add_action( 'admin_init', 'FrmAppController::admin_init', 11 ); | 
| 90 | 90 | add_filter( 'admin_body_class', 'FrmAppController::wp_admin_body_class' ); | 
| 91 | 91 | add_filter( 'plugin_action_links_' . FrmAppHelper::plugin_folder() . '/formidable.php', 'FrmAppController::settings_link' ); | 
| @@ -94,122 +94,122 @@ discard block | ||
| 94 | 94 | // Addons Controller | 
| 95 | 95 | add_action( 'admin_menu', 'FrmAddonsController::menu', 100 ); | 
| 96 | 96 | |
| 97 | - // Entries Controller | |
| 98 | - add_action( 'admin_menu', 'FrmEntriesController::menu', 12 ); | |
| 99 | - add_filter( 'contextual_help', 'FrmEntriesController::contextual_help', 10, 3 ); | |
| 100 | - add_filter( 'set-screen-option', 'FrmEntriesController::save_per_page', 10, 3 ); | |
| 101 | - add_filter( 'update_user_metadata', 'FrmEntriesController::check_hidden_cols', 10, 5 ); | |
| 102 | - add_action( 'updated_user_meta', 'FrmEntriesController::update_hidden_cols', 10, 4 ); | |
| 97 | + // Entries Controller | |
| 98 | + add_action( 'admin_menu', 'FrmEntriesController::menu', 12 ); | |
| 99 | + add_filter( 'contextual_help', 'FrmEntriesController::contextual_help', 10, 3 ); | |
| 100 | + add_filter( 'set-screen-option', 'FrmEntriesController::save_per_page', 10, 3 ); | |
| 101 | + add_filter( 'update_user_metadata', 'FrmEntriesController::check_hidden_cols', 10, 5 ); | |
| 102 | + add_action( 'updated_user_meta', 'FrmEntriesController::update_hidden_cols', 10, 4 ); | |
| 103 | 103 | |
| 104 | - // Fields Controller | |
| 105 | - add_filter( 'frm_display_field_options', 'FrmFieldsController::display_field_options' ); | |
| 104 | + // Fields Controller | |
| 105 | + add_filter( 'frm_display_field_options', 'FrmFieldsController::display_field_options' ); | |
| 106 | 106 | |
| 107 | - // Form Actions Controller | |
| 108 | -        if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { | |
| 109 | - add_action( 'frm_before_update_form_settings', 'FrmFormActionsController::update_settings' ); | |
| 110 | - } | |
| 111 | - add_action( 'frm_after_duplicate_form', 'FrmFormActionsController::duplicate_form_actions', 20, 3 ); | |
| 107 | + // Form Actions Controller | |
| 108 | +		if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { | |
| 109 | + add_action( 'frm_before_update_form_settings', 'FrmFormActionsController::update_settings' ); | |
| 110 | + } | |
| 111 | + add_action( 'frm_after_duplicate_form', 'FrmFormActionsController::duplicate_form_actions', 20, 3 ); | |
| 112 | 112 | |
| 113 | - // Forms Controller | |
| 114 | - add_action( 'admin_menu', 'FrmFormsController::menu', 10 ); | |
| 115 | - add_action( 'admin_head-toplevel_page_formidable', 'FrmFormsController::head' ); | |
| 113 | + // Forms Controller | |
| 114 | + add_action( 'admin_menu', 'FrmFormsController::menu', 10 ); | |
| 115 | + add_action( 'admin_head-toplevel_page_formidable', 'FrmFormsController::head' ); | |
| 116 | 116 | |
| 117 | - add_filter( 'set-screen-option', 'FrmFormsController::save_per_page', 10, 3 ); | |
| 118 | - add_action( 'admin_footer', 'FrmFormsController::insert_form_popup' ); | |
| 117 | + add_filter( 'set-screen-option', 'FrmFormsController::save_per_page', 10, 3 ); | |
| 118 | + add_action( 'admin_footer', 'FrmFormsController::insert_form_popup' ); | |
| 119 | 119 | add_action( 'media_buttons', 'FrmFormsController::insert_form_button' ); | 
| 120 | 120 | |
| 121 | - // Forms Model | |
| 122 | - add_action( 'frm_after_duplicate_form', 'FrmForm::after_duplicate', 10, 2 ); | |
| 121 | + // Forms Model | |
| 122 | + add_action( 'frm_after_duplicate_form', 'FrmForm::after_duplicate', 10, 2 ); | |
| 123 | 123 | |
| 124 | - // Settings Controller | |
| 125 | - add_action( 'admin_menu', 'FrmSettingsController::menu', 45 ); | |
| 126 | - add_action( 'frm_before_settings', 'FrmSettingsController::license_box' ); | |
| 124 | + // Settings Controller | |
| 125 | + add_action( 'admin_menu', 'FrmSettingsController::menu', 45 ); | |
| 126 | + add_action( 'frm_before_settings', 'FrmSettingsController::license_box' ); | |
| 127 | 127 | |
| 128 | - // Styles Controller | |
| 129 | - add_action( 'admin_menu', 'FrmStylesController::menu', 14 ); | |
| 130 | - add_action( 'admin_init', 'FrmStylesController::admin_init' ); | |
| 128 | + // Styles Controller | |
| 129 | + add_action( 'admin_menu', 'FrmStylesController::menu', 14 ); | |
| 130 | + add_action( 'admin_init', 'FrmStylesController::admin_init' ); | |
| 131 | 131 | |
| 132 | - // XML Controller | |
| 133 | - add_action( 'admin_menu', 'FrmXMLController::menu', 41 ); | |
| 134 | - } | |
| 132 | + // XML Controller | |
| 133 | + add_action( 'admin_menu', 'FrmXMLController::menu', 41 ); | |
| 134 | + } | |
| 135 | 135 | |
| 136 | 136 |  	public static function load_ajax_hooks() { | 
| 137 | 137 | add_action( 'wp_ajax_frm_silent_upgrade', 'FrmAppController::ajax_install' ); | 
| 138 | 138 | add_action( 'wp_ajax_nopriv_frm_silent_upgrade', 'FrmAppController::ajax_install' ); | 
| 139 | 139 | add_action( 'wp_ajax_frm_install', 'FrmAppController::ajax_install' ); | 
| 140 | - add_action( 'wp_ajax_frm_uninstall', 'FrmAppController::uninstall' ); | |
| 141 | - add_action( 'wp_ajax_frm_deauthorize', 'FrmAppController::deauthorize' ); | |
| 140 | + add_action( 'wp_ajax_frm_uninstall', 'FrmAppController::uninstall' ); | |
| 141 | + add_action( 'wp_ajax_frm_deauthorize', 'FrmAppController::deauthorize' ); | |
| 142 | 142 | |
| 143 | 143 | // Addons | 
| 144 | 144 |  		add_action('wp_ajax_frm_addon_activate', 'FrmAddon::activate' ); | 
| 145 | 145 |  		add_action('wp_ajax_frm_addon_deactivate', 'FrmAddon::deactivate' ); | 
| 146 | 146 | add_action( 'wp_ajax_frm_fill_licenses', 'FrmAddonsController::get_licenses' ); | 
| 147 | 147 | |
| 148 | - // Fields Controller | |
| 149 | - add_action( 'wp_ajax_frm_load_field', 'FrmFieldsController::load_field' ); | |
| 150 | - add_action( 'wp_ajax_frm_insert_field', 'FrmFieldsController::create' ); | |
| 151 | - add_action( 'wp_ajax_frm_field_name_in_place_edit', 'FrmFieldsController::edit_name' ); | |
| 152 | - add_action( 'wp_ajax_frm_update_ajax_option', 'FrmFieldsController::update_ajax_option' ); | |
| 153 | - add_action( 'wp_ajax_frm_duplicate_field', 'FrmFieldsController::duplicate' ); | |
| 154 | - add_action( 'wp_ajax_frm_delete_field', 'FrmFieldsController::destroy' ); | |
| 155 | - add_action( 'wp_ajax_frm_add_field_option', 'FrmFieldsController::add_option' ); | |
| 156 | - add_action( 'wp_ajax_frm_field_option_ipe', 'FrmFieldsController::edit_option' ); | |
| 157 | - add_action( 'wp_ajax_frm_delete_field_option', 'FrmFieldsController::delete_option' ); | |
| 158 | - add_action( 'wp_ajax_frm_import_choices', 'FrmFieldsController::import_choices' ); | |
| 159 | - add_action( 'wp_ajax_frm_import_options', 'FrmFieldsController::import_options' ); | |
| 160 | - add_action( 'wp_ajax_frm_update_field_order', 'FrmFieldsController::update_order' ); | |
| 161 | - | |
| 162 | - // Form Actions Controller | |
| 163 | - add_action( 'wp_ajax_frm_add_form_action', 'FrmFormActionsController::add_form_action' ); | |
| 164 | - add_action( 'wp_ajax_frm_form_action_fill', 'FrmFormActionsController::fill_action' ); | |
| 165 | - | |
| 166 | - // Forms Controller | |
| 148 | + // Fields Controller | |
| 149 | + add_action( 'wp_ajax_frm_load_field', 'FrmFieldsController::load_field' ); | |
| 150 | + add_action( 'wp_ajax_frm_insert_field', 'FrmFieldsController::create' ); | |
| 151 | + add_action( 'wp_ajax_frm_field_name_in_place_edit', 'FrmFieldsController::edit_name' ); | |
| 152 | + add_action( 'wp_ajax_frm_update_ajax_option', 'FrmFieldsController::update_ajax_option' ); | |
| 153 | + add_action( 'wp_ajax_frm_duplicate_field', 'FrmFieldsController::duplicate' ); | |
| 154 | + add_action( 'wp_ajax_frm_delete_field', 'FrmFieldsController::destroy' ); | |
| 155 | + add_action( 'wp_ajax_frm_add_field_option', 'FrmFieldsController::add_option' ); | |
| 156 | + add_action( 'wp_ajax_frm_field_option_ipe', 'FrmFieldsController::edit_option' ); | |
| 157 | + add_action( 'wp_ajax_frm_delete_field_option', 'FrmFieldsController::delete_option' ); | |
| 158 | + add_action( 'wp_ajax_frm_import_choices', 'FrmFieldsController::import_choices' ); | |
| 159 | + add_action( 'wp_ajax_frm_import_options', 'FrmFieldsController::import_options' ); | |
| 160 | + add_action( 'wp_ajax_frm_update_field_order', 'FrmFieldsController::update_order' ); | |
| 161 | + | |
| 162 | + // Form Actions Controller | |
| 163 | + add_action( 'wp_ajax_frm_add_form_action', 'FrmFormActionsController::add_form_action' ); | |
| 164 | + add_action( 'wp_ajax_frm_form_action_fill', 'FrmFormActionsController::fill_action' ); | |
| 165 | + | |
| 166 | + // Forms Controller | |
| 167 | 167 | add_action( 'wp_ajax_frm_create_from_template', 'FrmFormsController::_create_from_template' ); | 
| 168 | 168 | add_action( 'wp_ajax_frm_save_form', 'FrmFormsController::route' ); | 
| 169 | 169 | add_action( 'wp_ajax_frm_form_key_in_place_edit', 'FrmFormsController::edit_key' ); | 
| 170 | 170 | add_action( 'wp_ajax_frm_form_desc_in_place_edit', 'FrmFormsController::edit_description' ); | 
| 171 | - add_action( 'wp_ajax_frm_get_default_html', 'FrmFormsController::get_email_html' ); | |
| 172 | - add_action( 'wp_ajax_frm_get_shortcode_opts', 'FrmFormsController::get_shortcode_opts' ); | |
| 173 | - add_action( 'wp_ajax_frm_forms_preview', 'FrmFormsController::preview' ); | |
| 174 | - add_action( 'wp_ajax_nopriv_frm_forms_preview', 'FrmFormsController::preview' ); | |
| 175 | - | |
| 176 | - // Styles Controller | |
| 177 | - add_action( 'wp_ajax_frm_settings_reset', 'FrmStylesController::reset_styling' ); | |
| 178 | - add_action( 'wp_ajax_frm_change_styling', 'FrmStylesController::change_styling' ); | |
| 179 | - add_action( 'wp_ajax_frmpro_load_css', 'FrmStylesController::load_css' ); | |
| 180 | - add_action( 'wp_ajax_nopriv_frmpro_load_css', 'FrmStylesController::load_css' ); | |
| 171 | + add_action( 'wp_ajax_frm_get_default_html', 'FrmFormsController::get_email_html' ); | |
| 172 | + add_action( 'wp_ajax_frm_get_shortcode_opts', 'FrmFormsController::get_shortcode_opts' ); | |
| 173 | + add_action( 'wp_ajax_frm_forms_preview', 'FrmFormsController::preview' ); | |
| 174 | + add_action( 'wp_ajax_nopriv_frm_forms_preview', 'FrmFormsController::preview' ); | |
| 175 | + | |
| 176 | + // Styles Controller | |
| 177 | + add_action( 'wp_ajax_frm_settings_reset', 'FrmStylesController::reset_styling' ); | |
| 178 | + add_action( 'wp_ajax_frm_change_styling', 'FrmStylesController::change_styling' ); | |
| 179 | + add_action( 'wp_ajax_frmpro_load_css', 'FrmStylesController::load_css' ); | |
| 180 | + add_action( 'wp_ajax_nopriv_frmpro_load_css', 'FrmStylesController::load_css' ); | |
| 181 | 181 | add_action( 'wp_ajax_frmpro_css', 'FrmStylesController::load_saved_css' ); | 
| 182 | 182 | add_action( 'wp_ajax_nopriv_frmpro_css', 'FrmStylesController::load_saved_css' ); | 
| 183 | 183 | |
| 184 | - // XML Controller | |
| 184 | + // XML Controller | |
| 185 | 185 | add_action( 'wp_ajax_frm_entries_csv', 'FrmXMLController::csv' ); | 
| 186 | 186 | add_action( 'wp_ajax_nopriv_frm_entries_csv', 'FrmXMLController::csv' ); | 
| 187 | - add_action( 'wp_ajax_frm_export_xml', 'FrmXMLController::export_xml' ); | |
| 188 | - } | |
| 187 | + add_action( 'wp_ajax_frm_export_xml', 'FrmXMLController::export_xml' ); | |
| 188 | + } | |
| 189 | 189 | |
| 190 | 190 |  	public static function load_form_hooks() { | 
| 191 | - // Fields Controller | |
| 192 | - add_filter( 'frm_field_type', 'FrmFieldsController::change_type' ); | |
| 193 | - add_action( 'frm_field_input_html', 'FrmFieldsController::input_html' ); | |
| 194 | - add_filter( 'frm_field_value_saved', 'FrmFieldsController::check_value', 50, 3 ); | |
| 195 | - add_filter( 'frm_field_label_seen', 'FrmFieldsController::check_label' ); | |
| 191 | + // Fields Controller | |
| 192 | + add_filter( 'frm_field_type', 'FrmFieldsController::change_type' ); | |
| 193 | + add_action( 'frm_field_input_html', 'FrmFieldsController::input_html' ); | |
| 194 | + add_filter( 'frm_field_value_saved', 'FrmFieldsController::check_value', 50, 3 ); | |
| 195 | + add_filter( 'frm_field_label_seen', 'FrmFieldsController::check_label' ); | |
| 196 | 196 | |
| 197 | 197 | // Forms Controller | 
| 198 | 198 | add_filter( 'frm_form_classes', 'FrmFormsController::form_classes' ); | 
| 199 | 199 | |
| 200 | - // Styles Controller | |
| 201 | - add_filter( 'frm_use_important_width', 'FrmStylesController::important_style', 10, 2 ); | |
| 202 | - } | |
| 200 | + // Styles Controller | |
| 201 | + add_filter( 'frm_use_important_width', 'FrmStylesController::important_style', 10, 2 ); | |
| 202 | + } | |
| 203 | 203 | |
| 204 | 204 |  	public static function load_view_hooks() { | 
| 205 | - // Hooks go here when a view is loaded | |
| 206 | - } | |
| 205 | + // Hooks go here when a view is loaded | |
| 206 | + } | |
| 207 | 207 | |
| 208 | 208 |  	public static function load_multisite_hooks() { | 
| 209 | 209 | add_action( 'init', 'FrmAppController::front_head' ); | 
| 210 | 210 | add_action( 'wpmu_upgrade_site', 'FrmAppController::network_upgrade_site' ); | 
| 211 | 211 | |
| 212 | - // drop tables when mu site is deleted | |
| 213 | - add_filter( 'wpmu_drop_tables', 'FrmAppController::drop_tables' ); | |
| 214 | - } | |
| 212 | + // drop tables when mu site is deleted | |
| 213 | + add_filter( 'wpmu_drop_tables', 'FrmAppController::drop_tables' ); | |
| 214 | + } | |
| 215 | 215 | } | 
| @@ -2,78 +2,78 @@ | ||
| 2 | 2 | |
| 3 | 3 |  class FrmSettingsController { | 
| 4 | 4 | |
| 5 | -    public static function menu() { | |
| 5 | +	public static function menu() { | |
| 6 | 6 | // Make sure admins can see the menu items | 
| 7 | 7 | FrmAppHelper::force_capability( 'frm_change_settings' ); | 
| 8 | 8 | |
| 9 | - add_submenu_page( 'formidable', 'Formidable | ' . __( 'Global Settings', 'formidable' ), __( 'Global Settings', 'formidable' ), 'frm_change_settings', 'formidable-settings', 'FrmSettingsController::route' ); | |
| 10 | - } | |
| 9 | + add_submenu_page( 'formidable', 'Formidable | ' . __( 'Global Settings', 'formidable' ), __( 'Global Settings', 'formidable' ), 'frm_change_settings', 'formidable-settings', 'FrmSettingsController::route' ); | |
| 10 | + } | |
| 11 | 11 | |
| 12 | -    public static function license_box() { | |
| 12 | +	public static function license_box() { | |
| 13 | 13 | $a = FrmAppHelper::simple_get( 't', 'sanitize_title', 'general_settings' ); | 
| 14 | - include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/license_box.php' ); | |
| 15 | - } | |
| 14 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/license_box.php' ); | |
| 15 | + } | |
| 16 | 16 | |
| 17 | -    public static function display_form( $errors = array(), $message = '' ) { | |
| 18 | - global $frm_vars; | |
| 17 | +	public static function display_form( $errors = array(), $message = '' ) { | |
| 18 | + global $frm_vars; | |
| 19 | 19 | |
| 20 | - $frm_settings = FrmAppHelper::get_settings(); | |
| 21 | - $frm_roles = FrmAppHelper::frm_capabilities(); | |
| 20 | + $frm_settings = FrmAppHelper::get_settings(); | |
| 21 | + $frm_roles = FrmAppHelper::frm_capabilities(); | |
| 22 | 22 | |
| 23 | - $uploads = wp_upload_dir(); | |
| 24 | - $target_path = $uploads['basedir'] . '/formidable/css'; | |
| 23 | + $uploads = wp_upload_dir(); | |
| 24 | + $target_path = $uploads['basedir'] . '/formidable/css'; | |
| 25 | 25 | |
| 26 | 26 | $sections = array(); | 
| 27 | 27 |  		if ( apply_filters( 'frm_include_addon_page', false ) ) { | 
| 28 | 28 | $sections['licenses'] = array( 'class' => 'FrmAddonsController', 'function' => 'show_addons' ); | 
| 29 | 29 | } | 
| 30 | - $sections = apply_filters( 'frm_add_settings_section', $sections ); | |
| 30 | + $sections = apply_filters( 'frm_add_settings_section', $sections ); | |
| 31 | 31 | |
| 32 | - $captcha_lang = FrmAppHelper::locales( 'captcha' ); | |
| 32 | + $captcha_lang = FrmAppHelper::locales( 'captcha' ); | |
| 33 | 33 | |
| 34 | - require( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/form.php' ); | |
| 35 | - } | |
| 34 | + require( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/form.php' ); | |
| 35 | + } | |
| 36 | 36 | |
| 37 | -    public static function process_form( $stop_load = false ) { | |
| 38 | - global $frm_vars; | |
| 37 | +	public static function process_form( $stop_load = false ) { | |
| 38 | + global $frm_vars; | |
| 39 | 39 | |
| 40 | - $frm_settings = FrmAppHelper::get_settings(); | |
| 40 | + $frm_settings = FrmAppHelper::get_settings(); | |
| 41 | 41 | |
| 42 | 42 | $process_form = FrmAppHelper::get_post_param( 'process_form', '', 'sanitize_text_field' ); | 
| 43 | 43 |  		if ( ! wp_verify_nonce( $process_form, 'process_form_nonce' ) ) { | 
| 44 | - wp_die( $frm_settings->admin_permission ); | |
| 45 | - } | |
| 44 | + wp_die( $frm_settings->admin_permission ); | |
| 45 | + } | |
| 46 | 46 | |
| 47 | - $errors = array(); | |
| 48 | - $message = ''; | |
| 47 | + $errors = array(); | |
| 48 | + $message = ''; | |
| 49 | 49 | |
| 50 | -        if ( ! isset( $frm_vars['settings_routed'] ) || ! $frm_vars['settings_routed'] ) { | |
| 51 | - //$errors = $frm_settings->validate($_POST,array()); | |
| 52 | - $frm_settings->update( stripslashes_deep( $_POST ) ); | |
| 50 | +		if ( ! isset( $frm_vars['settings_routed'] ) || ! $frm_vars['settings_routed'] ) { | |
| 51 | + //$errors = $frm_settings->validate($_POST,array()); | |
| 52 | + $frm_settings->update( stripslashes_deep( $_POST ) ); | |
| 53 | 53 | |
| 54 | -            if ( empty( $errors ) ) { | |
| 55 | - $frm_settings->store(); | |
| 56 | - $message = __( 'Settings Saved', 'formidable' ); | |
| 57 | - } | |
| 58 | -        } else { | |
| 59 | - $message = __( 'Settings Saved', 'formidable' ); | |
| 60 | - } | |
| 54 | +			if ( empty( $errors ) ) { | |
| 55 | + $frm_settings->store(); | |
| 56 | + $message = __( 'Settings Saved', 'formidable' ); | |
| 57 | + } | |
| 58 | +		} else { | |
| 59 | + $message = __( 'Settings Saved', 'formidable' ); | |
| 60 | + } | |
| 61 | 61 | |
| 62 | 62 |  		if ( $stop_load == 'stop_load' ) { | 
| 63 | - $frm_vars['settings_routed'] = true; | |
| 64 | - return; | |
| 65 | - } | |
| 63 | + $frm_vars['settings_routed'] = true; | |
| 64 | + return; | |
| 65 | + } | |
| 66 | 66 | |
| 67 | - self::display_form( $errors, $message ); | |
| 68 | - } | |
| 67 | + self::display_form( $errors, $message ); | |
| 68 | + } | |
| 69 | 69 | |
| 70 | -    public static function route( $stop_load = false ) { | |
| 71 | - $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; | |
| 70 | +	public static function route( $stop_load = false ) { | |
| 71 | + $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; | |
| 72 | 72 | $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ); | 
| 73 | -        if ( $action == 'process-form' ) { | |
| 74 | - return self::process_form( $stop_load ); | |
| 75 | -        } else if ( $stop_load != 'stop_load' ) { | |
| 76 | - return self::display_form(); | |
| 77 | - } | |
| 78 | - } | |
| 73 | +		if ( $action == 'process-form' ) { | |
| 74 | + return self::process_form( $stop_load ); | |
| 75 | +		} else if ( $stop_load != 'stop_load' ) { | |
| 76 | + return self::display_form(); | |
| 77 | + } | |
| 78 | + } | |
| 79 | 79 | } | 
| @@ -5,68 +5,68 @@ discard block | ||
| 5 | 5 | |
| 6 | 6 |  class FrmEntriesHelper { | 
| 7 | 7 | |
| 8 | -    public static function setup_new_vars( $fields, $form = '', $reset = false, $args = array() ) { | |
| 9 | - global $frm_vars; | |
| 10 | - $values = array(); | |
| 8 | +	public static function setup_new_vars( $fields, $form = '', $reset = false, $args = array() ) { | |
| 9 | + global $frm_vars; | |
| 10 | + $values = array(); | |
| 11 | 11 |  		foreach ( array( 'name' => '', 'description' => '', 'item_key' => '' ) as $var => $default ) { | 
| 12 | - $values[ $var ] = FrmAppHelper::get_post_param( $var, $default ); | |
| 13 | - } | |
| 14 | - | |
| 15 | - $values['fields'] = array(); | |
| 16 | -        if ( empty($fields) ) { | |
| 17 | -            return apply_filters('frm_setup_new_entry', $values); | |
| 18 | - } | |
| 19 | - | |
| 20 | -        foreach ( (array) $fields as $field ) { | |
| 21 | - $new_value = self::get_field_value_for_new_entry( $field, $reset ); | |
| 22 | - | |
| 23 | - $field_array = array( | |
| 24 | - 'id' => $field->id, | |
| 25 | - 'value' => $new_value, | |
| 26 | - 'default_value' => $field->default_value, | |
| 27 | - 'name' => $field->name, | |
| 28 | - 'description' => $field->description, | |
| 29 | -                'type' => apply_filters('frm_field_type', $field->type, $field, $new_value), | |
| 30 | - 'options' => $field->options, | |
| 31 | - 'required' => $field->required, | |
| 32 | - 'field_key' => $field->field_key, | |
| 33 | - 'field_order' => $field->field_order, | |
| 34 | - 'form_id' => $field->form_id, | |
| 12 | + $values[ $var ] = FrmAppHelper::get_post_param( $var, $default ); | |
| 13 | + } | |
| 14 | + | |
| 15 | + $values['fields'] = array(); | |
| 16 | +		if ( empty($fields) ) { | |
| 17 | +			return apply_filters('frm_setup_new_entry', $values); | |
| 18 | + } | |
| 19 | + | |
| 20 | +		foreach ( (array) $fields as $field ) { | |
| 21 | + $new_value = self::get_field_value_for_new_entry( $field, $reset ); | |
| 22 | + | |
| 23 | + $field_array = array( | |
| 24 | + 'id' => $field->id, | |
| 25 | + 'value' => $new_value, | |
| 26 | + 'default_value' => $field->default_value, | |
| 27 | + 'name' => $field->name, | |
| 28 | + 'description' => $field->description, | |
| 29 | +				'type' => apply_filters('frm_field_type', $field->type, $field, $new_value), | |
| 30 | + 'options' => $field->options, | |
| 31 | + 'required' => $field->required, | |
| 32 | + 'field_key' => $field->field_key, | |
| 33 | + 'field_order' => $field->field_order, | |
| 34 | + 'form_id' => $field->form_id, | |
| 35 | 35 | 'parent_form_id' => isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id, | 
| 36 | - ); | |
| 36 | + ); | |
| 37 | 37 | |
| 38 | - $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); | |
| 39 | - $opt_defaults['required_indicator'] = ''; | |
| 38 | + $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); | |
| 39 | + $opt_defaults['required_indicator'] = ''; | |
| 40 | 40 | $opt_defaults['original_type'] = $field->type; | 
| 41 | 41 | |
| 42 | 42 |  			foreach ( $opt_defaults as $opt => $default_opt ) { | 
| 43 | - $field_array[ $opt ] = ( isset( $field->field_options[ $opt ] ) && $field->field_options[ $opt ] != '' ) ? $field->field_options[ $opt ] : $default_opt; | |
| 44 | - unset($opt, $default_opt); | |
| 45 | - } | |
| 43 | + $field_array[ $opt ] = ( isset( $field->field_options[ $opt ] ) && $field->field_options[ $opt ] != '' ) ? $field->field_options[ $opt ] : $default_opt; | |
| 44 | + unset($opt, $default_opt); | |
| 45 | + } | |
| 46 | 46 | |
| 47 | - unset($opt_defaults); | |
| 47 | + unset($opt_defaults); | |
| 48 | 48 | |
| 49 | -            if ( $field_array['custom_html'] == '' ) { | |
| 50 | - $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type); | |
| 51 | - } | |
| 49 | +			if ( $field_array['custom_html'] == '' ) { | |
| 50 | + $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type); | |
| 51 | + } | |
| 52 | 52 | |
| 53 | -            $field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field); | |
| 54 | - $field_array = array_merge( $field->field_options, $field_array ); | |
| 53 | +			$field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field); | |
| 54 | + $field_array = array_merge( $field->field_options, $field_array ); | |
| 55 | 55 | |
| 56 | - $values['fields'][] = $field_array; | |
| 56 | + $values['fields'][] = $field_array; | |
| 57 | 57 | |
| 58 | -            if ( ! $form || ! isset($form->id) ) { | |
| 59 | - $form = FrmForm::getOne($field->form_id); | |
| 60 | - } | |
| 61 | - } | |
| 58 | +			if ( ! $form || ! isset($form->id) ) { | |
| 59 | + $form = FrmForm::getOne($field->form_id); | |
| 60 | + } | |
| 61 | + } | |
| 62 | 62 | |
| 63 | - $form->options = maybe_unserialize($form->options); | |
| 64 | -        if ( is_array($form->options) ) { | |
| 65 | -            foreach ( $form->options as $opt => $value ) { | |
| 66 | - $values[ $opt ] = FrmAppHelper::get_post_param( $opt, $value ); | |
| 67 | - unset($opt, $value); | |
| 68 | - } | |
| 69 | - } | |
| 63 | + $form->options = maybe_unserialize($form->options); | |
| 64 | +		if ( is_array($form->options) ) { | |
| 65 | +			foreach ( $form->options as $opt => $value ) { | |
| 66 | + $values[ $opt ] = FrmAppHelper::get_post_param( $opt, $value ); | |
| 67 | + unset($opt, $value); | |
| 68 | + } | |
| 69 | + } | |
| 70 | 70 | |
| 71 | 71 | $form_defaults = FrmFormsHelper::get_default_opts(); | 
| 72 | 72 | |
| @@ -76,18 +76,18 @@ discard block | ||
| 76 | 76 | $values = array_merge( $form_defaults, $values ); | 
| 77 | 77 | |
| 78 | 78 | return apply_filters( 'frm_setup_new_entry', $values ); | 
| 79 | - } | |
| 79 | + } | |
| 80 | 80 | |
| 81 | 81 | /** | 
| 82 | - * Set the value for each field | |
| 83 | - * This function is used when the form is first loaded and on all page turns *for a new entry* | |
| 84 | - * | |
| 85 | - * @since 2.0.13 | |
| 86 | - * | |
| 87 | - * @param object $field - this is passed by reference since it is an object | |
| 88 | - * @param boolean $reset | |
| 89 | - * @return string|array $new_value | |
| 90 | - */ | |
| 82 | + * Set the value for each field | |
| 83 | + * This function is used when the form is first loaded and on all page turns *for a new entry* | |
| 84 | + * | |
| 85 | + * @since 2.0.13 | |
| 86 | + * | |
| 87 | + * @param object $field - this is passed by reference since it is an object | |
| 88 | + * @param boolean $reset | |
| 89 | + * @return string|array $new_value | |
| 90 | + */ | |
| 91 | 91 |  	private static function get_field_value_for_new_entry( $field, $reset ) { | 
| 92 | 92 | //If checkbox, multi-select dropdown, or checkbox data from entries field, the value should be an array | 
| 93 | 93 | $return_array = FrmField::is_field_with_multiple_values( $field ); | 
| @@ -118,15 +118,15 @@ discard block | ||
| 118 | 118 | |
| 119 | 119 |  	public static function setup_edit_vars( $values, $record ) { | 
| 120 | 120 | $values['item_key'] = FrmAppHelper::get_post_param( 'item_key', $record->item_key, 'sanitize_title' ); | 
| 121 | - $values['form_id'] = $record->form_id; | |
| 122 | - $values['is_draft'] = $record->is_draft; | |
| 123 | -        return apply_filters('frm_setup_edit_entry_vars', $values, $record); | |
| 124 | - } | |
| 121 | + $values['form_id'] = $record->form_id; | |
| 122 | + $values['is_draft'] = $record->is_draft; | |
| 123 | +		return apply_filters('frm_setup_edit_entry_vars', $values, $record); | |
| 124 | + } | |
| 125 | 125 | |
| 126 | -    public static function get_admin_params( $form = null ) { | |
| 126 | +	public static function get_admin_params( $form = null ) { | |
| 127 | 127 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::get_admin_params' ); | 
| 128 | 128 | return FrmForm::set_current_form( $form ); | 
| 129 | - } | |
| 129 | + } | |
| 130 | 130 | |
| 131 | 131 |  	public static function set_current_form( $form_id ) { | 
| 132 | 132 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::set_current_form' ); | 
| @@ -138,280 +138,280 @@ discard block | ||
| 138 | 138 | return FrmForm::get_current_form( $form_id ); | 
| 139 | 139 | } | 
| 140 | 140 | |
| 141 | -    public static function get_current_form_id() { | |
| 141 | +	public static function get_current_form_id() { | |
| 142 | 142 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::get_current_form_id' ); | 
| 143 | 143 | return FrmForm::get_current_form_id(); | 
| 144 | - } | |
| 144 | + } | |
| 145 | 145 | |
| 146 | -    public static function maybe_get_entry( &$entry ) { | |
| 146 | +	public static function maybe_get_entry( &$entry ) { | |
| 147 | 147 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntry::maybe_get_entry' ); | 
| 148 | 148 | FrmEntry::maybe_get_entry( $entry ); | 
| 149 | - } | |
| 149 | + } | |
| 150 | 150 | |
| 151 | 151 |  	public static function replace_default_message( $message, $atts ) { | 
| 152 | - if ( strpos($message, '[default-message') === false && | |
| 153 | - strpos($message, '[default_message') === false && | |
| 154 | -            ! empty( $message ) ) { | |
| 155 | - return $message; | |
| 156 | - } | |
| 157 | - | |
| 158 | -        if ( empty($message) ) { | |
| 159 | - $message = '[default-message]'; | |
| 160 | - } | |
| 161 | - | |
| 162 | -        preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER); | |
| 163 | - | |
| 164 | -        foreach ( $shortcodes[0] as $short_key => $tag ) { | |
| 165 | - $add_atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] ); | |
| 166 | -            if ( $add_atts ) { | |
| 167 | - $this_atts = array_merge($atts, $add_atts); | |
| 168 | -            } else { | |
| 169 | - $this_atts = $atts; | |
| 170 | - } | |
| 152 | + if ( strpos($message, '[default-message') === false && | |
| 153 | + strpos($message, '[default_message') === false && | |
| 154 | +			! empty( $message ) ) { | |
| 155 | + return $message; | |
| 156 | + } | |
| 157 | + | |
| 158 | +		if ( empty($message) ) { | |
| 159 | + $message = '[default-message]'; | |
| 160 | + } | |
| 161 | + | |
| 162 | +		preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER); | |
| 163 | + | |
| 164 | +		foreach ( $shortcodes[0] as $short_key => $tag ) { | |
| 165 | + $add_atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] ); | |
| 166 | +			if ( $add_atts ) { | |
| 167 | + $this_atts = array_merge($atts, $add_atts); | |
| 168 | +			} else { | |
| 169 | + $this_atts = $atts; | |
| 170 | + } | |
| 171 | 171 | |
| 172 | 172 | $default = FrmEntryFormat::show_entry( $this_atts ); | 
| 173 | 173 | |
| 174 | - // Add the default message | |
| 175 | - $message = str_replace( $shortcodes[0][ $short_key ], $default, $message ); | |
| 176 | - } | |
| 174 | + // Add the default message | |
| 175 | + $message = str_replace( $shortcodes[0][ $short_key ], $default, $message ); | |
| 176 | + } | |
| 177 | 177 | |
| 178 | - return $message; | |
| 179 | - } | |
| 178 | + return $message; | |
| 179 | + } | |
| 180 | 180 | |
| 181 | 181 |  	public static function prepare_display_value( $entry, $field, $atts ) { | 
| 182 | 182 | $field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false; | 
| 183 | -        if ( FrmAppHelper::pro_is_installed() ) { | |
| 183 | +		if ( FrmAppHelper::pro_is_installed() ) { | |
| 184 | 184 | FrmProEntriesHelper::get_dynamic_list_values( $field, $entry, $field_value ); | 
| 185 | - } | |
| 185 | + } | |
| 186 | 186 | |
| 187 | -        if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) { | |
| 188 | - return self::display_value($field_value, $field, $atts); | |
| 189 | - } | |
| 187 | +		if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) { | |
| 188 | + return self::display_value($field_value, $field, $atts); | |
| 189 | + } | |
| 190 | 190 | |
| 191 | - // this is an embeded form | |
| 192 | - $val = ''; | |
| 191 | + // this is an embeded form | |
| 192 | + $val = ''; | |
| 193 | 193 | |
| 194 | -	    if ( strpos($atts['embedded_field_id'], 'form') === 0 ) { | |
| 195 | - //this is a repeating section | |
| 194 | +		if ( strpos($atts['embedded_field_id'], 'form') === 0 ) { | |
| 195 | + //this is a repeating section | |
| 196 | 196 | $child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ) ); | 
| 197 | -        } else { | |
| 198 | - // get all values for this field | |
| 199 | - $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false; | |
| 197 | +		} else { | |
| 198 | + // get all values for this field | |
| 199 | + $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false; | |
| 200 | 200 | |
| 201 | -            if ( $child_values ) { | |
| 202 | - $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) ); | |
| 203 | - } | |
| 204 | - } | |
| 201 | +			if ( $child_values ) { | |
| 202 | + $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) ); | |
| 203 | + } | |
| 204 | + } | |
| 205 | 205 | |
| 206 | - $field_value = array(); | |
| 206 | + $field_value = array(); | |
| 207 | 207 | |
| 208 | -        if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) { | |
| 209 | - return $val; | |
| 210 | - } | |
| 208 | +		if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) { | |
| 209 | + return $val; | |
| 210 | + } | |
| 211 | 211 | |
| 212 | -        foreach ( $child_entries as $child_entry ) { | |
| 213 | - $atts['item_id'] = $child_entry->id; | |
| 214 | - $atts['post_id'] = $child_entry->post_id; | |
| 212 | +		foreach ( $child_entries as $child_entry ) { | |
| 213 | + $atts['item_id'] = $child_entry->id; | |
| 214 | + $atts['post_id'] = $child_entry->post_id; | |
| 215 | 215 | |
| 216 | - // get the value for this field -- check for post values as well | |
| 217 | - $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field); | |
| 216 | + // get the value for this field -- check for post values as well | |
| 217 | + $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field); | |
| 218 | 218 | |
| 219 | -            if ( $entry_val ) { | |
| 220 | - // foreach entry get display_value | |
| 221 | - $field_value[] = self::display_value($entry_val, $field, $atts); | |
| 222 | - } | |
| 219 | +			if ( $entry_val ) { | |
| 220 | + // foreach entry get display_value | |
| 221 | + $field_value[] = self::display_value($entry_val, $field, $atts); | |
| 222 | + } | |
| 223 | 223 | |
| 224 | - unset($child_entry); | |
| 225 | - } | |
| 224 | + unset($child_entry); | |
| 225 | + } | |
| 226 | 226 | |
| 227 | -        $val = implode(', ', (array) $field_value ); | |
| 227 | +		$val = implode(', ', (array) $field_value ); | |
| 228 | 228 | $val = wp_kses_post( $val ); | 
| 229 | 229 | |
| 230 | - return $val; | |
| 231 | - } | |
| 230 | + return $val; | |
| 231 | + } | |
| 232 | 232 | |
| 233 | - /** | |
| 234 | - * Prepare the saved value for display | |
| 235 | - * @return string | |
| 236 | - */ | |
| 233 | + /** | |
| 234 | + * Prepare the saved value for display | |
| 235 | + * @return string | |
| 236 | + */ | |
| 237 | 237 |  	public static function display_value( $value, $field, $atts = array() ) { | 
| 238 | 238 | |
| 239 | - $defaults = array( | |
| 240 | - 'type' => '', 'html' => false, 'show_filename' => true, | |
| 241 | - 'truncate' => false, 'sep' => ', ', 'post_id' => 0, | |
| 242 | - 'form_id' => $field->form_id, 'field' => $field, 'keepjs' => 0, | |
| 239 | + $defaults = array( | |
| 240 | + 'type' => '', 'html' => false, 'show_filename' => true, | |
| 241 | + 'truncate' => false, 'sep' => ', ', 'post_id' => 0, | |
| 242 | + 'form_id' => $field->form_id, 'field' => $field, 'keepjs' => 0, | |
| 243 | 243 | 'return_array' => false, | 
| 244 | - ); | |
| 244 | + ); | |
| 245 | 245 | |
| 246 | - $atts = wp_parse_args( $atts, $defaults ); | |
| 247 | -        $atts = apply_filters('frm_display_value_atts', $atts, $field, $value); | |
| 246 | + $atts = wp_parse_args( $atts, $defaults ); | |
| 247 | +		$atts = apply_filters('frm_display_value_atts', $atts, $field, $value); | |
| 248 | 248 | |
| 249 | -        if ( ! isset($field->field_options['post_field']) ) { | |
| 250 | - $field->field_options['post_field'] = ''; | |
| 251 | - } | |
| 249 | +		if ( ! isset($field->field_options['post_field']) ) { | |
| 250 | + $field->field_options['post_field'] = ''; | |
| 251 | + } | |
| 252 | 252 | |
| 253 | -        if ( ! isset($field->field_options['custom_field']) ) { | |
| 254 | - $field->field_options['custom_field'] = ''; | |
| 255 | - } | |
| 253 | +		if ( ! isset($field->field_options['custom_field']) ) { | |
| 254 | + $field->field_options['custom_field'] = ''; | |
| 255 | + } | |
| 256 | 256 | |
| 257 | -        if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) { | |
| 258 | - $atts['pre_truncate'] = $atts['truncate']; | |
| 259 | - $atts['truncate'] = true; | |
| 260 | - $atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0; | |
| 257 | +		if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) { | |
| 258 | + $atts['pre_truncate'] = $atts['truncate']; | |
| 259 | + $atts['truncate'] = true; | |
| 260 | + $atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0; | |
| 261 | 261 | |
| 262 | - $value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts); | |
| 263 | - $atts['truncate'] = $atts['pre_truncate']; | |
| 264 | - } | |
| 262 | + $value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts); | |
| 263 | + $atts['truncate'] = $atts['pre_truncate']; | |
| 264 | + } | |
| 265 | 265 | |
| 266 | -        if ( $value == '' ) { | |
| 267 | - return $value; | |
| 268 | - } | |
| 266 | +		if ( $value == '' ) { | |
| 267 | + return $value; | |
| 268 | + } | |
| 269 | 269 | |
| 270 | -        $value = apply_filters('frm_display_value_custom', maybe_unserialize($value), $field, $atts); | |
| 270 | +		$value = apply_filters('frm_display_value_custom', maybe_unserialize($value), $field, $atts); | |
| 271 | 271 | |
| 272 | - $new_value = ''; | |
| 272 | + $new_value = ''; | |
| 273 | 273 | |
| 274 | -        if ( is_array($value) && $atts['type'] != 'file' ) { | |
| 275 | -            foreach ( $value as $val ) { | |
| 276 | -                if ( is_array($val) ) { | |
| 274 | +		if ( is_array($value) && $atts['type'] != 'file' ) { | |
| 275 | +			foreach ( $value as $val ) { | |
| 276 | +				if ( is_array($val) ) { | |
| 277 | 277 | //TODO: add options for display (li or ,) | 
| 278 | - $new_value .= implode($atts['sep'], $val); | |
| 279 | -                    if ( $atts['type'] != 'data' ) { | |
| 280 | - $new_value .= '<br/>'; | |
| 281 | - } | |
| 282 | - } | |
| 283 | - unset($val); | |
| 284 | - } | |
| 285 | - } | |
| 286 | - | |
| 287 | -        if ( ! empty($new_value) ) { | |
| 288 | - $value = $new_value; | |
| 289 | -        } else if ( is_array($value) && $atts['type'] != 'file' && ! $atts['return_array'] ) { | |
| 290 | - $value = implode($atts['sep'], $value); | |
| 291 | - } | |
| 292 | - | |
| 293 | -        if ( $atts['truncate'] && $atts['type'] != 'image' ) { | |
| 294 | - $value = FrmAppHelper::truncate($value, 50); | |
| 295 | - } | |
| 278 | + $new_value .= implode($atts['sep'], $val); | |
| 279 | +					if ( $atts['type'] != 'data' ) { | |
| 280 | + $new_value .= '<br/>'; | |
| 281 | + } | |
| 282 | + } | |
| 283 | + unset($val); | |
| 284 | + } | |
| 285 | + } | |
| 286 | + | |
| 287 | +		if ( ! empty($new_value) ) { | |
| 288 | + $value = $new_value; | |
| 289 | +		} else if ( is_array($value) && $atts['type'] != 'file' && ! $atts['return_array'] ) { | |
| 290 | + $value = implode($atts['sep'], $value); | |
| 291 | + } | |
| 292 | + | |
| 293 | +		if ( $atts['truncate'] && $atts['type'] != 'image' ) { | |
| 294 | + $value = FrmAppHelper::truncate($value, 50); | |
| 295 | + } | |
| 296 | 296 | |
| 297 | 297 |  		if ( ! $atts['keepjs'] && ! is_array( $value ) ) { | 
| 298 | 298 | $value = wp_kses_post( $value ); | 
| 299 | 299 | } | 
| 300 | 300 | |
| 301 | -        return apply_filters('frm_display_value', $value, $field, $atts); | |
| 302 | - } | |
| 301 | +		return apply_filters('frm_display_value', $value, $field, $atts); | |
| 302 | + } | |
| 303 | 303 | |
| 304 | 304 |  	public static function set_posted_value( $field, $value, $args ) { | 
| 305 | - // If validating a field with "other" opt, set back to prev value now | |
| 306 | -        if ( isset( $args['other'] ) && $args['other'] ) { | |
| 307 | - $value = $args['temp_value']; | |
| 308 | - } | |
| 309 | -        if ( empty($args['parent_field_id']) ) { | |
| 310 | - $_POST['item_meta'][ $field->id ] = $value; | |
| 311 | -        } else { | |
| 312 | - $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value; | |
| 313 | - } | |
| 314 | - } | |
| 305 | + // If validating a field with "other" opt, set back to prev value now | |
| 306 | +		if ( isset( $args['other'] ) && $args['other'] ) { | |
| 307 | + $value = $args['temp_value']; | |
| 308 | + } | |
| 309 | +		if ( empty($args['parent_field_id']) ) { | |
| 310 | + $_POST['item_meta'][ $field->id ] = $value; | |
| 311 | +		} else { | |
| 312 | + $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value; | |
| 313 | + } | |
| 314 | + } | |
| 315 | 315 | |
| 316 | 316 |  	public static function get_posted_value( $field, &$value, $args ) { | 
| 317 | 317 | $field_id = is_object( $field ) ? $field->id : $field; | 
| 318 | 318 | |
| 319 | -        if ( empty($args['parent_field_id']) ) { | |
| 320 | - $value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : ''; | |
| 321 | -        } else { | |
| 322 | - $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : ''; | |
| 323 | - } | |
| 324 | - } | |
| 325 | - | |
| 326 | - /** | |
| 327 | - * Check if field has an "Other" option and if any other values are posted | |
| 328 | - * | |
| 329 | - * @since 2.0 | |
| 330 | - * | |
| 331 | - * @param object $field | |
| 332 | - * @param string|array $value | |
| 333 | - * @param array $args | |
| 334 | - */ | |
| 335 | -    public static function maybe_set_other_validation( $field, &$value, &$args ) { | |
| 336 | - $args['other'] = false; | |
| 337 | -        if ( ! $value || empty( $value ) || ! FrmAppHelper::pro_is_installed() ) { | |
| 338 | - return; | |
| 339 | - } | |
| 340 | - | |
| 341 | - // Get other value for fields in repeating section | |
| 342 | - self::set_other_repeating_vals( $field, $value, $args ); | |
| 343 | - | |
| 344 | - // Check if there are any posted "Other" values | |
| 319 | +		if ( empty($args['parent_field_id']) ) { | |
| 320 | + $value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : ''; | |
| 321 | +		} else { | |
| 322 | + $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : ''; | |
| 323 | + } | |
| 324 | + } | |
| 325 | + | |
| 326 | + /** | |
| 327 | + * Check if field has an "Other" option and if any other values are posted | |
| 328 | + * | |
| 329 | + * @since 2.0 | |
| 330 | + * | |
| 331 | + * @param object $field | |
| 332 | + * @param string|array $value | |
| 333 | + * @param array $args | |
| 334 | + */ | |
| 335 | +	public static function maybe_set_other_validation( $field, &$value, &$args ) { | |
| 336 | + $args['other'] = false; | |
| 337 | +		if ( ! $value || empty( $value ) || ! FrmAppHelper::pro_is_installed() ) { | |
| 338 | + return; | |
| 339 | + } | |
| 340 | + | |
| 341 | + // Get other value for fields in repeating section | |
| 342 | + self::set_other_repeating_vals( $field, $value, $args ); | |
| 343 | + | |
| 344 | + // Check if there are any posted "Other" values | |
| 345 | 345 |  		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) { | 
| 346 | 346 | |
| 347 | - // Save original value | |
| 348 | - $args['temp_value'] = $value; | |
| 349 | - $args['other'] = true; | |
| 350 | - $other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] ); | |
| 351 | - | |
| 352 | - // Set the validation value now | |
| 353 | - self::set_other_validation_val( $value, $other_vals, $field, $args ); | |
| 354 | - } | |
| 355 | - } | |
| 356 | - | |
| 357 | - /** | |
| 358 | - * Sets radio or checkbox value equal to "other" value if it is set - FOR REPEATING SECTIONS | |
| 359 | - * | |
| 360 | - * @since 2.0 | |
| 361 | - * | |
| 362 | - * @param object $field | |
| 363 | - * @param string|array $value | |
| 364 | - * @param array $args | |
| 365 | - */ | |
| 366 | -    public static function set_other_repeating_vals( $field, &$value, &$args ) { | |
| 367 | -        if ( ! $args['parent_field_id'] ) { | |
| 368 | - return; | |
| 369 | - } | |
| 370 | - | |
| 371 | - // Check if there are any other posted "other" values for this field | |
| 347 | + // Save original value | |
| 348 | + $args['temp_value'] = $value; | |
| 349 | + $args['other'] = true; | |
| 350 | + $other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] ); | |
| 351 | + | |
| 352 | + // Set the validation value now | |
| 353 | + self::set_other_validation_val( $value, $other_vals, $field, $args ); | |
| 354 | + } | |
| 355 | + } | |
| 356 | + | |
| 357 | + /** | |
| 358 | + * Sets radio or checkbox value equal to "other" value if it is set - FOR REPEATING SECTIONS | |
| 359 | + * | |
| 360 | + * @since 2.0 | |
| 361 | + * | |
| 362 | + * @param object $field | |
| 363 | + * @param string|array $value | |
| 364 | + * @param array $args | |
| 365 | + */ | |
| 366 | +	public static function set_other_repeating_vals( $field, &$value, &$args ) { | |
| 367 | +		if ( ! $args['parent_field_id'] ) { | |
| 368 | + return; | |
| 369 | + } | |
| 370 | + | |
| 371 | + // Check if there are any other posted "other" values for this field | |
| 372 | 372 |  		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) { | 
| 373 | - // Save original value | |
| 374 | - $args['temp_value'] = $value; | |
| 375 | - $args['other'] = true; | |
| 376 | - | |
| 377 | - $other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ]; | |
| 378 | - | |
| 379 | - // Set the validation value now | |
| 380 | - self::set_other_validation_val( $value, $other_vals, $field, $args ); | |
| 381 | - } | |
| 382 | - } | |
| 383 | - | |
| 384 | - /** | |
| 385 | - * Modify value used for validation | |
| 386 | - * This function essentially removes the "Other" radio or checkbox value from the $value being validated. | |
| 387 | - * It also adds any text from the free text fields to the value | |
| 388 | - * | |
| 389 | - * Needs to accommodate for times when other opt is selected, but no other free text is entered | |
| 390 | - * | |
| 391 | - * @since 2.0 | |
| 392 | - * | |
| 393 | - * @param string|array $value | |
| 394 | - * @param string|array $other_vals (usually of posted values) | |
| 395 | - * @param object $field | |
| 396 | - * @param array $args | |
| 397 | - */ | |
| 398 | -    public static function set_other_validation_val( &$value, $other_vals, $field, &$args ) { | |
| 399 | - // Checkboxes and multi-select dropdowns | |
| 400 | -        if ( is_array( $value ) && $field->type == 'checkbox' ) { | |
| 401 | - // Combine "Other" values with checked values. "Other" values will override checked box values. | |
| 402 | - $value = array_merge( $value, $other_vals ); | |
| 403 | - $value = array_filter( $value ); | |
| 404 | -            if ( count( $value ) == 0 ) { | |
| 405 | - $value = ''; | |
| 406 | - } | |
| 407 | -        } else { | |
| 373 | + // Save original value | |
| 374 | + $args['temp_value'] = $value; | |
| 375 | + $args['other'] = true; | |
| 376 | + | |
| 377 | + $other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ]; | |
| 378 | + | |
| 379 | + // Set the validation value now | |
| 380 | + self::set_other_validation_val( $value, $other_vals, $field, $args ); | |
| 381 | + } | |
| 382 | + } | |
| 383 | + | |
| 384 | + /** | |
| 385 | + * Modify value used for validation | |
| 386 | + * This function essentially removes the "Other" radio or checkbox value from the $value being validated. | |
| 387 | + * It also adds any text from the free text fields to the value | |
| 388 | + * | |
| 389 | + * Needs to accommodate for times when other opt is selected, but no other free text is entered | |
| 390 | + * | |
| 391 | + * @since 2.0 | |
| 392 | + * | |
| 393 | + * @param string|array $value | |
| 394 | + * @param string|array $other_vals (usually of posted values) | |
| 395 | + * @param object $field | |
| 396 | + * @param array $args | |
| 397 | + */ | |
| 398 | +	public static function set_other_validation_val( &$value, $other_vals, $field, &$args ) { | |
| 399 | + // Checkboxes and multi-select dropdowns | |
| 400 | +		if ( is_array( $value ) && $field->type == 'checkbox' ) { | |
| 401 | + // Combine "Other" values with checked values. "Other" values will override checked box values. | |
| 402 | + $value = array_merge( $value, $other_vals ); | |
| 403 | + $value = array_filter( $value ); | |
| 404 | +			if ( count( $value ) == 0 ) { | |
| 405 | + $value = ''; | |
| 406 | + } | |
| 407 | +		} else { | |
| 408 | 408 | // Radio and dropdowns | 
| 409 | - $other_key = array_filter( array_keys($field->options), 'is_string'); | |
| 410 | - $other_key = reset( $other_key ); | |
| 409 | + $other_key = array_filter( array_keys($field->options), 'is_string'); | |
| 410 | + $other_key = reset( $other_key ); | |
| 411 | 411 | |
| 412 | - // Multi-select dropdown | |
| 413 | -            if ( is_array( $value ) ) { | |
| 414 | - $o_key = array_search( $field->options[ $other_key ], $value ); | |
| 412 | + // Multi-select dropdown | |
| 413 | +			if ( is_array( $value ) ) { | |
| 414 | + $o_key = array_search( $field->options[ $other_key ], $value ); | |
| 415 | 415 | |
| 416 | 416 |  				if ( $o_key !== false ) { | 
| 417 | 417 | // Modify the original value so other key will be preserved | 
| @@ -426,20 +426,20 @@ discard block | ||
| 426 | 426 | $args['temp_value'] = $value; | 
| 427 | 427 | $value[ $other_key ] = reset( $other_vals ); | 
| 428 | 428 | } | 
| 429 | -            } else if ( $field->options[ $other_key ] == $value ) { | |
| 430 | - $value = $other_vals; | |
| 431 | - } | |
| 432 | - } | |
| 433 | - } | |
| 429 | +			} else if ( $field->options[ $other_key ] == $value ) { | |
| 430 | + $value = $other_vals; | |
| 431 | + } | |
| 432 | + } | |
| 433 | + } | |
| 434 | 434 | |
| 435 | 435 |  	public static function enqueue_scripts( $params ) { | 
| 436 | 436 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmFormsController::enqueue_scripts' ); | 
| 437 | 437 | return FrmFormsController::enqueue_scripts( $params ); | 
| 438 | 438 | } | 
| 439 | 439 | |
| 440 | - // Add submitted values to a string for spam checking | |
| 440 | + // Add submitted values to a string for spam checking | |
| 441 | 441 |  	public static function entry_array_to_string( $values ) { | 
| 442 | - $content = ''; | |
| 442 | + $content = ''; | |
| 443 | 443 |  		foreach ( $values['item_meta'] as $val ) { | 
| 444 | 444 |  			if ( $content != '' ) { | 
| 445 | 445 | $content .= "\n\n"; | 
| @@ -447,14 +447,14 @@ discard block | ||
| 447 | 447 | |
| 448 | 448 |  			if ( is_array($val) ) { | 
| 449 | 449 | $val = FrmAppHelper::array_flatten( $val ); | 
| 450 | -			    $val = implode(',', $val); | |
| 450 | +				$val = implode(',', $val); | |
| 451 | 451 | } | 
| 452 | 452 | |
| 453 | 453 | $content .= $val; | 
| 454 | 454 | } | 
| 455 | 455 | |
| 456 | 456 | return $content; | 
| 457 | - } | |
| 457 | + } | |
| 458 | 458 | |
| 459 | 459 |  	public static function fill_entry_values( $atts, $f, array &$values ) { | 
| 460 | 460 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryFormat::fill_entry_values' ); | 
| @@ -1,5 +1,5 @@ discard block | ||
| 1 | 1 | <?php | 
| 2 | -if ( ! defined('ABSPATH') ) { | |
| 2 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 3 | 3 | die( 'You are not allowed to call this page directly.' ); | 
| 4 | 4 | } | 
| 5 | 5 | |
| @@ -9,12 +9,12 @@ discard block | ||
| 9 | 9 | global $frm_vars; | 
| 10 | 10 | $values = array(); | 
| 11 | 11 |  		foreach ( array( 'name' => '', 'description' => '', 'item_key' => '' ) as $var => $default ) { | 
| 12 | - $values[ $var ] = FrmAppHelper::get_post_param( $var, $default ); | |
| 12 | + $values[$var] = FrmAppHelper::get_post_param( $var, $default ); | |
| 13 | 13 | } | 
| 14 | 14 | |
| 15 | 15 | $values['fields'] = array(); | 
| 16 | -        if ( empty($fields) ) { | |
| 17 | -            return apply_filters('frm_setup_new_entry', $values); | |
| 16 | +        if ( empty( $fields ) ) { | |
| 17 | + return apply_filters( 'frm_setup_new_entry', $values ); | |
| 18 | 18 | } | 
| 19 | 19 | |
| 20 | 20 |          foreach ( (array) $fields as $field ) { | 
| @@ -26,7 +26,7 @@ discard block | ||
| 26 | 26 | 'default_value' => $field->default_value, | 
| 27 | 27 | 'name' => $field->name, | 
| 28 | 28 | 'description' => $field->description, | 
| 29 | -                'type' => apply_filters('frm_field_type', $field->type, $field, $new_value), | |
| 29 | + 'type' => apply_filters( 'frm_field_type', $field->type, $field, $new_value ), | |
| 30 | 30 | 'options' => $field->options, | 
| 31 | 31 | 'required' => $field->required, | 
| 32 | 32 | 'field_key' => $field->field_key, | 
| @@ -35,43 +35,43 @@ discard block | ||
| 35 | 35 | 'parent_form_id' => isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id, | 
| 36 | 36 | ); | 
| 37 | 37 | |
| 38 | - $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); | |
| 38 | + $opt_defaults = FrmFieldsHelper::get_default_field_opts( $field_array['type'], $field, true ); | |
| 39 | 39 | $opt_defaults['required_indicator'] = ''; | 
| 40 | 40 | $opt_defaults['original_type'] = $field->type; | 
| 41 | 41 | |
| 42 | 42 |  			foreach ( $opt_defaults as $opt => $default_opt ) { | 
| 43 | - $field_array[ $opt ] = ( isset( $field->field_options[ $opt ] ) && $field->field_options[ $opt ] != '' ) ? $field->field_options[ $opt ] : $default_opt; | |
| 44 | - unset($opt, $default_opt); | |
| 43 | + $field_array[$opt] = ( isset( $field->field_options[$opt] ) && $field->field_options[$opt] != '' ) ? $field->field_options[$opt] : $default_opt; | |
| 44 | + unset( $opt, $default_opt ); | |
| 45 | 45 | } | 
| 46 | 46 | |
| 47 | - unset($opt_defaults); | |
| 47 | + unset( $opt_defaults ); | |
| 48 | 48 | |
| 49 | 49 |              if ( $field_array['custom_html'] == '' ) { | 
| 50 | - $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type); | |
| 50 | + $field_array['custom_html'] = FrmFieldsHelper::get_default_html( $field->type ); | |
| 51 | 51 | } | 
| 52 | 52 | |
| 53 | -            $field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field); | |
| 53 | + $field_array = apply_filters( 'frm_setup_new_fields_vars', $field_array, $field ); | |
| 54 | 54 | $field_array = array_merge( $field->field_options, $field_array ); | 
| 55 | 55 | |
| 56 | 56 | $values['fields'][] = $field_array; | 
| 57 | 57 | |
| 58 | -            if ( ! $form || ! isset($form->id) ) { | |
| 59 | - $form = FrmForm::getOne($field->form_id); | |
| 58 | +            if ( ! $form || ! isset( $form->id ) ) { | |
| 59 | + $form = FrmForm::getOne( $field->form_id ); | |
| 60 | 60 | } | 
| 61 | 61 | } | 
| 62 | 62 | |
| 63 | - $form->options = maybe_unserialize($form->options); | |
| 64 | -        if ( is_array($form->options) ) { | |
| 63 | + $form->options = maybe_unserialize( $form->options ); | |
| 64 | +        if ( is_array( $form->options ) ) { | |
| 65 | 65 |              foreach ( $form->options as $opt => $value ) { | 
| 66 | - $values[ $opt ] = FrmAppHelper::get_post_param( $opt, $value ); | |
| 67 | - unset($opt, $value); | |
| 66 | + $values[$opt] = FrmAppHelper::get_post_param( $opt, $value ); | |
| 67 | + unset( $opt, $value ); | |
| 68 | 68 | } | 
| 69 | 69 | } | 
| 70 | 70 | |
| 71 | 71 | $form_defaults = FrmFormsHelper::get_default_opts(); | 
| 72 | 72 | |
| 73 | 73 | $frm_settings = FrmAppHelper::get_settings(); | 
| 74 | - $form_defaults['custom_style'] = ( $frm_settings->load_style != 'none' ); | |
| 74 | + $form_defaults['custom_style'] = ( $frm_settings->load_style != 'none' ); | |
| 75 | 75 | |
| 76 | 76 | $values = array_merge( $form_defaults, $values ); | 
| 77 | 77 | |
| @@ -93,15 +93,15 @@ discard block | ||
| 93 | 93 | $return_array = FrmField::is_field_with_multiple_values( $field ); | 
| 94 | 94 | |
| 95 | 95 | // Do any shortcodes in default value and allow customization of default value | 
| 96 | -		$field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true, $return_array); | |
| 96 | + $field->default_value = apply_filters( 'frm_get_default_value', $field->default_value, $field, true, $return_array ); | |
| 97 | 97 | // Calls FrmProFieldsHelper::get_default_value | 
| 98 | 98 | |
| 99 | 99 | $new_value = $field->default_value; | 
| 100 | 100 | |
| 101 | -		if ( ! $reset && $_POST && isset( $_POST['item_meta'][ $field->id ] ) ) { | |
| 101 | +		if ( ! $reset && $_POST && isset( $_POST['item_meta'][$field->id] ) ) { | |
| 102 | 102 | // If value was posted, get it | 
| 103 | 103 | |
| 104 | - $new_value = stripslashes_deep( $_POST['item_meta'][ $field->id ] ); | |
| 104 | + $new_value = stripslashes_deep( $_POST['item_meta'][$field->id] ); | |
| 105 | 105 | |
| 106 | 106 |  		} else if ( FrmField::is_option_true( $field, 'clear_on_focus' ) ) { | 
| 107 | 107 | // If clear on focus is selected, the value should be blank (unless it was posted, of course) | 
| @@ -110,7 +110,7 @@ discard block | ||
| 110 | 110 | } | 
| 111 | 111 | |
| 112 | 112 |  		if ( ! is_array( $new_value ) ) { | 
| 113 | -			$new_value = str_replace('"', '"', $new_value); | |
| 113 | + $new_value = str_replace( '"', '"', $new_value ); | |
| 114 | 114 | } | 
| 115 | 115 | |
| 116 | 116 | return $new_value; | 
| @@ -120,7 +120,7 @@ discard block | ||
| 120 | 120 | $values['item_key'] = FrmAppHelper::get_post_param( 'item_key', $record->item_key, 'sanitize_title' ); | 
| 121 | 121 | $values['form_id'] = $record->form_id; | 
| 122 | 122 | $values['is_draft'] = $record->is_draft; | 
| 123 | -        return apply_filters('frm_setup_edit_entry_vars', $values, $record); | |
| 123 | + return apply_filters( 'frm_setup_edit_entry_vars', $values, $record ); | |
| 124 | 124 | } | 
| 125 | 125 | |
| 126 | 126 |      public static function get_admin_params( $form = null ) { | 
| @@ -149,22 +149,22 @@ discard block | ||
| 149 | 149 | } | 
| 150 | 150 | |
| 151 | 151 |  	public static function replace_default_message( $message, $atts ) { | 
| 152 | - if ( strpos($message, '[default-message') === false && | |
| 153 | - strpos($message, '[default_message') === false && | |
| 152 | + if ( strpos( $message, '[default-message' ) === false && | |
| 153 | + strpos( $message, '[default_message' ) === false && | |
| 154 | 154 |              ! empty( $message ) ) { | 
| 155 | 155 | return $message; | 
| 156 | 156 | } | 
| 157 | 157 | |
| 158 | -        if ( empty($message) ) { | |
| 158 | +        if ( empty( $message ) ) { | |
| 159 | 159 | $message = '[default-message]'; | 
| 160 | 160 | } | 
| 161 | 161 | |
| 162 | -        preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER); | |
| 162 | + preg_match_all( "/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER ); | |
| 163 | 163 | |
| 164 | 164 |          foreach ( $shortcodes[0] as $short_key => $tag ) { | 
| 165 | - $add_atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] ); | |
| 165 | + $add_atts = shortcode_parse_atts( $shortcodes[2][$short_key] ); | |
| 166 | 166 |              if ( $add_atts ) { | 
| 167 | - $this_atts = array_merge($atts, $add_atts); | |
| 167 | + $this_atts = array_merge( $atts, $add_atts ); | |
| 168 | 168 |              } else { | 
| 169 | 169 | $this_atts = $atts; | 
| 170 | 170 | } | 
| @@ -172,31 +172,31 @@ discard block | ||
| 172 | 172 | $default = FrmEntryFormat::show_entry( $this_atts ); | 
| 173 | 173 | |
| 174 | 174 | // Add the default message | 
| 175 | - $message = str_replace( $shortcodes[0][ $short_key ], $default, $message ); | |
| 175 | + $message = str_replace( $shortcodes[0][$short_key], $default, $message ); | |
| 176 | 176 | } | 
| 177 | 177 | |
| 178 | 178 | return $message; | 
| 179 | 179 | } | 
| 180 | 180 | |
| 181 | 181 |  	public static function prepare_display_value( $entry, $field, $atts ) { | 
| 182 | - $field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false; | |
| 182 | + $field_value = isset( $entry->metas[$field->id] ) ? $entry->metas[$field->id] : false; | |
| 183 | 183 |          if ( FrmAppHelper::pro_is_installed() ) { | 
| 184 | 184 | FrmProEntriesHelper::get_dynamic_list_values( $field, $entry, $field_value ); | 
| 185 | 185 | } | 
| 186 | 186 | |
| 187 | -        if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) { | |
| 188 | - return self::display_value($field_value, $field, $atts); | |
| 187 | +        if ( $field->form_id == $entry->form_id || empty( $atts['embedded_field_id'] ) ) { | |
| 188 | + return self::display_value( $field_value, $field, $atts ); | |
| 189 | 189 | } | 
| 190 | 190 | |
| 191 | 191 | // this is an embeded form | 
| 192 | 192 | $val = ''; | 
| 193 | 193 | |
| 194 | -	    if ( strpos($atts['embedded_field_id'], 'form') === 0 ) { | |
| 194 | +	    if ( strpos( $atts['embedded_field_id'], 'form' ) === 0 ) { | |
| 195 | 195 | //this is a repeating section | 
| 196 | 196 | $child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ) ); | 
| 197 | 197 |          } else { | 
| 198 | 198 | // get all values for this field | 
| 199 | - $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false; | |
| 199 | + $child_values = isset( $entry->metas[$atts['embedded_field_id']] ) ? $entry->metas[$atts['embedded_field_id']] : false; | |
| 200 | 200 | |
| 201 | 201 |              if ( $child_values ) { | 
| 202 | 202 | $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) ); | 
| @@ -205,7 +205,7 @@ discard block | ||
| 205 | 205 | |
| 206 | 206 | $field_value = array(); | 
| 207 | 207 | |
| 208 | -        if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) { | |
| 208 | +        if ( ! isset( $child_entries ) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) { | |
| 209 | 209 | return $val; | 
| 210 | 210 | } | 
| 211 | 211 | |
| @@ -214,17 +214,17 @@ discard block | ||
| 214 | 214 | $atts['post_id'] = $child_entry->post_id; | 
| 215 | 215 | |
| 216 | 216 | // get the value for this field -- check for post values as well | 
| 217 | - $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field); | |
| 217 | + $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value( $child_entry, $field ); | |
| 218 | 218 | |
| 219 | 219 |              if ( $entry_val ) { | 
| 220 | 220 | // foreach entry get display_value | 
| 221 | - $field_value[] = self::display_value($entry_val, $field, $atts); | |
| 221 | + $field_value[] = self::display_value( $entry_val, $field, $atts ); | |
| 222 | 222 | } | 
| 223 | 223 | |
| 224 | - unset($child_entry); | |
| 224 | + unset( $child_entry ); | |
| 225 | 225 | } | 
| 226 | 226 | |
| 227 | -        $val = implode(', ', (array) $field_value ); | |
| 227 | + $val = implode( ', ', (array) $field_value ); | |
| 228 | 228 | $val = wp_kses_post( $val ); | 
| 229 | 229 | |
| 230 | 230 | return $val; | 
| @@ -244,22 +244,22 @@ discard block | ||
| 244 | 244 | ); | 
| 245 | 245 | |
| 246 | 246 | $atts = wp_parse_args( $atts, $defaults ); | 
| 247 | -        $atts = apply_filters('frm_display_value_atts', $atts, $field, $value); | |
| 247 | + $atts = apply_filters( 'frm_display_value_atts', $atts, $field, $value ); | |
| 248 | 248 | |
| 249 | -        if ( ! isset($field->field_options['post_field']) ) { | |
| 249 | +        if ( ! isset( $field->field_options['post_field'] ) ) { | |
| 250 | 250 | $field->field_options['post_field'] = ''; | 
| 251 | 251 | } | 
| 252 | 252 | |
| 253 | -        if ( ! isset($field->field_options['custom_field']) ) { | |
| 253 | +        if ( ! isset( $field->field_options['custom_field'] ) ) { | |
| 254 | 254 | $field->field_options['custom_field'] = ''; | 
| 255 | 255 | } | 
| 256 | 256 | |
| 257 | 257 |          if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) { | 
| 258 | 258 | $atts['pre_truncate'] = $atts['truncate']; | 
| 259 | 259 | $atts['truncate'] = true; | 
| 260 | - $atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0; | |
| 260 | + $atts['exclude_cat'] = isset( $field->field_options['exclude_cat'] ) ? $field->field_options['exclude_cat'] : 0; | |
| 261 | 261 | |
| 262 | - $value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts); | |
| 262 | + $value = FrmProEntryMetaHelper::get_post_value( $atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts ); | |
| 263 | 263 | $atts['truncate'] = $atts['pre_truncate']; | 
| 264 | 264 | } | 
| 265 | 265 | |
| @@ -267,38 +267,38 @@ discard block | ||
| 267 | 267 | return $value; | 
| 268 | 268 | } | 
| 269 | 269 | |
| 270 | -        $value = apply_filters('frm_display_value_custom', maybe_unserialize($value), $field, $atts); | |
| 270 | + $value = apply_filters( 'frm_display_value_custom', maybe_unserialize( $value ), $field, $atts ); | |
| 271 | 271 | |
| 272 | 272 | $new_value = ''; | 
| 273 | 273 | |
| 274 | -        if ( is_array($value) && $atts['type'] != 'file' ) { | |
| 274 | +        if ( is_array( $value ) && $atts['type'] != 'file' ) { | |
| 275 | 275 |              foreach ( $value as $val ) { | 
| 276 | -                if ( is_array($val) ) { | |
| 276 | +                if ( is_array( $val ) ) { | |
| 277 | 277 | //TODO: add options for display (li or ,) | 
| 278 | - $new_value .= implode($atts['sep'], $val); | |
| 278 | + $new_value .= implode( $atts['sep'], $val ); | |
| 279 | 279 |                      if ( $atts['type'] != 'data' ) { | 
| 280 | 280 | $new_value .= '<br/>'; | 
| 281 | 281 | } | 
| 282 | 282 | } | 
| 283 | - unset($val); | |
| 283 | + unset( $val ); | |
| 284 | 284 | } | 
| 285 | 285 | } | 
| 286 | 286 | |
| 287 | -        if ( ! empty($new_value) ) { | |
| 287 | +        if ( ! empty( $new_value ) ) { | |
| 288 | 288 | $value = $new_value; | 
| 289 | -        } else if ( is_array($value) && $atts['type'] != 'file' && ! $atts['return_array'] ) { | |
| 290 | - $value = implode($atts['sep'], $value); | |
| 289 | +        } else if ( is_array( $value ) && $atts['type'] != 'file' && ! $atts['return_array'] ) { | |
| 290 | + $value = implode( $atts['sep'], $value ); | |
| 291 | 291 | } | 
| 292 | 292 | |
| 293 | 293 |          if ( $atts['truncate'] && $atts['type'] != 'image' ) { | 
| 294 | - $value = FrmAppHelper::truncate($value, 50); | |
| 294 | + $value = FrmAppHelper::truncate( $value, 50 ); | |
| 295 | 295 | } | 
| 296 | 296 | |
| 297 | 297 |  		if ( ! $atts['keepjs'] && ! is_array( $value ) ) { | 
| 298 | 298 | $value = wp_kses_post( $value ); | 
| 299 | 299 | } | 
| 300 | 300 | |
| 301 | -        return apply_filters('frm_display_value', $value, $field, $atts); | |
| 301 | + return apply_filters( 'frm_display_value', $value, $field, $atts ); | |
| 302 | 302 | } | 
| 303 | 303 | |
| 304 | 304 |  	public static function set_posted_value( $field, $value, $args ) { | 
| @@ -306,20 +306,20 @@ discard block | ||
| 306 | 306 |          if ( isset( $args['other'] ) && $args['other'] ) { | 
| 307 | 307 | $value = $args['temp_value']; | 
| 308 | 308 | } | 
| 309 | -        if ( empty($args['parent_field_id']) ) { | |
| 310 | - $_POST['item_meta'][ $field->id ] = $value; | |
| 309 | +        if ( empty( $args['parent_field_id'] ) ) { | |
| 310 | + $_POST['item_meta'][$field->id] = $value; | |
| 311 | 311 |          } else { | 
| 312 | - $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value; | |
| 312 | + $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field->id] = $value; | |
| 313 | 313 | } | 
| 314 | 314 | } | 
| 315 | 315 | |
| 316 | 316 |  	public static function get_posted_value( $field, &$value, $args ) { | 
| 317 | 317 | $field_id = is_object( $field ) ? $field->id : $field; | 
| 318 | 318 | |
| 319 | -        if ( empty($args['parent_field_id']) ) { | |
| 320 | - $value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : ''; | |
| 319 | +        if ( empty( $args['parent_field_id'] ) ) { | |
| 320 | + $value = isset( $_POST['item_meta'][$field_id] ) ? $_POST['item_meta'][$field_id] : ''; | |
| 321 | 321 |          } else { | 
| 322 | - $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : ''; | |
| 322 | + $value = isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field_id] ) ? $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field_id] : ''; | |
| 323 | 323 | } | 
| 324 | 324 | } | 
| 325 | 325 | |
| @@ -342,12 +342,12 @@ discard block | ||
| 342 | 342 | self::set_other_repeating_vals( $field, $value, $args ); | 
| 343 | 343 | |
| 344 | 344 | // Check if there are any posted "Other" values | 
| 345 | -		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) { | |
| 345 | +		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][$field->id] ) ) { | |
| 346 | 346 | |
| 347 | 347 | // Save original value | 
| 348 | 348 | $args['temp_value'] = $value; | 
| 349 | 349 | $args['other'] = true; | 
| 350 | - $other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] ); | |
| 350 | + $other_vals = stripslashes_deep( $_POST['item_meta']['other'][$field->id] ); | |
| 351 | 351 | |
| 352 | 352 | // Set the validation value now | 
| 353 | 353 | self::set_other_validation_val( $value, $other_vals, $field, $args ); | 
| @@ -369,12 +369,12 @@ discard block | ||
| 369 | 369 | } | 
| 370 | 370 | |
| 371 | 371 | // Check if there are any other posted "other" values for this field | 
| 372 | -		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) { | |
| 372 | +		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id] ) ) { | |
| 373 | 373 | // Save original value | 
| 374 | 374 | $args['temp_value'] = $value; | 
| 375 | 375 | $args['other'] = true; | 
| 376 | 376 | |
| 377 | - $other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ]; | |
| 377 | + $other_vals = $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id]; | |
| 378 | 378 | |
| 379 | 379 | // Set the validation value now | 
| 380 | 380 | self::set_other_validation_val( $value, $other_vals, $field, $args ); | 
| @@ -406,27 +406,27 @@ discard block | ||
| 406 | 406 | } | 
| 407 | 407 |          } else { | 
| 408 | 408 | // Radio and dropdowns | 
| 409 | - $other_key = array_filter( array_keys($field->options), 'is_string'); | |
| 409 | + $other_key = array_filter( array_keys( $field->options ), 'is_string' ); | |
| 410 | 410 | $other_key = reset( $other_key ); | 
| 411 | 411 | |
| 412 | 412 | // Multi-select dropdown | 
| 413 | 413 |              if ( is_array( $value ) ) { | 
| 414 | - $o_key = array_search( $field->options[ $other_key ], $value ); | |
| 414 | + $o_key = array_search( $field->options[$other_key], $value ); | |
| 415 | 415 | |
| 416 | 416 |  				if ( $o_key !== false ) { | 
| 417 | 417 | // Modify the original value so other key will be preserved | 
| 418 | - $value[ $other_key ] = $value[ $o_key ]; | |
| 418 | + $value[$other_key] = $value[$o_key]; | |
| 419 | 419 | |
| 420 | 420 | // By default, the array keys will be numeric for multi-select dropdowns | 
| 421 | 421 | // If going backwards and forwards between pages, the array key will match the other key | 
| 422 | 422 |  					if ( $o_key != $other_key ) { | 
| 423 | - unset( $value[ $o_key ] ); | |
| 423 | + unset( $value[$o_key] ); | |
| 424 | 424 | } | 
| 425 | 425 | |
| 426 | 426 | $args['temp_value'] = $value; | 
| 427 | - $value[ $other_key ] = reset( $other_vals ); | |
| 427 | + $value[$other_key] = reset( $other_vals ); | |
| 428 | 428 | } | 
| 429 | -            } else if ( $field->options[ $other_key ] == $value ) { | |
| 429 | +            } else if ( $field->options[$other_key] == $value ) { | |
| 430 | 430 | $value = $other_vals; | 
| 431 | 431 | } | 
| 432 | 432 | } | 
| @@ -445,9 +445,9 @@ discard block | ||
| 445 | 445 | $content .= "\n\n"; | 
| 446 | 446 | } | 
| 447 | 447 | |
| 448 | -			if ( is_array($val) ) { | |
| 448 | +			if ( is_array( $val ) ) { | |
| 449 | 449 | $val = FrmAppHelper::array_flatten( $val ); | 
| 450 | -			    $val = implode(',', $val); | |
| 450 | + $val = implode( ',', $val ); | |
| 451 | 451 | } | 
| 452 | 452 | |
| 453 | 453 | $content .= $val; | 
| @@ -492,6 +492,6 @@ discard block | ||
| 492 | 492 | } | 
| 493 | 493 | |
| 494 | 494 |  	public static function entries_dropdown() { | 
| 495 | - _deprecated_function( __FUNCTION__, '1.07.09'); | |
| 495 | + _deprecated_function( __FUNCTION__, '1.07.09' ); | |
| 496 | 496 | } | 
| 497 | 497 | } | 
| @@ -126,19 +126,19 @@ | ||
| 126 | 126 | } | 
| 127 | 127 | |
| 128 | 128 | /** | 
| 129 | - * Flatten multi-dimensional array for multi-file upload fields | |
| 130 | - * @since 2.0.9 | |
| 131 | - */ | |
| 129 | + * Flatten multi-dimensional array for multi-file upload fields | |
| 130 | + * @since 2.0.9 | |
| 131 | + */ | |
| 132 | 132 |  	public static function flatten_multi_file_upload( $field, &$val ) { | 
| 133 | 133 |  		if ( $field->type == 'file' && FrmField::is_option_true( $field, 'multiple' ) ) { | 
| 134 | 134 | $val = FrmAppHelper::array_flatten( $val ); | 
| 135 | 135 | } | 
| 136 | 136 | } | 
| 137 | 137 | |
| 138 | - /** | |
| 139 | - * Replace returns with HTML line breaks for display | |
| 140 | - * @since 2.0.9 | |
| 141 | - */ | |
| 138 | + /** | |
| 139 | + * Replace returns with HTML line breaks for display | |
| 140 | + * @since 2.0.9 | |
| 141 | + */ | |
| 142 | 142 |  	public static function textarea_display_value( $type, $plain_text, &$value ) { | 
| 143 | 143 |  		if ( $type == 'textarea' && ! $plain_text ) { | 
| 144 | 144 | $value = str_replace( array( "\r\n", "\r", "\n" ), ' <br/>', $value ); | 
| @@ -37,20 +37,20 @@ discard block | ||
| 37 | 37 | $atts['id'] = $atts['entry']->id; | 
| 38 | 38 | } | 
| 39 | 39 | |
| 40 | -		if ( ! $atts['fields'] || ! is_array($atts['fields']) ) { | |
| 40 | +		if ( ! $atts['fields'] || ! is_array( $atts['fields'] ) ) { | |
| 41 | 41 | $atts['fields'] = FrmField::get_all_for_form( $atts['form_id'], '', 'include' ); | 
| 42 | 42 | } | 
| 43 | 43 | |
| 44 | 44 | $values = array(); | 
| 45 | 45 |  		foreach ( $atts['fields'] as $f ) { | 
| 46 | 46 | self::fill_entry_values( $atts, $f, $values ); | 
| 47 | - unset($f); | |
| 47 | + unset( $f ); | |
| 48 | 48 | } | 
| 49 | 49 | |
| 50 | 50 | self::fill_entry_user_info( $atts, $values ); | 
| 51 | 51 | |
| 52 | 52 |  		if ( $atts['format'] == 'json' ) { | 
| 53 | - return json_encode($values); | |
| 53 | + return json_encode( $values ); | |
| 54 | 54 |  		} else if ( $atts['format'] == 'array' ) { | 
| 55 | 55 | return $values; | 
| 56 | 56 | } | 
| @@ -59,7 +59,7 @@ discard block | ||
| 59 | 59 | self::convert_entry_to_content( $values, $atts, $content ); | 
| 60 | 60 | |
| 61 | 61 |  		if ( 'text' == $atts['format'] ) { | 
| 62 | -			$content = implode('', $content); | |
| 62 | + $content = implode( '', $content ); | |
| 63 | 63 | } | 
| 64 | 64 | |
| 65 | 65 |  		if ( $atts['clickable'] ) { | 
| @@ -82,7 +82,7 @@ discard block | ||
| 82 | 82 | 'val' => '[' . $f->id . ']' | 
| 83 | 83 | ); | 
| 84 | 84 | |
| 85 | - $values[ $f->id ] = apply_filters( 'frm_field_shortcodes_for_default_html_email', $field_shortcodes, $f ); | |
| 85 | + $values[$f->id] = apply_filters( 'frm_field_shortcodes_for_default_html_email', $field_shortcodes, $f ); | |
| 86 | 86 | } | 
| 87 | 87 | |
| 88 | 88 |  	public static function fill_entry_values( $atts, $f, array &$values ) { | 
| @@ -95,9 +95,9 @@ discard block | ||
| 95 | 95 | return; | 
| 96 | 96 | } | 
| 97 | 97 | |
| 98 | -		if ( $atts['entry'] && ! isset( $atts['entry']->metas[ $f->id ] ) ) { | |
| 98 | +		if ( $atts['entry'] && ! isset( $atts['entry']->metas[$f->id] ) ) { | |
| 99 | 99 | // In case include_blank is set | 
| 100 | - $atts['entry']->metas[ $f->id ] = ''; | |
| 100 | + $atts['entry']->metas[$f->id] = ''; | |
| 101 | 101 | |
| 102 | 102 |  			if ( FrmAppHelper::pro_is_installed() ) { | 
| 103 | 103 | FrmProEntryMeta::add_post_value_to_entry( $f, $atts['entry'] ); | 
| @@ -107,7 +107,7 @@ discard block | ||
| 107 | 107 | |
| 108 | 108 | $val = ''; | 
| 109 | 109 |  		if ( $atts['entry'] ) { | 
| 110 | - $prev_val = maybe_unserialize( $atts['entry']->metas[ $f->id ] ); | |
| 110 | + $prev_val = maybe_unserialize( $atts['entry']->metas[$f->id] ); | |
| 111 | 111 | $meta = array( 'item_id' => $atts['id'], 'field_id' => $f->id, 'meta_value' => $prev_val, 'field_type' => $f->type ); | 
| 112 | 112 | |
| 113 | 113 | //This filter applies to the default-message shortcode and frm-show-entry shortcode only | 
| @@ -132,12 +132,12 @@ discard block | ||
| 132 | 132 | self::maybe_strip_html( $atts['plain_text'], $val ); | 
| 133 | 133 | |
| 134 | 134 |  		if ( $atts['format'] != 'text' ) { | 
| 135 | - $values[ $f->field_key ] = $val; | |
| 135 | + $values[$f->field_key] = $val; | |
| 136 | 136 |  			if ( isset( $prev_val ) && $prev_val != $val && $f->type != 'textarea' ) { | 
| 137 | - $values[ $f->field_key . '-value' ] = $prev_val; | |
| 137 | + $values[$f->field_key . '-value'] = $prev_val; | |
| 138 | 138 | } | 
| 139 | 139 |  		} else { | 
| 140 | - $values[ $f->id ] = array( 'label' => $f->name, 'val' => $val ); | |
| 140 | + $values[$f->id] = array( 'label' => $f->name, 'val' => $val ); | |
| 141 | 141 | } | 
| 142 | 142 | } | 
| 143 | 143 | |
| @@ -183,7 +183,7 @@ discard block | ||
| 183 | 183 | return; | 
| 184 | 184 | } | 
| 185 | 185 | |
| 186 | - $data = self::get_entry_description_data( $atts ); | |
| 186 | + $data = self::get_entry_description_data( $atts ); | |
| 187 | 187 | |
| 188 | 188 |  		if ( $atts['default_email'] ) { | 
| 189 | 189 | $atts['entry']->ip = '[ip]'; | 
| @@ -270,7 +270,7 @@ discard block | ||
| 270 | 270 | preg_match_all( $pattern, $u_agent, $matches ); // get the matching numbers | 
| 271 | 271 | |
| 272 | 272 | // see how many we have | 
| 273 | - $i = count($matches['browser']); | |
| 273 | + $i = count( $matches['browser'] ); | |
| 274 | 274 |  		if ( $i != 1 ) { | 
| 275 | 275 | //we will have two since we are not using 'other' argument yet | 
| 276 | 276 | //see if version is before or after the name | 
| @@ -307,15 +307,15 @@ discard block | ||
| 307 | 307 | |
| 308 | 308 | // merge defaults, global settings, and shortcode options | 
| 309 | 309 |  			foreach ( $default_settings as $key => $setting ) { | 
| 310 | -				if ( $atts[ $key ] != '' ) { | |
| 310 | +				if ( $atts[$key] != '' ) { | |
| 311 | 311 | continue; | 
| 312 | 312 | } | 
| 313 | 313 | |
| 314 | - $atts[ $key ] = $setting; | |
| 314 | + $atts[$key] = $setting; | |
| 315 | 315 | unset( $key, $setting ); | 
| 316 | 316 | } | 
| 317 | 317 | |
| 318 | - unset($default_settings); | |
| 318 | + unset( $default_settings ); | |
| 319 | 319 | |
| 320 | 320 | $content[] = '<table cellspacing="0" style="font-size:' . $atts['font_size'] . ';line-height:135%; border-bottom:' . $atts['border_width'] . ' solid #' . $atts['border_color'] . ';"><tbody>' . "\r\n"; | 
| 321 | 321 | $atts['bg_color'] = ' style="background-color:#' . $atts['bg_color'] . ';"'; | 
| @@ -338,7 +338,7 @@ discard block | ||
| 338 | 338 | continue; | 
| 339 | 339 | } | 
| 340 | 340 | |
| 341 | -			if ( $atts['default_email'] && is_numeric($id) ) { | |
| 341 | +			if ( $atts['default_email'] && is_numeric( $id ) ) { | |
| 342 | 342 | $content[] = '[if ' . $id . ']<tr style="[frm-alt-color]">'; | 
| 343 | 343 |  			} else { | 
| 344 | 344 | $content[] = '<tr' . ( $odd ? $atts['bg_color'] : $bg_color_alt ) . '>'; | 
| @@ -1,6 +1,6 @@ discard block | ||
| 1 | 1 | <?php | 
| 2 | 2 | |
| 3 | -class FrmSettings{ | |
| 3 | +class FrmSettings { | |
| 4 | 4 | public $option_name = 'frm_options'; | 
| 5 | 5 | public $menu; | 
| 6 | 6 | public $mu_menu; | 
| @@ -28,19 +28,19 @@ discard block | ||
| 28 | 28 | public $re_msg; | 
| 29 | 29 | |
| 30 | 30 |      public function __construct() { | 
| 31 | -        if ( ! defined('ABSPATH') ) { | |
| 32 | -            die('You are not allowed to call this page directly.'); | |
| 31 | +        if ( ! defined( 'ABSPATH' ) ) { | |
| 32 | + die( 'You are not allowed to call this page directly.' ); | |
| 33 | 33 | } | 
| 34 | 34 | |
| 35 | - $settings = get_transient($this->option_name); | |
| 35 | + $settings = get_transient( $this->option_name ); | |
| 36 | 36 | |
| 37 | -        if ( ! is_object($settings) ) { | |
| 38 | - $settings = $this->translate_settings($settings); | |
| 37 | +        if ( ! is_object( $settings ) ) { | |
| 38 | + $settings = $this->translate_settings( $settings ); | |
| 39 | 39 | } | 
| 40 | 40 | |
| 41 | 41 |          foreach ( $settings as $setting_name => $setting ) { | 
| 42 | 42 |              $this->{$setting_name} = $setting; | 
| 43 | - unset($setting_name, $setting); | |
| 43 | + unset( $setting_name, $setting ); | |
| 44 | 44 | } | 
| 45 | 45 | |
| 46 | 46 | $this->set_default_options(); | 
| @@ -48,24 +48,24 @@ discard block | ||
| 48 | 48 | |
| 49 | 49 |  	private function translate_settings( $settings ) { | 
| 50 | 50 |          if ( $settings ) { //workaround for W3 total cache conflict | 
| 51 | - return unserialize(serialize($settings)); | |
| 51 | + return unserialize( serialize( $settings ) ); | |
| 52 | 52 | } | 
| 53 | 53 | |
| 54 | - $settings = get_option($this->option_name); | |
| 55 | -        if ( is_object($settings) ) { | |
| 56 | - set_transient($this->option_name, $settings); | |
| 54 | + $settings = get_option( $this->option_name ); | |
| 55 | +        if ( is_object( $settings ) ) { | |
| 56 | + set_transient( $this->option_name, $settings ); | |
| 57 | 57 | return $settings; | 
| 58 | 58 | } | 
| 59 | 59 | |
| 60 | 60 | // If unserializing didn't work | 
| 61 | 61 |          if ( $settings ) { //workaround for W3 total cache conflict | 
| 62 | - $settings = unserialize(serialize($settings)); | |
| 62 | + $settings = unserialize( serialize( $settings ) ); | |
| 63 | 63 |          } else { | 
| 64 | 64 | $settings = $this; | 
| 65 | 65 | } | 
| 66 | 66 | |
| 67 | - update_option($this->option_name, $settings); | |
| 68 | - set_transient($this->option_name, $settings); | |
| 67 | + update_option( $this->option_name, $settings ); | |
| 68 | + set_transient( $this->option_name, $settings ); | |
| 69 | 69 | |
| 70 | 70 | return $settings; | 
| 71 | 71 | } | 
| @@ -98,8 +98,8 @@ discard block | ||
| 98 | 98 |  	private function set_default_options() { | 
| 99 | 99 | $this->fill_recaptcha_settings(); | 
| 100 | 100 | |
| 101 | -        if ( ! isset($this->load_style) ) { | |
| 102 | -            if ( ! isset($this->custom_style) ) { | |
| 101 | +        if ( ! isset( $this->load_style ) ) { | |
| 102 | +            if ( ! isset( $this->custom_style ) ) { | |
| 103 | 103 | $this->custom_style = true; | 
| 104 | 104 | } | 
| 105 | 105 | |
| @@ -109,16 +109,16 @@ discard block | ||
| 109 | 109 | $this->fill_with_defaults(); | 
| 110 | 110 | |
| 111 | 111 |          if ( is_multisite() && is_admin() ) { | 
| 112 | -            $mu_menu = get_site_option('frm_admin_menu_name'); | |
| 113 | -            if ( $mu_menu && ! empty($mu_menu) ) { | |
| 112 | + $mu_menu = get_site_option( 'frm_admin_menu_name' ); | |
| 113 | +            if ( $mu_menu && ! empty( $mu_menu ) ) { | |
| 114 | 114 | $this->menu = $mu_menu; | 
| 115 | 115 | $this->mu_menu = 1; | 
| 116 | 116 | } | 
| 117 | 117 | } | 
| 118 | 118 | |
| 119 | -        $frm_roles = FrmAppHelper::frm_capabilities('pro'); | |
| 119 | + $frm_roles = FrmAppHelper::frm_capabilities( 'pro' ); | |
| 120 | 120 |          foreach ( $frm_roles as $frm_role => $frm_role_description ) { | 
| 121 | -            if ( ! isset($this->$frm_role) ) { | |
| 121 | +            if ( ! isset( $this->$frm_role ) ) { | |
| 122 | 122 | $this->$frm_role = 'administrator'; | 
| 123 | 123 | } | 
| 124 | 124 | } | 
| @@ -128,12 +128,12 @@ discard block | ||
| 128 | 128 | $settings = $this->default_options(); | 
| 129 | 129 | |
| 130 | 130 |          foreach ( $settings as $setting => $default ) { | 
| 131 | -			if ( isset( $params[ 'frm_' . $setting ] ) ) { | |
| 132 | -				$this->{$setting} = $params[ 'frm_' . $setting ]; | |
| 133 | -            } else if ( ! isset($this->{$setting}) ) { | |
| 131 | +			if ( isset( $params['frm_' . $setting] ) ) { | |
| 132 | +				$this->{$setting} = $params['frm_' . $setting]; | |
| 133 | +            } else if ( ! isset( $this->{$setting}) ) { | |
| 134 | 134 |                  $this->{$setting} = $default; | 
| 135 | 135 | } | 
| 136 | - unset($setting, $default); | |
| 136 | + unset( $setting, $default ); | |
| 137 | 137 | } | 
| 138 | 138 | } | 
| 139 | 139 | |
| @@ -141,23 +141,23 @@ discard block | ||
| 141 | 141 | $privkey = ''; | 
| 142 | 142 | $re_lang = 'en'; | 
| 143 | 143 | |
| 144 | -        if ( ! isset($this->pubkey) ) { | |
| 144 | +        if ( ! isset( $this->pubkey ) ) { | |
| 145 | 145 | // get the options from the database | 
| 146 | -            $recaptcha_opt = is_multisite() ? get_site_option('recaptcha') : get_option('recaptcha'); | |
| 147 | - $this->pubkey = isset($recaptcha_opt['pubkey']) ? $recaptcha_opt['pubkey'] : ''; | |
| 148 | - $privkey = isset($recaptcha_opt['privkey']) ? $recaptcha_opt['privkey'] : $privkey; | |
| 149 | - $re_lang = isset($recaptcha_opt['re_lang']) ? $recaptcha_opt['re_lang'] : $re_lang; | |
| 146 | + $recaptcha_opt = is_multisite() ? get_site_option( 'recaptcha' ) : get_option( 'recaptcha' ); | |
| 147 | + $this->pubkey = isset( $recaptcha_opt['pubkey'] ) ? $recaptcha_opt['pubkey'] : ''; | |
| 148 | + $privkey = isset( $recaptcha_opt['privkey'] ) ? $recaptcha_opt['privkey'] : $privkey; | |
| 149 | + $re_lang = isset( $recaptcha_opt['re_lang'] ) ? $recaptcha_opt['re_lang'] : $re_lang; | |
| 150 | 150 | } | 
| 151 | 151 | |
| 152 | -        if ( ! isset($this->re_msg) || empty($this->re_msg) ) { | |
| 152 | +        if ( ! isset( $this->re_msg ) || empty( $this->re_msg ) ) { | |
| 153 | 153 | $this->re_msg = __( 'The reCAPTCHA was not entered correctly', 'formidable' ); | 
| 154 | 154 | } | 
| 155 | 155 | |
| 156 | -        if ( ! isset($this->privkey) ) { | |
| 156 | +        if ( ! isset( $this->privkey ) ) { | |
| 157 | 157 | $this->privkey = $privkey; | 
| 158 | 158 | } | 
| 159 | 159 | |
| 160 | -        if ( ! isset($this->re_lang) ) { | |
| 160 | +        if ( ! isset( $this->re_lang ) ) { | |
| 161 | 161 | $this->re_lang = $re_lang; | 
| 162 | 162 | } | 
| 163 | 163 | } | 
| @@ -168,31 +168,31 @@ discard block | ||
| 168 | 168 | } | 
| 169 | 169 | |
| 170 | 170 |  	public function update( $params ) { | 
| 171 | - $this->fill_with_defaults($params); | |
| 172 | - $this->update_settings($params); | |
| 171 | + $this->fill_with_defaults( $params ); | |
| 172 | + $this->update_settings( $params ); | |
| 173 | 173 | |
| 174 | 174 |          if ( $this->mu_menu ) { | 
| 175 | -            update_site_option('frm_admin_menu_name', $this->menu); | |
| 176 | -        } else if ( current_user_can('administrator') ) { | |
| 177 | -            update_site_option('frm_admin_menu_name', false); | |
| 175 | + update_site_option( 'frm_admin_menu_name', $this->menu ); | |
| 176 | +        } else if ( current_user_can( 'administrator' ) ) { | |
| 177 | + update_site_option( 'frm_admin_menu_name', false ); | |
| 178 | 178 | } | 
| 179 | 179 | |
| 180 | - $this->update_roles($params); | |
| 180 | + $this->update_roles( $params ); | |
| 181 | 181 | |
| 182 | 182 | do_action( 'frm_update_settings', $params ); | 
| 183 | 183 | } | 
| 184 | 184 | |
| 185 | 185 |  	private function update_settings( $params ) { | 
| 186 | - $this->mu_menu = isset($params['frm_mu_menu']) ? $params['frm_mu_menu'] : 0; | |
| 186 | + $this->mu_menu = isset( $params['frm_mu_menu'] ) ? $params['frm_mu_menu'] : 0; | |
| 187 | 187 | |
| 188 | - $this->pubkey = trim($params['frm_pubkey']); | |
| 188 | + $this->pubkey = trim( $params['frm_pubkey'] ); | |
| 189 | 189 | $this->privkey = $params['frm_privkey']; | 
| 190 | 190 | $this->re_lang = $params['frm_re_lang']; | 
| 191 | 191 | |
| 192 | 192 | $this->load_style = $params['frm_load_style']; | 
| 193 | 193 | $this->preview_page_id = (int) $params['frm-preview-page-id']; | 
| 194 | 194 | |
| 195 | - $this->use_html = isset($params['frm_use_html']) ? $params['frm_use_html'] : 0; | |
| 195 | + $this->use_html = isset( $params['frm_use_html'] ) ? $params['frm_use_html'] : 0; | |
| 196 | 196 | //$this->custom_style = isset($params['frm_custom_style']) ? $params['frm_custom_style'] : 0; | 
| 197 | 197 | $this->jquery_css = isset( $params['frm_jquery_css'] ) ? absint( $params['frm_jquery_css'] ) : 0; | 
| 198 | 198 | $this->accordion_js = isset( $params['frm_accordion_js'] ) ? absint( $params['frm_accordion_js'] ) : 0; | 
| @@ -205,30 +205,30 @@ discard block | ||
| 205 | 205 | $frm_roles = FrmAppHelper::frm_capabilities(); | 
| 206 | 206 | $roles = get_editable_roles(); | 
| 207 | 207 |          foreach ( $frm_roles as $frm_role => $frm_role_description ) { | 
| 208 | - $this->$frm_role = (array) ( isset( $params[ $frm_role ] ) ? $params[ $frm_role ] : 'administrator' ); | |
| 208 | + $this->$frm_role = (array) ( isset( $params[$frm_role] ) ? $params[$frm_role] : 'administrator' ); | |
| 209 | 209 | |
| 210 | -            if ( count($this->$frm_role) === 1 ) { | |
| 211 | - $set_role = reset($this->$frm_role); | |
| 210 | +            if ( count( $this->$frm_role ) === 1 ) { | |
| 211 | + $set_role = reset( $this->$frm_role ); | |
| 212 | 212 |                  switch ( $set_role ) { | 
| 213 | 213 | case 'subscriber': | 
| 214 | - array_push($this->$frm_role, 'contributor'); | |
| 214 | + array_push( $this->$frm_role, 'contributor' ); | |
| 215 | 215 | case 'contributor': | 
| 216 | - array_push($this->$frm_role, 'author'); | |
| 216 | + array_push( $this->$frm_role, 'author' ); | |
| 217 | 217 | case 'author': | 
| 218 | - array_push($this->$frm_role, 'editor'); | |
| 218 | + array_push( $this->$frm_role, 'editor' ); | |
| 219 | 219 | case 'editor': | 
| 220 | - array_push($this->$frm_role, 'administrator'); | |
| 220 | + array_push( $this->$frm_role, 'administrator' ); | |
| 221 | 221 | } | 
| 222 | - unset($set_role); | |
| 222 | + unset( $set_role ); | |
| 223 | 223 | } | 
| 224 | 224 | |
| 225 | 225 |              foreach ( $roles as $role => $details ) { | 
| 226 | -                if ( in_array($role, $this->$frm_role) ) { | |
| 226 | +                if ( in_array( $role, $this->$frm_role ) ) { | |
| 227 | 227 | $wp_roles->add_cap( $role, $frm_role ); | 
| 228 | 228 |      			} else { | 
| 229 | 229 | $wp_roles->remove_cap( $role, $frm_role ); | 
| 230 | 230 | } | 
| 231 | - unset($role, $details); | |
| 231 | + unset( $role, $details ); | |
| 232 | 232 | } | 
| 233 | 233 | } | 
| 234 | 234 | } | 
| @@ -236,10 +236,10 @@ discard block | ||
| 236 | 236 |  	public function store() { | 
| 237 | 237 | // Save the posted value in the database | 
| 238 | 238 | |
| 239 | -        update_option('frm_options', $this); | |
| 239 | + update_option( 'frm_options', $this ); | |
| 240 | 240 | |
| 241 | -        delete_transient('frm_options'); | |
| 242 | -        set_transient('frm_options', $this); | |
| 241 | + delete_transient( 'frm_options' ); | |
| 242 | + set_transient( 'frm_options', $this ); | |
| 243 | 243 | |
| 244 | 244 | do_action( 'frm_store_settings' ); | 
| 245 | 245 | } | 
| @@ -1,6 +1,6 @@ discard block | ||
| 1 | 1 | <?php | 
| 2 | 2 | |
| 3 | -class FrmSettings{ | |
| 3 | +class FrmSettings { | |
| 4 | 4 | public $option_name = 'frm_options'; | 
| 5 | 5 | public $menu; | 
| 6 | 6 | public $mu_menu; | 
| @@ -47,7 +47,8 @@ discard block | ||
| 47 | 47 | } | 
| 48 | 48 | |
| 49 | 49 |  	private function translate_settings( $settings ) { | 
| 50 | -        if ( $settings ) { //workaround for W3 total cache conflict | |
| 50 | +        if ( $settings ) { | |
| 51 | +//workaround for W3 total cache conflict | |
| 51 | 52 | return unserialize(serialize($settings)); | 
| 52 | 53 | } | 
| 53 | 54 | |
| @@ -58,7 +59,8 @@ discard block | ||
| 58 | 59 | } | 
| 59 | 60 | |
| 60 | 61 | // If unserializing didn't work | 
| 61 | -        if ( $settings ) { //workaround for W3 total cache conflict | |
| 62 | +        if ( $settings ) { | |
| 63 | +//workaround for W3 total cache conflict | |
| 62 | 64 | $settings = unserialize(serialize($settings)); | 
| 63 | 65 |          } else { | 
| 64 | 66 | $settings = $this; | 
| @@ -1,251 +1,251 @@ | ||
| 1 | 1 | <?php | 
| 2 | 2 | |
| 3 | 3 |  class FrmSettings{ | 
| 4 | - public $option_name = 'frm_options'; | |
| 5 | - public $menu; | |
| 6 | - public $mu_menu; | |
| 7 | - public $preview_page_id; | |
| 8 | - public $use_html; | |
| 9 | - public $jquery_css; | |
| 10 | - public $accordion_js; | |
| 11 | - | |
| 12 | - public $success_msg; | |
| 13 | - public $blank_msg; | |
| 14 | - public $unique_msg; | |
| 15 | - public $invalid_msg; | |
| 16 | - public $failed_msg; | |
| 17 | - public $submit_value; | |
| 18 | - public $login_msg; | |
| 19 | - public $admin_permission; | |
| 20 | - | |
| 21 | - public $email_to; | |
| 22 | - public $load_style; | |
| 23 | - public $custom_style; | |
| 24 | - | |
| 25 | - public $pubkey; | |
| 26 | - public $privkey; | |
| 27 | - public $re_lang; | |
| 28 | - public $re_msg; | |
| 29 | - | |
| 30 | -    public function __construct() { | |
| 31 | -        if ( ! defined('ABSPATH') ) { | |
| 32 | -            die('You are not allowed to call this page directly.'); | |
| 33 | - } | |
| 34 | - | |
| 35 | - $settings = get_transient($this->option_name); | |
| 36 | - | |
| 37 | -        if ( ! is_object($settings) ) { | |
| 38 | - $settings = $this->translate_settings($settings); | |
| 39 | - } | |
| 40 | - | |
| 41 | -        foreach ( $settings as $setting_name => $setting ) { | |
| 42 | -            $this->{$setting_name} = $setting; | |
| 43 | - unset($setting_name, $setting); | |
| 44 | - } | |
| 45 | - | |
| 46 | - $this->set_default_options(); | |
| 47 | - } | |
| 4 | + public $option_name = 'frm_options'; | |
| 5 | + public $menu; | |
| 6 | + public $mu_menu; | |
| 7 | + public $preview_page_id; | |
| 8 | + public $use_html; | |
| 9 | + public $jquery_css; | |
| 10 | + public $accordion_js; | |
| 11 | + | |
| 12 | + public $success_msg; | |
| 13 | + public $blank_msg; | |
| 14 | + public $unique_msg; | |
| 15 | + public $invalid_msg; | |
| 16 | + public $failed_msg; | |
| 17 | + public $submit_value; | |
| 18 | + public $login_msg; | |
| 19 | + public $admin_permission; | |
| 20 | + | |
| 21 | + public $email_to; | |
| 22 | + public $load_style; | |
| 23 | + public $custom_style; | |
| 24 | + | |
| 25 | + public $pubkey; | |
| 26 | + public $privkey; | |
| 27 | + public $re_lang; | |
| 28 | + public $re_msg; | |
| 29 | + | |
| 30 | +	public function __construct() { | |
| 31 | +		if ( ! defined('ABSPATH') ) { | |
| 32 | +			die('You are not allowed to call this page directly.'); | |
| 33 | + } | |
| 34 | + | |
| 35 | + $settings = get_transient($this->option_name); | |
| 36 | + | |
| 37 | +		if ( ! is_object($settings) ) { | |
| 38 | + $settings = $this->translate_settings($settings); | |
| 39 | + } | |
| 40 | + | |
| 41 | +		foreach ( $settings as $setting_name => $setting ) { | |
| 42 | +			$this->{$setting_name} = $setting; | |
| 43 | + unset($setting_name, $setting); | |
| 44 | + } | |
| 45 | + | |
| 46 | + $this->set_default_options(); | |
| 47 | + } | |
| 48 | 48 | |
| 49 | 49 |  	private function translate_settings( $settings ) { | 
| 50 | -        if ( $settings ) { //workaround for W3 total cache conflict | |
| 51 | - return unserialize(serialize($settings)); | |
| 52 | - } | |
| 53 | - | |
| 54 | - $settings = get_option($this->option_name); | |
| 55 | -        if ( is_object($settings) ) { | |
| 56 | - set_transient($this->option_name, $settings); | |
| 57 | - return $settings; | |
| 58 | - } | |
| 59 | - | |
| 60 | - // If unserializing didn't work | |
| 61 | -        if ( $settings ) { //workaround for W3 total cache conflict | |
| 62 | - $settings = unserialize(serialize($settings)); | |
| 63 | -        } else { | |
| 64 | - $settings = $this; | |
| 65 | - } | |
| 66 | - | |
| 67 | - update_option($this->option_name, $settings); | |
| 68 | - set_transient($this->option_name, $settings); | |
| 69 | - | |
| 70 | - return $settings; | |
| 71 | - } | |
| 72 | - | |
| 73 | - /** | |
| 74 | - * @return array | |
| 75 | - */ | |
| 50 | +		if ( $settings ) { //workaround for W3 total cache conflict | |
| 51 | + return unserialize(serialize($settings)); | |
| 52 | + } | |
| 53 | + | |
| 54 | + $settings = get_option($this->option_name); | |
| 55 | +		if ( is_object($settings) ) { | |
| 56 | + set_transient($this->option_name, $settings); | |
| 57 | + return $settings; | |
| 58 | + } | |
| 59 | + | |
| 60 | + // If unserializing didn't work | |
| 61 | +		if ( $settings ) { //workaround for W3 total cache conflict | |
| 62 | + $settings = unserialize(serialize($settings)); | |
| 63 | +		} else { | |
| 64 | + $settings = $this; | |
| 65 | + } | |
| 66 | + | |
| 67 | + update_option($this->option_name, $settings); | |
| 68 | + set_transient($this->option_name, $settings); | |
| 69 | + | |
| 70 | + return $settings; | |
| 71 | + } | |
| 72 | + | |
| 73 | + /** | |
| 74 | + * @return array | |
| 75 | + */ | |
| 76 | 76 |  	public function default_options() { | 
| 77 | - return array( | |
| 78 | - 'menu' => apply_filters( 'frm_default_menu', __( 'Forms', 'formidable' ) ), | |
| 79 | - 'mu_menu' => 0, | |
| 80 | - 'preview_page_id' => 0, | |
| 81 | - 'use_html' => true, | |
| 82 | - 'jquery_css' => false, | |
| 83 | - 'accordion_js' => false, | |
| 84 | - | |
| 85 | - 'success_msg' => __( 'Your responses were successfully submitted. Thank you!', 'formidable' ), | |
| 86 | - 'blank_msg' => __( 'This field cannot be blank.', 'formidable' ), | |
| 87 | - 'unique_msg' => __( 'This value must be unique.', 'formidable' ), | |
| 88 | - 'invalid_msg' => __( 'There was a problem with your submission. Errors are marked below.', 'formidable' ), | |
| 89 | - 'failed_msg' => __( 'We\'re sorry. It looks like you\'ve already submitted that.', 'formidable' ), | |
| 90 | - 'submit_value' => __( 'Submit', 'formidable' ), | |
| 91 | - 'login_msg' => __( 'You do not have permission to view this form.', 'formidable' ), | |
| 92 | - 'admin_permission' => __( 'You do not have permission to do that', 'formidable' ), | |
| 93 | - | |
| 94 | - 'email_to' => '[admin_email]', | |
| 95 | - ); | |
| 96 | - } | |
| 77 | + return array( | |
| 78 | + 'menu' => apply_filters( 'frm_default_menu', __( 'Forms', 'formidable' ) ), | |
| 79 | + 'mu_menu' => 0, | |
| 80 | + 'preview_page_id' => 0, | |
| 81 | + 'use_html' => true, | |
| 82 | + 'jquery_css' => false, | |
| 83 | + 'accordion_js' => false, | |
| 84 | + | |
| 85 | + 'success_msg' => __( 'Your responses were successfully submitted. Thank you!', 'formidable' ), | |
| 86 | + 'blank_msg' => __( 'This field cannot be blank.', 'formidable' ), | |
| 87 | + 'unique_msg' => __( 'This value must be unique.', 'formidable' ), | |
| 88 | + 'invalid_msg' => __( 'There was a problem with your submission. Errors are marked below.', 'formidable' ), | |
| 89 | + 'failed_msg' => __( 'We\'re sorry. It looks like you\'ve already submitted that.', 'formidable' ), | |
| 90 | + 'submit_value' => __( 'Submit', 'formidable' ), | |
| 91 | + 'login_msg' => __( 'You do not have permission to view this form.', 'formidable' ), | |
| 92 | + 'admin_permission' => __( 'You do not have permission to do that', 'formidable' ), | |
| 93 | + | |
| 94 | + 'email_to' => '[admin_email]', | |
| 95 | + ); | |
| 96 | + } | |
| 97 | 97 | |
| 98 | 98 |  	private function set_default_options() { | 
| 99 | - $this->fill_recaptcha_settings(); | |
| 100 | - | |
| 101 | -        if ( ! isset($this->load_style) ) { | |
| 102 | -            if ( ! isset($this->custom_style) ) { | |
| 103 | - $this->custom_style = true; | |
| 104 | - } | |
| 105 | - | |
| 106 | - $this->load_style = 'all'; | |
| 107 | - } | |
| 108 | - | |
| 109 | - $this->fill_with_defaults(); | |
| 110 | - | |
| 111 | -        if ( is_multisite() && is_admin() ) { | |
| 112 | -            $mu_menu = get_site_option('frm_admin_menu_name'); | |
| 113 | -            if ( $mu_menu && ! empty($mu_menu) ) { | |
| 114 | - $this->menu = $mu_menu; | |
| 115 | - $this->mu_menu = 1; | |
| 116 | - } | |
| 117 | - } | |
| 118 | - | |
| 119 | -        $frm_roles = FrmAppHelper::frm_capabilities('pro'); | |
| 120 | -        foreach ( $frm_roles as $frm_role => $frm_role_description ) { | |
| 121 | -            if ( ! isset($this->$frm_role) ) { | |
| 122 | - $this->$frm_role = 'administrator'; | |
| 123 | - } | |
| 124 | - } | |
| 125 | - } | |
| 99 | + $this->fill_recaptcha_settings(); | |
| 100 | + | |
| 101 | +		if ( ! isset($this->load_style) ) { | |
| 102 | +			if ( ! isset($this->custom_style) ) { | |
| 103 | + $this->custom_style = true; | |
| 104 | + } | |
| 105 | + | |
| 106 | + $this->load_style = 'all'; | |
| 107 | + } | |
| 108 | + | |
| 109 | + $this->fill_with_defaults(); | |
| 110 | + | |
| 111 | +		if ( is_multisite() && is_admin() ) { | |
| 112 | +			$mu_menu = get_site_option('frm_admin_menu_name'); | |
| 113 | +			if ( $mu_menu && ! empty($mu_menu) ) { | |
| 114 | + $this->menu = $mu_menu; | |
| 115 | + $this->mu_menu = 1; | |
| 116 | + } | |
| 117 | + } | |
| 118 | + | |
| 119 | +		$frm_roles = FrmAppHelper::frm_capabilities('pro'); | |
| 120 | +		foreach ( $frm_roles as $frm_role => $frm_role_description ) { | |
| 121 | +			if ( ! isset($this->$frm_role) ) { | |
| 122 | + $this->$frm_role = 'administrator'; | |
| 123 | + } | |
| 124 | + } | |
| 125 | + } | |
| 126 | 126 | |
| 127 | 127 |  	public function fill_with_defaults( $params = array() ) { | 
| 128 | - $settings = $this->default_options(); | |
| 128 | + $settings = $this->default_options(); | |
| 129 | 129 | |
| 130 | -        foreach ( $settings as $setting => $default ) { | |
| 130 | +		foreach ( $settings as $setting => $default ) { | |
| 131 | 131 |  			if ( isset( $params[ 'frm_' . $setting ] ) ) { | 
| 132 | 132 |  				$this->{$setting} = $params[ 'frm_' . $setting ]; | 
| 133 | -            } else if ( ! isset($this->{$setting}) ) { | |
| 134 | -                $this->{$setting} = $default; | |
| 135 | - } | |
| 133 | +			} else if ( ! isset($this->{$setting}) ) { | |
| 134 | +				$this->{$setting} = $default; | |
| 135 | + } | |
| 136 | 136 | |
| 137 | 137 |  			if ( $setting == 'menu' && empty( $this->{$setting} ) ) { | 
| 138 | 138 |  				$this->{$setting} = $default; | 
| 139 | 139 | } | 
| 140 | 140 | |
| 141 | - unset($setting, $default); | |
| 142 | - } | |
| 143 | - } | |
| 144 | - | |
| 145 | -    private function fill_recaptcha_settings() { | |
| 146 | - $privkey = ''; | |
| 147 | - $re_lang = 'en'; | |
| 148 | - | |
| 149 | -        if ( ! isset($this->pubkey) ) { | |
| 150 | - // get the options from the database | |
| 151 | -            $recaptcha_opt = is_multisite() ? get_site_option('recaptcha') : get_option('recaptcha'); | |
| 152 | - $this->pubkey = isset($recaptcha_opt['pubkey']) ? $recaptcha_opt['pubkey'] : ''; | |
| 153 | - $privkey = isset($recaptcha_opt['privkey']) ? $recaptcha_opt['privkey'] : $privkey; | |
| 154 | - $re_lang = isset($recaptcha_opt['re_lang']) ? $recaptcha_opt['re_lang'] : $re_lang; | |
| 155 | - } | |
| 141 | + unset($setting, $default); | |
| 142 | + } | |
| 143 | + } | |
| 144 | + | |
| 145 | +	private function fill_recaptcha_settings() { | |
| 146 | + $privkey = ''; | |
| 147 | + $re_lang = 'en'; | |
| 148 | + | |
| 149 | +		if ( ! isset($this->pubkey) ) { | |
| 150 | + // get the options from the database | |
| 151 | +			$recaptcha_opt = is_multisite() ? get_site_option('recaptcha') : get_option('recaptcha'); | |
| 152 | + $this->pubkey = isset($recaptcha_opt['pubkey']) ? $recaptcha_opt['pubkey'] : ''; | |
| 153 | + $privkey = isset($recaptcha_opt['privkey']) ? $recaptcha_opt['privkey'] : $privkey; | |
| 154 | + $re_lang = isset($recaptcha_opt['re_lang']) ? $recaptcha_opt['re_lang'] : $re_lang; | |
| 155 | + } | |
| 156 | 156 | |
| 157 | -        if ( ! isset($this->re_msg) || empty($this->re_msg) ) { | |
| 158 | - $this->re_msg = __( 'The reCAPTCHA was not entered correctly', 'formidable' ); | |
| 159 | - } | |
| 157 | +		if ( ! isset($this->re_msg) || empty($this->re_msg) ) { | |
| 158 | + $this->re_msg = __( 'The reCAPTCHA was not entered correctly', 'formidable' ); | |
| 159 | + } | |
| 160 | 160 | |
| 161 | -        if ( ! isset($this->privkey) ) { | |
| 162 | - $this->privkey = $privkey; | |
| 163 | - } | |
| 161 | +		if ( ! isset($this->privkey) ) { | |
| 162 | + $this->privkey = $privkey; | |
| 163 | + } | |
| 164 | 164 | |
| 165 | -        if ( ! isset($this->re_lang) ) { | |
| 166 | - $this->re_lang = $re_lang; | |
| 167 | - } | |
| 168 | - } | |
| 165 | +		if ( ! isset($this->re_lang) ) { | |
| 166 | + $this->re_lang = $re_lang; | |
| 167 | + } | |
| 168 | + } | |
| 169 | 169 | |
| 170 | -    public function validate( $params, $errors ) { | |
| 171 | - $errors = apply_filters( 'frm_validate_settings', $errors, $params ); | |
| 172 | - return $errors; | |
| 173 | - } | |
| 170 | +	public function validate( $params, $errors ) { | |
| 171 | + $errors = apply_filters( 'frm_validate_settings', $errors, $params ); | |
| 172 | + return $errors; | |
| 173 | + } | |
| 174 | 174 | |
| 175 | 175 |  	public function update( $params ) { | 
| 176 | - $this->fill_with_defaults($params); | |
| 177 | - $this->update_settings($params); | |
| 176 | + $this->fill_with_defaults($params); | |
| 177 | + $this->update_settings($params); | |
| 178 | 178 | |
| 179 | -        if ( $this->mu_menu ) { | |
| 180 | -            update_site_option('frm_admin_menu_name', $this->menu); | |
| 181 | -        } else if ( current_user_can('administrator') ) { | |
| 182 | -            update_site_option('frm_admin_menu_name', false); | |
| 183 | - } | |
| 179 | +		if ( $this->mu_menu ) { | |
| 180 | +			update_site_option('frm_admin_menu_name', $this->menu); | |
| 181 | +		} else if ( current_user_can('administrator') ) { | |
| 182 | +			update_site_option('frm_admin_menu_name', false); | |
| 183 | + } | |
| 184 | 184 | |
| 185 | - $this->update_roles($params); | |
| 185 | + $this->update_roles($params); | |
| 186 | 186 | |
| 187 | - do_action( 'frm_update_settings', $params ); | |
| 188 | - } | |
| 187 | + do_action( 'frm_update_settings', $params ); | |
| 188 | + } | |
| 189 | 189 | |
| 190 | 190 |  	private function update_settings( $params ) { | 
| 191 | - $this->mu_menu = isset($params['frm_mu_menu']) ? $params['frm_mu_menu'] : 0; | |
| 191 | + $this->mu_menu = isset($params['frm_mu_menu']) ? $params['frm_mu_menu'] : 0; | |
| 192 | 192 | |
| 193 | - $this->pubkey = trim($params['frm_pubkey']); | |
| 194 | - $this->privkey = $params['frm_privkey']; | |
| 195 | - $this->re_lang = $params['frm_re_lang']; | |
| 193 | + $this->pubkey = trim($params['frm_pubkey']); | |
| 194 | + $this->privkey = $params['frm_privkey']; | |
| 195 | + $this->re_lang = $params['frm_re_lang']; | |
| 196 | 196 | |
| 197 | - $this->load_style = $params['frm_load_style']; | |
| 198 | - $this->preview_page_id = (int) $params['frm-preview-page-id']; | |
| 197 | + $this->load_style = $params['frm_load_style']; | |
| 198 | + $this->preview_page_id = (int) $params['frm-preview-page-id']; | |
| 199 | 199 | |
| 200 | - $this->use_html = isset($params['frm_use_html']) ? $params['frm_use_html'] : 0; | |
| 201 | - //$this->custom_style = isset($params['frm_custom_style']) ? $params['frm_custom_style'] : 0; | |
| 200 | + $this->use_html = isset($params['frm_use_html']) ? $params['frm_use_html'] : 0; | |
| 201 | + //$this->custom_style = isset($params['frm_custom_style']) ? $params['frm_custom_style'] : 0; | |
| 202 | 202 | $this->jquery_css = isset( $params['frm_jquery_css'] ) ? absint( $params['frm_jquery_css'] ) : 0; | 
| 203 | 203 | $this->accordion_js = isset( $params['frm_accordion_js'] ) ? absint( $params['frm_accordion_js'] ) : 0; | 
| 204 | - } | |
| 204 | + } | |
| 205 | 205 | |
| 206 | 206 |  	private function update_roles( $params ) { | 
| 207 | - //update roles | |
| 208 | - global $wp_roles; | |
| 209 | - | |
| 210 | - $frm_roles = FrmAppHelper::frm_capabilities(); | |
| 211 | - $roles = get_editable_roles(); | |
| 212 | -        foreach ( $frm_roles as $frm_role => $frm_role_description ) { | |
| 213 | - $this->$frm_role = (array) ( isset( $params[ $frm_role ] ) ? $params[ $frm_role ] : 'administrator' ); | |
| 214 | - | |
| 215 | -            if ( count($this->$frm_role) === 1 ) { | |
| 216 | - $set_role = reset($this->$frm_role); | |
| 217 | -                switch ( $set_role ) { | |
| 218 | - case 'subscriber': | |
| 219 | - array_push($this->$frm_role, 'contributor'); | |
| 220 | - case 'contributor': | |
| 221 | - array_push($this->$frm_role, 'author'); | |
| 222 | - case 'author': | |
| 223 | - array_push($this->$frm_role, 'editor'); | |
| 224 | - case 'editor': | |
| 225 | - array_push($this->$frm_role, 'administrator'); | |
| 226 | - } | |
| 227 | - unset($set_role); | |
| 228 | - } | |
| 229 | - | |
| 230 | -            foreach ( $roles as $role => $details ) { | |
| 231 | -                if ( in_array($role, $this->$frm_role) ) { | |
| 232 | - $wp_roles->add_cap( $role, $frm_role ); | |
| 233 | -    			} else { | |
| 234 | - $wp_roles->remove_cap( $role, $frm_role ); | |
| 235 | - } | |
| 236 | - unset($role, $details); | |
| 237 | - } | |
| 238 | - } | |
| 239 | - } | |
| 207 | + //update roles | |
| 208 | + global $wp_roles; | |
| 209 | + | |
| 210 | + $frm_roles = FrmAppHelper::frm_capabilities(); | |
| 211 | + $roles = get_editable_roles(); | |
| 212 | +		foreach ( $frm_roles as $frm_role => $frm_role_description ) { | |
| 213 | + $this->$frm_role = (array) ( isset( $params[ $frm_role ] ) ? $params[ $frm_role ] : 'administrator' ); | |
| 214 | + | |
| 215 | +			if ( count($this->$frm_role) === 1 ) { | |
| 216 | + $set_role = reset($this->$frm_role); | |
| 217 | +				switch ( $set_role ) { | |
| 218 | + case 'subscriber': | |
| 219 | + array_push($this->$frm_role, 'contributor'); | |
| 220 | + case 'contributor': | |
| 221 | + array_push($this->$frm_role, 'author'); | |
| 222 | + case 'author': | |
| 223 | + array_push($this->$frm_role, 'editor'); | |
| 224 | + case 'editor': | |
| 225 | + array_push($this->$frm_role, 'administrator'); | |
| 226 | + } | |
| 227 | + unset($set_role); | |
| 228 | + } | |
| 229 | + | |
| 230 | +			foreach ( $roles as $role => $details ) { | |
| 231 | +				if ( in_array($role, $this->$frm_role) ) { | |
| 232 | + $wp_roles->add_cap( $role, $frm_role ); | |
| 233 | +				} else { | |
| 234 | + $wp_roles->remove_cap( $role, $frm_role ); | |
| 235 | + } | |
| 236 | + unset($role, $details); | |
| 237 | + } | |
| 238 | + } | |
| 239 | + } | |
| 240 | 240 | |
| 241 | 241 |  	public function store() { | 
| 242 | - // Save the posted value in the database | |
| 242 | + // Save the posted value in the database | |
| 243 | 243 | |
| 244 | -        update_option('frm_options', $this); | |
| 244 | +		update_option('frm_options', $this); | |
| 245 | 245 | |
| 246 | -        delete_transient('frm_options'); | |
| 247 | -        set_transient('frm_options', $this); | |
| 246 | +		delete_transient('frm_options'); | |
| 247 | +		set_transient('frm_options', $this); | |
| 248 | 248 | |
| 249 | - do_action( 'frm_store_settings' ); | |
| 250 | - } | |
| 249 | + do_action( 'frm_store_settings' ); | |
| 250 | + } | |
| 251 | 251 | } | 
| @@ -1,12 +1,12 @@ | ||
| 1 | 1 | <?php | 
| 2 | 2 |  if ( ! isset( $entry) ) { | 
| 3 | - $entry = $record; | |
| 3 | + $entry = $record; | |
| 4 | 4 | } ?> | 
| 5 | 5 | |
| 6 | 6 | <div class="misc-pub-section curtime misc-pub-curtime"> | 
| 7 | 7 | <span id="timestamp"> | 
| 8 | 8 | <?php | 
| 9 | - $date_format = __( 'M j, Y @ G:i' ); | |
| 9 | + $date_format = __( 'M j, Y @ G:i' ); | |
| 10 | 10 | printf( __( 'Published on: <b>%1$s</b>' ), FrmAppHelper::get_localized_date( $date_format, $entry->created_at ) ); ?> | 
| 11 | 11 | </span> | 
| 12 | 12 | </div> | 
| @@ -1,5 +1,5 @@ discard block | ||
| 1 | 1 | <?php | 
| 2 | -if ( ! isset( $entry) ) { | |
| 2 | +if ( ! isset( $entry ) ) { | |
| 3 | 3 | $entry = $record; | 
| 4 | 4 | } ?> | 
| 5 | 5 | |
| @@ -18,4 +18,4 @@ discard block | ||
| 18 | 18 | </div> | 
| 19 | 19 | <?php } ?> | 
| 20 | 20 | |
| 21 | -<?php do_action('frm_entry_shared_sidebar', $entry); ?> | |
| 21 | +<?php do_action( 'frm_entry_shared_sidebar', $entry ); ?> | |