@@ -27,14 +27,14 @@ |
||
| 27 | 27 | ); |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - foreach ( $style->post_content as $k => $v ) { |
|
| 31 | - if ( $k == 'custom_css' ) { |
|
| 32 | - continue; |
|
| 33 | - } |
|
| 34 | - ?> |
|
| 30 | + foreach ( $style->post_content as $k => $v ) { |
|
| 31 | + if ( $k == 'custom_css' ) { |
|
| 32 | + continue; |
|
| 33 | + } |
|
| 34 | + ?> |
|
| 35 | 35 | <input type="hidden" value="<?php echo esc_attr($v) ?>" name="<?php echo esc_attr( $frm_style->get_field_name( $k ) ) ?>" /> |
| 36 | 36 | <?php |
| 37 | - } ?> |
|
| 37 | + } ?> |
|
| 38 | 38 | <p class="button-controls"><input type="submit" name="nav-menu-locations" id="nav-menu-locations" class="button button-primary left" value="<?php esc_attr_e( 'Save Changes', 'formidable' ) ?>" /></p> |
| 39 | 39 | |
| 40 | 40 | </form> |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <div class="nav-menus-php"> |
| 2 | 2 | <div class="wrap"> |
| 3 | - <?php FrmStylesHelper::style_menu('custom_css'); ?> |
|
| 3 | + <?php FrmStylesHelper::style_menu( 'custom_css' ); ?> |
|
| 4 | 4 | |
| 5 | 5 | <p><?php esc_html_e( 'You can add custom css here or in your theme style.css', 'formidable' ) ?></p> |
| 6 | 6 | |
@@ -8,13 +8,13 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | <form method="post"> |
| 10 | 10 | <input type="hidden" name="ID" value="<?php echo esc_attr( $style->ID ) ?>" /> |
| 11 | - <input type="hidden" name="<?php echo esc_attr( $frm_style->get_field_name('post_title', '') ); ?>" value="<?php echo esc_attr( $style->post_title ) ?>" /> |
|
| 12 | - <input type="hidden" name="<?php echo esc_attr( $frm_style->get_field_name('menu_order', '') ); ?>" value="<?php echo esc_attr( $style->menu_order ) ?>" /> |
|
| 11 | + <input type="hidden" name="<?php echo esc_attr( $frm_style->get_field_name( 'post_title', '' ) ); ?>" value="<?php echo esc_attr( $style->post_title ) ?>" /> |
|
| 12 | + <input type="hidden" name="<?php echo esc_attr( $frm_style->get_field_name( 'menu_order', '' ) ); ?>" value="<?php echo esc_attr( $style->menu_order ) ?>" /> |
|
| 13 | 13 | <input type="hidden" name="style_name" value="frm_style_<?php echo esc_attr( $style->post_name ) ?>" /> |
| 14 | 14 | <input type="hidden" name="frm_action" value="save_css" /> |
| 15 | 15 | <?php wp_nonce_field( 'frm_custom_css_nonce', 'frm_custom_css' ); ?> |
| 16 | 16 | |
| 17 | - <textarea name="<?php echo esc_attr( $frm_style->get_field_name('custom_css') ) ?>" id="<?php echo esc_attr( $id ) ?>" class="hide-if-js"><?php echo FrmAppHelper::esc_textarea( $style->post_content['custom_css'] ) ?></textarea> |
|
| 17 | + <textarea name="<?php echo esc_attr( $frm_style->get_field_name( 'custom_css' ) ) ?>" id="<?php echo esc_attr( $id ) ?>" class="hide-if-js"><?php echo FrmAppHelper::esc_textarea( $style->post_content['custom_css'] ) ?></textarea> |
|
| 18 | 18 | |
| 19 | 19 | <?php |
| 20 | 20 | if ( ! empty( $settings ) && $id == 'frm_codemirror_box' ) { |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | continue; |
| 33 | 33 | } |
| 34 | 34 | ?> |
| 35 | - <input type="hidden" value="<?php echo esc_attr($v) ?>" name="<?php echo esc_attr( $frm_style->get_field_name( $k ) ) ?>" /> |
|
| 35 | + <input type="hidden" value="<?php echo esc_attr( $v ) ?>" name="<?php echo esc_attr( $frm_style->get_field_name( $k ) ) ?>" /> |
|
| 36 | 36 | <?php |
| 37 | 37 | } ?> |
| 38 | 38 | <p class="button-controls"><input type="submit" name="nav-menu-locations" id="nav-menu-locations" class="button button-primary left" value="<?php esc_attr_e( 'Save Changes', 'formidable' ) ?>" /></p> |
@@ -12,50 +12,50 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | public static $plug_version = '2.05.03'; |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * @since 1.07.02 |
|
| 17 | - * |
|
| 18 | - * @param none |
|
| 19 | - * @return string The version of this plugin |
|
| 20 | - */ |
|
| 21 | - public static function plugin_version() { |
|
| 22 | - return self::$plug_version; |
|
| 23 | - } |
|
| 24 | - |
|
| 25 | - public static function plugin_folder() { |
|
| 26 | - return basename(self::plugin_path()); |
|
| 27 | - } |
|
| 28 | - |
|
| 29 | - public static function plugin_path() { |
|
| 30 | - return dirname(dirname(dirname(__FILE__))); |
|
| 31 | - } |
|
| 32 | - |
|
| 33 | - public static function plugin_url() { |
|
| 34 | - //prevously FRM_URL constant |
|
| 15 | + /** |
|
| 16 | + * @since 1.07.02 |
|
| 17 | + * |
|
| 18 | + * @param none |
|
| 19 | + * @return string The version of this plugin |
|
| 20 | + */ |
|
| 21 | + public static function plugin_version() { |
|
| 22 | + return self::$plug_version; |
|
| 23 | + } |
|
| 24 | + |
|
| 25 | + public static function plugin_folder() { |
|
| 26 | + return basename(self::plugin_path()); |
|
| 27 | + } |
|
| 28 | + |
|
| 29 | + public static function plugin_path() { |
|
| 30 | + return dirname(dirname(dirname(__FILE__))); |
|
| 31 | + } |
|
| 32 | + |
|
| 33 | + public static function plugin_url() { |
|
| 34 | + //prevously FRM_URL constant |
|
| 35 | 35 | return plugins_url( '', self::plugin_path() . '/formidable.php' ); |
| 36 | - } |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | 38 | public static function relative_plugin_url() { |
| 39 | 39 | return str_replace( array( 'https:', 'http:' ), '', self::plugin_url() ); |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * @return string Site URL |
|
| 44 | - */ |
|
| 45 | - public static function site_url() { |
|
| 46 | - return site_url(); |
|
| 47 | - } |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * Get the name of this site |
|
| 51 | - * Used for [sitename] shortcode |
|
| 52 | - * |
|
| 53 | - * @since 2.0 |
|
| 54 | - * @return string |
|
| 55 | - */ |
|
| 56 | - public static function site_name() { |
|
| 57 | - return get_option('blogname'); |
|
| 58 | - } |
|
| 42 | + /** |
|
| 43 | + * @return string Site URL |
|
| 44 | + */ |
|
| 45 | + public static function site_url() { |
|
| 46 | + return site_url(); |
|
| 47 | + } |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * Get the name of this site |
|
| 51 | + * Used for [sitename] shortcode |
|
| 52 | + * |
|
| 53 | + * @since 2.0 |
|
| 54 | + * @return string |
|
| 55 | + */ |
|
| 56 | + public static function site_name() { |
|
| 57 | + return get_option('blogname'); |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | 60 | public static function make_affiliate_url( $url ) { |
| 61 | 61 | $affiliate_id = self::get_affiliate(); |
@@ -70,21 +70,21 @@ discard block |
||
| 70 | 70 | return absint( apply_filters( 'frm_affiliate_id', 0 ) ); |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * Get the Formidable settings |
|
| 75 | - * |
|
| 76 | - * @since 2.0 |
|
| 77 | - * |
|
| 78 | - * @param None |
|
| 79 | - * @return FrmSettings $frm_setings |
|
| 80 | - */ |
|
| 81 | - public static function get_settings() { |
|
| 82 | - global $frm_settings; |
|
| 83 | - if ( empty($frm_settings) ) { |
|
| 84 | - $frm_settings = new FrmSettings(); |
|
| 85 | - } |
|
| 86 | - return $frm_settings; |
|
| 87 | - } |
|
| 73 | + /** |
|
| 74 | + * Get the Formidable settings |
|
| 75 | + * |
|
| 76 | + * @since 2.0 |
|
| 77 | + * |
|
| 78 | + * @param None |
|
| 79 | + * @return FrmSettings $frm_setings |
|
| 80 | + */ |
|
| 81 | + public static function get_settings() { |
|
| 82 | + global $frm_settings; |
|
| 83 | + if ( empty($frm_settings) ) { |
|
| 84 | + $frm_settings = new FrmSettings(); |
|
| 85 | + } |
|
| 86 | + return $frm_settings; |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | 89 | public static function get_menu_name() { |
| 90 | 90 | $frm_settings = FrmAppHelper::get_settings(); |
@@ -99,62 +99,62 @@ discard block |
||
| 99 | 99 | return ! $frm_settings->no_ips; |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - /** |
|
| 103 | - * Show a message in place of pro features |
|
| 104 | - * |
|
| 105 | - * @since 2.0 |
|
| 106 | - */ |
|
| 102 | + /** |
|
| 103 | + * Show a message in place of pro features |
|
| 104 | + * |
|
| 105 | + * @since 2.0 |
|
| 106 | + */ |
|
| 107 | 107 | public static function update_message() { |
| 108 | 108 | _deprecated_function( __FUNCTION__, '2.0.19' ); |
| 109 | - } |
|
| 110 | - |
|
| 111 | - public static function pro_is_installed() { |
|
| 112 | - return apply_filters('frm_pro_installed', false); |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - /** |
|
| 116 | - * Check for certain page in Formidable settings |
|
| 117 | - * |
|
| 118 | - * @since 2.0 |
|
| 119 | - * |
|
| 120 | - * @param string $page The name of the page to check |
|
| 121 | - * @return boolean |
|
| 122 | - */ |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + public static function pro_is_installed() { |
|
| 112 | + return apply_filters('frm_pro_installed', false); |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + /** |
|
| 116 | + * Check for certain page in Formidable settings |
|
| 117 | + * |
|
| 118 | + * @since 2.0 |
|
| 119 | + * |
|
| 120 | + * @param string $page The name of the page to check |
|
| 121 | + * @return boolean |
|
| 122 | + */ |
|
| 123 | 123 | public static function is_admin_page( $page = 'formidable' ) { |
| 124 | - global $pagenow; |
|
| 124 | + global $pagenow; |
|
| 125 | 125 | $get_page = self::simple_get( 'page', 'sanitize_title' ); |
| 126 | - if ( $pagenow ) { |
|
| 126 | + if ( $pagenow ) { |
|
| 127 | 127 | return $pagenow == 'admin.php' && $get_page == $page; |
| 128 | - } |
|
| 128 | + } |
|
| 129 | 129 | |
| 130 | 130 | return is_admin() && $get_page == $page; |
| 131 | - } |
|
| 132 | - |
|
| 133 | - /** |
|
| 134 | - * Check for the form preview page |
|
| 135 | - * |
|
| 136 | - * @since 2.0 |
|
| 137 | - * |
|
| 138 | - * @param None |
|
| 139 | - * @return boolean |
|
| 140 | - */ |
|
| 141 | - public static function is_preview_page() { |
|
| 142 | - global $pagenow; |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + /** |
|
| 134 | + * Check for the form preview page |
|
| 135 | + * |
|
| 136 | + * @since 2.0 |
|
| 137 | + * |
|
| 138 | + * @param None |
|
| 139 | + * @return boolean |
|
| 140 | + */ |
|
| 141 | + public static function is_preview_page() { |
|
| 142 | + global $pagenow; |
|
| 143 | 143 | $action = FrmAppHelper::simple_get( 'action', 'sanitize_title' ); |
| 144 | 144 | return $pagenow && $pagenow == 'admin-ajax.php' && $action == 'frm_forms_preview'; |
| 145 | - } |
|
| 145 | + } |
|
| 146 | 146 | |
| 147 | - /** |
|
| 148 | - * Check for ajax except the form preview page |
|
| 149 | - * |
|
| 150 | - * @since 2.0 |
|
| 151 | - * |
|
| 152 | - * @param None |
|
| 153 | - * @return boolean |
|
| 154 | - */ |
|
| 155 | - public static function doing_ajax() { |
|
| 156 | - return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page(); |
|
| 157 | - } |
|
| 147 | + /** |
|
| 148 | + * Check for ajax except the form preview page |
|
| 149 | + * |
|
| 150 | + * @since 2.0 |
|
| 151 | + * |
|
| 152 | + * @param None |
|
| 153 | + * @return boolean |
|
| 154 | + */ |
|
| 155 | + public static function doing_ajax() { |
|
| 156 | + return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page(); |
|
| 157 | + } |
|
| 158 | 158 | |
| 159 | 159 | /** |
| 160 | 160 | * @since 2.0.8 |
@@ -164,102 +164,102 @@ discard block |
||
| 164 | 164 | return isset( $frm_vars['prevent_caching'] ) && $frm_vars['prevent_caching']; |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - /** |
|
| 168 | - * Check if on an admin page |
|
| 169 | - * |
|
| 170 | - * @since 2.0 |
|
| 171 | - * |
|
| 172 | - * @param None |
|
| 173 | - * @return boolean |
|
| 174 | - */ |
|
| 175 | - public static function is_admin() { |
|
| 176 | - return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX ); |
|
| 177 | - } |
|
| 178 | - |
|
| 179 | - /** |
|
| 180 | - * Check if value contains blank value or empty array |
|
| 181 | - * |
|
| 182 | - * @since 2.0 |
|
| 183 | - * @param mixed $value - value to check |
|
| 167 | + /** |
|
| 168 | + * Check if on an admin page |
|
| 169 | + * |
|
| 170 | + * @since 2.0 |
|
| 171 | + * |
|
| 172 | + * @param None |
|
| 173 | + * @return boolean |
|
| 174 | + */ |
|
| 175 | + public static function is_admin() { |
|
| 176 | + return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX ); |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + /** |
|
| 180 | + * Check if value contains blank value or empty array |
|
| 181 | + * |
|
| 182 | + * @since 2.0 |
|
| 183 | + * @param mixed $value - value to check |
|
| 184 | 184 | * @param string |
| 185 | - * @return boolean |
|
| 186 | - */ |
|
| 187 | - public static function is_empty_value( $value, $empty = '' ) { |
|
| 188 | - return ( is_array( $value ) && empty( $value ) ) || $value == $empty; |
|
| 189 | - } |
|
| 190 | - |
|
| 191 | - public static function is_not_empty_value( $value, $empty = '' ) { |
|
| 192 | - return ! self::is_empty_value( $value, $empty ); |
|
| 193 | - } |
|
| 194 | - |
|
| 195 | - /** |
|
| 196 | - * Get any value from the $_SERVER |
|
| 197 | - * |
|
| 198 | - * @since 2.0 |
|
| 199 | - * @param string $value |
|
| 200 | - * @return string |
|
| 201 | - */ |
|
| 185 | + * @return boolean |
|
| 186 | + */ |
|
| 187 | + public static function is_empty_value( $value, $empty = '' ) { |
|
| 188 | + return ( is_array( $value ) && empty( $value ) ) || $value == $empty; |
|
| 189 | + } |
|
| 190 | + |
|
| 191 | + public static function is_not_empty_value( $value, $empty = '' ) { |
|
| 192 | + return ! self::is_empty_value( $value, $empty ); |
|
| 193 | + } |
|
| 194 | + |
|
| 195 | + /** |
|
| 196 | + * Get any value from the $_SERVER |
|
| 197 | + * |
|
| 198 | + * @since 2.0 |
|
| 199 | + * @param string $value |
|
| 200 | + * @return string |
|
| 201 | + */ |
|
| 202 | 202 | public static function get_server_value( $value ) { |
| 203 | - return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; |
|
| 204 | - } |
|
| 205 | - |
|
| 206 | - /** |
|
| 207 | - * Check for the IP address in several places |
|
| 208 | - * Used by [ip] shortcode |
|
| 209 | - * |
|
| 210 | - * @return string The IP address of the current user |
|
| 211 | - */ |
|
| 212 | - public static function get_ip_address() { |
|
| 203 | + return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; |
|
| 204 | + } |
|
| 205 | + |
|
| 206 | + /** |
|
| 207 | + * Check for the IP address in several places |
|
| 208 | + * Used by [ip] shortcode |
|
| 209 | + * |
|
| 210 | + * @return string The IP address of the current user |
|
| 211 | + */ |
|
| 212 | + public static function get_ip_address() { |
|
| 213 | 213 | $ip = ''; |
| 214 | - foreach ( array( |
|
| 215 | - 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', |
|
| 216 | - 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR', |
|
| 217 | - ) as $key ) { |
|
| 218 | - if ( ! isset( $_SERVER[ $key ] ) ) { |
|
| 219 | - continue; |
|
| 220 | - } |
|
| 221 | - |
|
| 222 | - foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { |
|
| 223 | - $ip = trim($ip); // just to be safe |
|
| 224 | - |
|
| 225 | - if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) { |
|
| 226 | - return $ip; |
|
| 227 | - } |
|
| 228 | - } |
|
| 229 | - } |
|
| 214 | + foreach ( array( |
|
| 215 | + 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', |
|
| 216 | + 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR', |
|
| 217 | + ) as $key ) { |
|
| 218 | + if ( ! isset( $_SERVER[ $key ] ) ) { |
|
| 219 | + continue; |
|
| 220 | + } |
|
| 221 | + |
|
| 222 | + foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { |
|
| 223 | + $ip = trim($ip); // just to be safe |
|
| 224 | + |
|
| 225 | + if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) { |
|
| 226 | + return $ip; |
|
| 227 | + } |
|
| 228 | + } |
|
| 229 | + } |
|
| 230 | 230 | |
| 231 | 231 | return sanitize_text_field( $ip ); |
| 232 | - } |
|
| 232 | + } |
|
| 233 | 233 | |
| 234 | - public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
|
| 235 | - if ( strpos($param, '[') ) { |
|
| 236 | - $params = explode('[', $param); |
|
| 237 | - $param = $params[0]; |
|
| 238 | - } |
|
| 234 | + public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
|
| 235 | + if ( strpos($param, '[') ) { |
|
| 236 | + $params = explode('[', $param); |
|
| 237 | + $param = $params[0]; |
|
| 238 | + } |
|
| 239 | 239 | |
| 240 | 240 | if ( $src == 'get' ) { |
| 241 | - $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); |
|
| 242 | - if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { |
|
| 243 | - $value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) ); |
|
| 244 | - } |
|
| 241 | + $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); |
|
| 242 | + if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { |
|
| 243 | + $value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) ); |
|
| 244 | + } |
|
| 245 | 245 | self::sanitize_value( $sanitize, $value ); |
| 246 | 246 | } else { |
| 247 | - $value = self::get_simple_request( array( 'type' => $src, 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) ); |
|
| 248 | - } |
|
| 247 | + $value = self::get_simple_request( array( 'type' => $src, 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) ); |
|
| 248 | + } |
|
| 249 | 249 | |
| 250 | 250 | if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) { |
| 251 | - foreach ( $params as $k => $p ) { |
|
| 252 | - if ( ! $k || ! is_array($value) ) { |
|
| 253 | - continue; |
|
| 254 | - } |
|
| 251 | + foreach ( $params as $k => $p ) { |
|
| 252 | + if ( ! $k || ! is_array($value) ) { |
|
| 253 | + continue; |
|
| 254 | + } |
|
| 255 | 255 | |
| 256 | - $p = trim($p, ']'); |
|
| 257 | - $value = isset( $value[ $p ] ) ? $value[ $p ] : $default; |
|
| 258 | - } |
|
| 259 | - } |
|
| 256 | + $p = trim($p, ']'); |
|
| 257 | + $value = isset( $value[ $p ] ) ? $value[ $p ] : $default; |
|
| 258 | + } |
|
| 259 | + } |
|
| 260 | 260 | |
| 261 | - return $value; |
|
| 262 | - } |
|
| 261 | + return $value; |
|
| 262 | + } |
|
| 263 | 263 | |
| 264 | 264 | public static function get_post_param( $param, $default = '', $sanitize = '' ) { |
| 265 | 265 | return self::get_simple_request( array( 'type' => 'post', 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) ); |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | */ |
| 276 | 276 | public static function simple_get( $param, $sanitize = 'sanitize_text_field', $default = '' ) { |
| 277 | 277 | return self::get_simple_request( array( 'type' => 'get', 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) ); |
| 278 | - } |
|
| 278 | + } |
|
| 279 | 279 | |
| 280 | 280 | /** |
| 281 | 281 | * Get a GET/POST/REQUEST value and sanitize it |
@@ -311,12 +311,12 @@ discard block |
||
| 311 | 311 | } |
| 312 | 312 | |
| 313 | 313 | /** |
| 314 | - * Preserve backslashes in a value, but make sure value doesn't get compounding slashes |
|
| 315 | - * |
|
| 316 | - * @since 2.0.8 |
|
| 317 | - * @param string $value |
|
| 318 | - * @return string $value |
|
| 319 | - */ |
|
| 314 | + * Preserve backslashes in a value, but make sure value doesn't get compounding slashes |
|
| 315 | + * |
|
| 316 | + * @since 2.0.8 |
|
| 317 | + * @param string $value |
|
| 318 | + * @return string $value |
|
| 319 | + */ |
|
| 320 | 320 | public static function preserve_backslashes( $value ) { |
| 321 | 321 | // If backslashes have already been added, don't add them again |
| 322 | 322 | if ( strpos( $value, '\\\\' ) === false ) { |
@@ -338,14 +338,14 @@ discard block |
||
| 338 | 338 | } |
| 339 | 339 | } |
| 340 | 340 | |
| 341 | - public static function sanitize_request( $sanitize_method, &$values ) { |
|
| 342 | - $temp_values = $values; |
|
| 343 | - foreach ( $temp_values as $k => $val ) { |
|
| 344 | - if ( isset( $sanitize_method[ $k ] ) ) { |
|
| 341 | + public static function sanitize_request( $sanitize_method, &$values ) { |
|
| 342 | + $temp_values = $values; |
|
| 343 | + foreach ( $temp_values as $k => $val ) { |
|
| 344 | + if ( isset( $sanitize_method[ $k ] ) ) { |
|
| 345 | 345 | $values[ $k ] = call_user_func( $sanitize_method[ $k ], $val ); |
| 346 | - } |
|
| 347 | - } |
|
| 348 | - } |
|
| 346 | + } |
|
| 347 | + } |
|
| 348 | + } |
|
| 349 | 349 | |
| 350 | 350 | public static function sanitize_array( &$values ) { |
| 351 | 351 | $temp_values = $values; |
@@ -469,77 +469,77 @@ discard block |
||
| 469 | 469 | ); |
| 470 | 470 | } |
| 471 | 471 | |
| 472 | - /** |
|
| 473 | - * Used when switching the action for a bulk action |
|
| 474 | - * @since 2.0 |
|
| 475 | - */ |
|
| 476 | - public static function remove_get_action() { |
|
| 477 | - if ( ! isset($_GET) ) { |
|
| 478 | - return; |
|
| 479 | - } |
|
| 472 | + /** |
|
| 473 | + * Used when switching the action for a bulk action |
|
| 474 | + * @since 2.0 |
|
| 475 | + */ |
|
| 476 | + public static function remove_get_action() { |
|
| 477 | + if ( ! isset($_GET) ) { |
|
| 478 | + return; |
|
| 479 | + } |
|
| 480 | 480 | |
| 481 | - $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' ); |
|
| 482 | - if ( ! empty( $new_action ) ) { |
|
| 481 | + $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' ); |
|
| 482 | + if ( ! empty( $new_action ) ) { |
|
| 483 | 483 | $_SERVER['REQUEST_URI'] = str_replace( '&action=' . $new_action, '', FrmAppHelper::get_server_value( 'REQUEST_URI' ) ); |
| 484 | - } |
|
| 485 | - } |
|
| 486 | - |
|
| 487 | - /** |
|
| 488 | - * Check the WP query for a parameter |
|
| 489 | - * |
|
| 490 | - * @since 2.0 |
|
| 491 | - * @return string|array |
|
| 492 | - */ |
|
| 493 | - public static function get_query_var( $value, $param ) { |
|
| 494 | - if ( $value != '' ) { |
|
| 495 | - return $value; |
|
| 496 | - } |
|
| 497 | - |
|
| 498 | - global $wp_query; |
|
| 499 | - if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
| 500 | - $value = $wp_query->query_vars[ $param ]; |
|
| 501 | - } |
|
| 502 | - |
|
| 503 | - return $value; |
|
| 504 | - } |
|
| 505 | - |
|
| 506 | - /** |
|
| 507 | - * @param string $type |
|
| 508 | - */ |
|
| 509 | - public static function trigger_hook_load( $type, $object = null ) { |
|
| 510 | - // only load the form hooks once |
|
| 484 | + } |
|
| 485 | + } |
|
| 486 | + |
|
| 487 | + /** |
|
| 488 | + * Check the WP query for a parameter |
|
| 489 | + * |
|
| 490 | + * @since 2.0 |
|
| 491 | + * @return string|array |
|
| 492 | + */ |
|
| 493 | + public static function get_query_var( $value, $param ) { |
|
| 494 | + if ( $value != '' ) { |
|
| 495 | + return $value; |
|
| 496 | + } |
|
| 497 | + |
|
| 498 | + global $wp_query; |
|
| 499 | + if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
| 500 | + $value = $wp_query->query_vars[ $param ]; |
|
| 501 | + } |
|
| 502 | + |
|
| 503 | + return $value; |
|
| 504 | + } |
|
| 505 | + |
|
| 506 | + /** |
|
| 507 | + * @param string $type |
|
| 508 | + */ |
|
| 509 | + public static function trigger_hook_load( $type, $object = null ) { |
|
| 510 | + // only load the form hooks once |
|
| 511 | 511 | $hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object ); |
| 512 | - if ( ! $hooks_loaded ) { |
|
| 512 | + if ( ! $hooks_loaded ) { |
|
| 513 | 513 | do_action( 'frm_load_' . $type . '_hooks' ); |
| 514 | - } |
|
| 515 | - } |
|
| 516 | - |
|
| 517 | - /** |
|
| 518 | - * Check cache before fetching values and saving to cache |
|
| 519 | - * |
|
| 520 | - * @since 2.0 |
|
| 521 | - * |
|
| 522 | - * @param string $cache_key The unique name for this cache |
|
| 523 | - * @param string $group The name of the cache group |
|
| 524 | - * @param string $query If blank, don't run a db call |
|
| 525 | - * @param string $type The wpdb function to use with this query |
|
| 526 | - * @return mixed $results The cache or query results |
|
| 527 | - */ |
|
| 528 | - public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) { |
|
| 529 | - $results = wp_cache_get($cache_key, $group); |
|
| 530 | - if ( ! self::is_empty_value( $results, false ) || empty($query) ) { |
|
| 531 | - return $results; |
|
| 532 | - } |
|
| 533 | - |
|
| 534 | - if ( 'get_posts' == $type ) { |
|
| 535 | - $results = get_posts($query); |
|
| 514 | + } |
|
| 515 | + } |
|
| 516 | + |
|
| 517 | + /** |
|
| 518 | + * Check cache before fetching values and saving to cache |
|
| 519 | + * |
|
| 520 | + * @since 2.0 |
|
| 521 | + * |
|
| 522 | + * @param string $cache_key The unique name for this cache |
|
| 523 | + * @param string $group The name of the cache group |
|
| 524 | + * @param string $query If blank, don't run a db call |
|
| 525 | + * @param string $type The wpdb function to use with this query |
|
| 526 | + * @return mixed $results The cache or query results |
|
| 527 | + */ |
|
| 528 | + public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) { |
|
| 529 | + $results = wp_cache_get($cache_key, $group); |
|
| 530 | + if ( ! self::is_empty_value( $results, false ) || empty($query) ) { |
|
| 531 | + return $results; |
|
| 532 | + } |
|
| 533 | + |
|
| 534 | + if ( 'get_posts' == $type ) { |
|
| 535 | + $results = get_posts($query); |
|
| 536 | 536 | } else if ( 'get_associative_results' == $type ) { |
| 537 | 537 | global $wpdb; |
| 538 | 538 | $results = $wpdb->get_results( $query, OBJECT_K ); |
| 539 | - } else { |
|
| 540 | - global $wpdb; |
|
| 541 | - $results = $wpdb->{$type}($query); |
|
| 542 | - } |
|
| 539 | + } else { |
|
| 540 | + global $wpdb; |
|
| 541 | + $results = $wpdb->{$type}($query); |
|
| 542 | + } |
|
| 543 | 543 | |
| 544 | 544 | self::set_cache( $cache_key, $results, $group, $time ); |
| 545 | 545 | |
@@ -572,44 +572,44 @@ discard block |
||
| 572 | 572 | return $cached; |
| 573 | 573 | } |
| 574 | 574 | |
| 575 | - /** |
|
| 576 | - * Data that should be stored for a long time can be stored in a transient. |
|
| 577 | - * First check the cache, then check the transient |
|
| 578 | - * @since 2.0 |
|
| 579 | - * @return mixed The cached value or false |
|
| 580 | - */ |
|
| 575 | + /** |
|
| 576 | + * Data that should be stored for a long time can be stored in a transient. |
|
| 577 | + * First check the cache, then check the transient |
|
| 578 | + * @since 2.0 |
|
| 579 | + * @return mixed The cached value or false |
|
| 580 | + */ |
|
| 581 | 581 | public static function check_cache_and_transient( $cache_key ) { |
| 582 | - // check caching layer first |
|
| 583 | - $results = self::check_cache( $cache_key ); |
|
| 584 | - if ( $results ) { |
|
| 585 | - return $results; |
|
| 586 | - } |
|
| 587 | - |
|
| 588 | - // then check the transient |
|
| 589 | - $results = get_transient($cache_key); |
|
| 590 | - if ( $results ) { |
|
| 591 | - wp_cache_set($cache_key, $results); |
|
| 592 | - } |
|
| 593 | - |
|
| 594 | - return $results; |
|
| 595 | - } |
|
| 596 | - |
|
| 597 | - /** |
|
| 598 | - * @since 2.0 |
|
| 599 | - * @param string $cache_key |
|
| 600 | - */ |
|
| 582 | + // check caching layer first |
|
| 583 | + $results = self::check_cache( $cache_key ); |
|
| 584 | + if ( $results ) { |
|
| 585 | + return $results; |
|
| 586 | + } |
|
| 587 | + |
|
| 588 | + // then check the transient |
|
| 589 | + $results = get_transient($cache_key); |
|
| 590 | + if ( $results ) { |
|
| 591 | + wp_cache_set($cache_key, $results); |
|
| 592 | + } |
|
| 593 | + |
|
| 594 | + return $results; |
|
| 595 | + } |
|
| 596 | + |
|
| 597 | + /** |
|
| 598 | + * @since 2.0 |
|
| 599 | + * @param string $cache_key |
|
| 600 | + */ |
|
| 601 | 601 | public static function delete_cache_and_transient( $cache_key, $group = 'default' ) { |
| 602 | 602 | delete_transient($cache_key); |
| 603 | 603 | wp_cache_delete( $cache_key, $group ); |
| 604 | 604 | } |
| 605 | 605 | |
| 606 | - /** |
|
| 607 | - * Delete all caching in a single group |
|
| 608 | - * |
|
| 609 | - * @since 2.0 |
|
| 610 | - * |
|
| 611 | - * @param string $group The name of the cache group |
|
| 612 | - */ |
|
| 606 | + /** |
|
| 607 | + * Delete all caching in a single group |
|
| 608 | + * |
|
| 609 | + * @since 2.0 |
|
| 610 | + * |
|
| 611 | + * @param string $group The name of the cache group |
|
| 612 | + */ |
|
| 613 | 613 | public static function cache_delete_group( $group ) { |
| 614 | 614 | $cached_keys = self::get_group_cached_keys( $group ); |
| 615 | 615 | |
@@ -622,35 +622,35 @@ discard block |
||
| 622 | 622 | } |
| 623 | 623 | } |
| 624 | 624 | |
| 625 | - /** |
|
| 626 | - * Check a value from a shortcode to see if true or false. |
|
| 627 | - * True when value is 1, true, 'true', 'yes' |
|
| 628 | - * |
|
| 629 | - * @since 1.07.10 |
|
| 630 | - * |
|
| 631 | - * @param string $value The value to compare |
|
| 632 | - * @return boolean True or False |
|
| 633 | - */ |
|
| 625 | + /** |
|
| 626 | + * Check a value from a shortcode to see if true or false. |
|
| 627 | + * True when value is 1, true, 'true', 'yes' |
|
| 628 | + * |
|
| 629 | + * @since 1.07.10 |
|
| 630 | + * |
|
| 631 | + * @param string $value The value to compare |
|
| 632 | + * @return boolean True or False |
|
| 633 | + */ |
|
| 634 | 634 | public static function is_true( $value ) { |
| 635 | - return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value ); |
|
| 636 | - } |
|
| 635 | + return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value ); |
|
| 636 | + } |
|
| 637 | 637 | |
| 638 | - /** |
|
| 639 | - * Used to filter shortcode in text widgets |
|
| 640 | - */ |
|
| 641 | - public static function widget_text_filter_callback( $matches ) { |
|
| 638 | + /** |
|
| 639 | + * Used to filter shortcode in text widgets |
|
| 640 | + */ |
|
| 641 | + public static function widget_text_filter_callback( $matches ) { |
|
| 642 | 642 | _deprecated_function( __METHOD__, '2.5.4' ); |
| 643 | - return do_shortcode( $matches[0] ); |
|
| 644 | - } |
|
| 643 | + return do_shortcode( $matches[0] ); |
|
| 644 | + } |
|
| 645 | 645 | |
| 646 | - public static function get_pages() { |
|
| 646 | + public static function get_pages() { |
|
| 647 | 647 | return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' ) ); |
| 648 | - } |
|
| 648 | + } |
|
| 649 | 649 | |
| 650 | - public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
|
| 651 | - $pages = self::get_pages(); |
|
| 650 | + public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
|
| 651 | + $pages = self::get_pages(); |
|
| 652 | 652 | $selected = self::get_post_param( $field_name, $page_id, 'absint' ); |
| 653 | - ?> |
|
| 653 | + ?> |
|
| 654 | 654 | <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown"> |
| 655 | 655 | <option value=""> </option> |
| 656 | 656 | <?php foreach ( $pages as $page ) { ?> |
@@ -660,108 +660,108 @@ discard block |
||
| 660 | 660 | <?php } ?> |
| 661 | 661 | </select> |
| 662 | 662 | <?php |
| 663 | - } |
|
| 663 | + } |
|
| 664 | 664 | |
| 665 | 665 | public static function post_edit_link( $post_id ) { |
| 666 | - $post = get_post($post_id); |
|
| 667 | - if ( $post ) { |
|
| 666 | + $post = get_post($post_id); |
|
| 667 | + if ( $post ) { |
|
| 668 | 668 | $post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' ); |
| 669 | 669 | return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>'; |
| 670 | - } |
|
| 671 | - return ''; |
|
| 672 | - } |
|
| 670 | + } |
|
| 671 | + return ''; |
|
| 672 | + } |
|
| 673 | 673 | |
| 674 | 674 | public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) { |
| 675 | - ?> |
|
| 675 | + ?> |
|
| 676 | 676 | <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" <?php |
| 677 | - echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : ''; |
|
| 678 | - ?> class="frm_multiselect"> |
|
| 677 | + echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : ''; |
|
| 678 | + ?> class="frm_multiselect"> |
|
| 679 | 679 | <?php self::roles_options($capability); ?> |
| 680 | 680 | </select> |
| 681 | 681 | <?php |
| 682 | - } |
|
| 682 | + } |
|
| 683 | 683 | |
| 684 | 684 | public static function roles_options( $capability ) { |
| 685 | - global $frm_vars; |
|
| 686 | - if ( isset($frm_vars['editable_roles']) ) { |
|
| 687 | - $editable_roles = $frm_vars['editable_roles']; |
|
| 688 | - } else { |
|
| 689 | - $editable_roles = get_editable_roles(); |
|
| 690 | - $frm_vars['editable_roles'] = $editable_roles; |
|
| 691 | - } |
|
| 692 | - |
|
| 693 | - foreach ( $editable_roles as $role => $details ) { |
|
| 694 | - $name = translate_user_role($details['name'] ); ?> |
|
| 685 | + global $frm_vars; |
|
| 686 | + if ( isset($frm_vars['editable_roles']) ) { |
|
| 687 | + $editable_roles = $frm_vars['editable_roles']; |
|
| 688 | + } else { |
|
| 689 | + $editable_roles = get_editable_roles(); |
|
| 690 | + $frm_vars['editable_roles'] = $editable_roles; |
|
| 691 | + } |
|
| 692 | + |
|
| 693 | + foreach ( $editable_roles as $role => $details ) { |
|
| 694 | + $name = translate_user_role($details['name'] ); ?> |
|
| 695 | 695 | <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option> |
| 696 | 696 | <?php |
| 697 | - unset($role, $details); |
|
| 698 | - } |
|
| 699 | - } |
|
| 697 | + unset($role, $details); |
|
| 698 | + } |
|
| 699 | + } |
|
| 700 | 700 | |
| 701 | 701 | public static function frm_capabilities( $type = 'auto' ) { |
| 702 | - $cap = array( |
|
| 703 | - 'frm_view_forms' => __( 'View Forms and Templates', 'formidable' ), |
|
| 704 | - 'frm_edit_forms' => __( 'Add/Edit Forms and Templates', 'formidable' ), |
|
| 705 | - 'frm_delete_forms' => __( 'Delete Forms and Templates', 'formidable' ), |
|
| 706 | - 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ), |
|
| 707 | - 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ), |
|
| 708 | - 'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ), |
|
| 709 | - ); |
|
| 702 | + $cap = array( |
|
| 703 | + 'frm_view_forms' => __( 'View Forms and Templates', 'formidable' ), |
|
| 704 | + 'frm_edit_forms' => __( 'Add/Edit Forms and Templates', 'formidable' ), |
|
| 705 | + 'frm_delete_forms' => __( 'Delete Forms and Templates', 'formidable' ), |
|
| 706 | + 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ), |
|
| 707 | + 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ), |
|
| 708 | + 'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ), |
|
| 709 | + ); |
|
| 710 | 710 | |
| 711 | 711 | if ( ! self::pro_is_installed() && 'pro' != $type ) { |
| 712 | - return $cap; |
|
| 713 | - } |
|
| 712 | + return $cap; |
|
| 713 | + } |
|
| 714 | 714 | |
| 715 | - $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' ); |
|
| 716 | - $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' ); |
|
| 717 | - $cap['frm_view_reports'] = __( 'View Reports', 'formidable' ); |
|
| 718 | - $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' ); |
|
| 715 | + $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' ); |
|
| 716 | + $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' ); |
|
| 717 | + $cap['frm_view_reports'] = __( 'View Reports', 'formidable' ); |
|
| 718 | + $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' ); |
|
| 719 | 719 | |
| 720 | - return $cap; |
|
| 721 | - } |
|
| 720 | + return $cap; |
|
| 721 | + } |
|
| 722 | 722 | |
| 723 | 723 | public static function user_has_permission( $needed_role ) { |
| 724 | - if ( $needed_role == '-1' ) { |
|
| 725 | - return false; |
|
| 724 | + if ( $needed_role == '-1' ) { |
|
| 725 | + return false; |
|
| 726 | 726 | } |
| 727 | 727 | |
| 728 | - // $needed_role will be equal to blank if "Logged-in users" is selected |
|
| 729 | - if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) { |
|
| 730 | - return true; |
|
| 731 | - } |
|
| 728 | + // $needed_role will be equal to blank if "Logged-in users" is selected |
|
| 729 | + if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) { |
|
| 730 | + return true; |
|
| 731 | + } |
|
| 732 | 732 | |
| 733 | - $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ); |
|
| 734 | - foreach ( $roles as $role ) { |
|
| 733 | + $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ); |
|
| 734 | + foreach ( $roles as $role ) { |
|
| 735 | 735 | if ( current_user_can( $role ) ) { |
| 736 | - return true; |
|
| 736 | + return true; |
|
| 737 | 737 | } |
| 738 | - if ( $role == $needed_role ) { |
|
| 739 | - break; |
|
| 738 | + if ( $role == $needed_role ) { |
|
| 739 | + break; |
|
| 740 | 740 | } |
| 741 | - } |
|
| 742 | - return false; |
|
| 743 | - } |
|
| 744 | - |
|
| 745 | - /** |
|
| 746 | - * Make sure administrators can see Formidable menu |
|
| 747 | - * |
|
| 748 | - * @since 2.0 |
|
| 749 | - */ |
|
| 750 | - public static function maybe_add_permissions() { |
|
| 741 | + } |
|
| 742 | + return false; |
|
| 743 | + } |
|
| 744 | + |
|
| 745 | + /** |
|
| 746 | + * Make sure administrators can see Formidable menu |
|
| 747 | + * |
|
| 748 | + * @since 2.0 |
|
| 749 | + */ |
|
| 750 | + public static function maybe_add_permissions() { |
|
| 751 | 751 | self::force_capability( 'frm_view_entries' ); |
| 752 | 752 | |
| 753 | - if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) { |
|
| 754 | - return; |
|
| 755 | - } |
|
| 753 | + if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) { |
|
| 754 | + return; |
|
| 755 | + } |
|
| 756 | 756 | |
| 757 | 757 | $user_id = get_current_user_id(); |
| 758 | 758 | $user = new WP_User( $user_id ); |
| 759 | - $frm_roles = self::frm_capabilities(); |
|
| 760 | - foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 759 | + $frm_roles = self::frm_capabilities(); |
|
| 760 | + foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 761 | 761 | $user->add_cap( $frm_role ); |
| 762 | - unset($frm_role, $frm_role_description); |
|
| 763 | - } |
|
| 764 | - } |
|
| 762 | + unset($frm_role, $frm_role_description); |
|
| 763 | + } |
|
| 764 | + } |
|
| 765 | 765 | |
| 766 | 766 | /** |
| 767 | 767 | * Make sure admins have permission to see the menu items |
@@ -777,28 +777,28 @@ discard block |
||
| 777 | 777 | } |
| 778 | 778 | } |
| 779 | 779 | |
| 780 | - /** |
|
| 781 | - * Check if the user has permision for action. |
|
| 782 | - * Return permission message and stop the action if no permission |
|
| 783 | - * @since 2.0 |
|
| 784 | - * @param string $permission |
|
| 785 | - */ |
|
| 780 | + /** |
|
| 781 | + * Check if the user has permision for action. |
|
| 782 | + * Return permission message and stop the action if no permission |
|
| 783 | + * @since 2.0 |
|
| 784 | + * @param string $permission |
|
| 785 | + */ |
|
| 786 | 786 | public static function permission_check( $permission, $show_message = 'show' ) { |
| 787 | - $permission_error = self::permission_nonce_error($permission); |
|
| 788 | - if ( $permission_error !== false ) { |
|
| 789 | - if ( 'hide' == $show_message ) { |
|
| 790 | - $permission_error = ''; |
|
| 791 | - } |
|
| 792 | - wp_die($permission_error); |
|
| 793 | - } |
|
| 794 | - } |
|
| 795 | - |
|
| 796 | - /** |
|
| 797 | - * Check user permission and nonce |
|
| 798 | - * @since 2.0 |
|
| 799 | - * @param string $permission |
|
| 800 | - * @return false|string The permission message or false if allowed |
|
| 801 | - */ |
|
| 787 | + $permission_error = self::permission_nonce_error($permission); |
|
| 788 | + if ( $permission_error !== false ) { |
|
| 789 | + if ( 'hide' == $show_message ) { |
|
| 790 | + $permission_error = ''; |
|
| 791 | + } |
|
| 792 | + wp_die($permission_error); |
|
| 793 | + } |
|
| 794 | + } |
|
| 795 | + |
|
| 796 | + /** |
|
| 797 | + * Check user permission and nonce |
|
| 798 | + * @since 2.0 |
|
| 799 | + * @param string $permission |
|
| 800 | + * @return false|string The permission message or false if allowed |
|
| 801 | + */ |
|
| 802 | 802 | public static function permission_nonce_error( $permission, $nonce_name = '', $nonce = '' ) { |
| 803 | 803 | if ( ! empty( $permission ) && ! current_user_can( $permission ) && ! current_user_can( 'administrator' ) ) { |
| 804 | 804 | $frm_settings = self::get_settings(); |
@@ -806,23 +806,23 @@ discard block |
||
| 806 | 806 | } |
| 807 | 807 | |
| 808 | 808 | $error = false; |
| 809 | - if ( empty($nonce_name) ) { |
|
| 810 | - return $error; |
|
| 811 | - } |
|
| 809 | + if ( empty($nonce_name) ) { |
|
| 810 | + return $error; |
|
| 811 | + } |
|
| 812 | 812 | |
| 813 | - if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
| 814 | - $frm_settings = self::get_settings(); |
|
| 815 | - $error = $frm_settings->admin_permission; |
|
| 816 | - } |
|
| 813 | + if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
| 814 | + $frm_settings = self::get_settings(); |
|
| 815 | + $error = $frm_settings->admin_permission; |
|
| 816 | + } |
|
| 817 | 817 | |
| 818 | - return $error; |
|
| 819 | - } |
|
| 818 | + return $error; |
|
| 819 | + } |
|
| 820 | 820 | |
| 821 | - public static function checked( $values, $current ) { |
|
| 821 | + public static function checked( $values, $current ) { |
|
| 822 | 822 | if ( self::check_selected( $values, $current ) ) { |
| 823 | - echo ' checked="checked"'; |
|
| 823 | + echo ' checked="checked"'; |
|
| 824 | 824 | } |
| 825 | - } |
|
| 825 | + } |
|
| 826 | 826 | |
| 827 | 827 | public static function check_selected( $values, $current ) { |
| 828 | 828 | $values = self::recursive_function_map( $values, 'trim' ); |
@@ -832,50 +832,50 @@ discard block |
||
| 832 | 832 | return ( is_array( $values ) && in_array( $current, $values ) ) || ( ! is_array( $values ) && $values == $current ); |
| 833 | 833 | } |
| 834 | 834 | |
| 835 | - /** |
|
| 836 | - * Check if current field option is an "other" option |
|
| 837 | - * |
|
| 838 | - * @since 2.0 |
|
| 839 | - * |
|
| 840 | - * @param string $opt_key |
|
| 841 | - * @return boolean Returns true if current field option is an "Other" option |
|
| 842 | - */ |
|
| 843 | - public static function is_other_opt( $opt_key ) { |
|
| 844 | - _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::is_other_opt' ); |
|
| 845 | - return FrmFieldsHelper::is_other_opt( $opt_key ); |
|
| 846 | - } |
|
| 847 | - |
|
| 848 | - /** |
|
| 849 | - * Get value that belongs in "Other" text box |
|
| 850 | - * |
|
| 851 | - * @since 2.0 |
|
| 852 | - * |
|
| 853 | - * @param string $opt_key |
|
| 854 | - * @param array $field |
|
| 855 | - * @return string $other_val |
|
| 856 | - */ |
|
| 857 | - public static function get_other_val( $opt_key, $field, $parent = false, $pointer = false ) { |
|
| 835 | + /** |
|
| 836 | + * Check if current field option is an "other" option |
|
| 837 | + * |
|
| 838 | + * @since 2.0 |
|
| 839 | + * |
|
| 840 | + * @param string $opt_key |
|
| 841 | + * @return boolean Returns true if current field option is an "Other" option |
|
| 842 | + */ |
|
| 843 | + public static function is_other_opt( $opt_key ) { |
|
| 844 | + _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::is_other_opt' ); |
|
| 845 | + return FrmFieldsHelper::is_other_opt( $opt_key ); |
|
| 846 | + } |
|
| 847 | + |
|
| 848 | + /** |
|
| 849 | + * Get value that belongs in "Other" text box |
|
| 850 | + * |
|
| 851 | + * @since 2.0 |
|
| 852 | + * |
|
| 853 | + * @param string $opt_key |
|
| 854 | + * @param array $field |
|
| 855 | + * @return string $other_val |
|
| 856 | + */ |
|
| 857 | + public static function get_other_val( $opt_key, $field, $parent = false, $pointer = false ) { |
|
| 858 | 858 | _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::get_other_val' ); |
| 859 | 859 | return FrmFieldsHelper::get_other_val( compact( 'opt_key', 'field', 'parent', 'pointer' ) ); |
| 860 | - } |
|
| 861 | - |
|
| 862 | - /** |
|
| 863 | - * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val. |
|
| 864 | - * Intended for front-end use |
|
| 865 | - * |
|
| 866 | - * @since 2.0 |
|
| 867 | - * |
|
| 868 | - * @param array $field |
|
| 869 | - * @param boolean $other_opt |
|
| 870 | - * @param string $checked |
|
| 871 | - * @param array $args should include opt_key and field name |
|
| 872 | - * @return string $other_val |
|
| 873 | - */ |
|
| 874 | - public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) { |
|
| 860 | + } |
|
| 861 | + |
|
| 862 | + /** |
|
| 863 | + * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val. |
|
| 864 | + * Intended for front-end use |
|
| 865 | + * |
|
| 866 | + * @since 2.0 |
|
| 867 | + * |
|
| 868 | + * @param array $field |
|
| 869 | + * @param boolean $other_opt |
|
| 870 | + * @param string $checked |
|
| 871 | + * @param array $args should include opt_key and field name |
|
| 872 | + * @return string $other_val |
|
| 873 | + */ |
|
| 874 | + public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) { |
|
| 875 | 875 | _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::prepare_other_input' ); |
| 876 | 876 | $args['field'] = $field; |
| 877 | 877 | return FrmFieldsHelper::prepare_other_input( $args, $other_opt, $checked ); |
| 878 | - } |
|
| 878 | + } |
|
| 879 | 879 | |
| 880 | 880 | public static function recursive_function_map( $value, $function ) { |
| 881 | 881 | if ( is_array( $value ) ) { |
@@ -905,24 +905,24 @@ discard block |
||
| 905 | 905 | return (bool) count( array_filter( array_keys( $array ), 'is_string' ) ); |
| 906 | 906 | } |
| 907 | 907 | |
| 908 | - /** |
|
| 909 | - * Flatten a multi-dimensional array |
|
| 910 | - */ |
|
| 908 | + /** |
|
| 909 | + * Flatten a multi-dimensional array |
|
| 910 | + */ |
|
| 911 | 911 | public static function array_flatten( $array, $keys = 'keep' ) { |
| 912 | - $return = array(); |
|
| 913 | - foreach ( $array as $key => $value ) { |
|
| 914 | - if ( is_array($value) ) { |
|
| 912 | + $return = array(); |
|
| 913 | + foreach ( $array as $key => $value ) { |
|
| 914 | + if ( is_array($value) ) { |
|
| 915 | 915 | $return = array_merge( $return, self::array_flatten( $value, $keys ) ); |
| 916 | - } else { |
|
| 916 | + } else { |
|
| 917 | 917 | if ( $keys == 'keep' ) { |
| 918 | 918 | $return[ $key ] = $value; |
| 919 | 919 | } else { |
| 920 | 920 | $return[] = $value; |
| 921 | 921 | } |
| 922 | - } |
|
| 923 | - } |
|
| 924 | - return $return; |
|
| 925 | - } |
|
| 922 | + } |
|
| 923 | + } |
|
| 924 | + return $return; |
|
| 925 | + } |
|
| 926 | 926 | |
| 927 | 927 | public static function esc_textarea( $text, $is_rich_text = false ) { |
| 928 | 928 | $safe_text = str_replace( '"', '"', $text ); |
@@ -933,38 +933,38 @@ discard block |
||
| 933 | 933 | return apply_filters( 'esc_textarea', $safe_text, $text ); |
| 934 | 934 | } |
| 935 | 935 | |
| 936 | - /** |
|
| 937 | - * Add auto paragraphs to text areas |
|
| 938 | - * @since 2.0 |
|
| 939 | - */ |
|
| 936 | + /** |
|
| 937 | + * Add auto paragraphs to text areas |
|
| 938 | + * @since 2.0 |
|
| 939 | + */ |
|
| 940 | 940 | public static function use_wpautop( $content ) { |
| 941 | - if ( apply_filters('frm_use_wpautop', true) ) { |
|
| 942 | - $content = wpautop(str_replace( '<br>', '<br />', $content)); |
|
| 943 | - } |
|
| 944 | - return $content; |
|
| 945 | - } |
|
| 941 | + if ( apply_filters('frm_use_wpautop', true) ) { |
|
| 942 | + $content = wpautop(str_replace( '<br>', '<br />', $content)); |
|
| 943 | + } |
|
| 944 | + return $content; |
|
| 945 | + } |
|
| 946 | 946 | |
| 947 | 947 | public static function replace_quotes( $val ) { |
| 948 | - //Replace double quotes |
|
| 948 | + //Replace double quotes |
|
| 949 | 949 | $val = str_replace( array( '“', '”', '″' ), '"', $val ); |
| 950 | - //Replace single quotes |
|
| 951 | - $val = str_replace( array( '‘', '’', '′', '′', '’', '‘' ), "'", $val ); |
|
| 952 | - return $val; |
|
| 953 | - } |
|
| 954 | - |
|
| 955 | - /** |
|
| 956 | - * @since 2.0 |
|
| 957 | - * @return string The base Google APIS url for the current version of jQuery UI |
|
| 958 | - */ |
|
| 959 | - public static function jquery_ui_base_url() { |
|
| 950 | + //Replace single quotes |
|
| 951 | + $val = str_replace( array( '‘', '’', '′', '′', '’', '‘' ), "'", $val ); |
|
| 952 | + return $val; |
|
| 953 | + } |
|
| 954 | + |
|
| 955 | + /** |
|
| 956 | + * @since 2.0 |
|
| 957 | + * @return string The base Google APIS url for the current version of jQuery UI |
|
| 958 | + */ |
|
| 959 | + public static function jquery_ui_base_url() { |
|
| 960 | 960 | $url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core', '1.11.4' ); |
| 961 | - $url = apply_filters('frm_jquery_ui_base_url', $url); |
|
| 962 | - return $url; |
|
| 963 | - } |
|
| 961 | + $url = apply_filters('frm_jquery_ui_base_url', $url); |
|
| 962 | + return $url; |
|
| 963 | + } |
|
| 964 | 964 | |
| 965 | - /** |
|
| 966 | - * @param string $handle |
|
| 967 | - */ |
|
| 965 | + /** |
|
| 966 | + * @param string $handle |
|
| 967 | + */ |
|
| 968 | 968 | public static function script_version( $handle, $default = 0 ) { |
| 969 | 969 | global $wp_scripts; |
| 970 | 970 | if ( ! $wp_scripts ) { |
@@ -986,241 +986,241 @@ discard block |
||
| 986 | 986 | |
| 987 | 987 | public static function js_redirect( $url ) { |
| 988 | 988 | return '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>'; |
| 989 | - } |
|
| 989 | + } |
|
| 990 | 990 | |
| 991 | 991 | public static function get_user_id_param( $user_id ) { |
| 992 | - if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) { |
|
| 993 | - return $user_id; |
|
| 994 | - } |
|
| 992 | + if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) { |
|
| 993 | + return $user_id; |
|
| 994 | + } |
|
| 995 | 995 | |
| 996 | 996 | if ( $user_id == 'current' ) { |
| 997 | 997 | $user_id = get_current_user_id(); |
| 998 | 998 | } else { |
| 999 | - if ( is_email($user_id) ) { |
|
| 1000 | - $user = get_user_by('email', $user_id); |
|
| 1001 | - } else { |
|
| 1002 | - $user = get_user_by('login', $user_id); |
|
| 1003 | - } |
|
| 999 | + if ( is_email($user_id) ) { |
|
| 1000 | + $user = get_user_by('email', $user_id); |
|
| 1001 | + } else { |
|
| 1002 | + $user = get_user_by('login', $user_id); |
|
| 1003 | + } |
|
| 1004 | 1004 | |
| 1005 | - if ( $user ) { |
|
| 1006 | - $user_id = $user->ID; |
|
| 1007 | - } |
|
| 1008 | - unset($user); |
|
| 1009 | - } |
|
| 1005 | + if ( $user ) { |
|
| 1006 | + $user_id = $user->ID; |
|
| 1007 | + } |
|
| 1008 | + unset($user); |
|
| 1009 | + } |
|
| 1010 | 1010 | |
| 1011 | - return $user_id; |
|
| 1012 | - } |
|
| 1011 | + return $user_id; |
|
| 1012 | + } |
|
| 1013 | 1013 | |
| 1014 | 1014 | public static function get_file_contents( $filename, $atts = array() ) { |
| 1015 | - if ( ! is_file($filename) ) { |
|
| 1016 | - return false; |
|
| 1017 | - } |
|
| 1018 | - |
|
| 1019 | - extract($atts); |
|
| 1020 | - ob_start(); |
|
| 1021 | - include($filename); |
|
| 1022 | - $contents = ob_get_contents(); |
|
| 1023 | - ob_end_clean(); |
|
| 1024 | - return $contents; |
|
| 1025 | - } |
|
| 1026 | - |
|
| 1027 | - /** |
|
| 1028 | - * @param string $table_name |
|
| 1029 | - * @param string $column |
|
| 1015 | + if ( ! is_file($filename) ) { |
|
| 1016 | + return false; |
|
| 1017 | + } |
|
| 1018 | + |
|
| 1019 | + extract($atts); |
|
| 1020 | + ob_start(); |
|
| 1021 | + include($filename); |
|
| 1022 | + $contents = ob_get_contents(); |
|
| 1023 | + ob_end_clean(); |
|
| 1024 | + return $contents; |
|
| 1025 | + } |
|
| 1026 | + |
|
| 1027 | + /** |
|
| 1028 | + * @param string $table_name |
|
| 1029 | + * @param string $column |
|
| 1030 | 1030 | * @param int $id |
| 1031 | 1031 | * @param int $num_chars |
| 1032 | - */ |
|
| 1033 | - public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) { |
|
| 1034 | - $key = ''; |
|
| 1032 | + */ |
|
| 1033 | + public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) { |
|
| 1034 | + $key = ''; |
|
| 1035 | 1035 | |
| 1036 | - if ( ! empty( $name ) ) { |
|
| 1037 | - $key = sanitize_key($name); |
|
| 1038 | - } |
|
| 1036 | + if ( ! empty( $name ) ) { |
|
| 1037 | + $key = sanitize_key($name); |
|
| 1038 | + } |
|
| 1039 | 1039 | |
| 1040 | 1040 | if ( empty( $key ) ) { |
| 1041 | - $max_slug_value = pow(36, $num_chars); |
|
| 1042 | - $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
| 1043 | - $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
| 1044 | - } |
|
| 1041 | + $max_slug_value = pow(36, $num_chars); |
|
| 1042 | + $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
| 1043 | + $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
| 1044 | + } |
|
| 1045 | 1045 | |
| 1046 | 1046 | if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) { |
| 1047 | 1047 | $key = $key . 'a'; |
| 1048 | - } |
|
| 1048 | + } |
|
| 1049 | 1049 | |
| 1050 | 1050 | $key_check = FrmDb::get_var( $table_name, array( $column => $key, 'ID !' => $id ), $column ); |
| 1051 | 1051 | |
| 1052 | - if ( $key_check || is_numeric($key_check) ) { |
|
| 1053 | - $suffix = 2; |
|
| 1052 | + if ( $key_check || is_numeric($key_check) ) { |
|
| 1053 | + $suffix = 2; |
|
| 1054 | 1054 | do { |
| 1055 | 1055 | $alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix; |
| 1056 | 1056 | $key_check = FrmDb::get_var( $table_name, array( $column => $alt_post_name, 'ID !' => $id ), $column ); |
| 1057 | 1057 | $suffix++; |
| 1058 | 1058 | } while ( $key_check || is_numeric( $key_check ) ); |
| 1059 | 1059 | $key = $alt_post_name; |
| 1060 | - } |
|
| 1061 | - return $key; |
|
| 1062 | - } |
|
| 1063 | - |
|
| 1064 | - /** |
|
| 1065 | - * Editing a Form or Entry |
|
| 1066 | - * @param string $table |
|
| 1067 | - * @return bool|array |
|
| 1068 | - */ |
|
| 1069 | - public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) { |
|
| 1070 | - if ( ! $record ) { |
|
| 1071 | - return false; |
|
| 1072 | - } |
|
| 1073 | - |
|
| 1074 | - if ( empty($post_values) ) { |
|
| 1075 | - $post_values = stripslashes_deep($_POST); |
|
| 1076 | - } |
|
| 1060 | + } |
|
| 1061 | + return $key; |
|
| 1062 | + } |
|
| 1063 | + |
|
| 1064 | + /** |
|
| 1065 | + * Editing a Form or Entry |
|
| 1066 | + * @param string $table |
|
| 1067 | + * @return bool|array |
|
| 1068 | + */ |
|
| 1069 | + public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) { |
|
| 1070 | + if ( ! $record ) { |
|
| 1071 | + return false; |
|
| 1072 | + } |
|
| 1073 | + |
|
| 1074 | + if ( empty($post_values) ) { |
|
| 1075 | + $post_values = stripslashes_deep($_POST); |
|
| 1076 | + } |
|
| 1077 | 1077 | |
| 1078 | 1078 | $values = array( 'id' => $record->id, 'fields' => array() ); |
| 1079 | 1079 | |
| 1080 | 1080 | foreach ( array( 'name', 'description' ) as $var ) { |
| 1081 | - $default_val = isset($record->{$var}) ? $record->{$var} : ''; |
|
| 1081 | + $default_val = isset($record->{$var}) ? $record->{$var} : ''; |
|
| 1082 | 1082 | $values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' ); |
| 1083 | - unset($var, $default_val); |
|
| 1084 | - } |
|
| 1085 | - |
|
| 1086 | - $values['description'] = self::use_wpautop($values['description']); |
|
| 1087 | - $frm_settings = self::get_settings(); |
|
| 1088 | - $is_form_builder = self::is_admin_page('formidable' ); |
|
| 1089 | - |
|
| 1090 | - foreach ( (array) $fields as $field ) { |
|
| 1091 | - // Make sure to filter default values (for placeholder text), but not on the form builder page |
|
| 1092 | - if ( ! $is_form_builder ) { |
|
| 1093 | - $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true ); |
|
| 1094 | - } |
|
| 1083 | + unset($var, $default_val); |
|
| 1084 | + } |
|
| 1085 | + |
|
| 1086 | + $values['description'] = self::use_wpautop($values['description']); |
|
| 1087 | + $frm_settings = self::get_settings(); |
|
| 1088 | + $is_form_builder = self::is_admin_page('formidable' ); |
|
| 1089 | + |
|
| 1090 | + foreach ( (array) $fields as $field ) { |
|
| 1091 | + // Make sure to filter default values (for placeholder text), but not on the form builder page |
|
| 1092 | + if ( ! $is_form_builder ) { |
|
| 1093 | + $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true ); |
|
| 1094 | + } |
|
| 1095 | 1095 | $parent_form_id = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id; |
| 1096 | 1096 | self::fill_field_defaults($field, $record, $values, compact('default', 'post_values', 'frm_settings', 'parent_form_id' ) ); |
| 1097 | - } |
|
| 1097 | + } |
|
| 1098 | 1098 | |
| 1099 | - self::fill_form_opts($record, $table, $post_values, $values); |
|
| 1099 | + self::fill_form_opts($record, $table, $post_values, $values); |
|
| 1100 | 1100 | |
| 1101 | - if ( $table == 'entries' ) { |
|
| 1102 | - $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
|
| 1103 | - } else if ( $table == 'forms' ) { |
|
| 1104 | - $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values ); |
|
| 1105 | - } |
|
| 1101 | + if ( $table == 'entries' ) { |
|
| 1102 | + $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
|
| 1103 | + } else if ( $table == 'forms' ) { |
|
| 1104 | + $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values ); |
|
| 1105 | + } |
|
| 1106 | 1106 | |
| 1107 | - return $values; |
|
| 1108 | - } |
|
| 1107 | + return $values; |
|
| 1108 | + } |
|
| 1109 | 1109 | |
| 1110 | 1110 | private static function fill_field_defaults( $field, $record, array &$values, $args ) { |
| 1111 | - $post_values = $args['post_values']; |
|
| 1112 | - |
|
| 1113 | - if ( $args['default'] ) { |
|
| 1114 | - $meta_value = $field->default_value; |
|
| 1115 | - } else { |
|
| 1116 | - if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) { |
|
| 1117 | - if ( ! isset($field->field_options['custom_field']) ) { |
|
| 1118 | - $field->field_options['custom_field'] = ''; |
|
| 1119 | - } |
|
| 1111 | + $post_values = $args['post_values']; |
|
| 1112 | + |
|
| 1113 | + if ( $args['default'] ) { |
|
| 1114 | + $meta_value = $field->default_value; |
|
| 1115 | + } else { |
|
| 1116 | + if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) { |
|
| 1117 | + if ( ! isset($field->field_options['custom_field']) ) { |
|
| 1118 | + $field->field_options['custom_field'] = ''; |
|
| 1119 | + } |
|
| 1120 | 1120 | $meta_value = FrmProEntryMetaHelper::get_post_value( $record->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array( 'truncate' => false, 'type' => $field->type, 'form_id' => $field->form_id, 'field' => $field ) ); |
| 1121 | - } else { |
|
| 1121 | + } else { |
|
| 1122 | 1122 | $meta_value = FrmEntryMeta::get_meta_value( $record, $field->id ); |
| 1123 | - } |
|
| 1124 | - } |
|
| 1123 | + } |
|
| 1124 | + } |
|
| 1125 | 1125 | |
| 1126 | 1126 | $field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type; |
| 1127 | - $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
| 1128 | - |
|
| 1129 | - $field_array = array( |
|
| 1130 | - 'id' => $field->id, |
|
| 1131 | - 'value' => $new_value, |
|
| 1132 | - 'default_value' => $field->default_value, |
|
| 1133 | - 'name' => $field->name, |
|
| 1134 | - 'description' => $field->description, |
|
| 1135 | - 'type' => apply_filters('frm_field_type', $field_type, $field, $new_value), |
|
| 1136 | - 'options' => $field->options, |
|
| 1137 | - 'required' => $field->required, |
|
| 1138 | - 'field_key' => $field->field_key, |
|
| 1139 | - 'field_order' => $field->field_order, |
|
| 1140 | - 'form_id' => $field->form_id, |
|
| 1127 | + $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
| 1128 | + |
|
| 1129 | + $field_array = array( |
|
| 1130 | + 'id' => $field->id, |
|
| 1131 | + 'value' => $new_value, |
|
| 1132 | + 'default_value' => $field->default_value, |
|
| 1133 | + 'name' => $field->name, |
|
| 1134 | + 'description' => $field->description, |
|
| 1135 | + 'type' => apply_filters('frm_field_type', $field_type, $field, $new_value), |
|
| 1136 | + 'options' => $field->options, |
|
| 1137 | + 'required' => $field->required, |
|
| 1138 | + 'field_key' => $field->field_key, |
|
| 1139 | + 'field_order' => $field->field_order, |
|
| 1140 | + 'form_id' => $field->form_id, |
|
| 1141 | 1141 | 'parent_form_id' => $args['parent_form_id'], |
| 1142 | - ); |
|
| 1142 | + ); |
|
| 1143 | 1143 | |
| 1144 | - $args['field_type'] = $field_type; |
|
| 1145 | - self::fill_field_opts($field, $field_array, $args); |
|
| 1144 | + $args['field_type'] = $field_type; |
|
| 1145 | + self::fill_field_opts($field, $field_array, $args); |
|
| 1146 | 1146 | // Track the original field's type |
| 1147 | 1147 | $field_array['original_type'] = isset( $field->field_options['original_type'] ) ? $field->field_options['original_type'] : $field->type; |
| 1148 | 1148 | |
| 1149 | - $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() ); |
|
| 1149 | + $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() ); |
|
| 1150 | 1150 | |
| 1151 | - if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) { |
|
| 1152 | - $field_array['unique_msg'] = ''; |
|
| 1153 | - } |
|
| 1151 | + if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) { |
|
| 1152 | + $field_array['unique_msg'] = ''; |
|
| 1153 | + } |
|
| 1154 | 1154 | |
| 1155 | - $field_array = array_merge( $field->field_options, $field_array ); |
|
| 1155 | + $field_array = array_merge( $field->field_options, $field_array ); |
|
| 1156 | 1156 | |
| 1157 | - $values['fields'][ $field->id ] = $field_array; |
|
| 1158 | - } |
|
| 1157 | + $values['fields'][ $field->id ] = $field_array; |
|
| 1158 | + } |
|
| 1159 | 1159 | |
| 1160 | 1160 | private static function fill_field_opts( $field, array &$field_array, $args ) { |
| 1161 | - $post_values = $args['post_values']; |
|
| 1162 | - $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); |
|
| 1161 | + $post_values = $args['post_values']; |
|
| 1162 | + $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); |
|
| 1163 | 1163 | |
| 1164 | - foreach ( $opt_defaults as $opt => $default_opt ) { |
|
| 1164 | + foreach ( $opt_defaults as $opt => $default_opt ) { |
|
| 1165 | 1165 | $field_array[ $opt ] = ( $post_values && isset( $post_values['field_options'][ $opt . '_' . $field->id ] ) ) ? maybe_unserialize( $post_values['field_options'][ $opt . '_' . $field->id ] ) : ( isset( $field->field_options[ $opt ] ) ? $field->field_options[ $opt ] : $default_opt ); |
| 1166 | - if ( $opt == 'blank' && $field_array[ $opt ] == '' ) { |
|
| 1167 | - $field_array[ $opt ] = $args['frm_settings']->blank_msg; |
|
| 1168 | - } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) { |
|
| 1169 | - if ( $args['field_type'] == 'captcha' ) { |
|
| 1170 | - $field_array[ $opt ] = $args['frm_settings']->re_msg; |
|
| 1171 | - } else { |
|
| 1172 | - $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] ); |
|
| 1173 | - } |
|
| 1174 | - } |
|
| 1175 | - } |
|
| 1176 | - |
|
| 1177 | - if ( $field_array['custom_html'] == '' ) { |
|
| 1178 | - $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']); |
|
| 1179 | - } |
|
| 1180 | - } |
|
| 1181 | - |
|
| 1182 | - /** |
|
| 1183 | - * @param string $table |
|
| 1184 | - */ |
|
| 1166 | + if ( $opt == 'blank' && $field_array[ $opt ] == '' ) { |
|
| 1167 | + $field_array[ $opt ] = $args['frm_settings']->blank_msg; |
|
| 1168 | + } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) { |
|
| 1169 | + if ( $args['field_type'] == 'captcha' ) { |
|
| 1170 | + $field_array[ $opt ] = $args['frm_settings']->re_msg; |
|
| 1171 | + } else { |
|
| 1172 | + $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] ); |
|
| 1173 | + } |
|
| 1174 | + } |
|
| 1175 | + } |
|
| 1176 | + |
|
| 1177 | + if ( $field_array['custom_html'] == '' ) { |
|
| 1178 | + $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']); |
|
| 1179 | + } |
|
| 1180 | + } |
|
| 1181 | + |
|
| 1182 | + /** |
|
| 1183 | + * @param string $table |
|
| 1184 | + */ |
|
| 1185 | 1185 | private static function fill_form_opts( $record, $table, $post_values, array &$values ) { |
| 1186 | - if ( $table == 'entries' ) { |
|
| 1187 | - $form = $record->form_id; |
|
| 1186 | + if ( $table == 'entries' ) { |
|
| 1187 | + $form = $record->form_id; |
|
| 1188 | 1188 | FrmForm::maybe_get_form( $form ); |
| 1189 | - } else { |
|
| 1190 | - $form = $record; |
|
| 1191 | - } |
|
| 1189 | + } else { |
|
| 1190 | + $form = $record; |
|
| 1191 | + } |
|
| 1192 | 1192 | |
| 1193 | - if ( ! $form ) { |
|
| 1194 | - return; |
|
| 1195 | - } |
|
| 1193 | + if ( ! $form ) { |
|
| 1194 | + return; |
|
| 1195 | + } |
|
| 1196 | 1196 | |
| 1197 | - $values['form_name'] = isset($record->form_id) ? $form->name : ''; |
|
| 1197 | + $values['form_name'] = isset($record->form_id) ? $form->name : ''; |
|
| 1198 | 1198 | $values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0; |
| 1199 | 1199 | |
| 1200 | - if ( ! is_array($form->options) ) { |
|
| 1201 | - return; |
|
| 1202 | - } |
|
| 1200 | + if ( ! is_array($form->options) ) { |
|
| 1201 | + return; |
|
| 1202 | + } |
|
| 1203 | 1203 | |
| 1204 | - foreach ( $form->options as $opt => $value ) { |
|
| 1205 | - $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
| 1206 | - } |
|
| 1204 | + foreach ( $form->options as $opt => $value ) { |
|
| 1205 | + $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
| 1206 | + } |
|
| 1207 | 1207 | |
| 1208 | - self::fill_form_defaults($post_values, $values); |
|
| 1209 | - } |
|
| 1208 | + self::fill_form_defaults($post_values, $values); |
|
| 1209 | + } |
|
| 1210 | 1210 | |
| 1211 | - /** |
|
| 1212 | - * Set to POST value or default |
|
| 1213 | - */ |
|
| 1211 | + /** |
|
| 1212 | + * Set to POST value or default |
|
| 1213 | + */ |
|
| 1214 | 1214 | private static function fill_form_defaults( $post_values, array &$values ) { |
| 1215 | - $form_defaults = FrmFormsHelper::get_default_opts(); |
|
| 1215 | + $form_defaults = FrmFormsHelper::get_default_opts(); |
|
| 1216 | 1216 | |
| 1217 | - foreach ( $form_defaults as $opt => $default ) { |
|
| 1218 | - if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
| 1217 | + foreach ( $form_defaults as $opt => $default ) { |
|
| 1218 | + if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
| 1219 | 1219 | $values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default; |
| 1220 | - } |
|
| 1220 | + } |
|
| 1221 | 1221 | |
| 1222 | - unset($opt, $defaut); |
|
| 1223 | - } |
|
| 1222 | + unset($opt, $defaut); |
|
| 1223 | + } |
|
| 1224 | 1224 | |
| 1225 | 1225 | if ( ! isset( $values['custom_style'] ) ) { |
| 1226 | 1226 | $values['custom_style'] = self::custom_style_value( $post_values ); |
@@ -1229,10 +1229,10 @@ discard block |
||
| 1229 | 1229 | foreach ( array( 'before', 'after', 'submit' ) as $h ) { |
| 1230 | 1230 | if ( ! isset( $values[ $h . '_html' ] ) ) { |
| 1231 | 1231 | $values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) ); |
| 1232 | - } |
|
| 1233 | - unset($h); |
|
| 1234 | - } |
|
| 1235 | - } |
|
| 1232 | + } |
|
| 1233 | + unset($h); |
|
| 1234 | + } |
|
| 1235 | + } |
|
| 1236 | 1236 | |
| 1237 | 1237 | /** |
| 1238 | 1238 | * @since 2.2.10 |
@@ -1255,59 +1255,59 @@ discard block |
||
| 1255 | 1255 | } |
| 1256 | 1256 | |
| 1257 | 1257 | public static function insert_opt_html( $args ) { |
| 1258 | - $class = ''; |
|
| 1259 | - if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) { |
|
| 1260 | - $class .= 'show_frm_not_email_to'; |
|
| 1261 | - } |
|
| 1262 | - ?> |
|
| 1258 | + $class = ''; |
|
| 1259 | + if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) { |
|
| 1260 | + $class .= 'show_frm_not_email_to'; |
|
| 1261 | + } |
|
| 1262 | + ?> |
|
| 1263 | 1263 | <li> |
| 1264 | 1264 | <a href="javascript:void(0)" class="frmids frm_insert_code alignright <?php echo esc_attr($class) ?>" data-code="<?php echo esc_attr($args['id']) ?>" >[<?php echo esc_attr( $args['id'] ) ?>]</a> |
| 1265 | 1265 | <a href="javascript:void(0)" class="frmkeys frm_insert_code alignright <?php echo esc_attr($class) ?>" data-code="<?php echo esc_attr($args['key']) ?>" >[<?php echo esc_attr( self::truncate($args['key'], 10) ) ?>]</a> |
| 1266 | 1266 | <a href="javascript:void(0)" class="frm_insert_code <?php echo esc_attr( $class ) ?>" data-code="<?php echo esc_attr($args['id']) ?>" ><?php echo esc_attr( self::truncate($args['name'], 60) ) ?></a> |
| 1267 | 1267 | </li> |
| 1268 | 1268 | <?php |
| 1269 | - } |
|
| 1269 | + } |
|
| 1270 | 1270 | |
| 1271 | 1271 | public static function truncate( $str, $length, $minword = 3, $continue = '...' ) { |
| 1272 | - if ( is_array( $str ) ) { |
|
| 1273 | - return ''; |
|
| 1272 | + if ( is_array( $str ) ) { |
|
| 1273 | + return ''; |
|
| 1274 | 1274 | } |
| 1275 | 1275 | |
| 1276 | - $length = (int) $length; |
|
| 1276 | + $length = (int) $length; |
|
| 1277 | 1277 | $str = wp_strip_all_tags( $str ); |
| 1278 | 1278 | $original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) ); |
| 1279 | 1279 | |
| 1280 | 1280 | if ( $length == 0 ) { |
| 1281 | - return ''; |
|
| 1282 | - } else if ( $length <= 10 ) { |
|
| 1281 | + return ''; |
|
| 1282 | + } else if ( $length <= 10 ) { |
|
| 1283 | 1283 | $sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) ); |
| 1284 | - return $sub . (($length < $original_len) ? $continue : ''); |
|
| 1285 | - } |
|
| 1284 | + return $sub . (($length < $original_len) ? $continue : ''); |
|
| 1285 | + } |
|
| 1286 | 1286 | |
| 1287 | - $sub = ''; |
|
| 1288 | - $len = 0; |
|
| 1287 | + $sub = ''; |
|
| 1288 | + $len = 0; |
|
| 1289 | 1289 | |
| 1290 | 1290 | $words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) ); |
| 1291 | 1291 | |
| 1292 | 1292 | foreach ( $words as $word ) { |
| 1293 | - $part = (($sub != '') ? ' ' : '') . $word; |
|
| 1293 | + $part = (($sub != '') ? ' ' : '') . $word; |
|
| 1294 | 1294 | $total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) ); |
| 1295 | - if ( $total_len > $length && str_word_count($sub) ) { |
|
| 1296 | - break; |
|
| 1297 | - } |
|
| 1295 | + if ( $total_len > $length && str_word_count($sub) ) { |
|
| 1296 | + break; |
|
| 1297 | + } |
|
| 1298 | 1298 | |
| 1299 | - $sub .= $part; |
|
| 1299 | + $sub .= $part; |
|
| 1300 | 1300 | $len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) ); |
| 1301 | 1301 | |
| 1302 | - if ( str_word_count($sub) > $minword && $total_len >= $length ) { |
|
| 1303 | - break; |
|
| 1304 | - } |
|
| 1302 | + if ( str_word_count($sub) > $minword && $total_len >= $length ) { |
|
| 1303 | + break; |
|
| 1304 | + } |
|
| 1305 | 1305 | |
| 1306 | - unset($total_len, $word); |
|
| 1307 | - } |
|
| 1306 | + unset($total_len, $word); |
|
| 1307 | + } |
|
| 1308 | 1308 | |
| 1309 | - return $sub . (($len < $original_len) ? $continue : ''); |
|
| 1310 | - } |
|
| 1309 | + return $sub . (($len < $original_len) ? $continue : ''); |
|
| 1310 | + } |
|
| 1311 | 1311 | |
| 1312 | 1312 | public static function mb_function( $function_names, $args ) { |
| 1313 | 1313 | $mb_function_name = $function_names[0]; |
@@ -1319,18 +1319,18 @@ discard block |
||
| 1319 | 1319 | } |
| 1320 | 1320 | |
| 1321 | 1321 | public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) { |
| 1322 | - if ( empty($date) ) { |
|
| 1323 | - return $date; |
|
| 1324 | - } |
|
| 1322 | + if ( empty($date) ) { |
|
| 1323 | + return $date; |
|
| 1324 | + } |
|
| 1325 | 1325 | |
| 1326 | - if ( empty($date_format) ) { |
|
| 1327 | - $date_format = get_option('date_format'); |
|
| 1328 | - } |
|
| 1326 | + if ( empty($date_format) ) { |
|
| 1327 | + $date_format = get_option('date_format'); |
|
| 1328 | + } |
|
| 1329 | 1329 | |
| 1330 | - if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) { |
|
| 1331 | - $frmpro_settings = new FrmProSettings(); |
|
| 1332 | - $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d'); |
|
| 1333 | - } |
|
| 1330 | + if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) { |
|
| 1331 | + $frmpro_settings = new FrmProSettings(); |
|
| 1332 | + $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d'); |
|
| 1333 | + } |
|
| 1334 | 1334 | |
| 1335 | 1335 | $formatted = self::get_localized_date( $date_format, $date ); |
| 1336 | 1336 | |
@@ -1339,8 +1339,8 @@ discard block |
||
| 1339 | 1339 | $formatted .= self::add_time_to_date( $time_format, $date ); |
| 1340 | 1340 | } |
| 1341 | 1341 | |
| 1342 | - return $formatted; |
|
| 1343 | - } |
|
| 1342 | + return $formatted; |
|
| 1343 | + } |
|
| 1344 | 1344 | |
| 1345 | 1345 | private static function add_time_to_date( $time_format, $date ) { |
| 1346 | 1346 | if ( empty( $time_format ) ) { |
@@ -1422,61 +1422,61 @@ discard block |
||
| 1422 | 1422 | ); |
| 1423 | 1423 | } |
| 1424 | 1424 | |
| 1425 | - /** |
|
| 1426 | - * Added for < WP 4.0 compatability |
|
| 1427 | - * |
|
| 1428 | - * @since 1.07.10 |
|
| 1429 | - * |
|
| 1430 | - * @param string $term The value to escape |
|
| 1431 | - * @return string The escaped value |
|
| 1432 | - */ |
|
| 1425 | + /** |
|
| 1426 | + * Added for < WP 4.0 compatability |
|
| 1427 | + * |
|
| 1428 | + * @since 1.07.10 |
|
| 1429 | + * |
|
| 1430 | + * @param string $term The value to escape |
|
| 1431 | + * @return string The escaped value |
|
| 1432 | + */ |
|
| 1433 | 1433 | public static function esc_like( $term ) { |
| 1434 | - global $wpdb; |
|
| 1435 | - if ( method_exists($wpdb, 'esc_like') ) { |
|
| 1434 | + global $wpdb; |
|
| 1435 | + if ( method_exists($wpdb, 'esc_like') ) { |
|
| 1436 | 1436 | // WP 4.0 |
| 1437 | - $term = $wpdb->esc_like( $term ); |
|
| 1438 | - } else { |
|
| 1439 | - $term = like_escape( $term ); |
|
| 1440 | - } |
|
| 1437 | + $term = $wpdb->esc_like( $term ); |
|
| 1438 | + } else { |
|
| 1439 | + $term = like_escape( $term ); |
|
| 1440 | + } |
|
| 1441 | 1441 | |
| 1442 | - return $term; |
|
| 1443 | - } |
|
| 1442 | + return $term; |
|
| 1443 | + } |
|
| 1444 | 1444 | |
| 1445 | - /** |
|
| 1446 | - * @param string $order_query |
|
| 1447 | - */ |
|
| 1445 | + /** |
|
| 1446 | + * @param string $order_query |
|
| 1447 | + */ |
|
| 1448 | 1448 | public static function esc_order( $order_query ) { |
| 1449 | - if ( empty($order_query) ) { |
|
| 1450 | - return ''; |
|
| 1451 | - } |
|
| 1452 | - |
|
| 1453 | - // remove ORDER BY before santizing |
|
| 1454 | - $order_query = strtolower($order_query); |
|
| 1455 | - if ( strpos($order_query, 'order by') !== false ) { |
|
| 1456 | - $order_query = str_replace('order by', '', $order_query); |
|
| 1457 | - } |
|
| 1458 | - |
|
| 1459 | - $order_query = explode(' ', trim($order_query)); |
|
| 1460 | - |
|
| 1461 | - $order_fields = array( |
|
| 1462 | - 'id', 'form_key', 'name', 'description', |
|
| 1463 | - 'parent_form_id', 'logged_in', 'is_template', |
|
| 1464 | - 'default_template', 'status', 'created_at', |
|
| 1465 | - ); |
|
| 1466 | - |
|
| 1467 | - $order = trim(trim(reset($order_query), ',')); |
|
| 1468 | - if ( ! in_array($order, $order_fields) ) { |
|
| 1469 | - return ''; |
|
| 1470 | - } |
|
| 1471 | - |
|
| 1472 | - $order_by = ''; |
|
| 1473 | - if ( count($order_query) > 1 ) { |
|
| 1449 | + if ( empty($order_query) ) { |
|
| 1450 | + return ''; |
|
| 1451 | + } |
|
| 1452 | + |
|
| 1453 | + // remove ORDER BY before santizing |
|
| 1454 | + $order_query = strtolower($order_query); |
|
| 1455 | + if ( strpos($order_query, 'order by') !== false ) { |
|
| 1456 | + $order_query = str_replace('order by', '', $order_query); |
|
| 1457 | + } |
|
| 1458 | + |
|
| 1459 | + $order_query = explode(' ', trim($order_query)); |
|
| 1460 | + |
|
| 1461 | + $order_fields = array( |
|
| 1462 | + 'id', 'form_key', 'name', 'description', |
|
| 1463 | + 'parent_form_id', 'logged_in', 'is_template', |
|
| 1464 | + 'default_template', 'status', 'created_at', |
|
| 1465 | + ); |
|
| 1466 | + |
|
| 1467 | + $order = trim(trim(reset($order_query), ',')); |
|
| 1468 | + if ( ! in_array($order, $order_fields) ) { |
|
| 1469 | + return ''; |
|
| 1470 | + } |
|
| 1471 | + |
|
| 1472 | + $order_by = ''; |
|
| 1473 | + if ( count($order_query) > 1 ) { |
|
| 1474 | 1474 | $order_by = end( $order_query ); |
| 1475 | 1475 | self::esc_order_by( $order_by ); |
| 1476 | - } |
|
| 1476 | + } |
|
| 1477 | 1477 | |
| 1478 | 1478 | return ' ORDER BY ' . $order . ' ' . $order_by; |
| 1479 | - } |
|
| 1479 | + } |
|
| 1480 | 1480 | |
| 1481 | 1481 | /** |
| 1482 | 1482 | * Make sure this is ordering by either ASC or DESC |
@@ -1488,169 +1488,169 @@ discard block |
||
| 1488 | 1488 | } |
| 1489 | 1489 | } |
| 1490 | 1490 | |
| 1491 | - /** |
|
| 1492 | - * @param string $limit |
|
| 1493 | - */ |
|
| 1491 | + /** |
|
| 1492 | + * @param string $limit |
|
| 1493 | + */ |
|
| 1494 | 1494 | public static function esc_limit( $limit ) { |
| 1495 | - if ( empty($limit) ) { |
|
| 1496 | - return ''; |
|
| 1497 | - } |
|
| 1495 | + if ( empty($limit) ) { |
|
| 1496 | + return ''; |
|
| 1497 | + } |
|
| 1498 | 1498 | |
| 1499 | - $limit = trim(str_replace(' limit', '', strtolower($limit))); |
|
| 1500 | - if ( is_numeric($limit) ) { |
|
| 1499 | + $limit = trim(str_replace(' limit', '', strtolower($limit))); |
|
| 1500 | + if ( is_numeric($limit) ) { |
|
| 1501 | 1501 | return ' LIMIT ' . $limit; |
| 1502 | - } |
|
| 1502 | + } |
|
| 1503 | 1503 | |
| 1504 | - $limit = explode(',', trim($limit)); |
|
| 1505 | - foreach ( $limit as $k => $l ) { |
|
| 1506 | - if ( is_numeric( $l ) ) { |
|
| 1507 | - $limit[ $k ] = $l; |
|
| 1508 | - } |
|
| 1509 | - } |
|
| 1504 | + $limit = explode(',', trim($limit)); |
|
| 1505 | + foreach ( $limit as $k => $l ) { |
|
| 1506 | + if ( is_numeric( $l ) ) { |
|
| 1507 | + $limit[ $k ] = $l; |
|
| 1508 | + } |
|
| 1509 | + } |
|
| 1510 | 1510 | |
| 1511 | - $limit = implode(',', $limit); |
|
| 1511 | + $limit = implode(',', $limit); |
|
| 1512 | 1512 | return ' LIMIT ' . $limit; |
| 1513 | - } |
|
| 1514 | - |
|
| 1515 | - /** |
|
| 1516 | - * Get an array of values ready to go through $wpdb->prepare |
|
| 1517 | - * @since 2.0 |
|
| 1518 | - */ |
|
| 1519 | - public static function prepare_array_values( $array, $type = '%s' ) { |
|
| 1520 | - $placeholders = array_fill(0, count($array), $type); |
|
| 1521 | - return implode(', ', $placeholders); |
|
| 1522 | - } |
|
| 1523 | - |
|
| 1524 | - public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) { |
|
| 1525 | - if ( empty($where) ) { |
|
| 1526 | - return ''; |
|
| 1527 | - } |
|
| 1513 | + } |
|
| 1514 | + |
|
| 1515 | + /** |
|
| 1516 | + * Get an array of values ready to go through $wpdb->prepare |
|
| 1517 | + * @since 2.0 |
|
| 1518 | + */ |
|
| 1519 | + public static function prepare_array_values( $array, $type = '%s' ) { |
|
| 1520 | + $placeholders = array_fill(0, count($array), $type); |
|
| 1521 | + return implode(', ', $placeholders); |
|
| 1522 | + } |
|
| 1523 | + |
|
| 1524 | + public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) { |
|
| 1525 | + if ( empty($where) ) { |
|
| 1526 | + return ''; |
|
| 1527 | + } |
|
| 1528 | 1528 | |
| 1529 | 1529 | if ( is_array( $where ) ) { |
| 1530 | - global $wpdb; |
|
| 1531 | - FrmDb::get_where_clause_and_values( $where, $starts_with ); |
|
| 1530 | + global $wpdb; |
|
| 1531 | + FrmDb::get_where_clause_and_values( $where, $starts_with ); |
|
| 1532 | 1532 | $where = $wpdb->prepare( $where['where'], $where['values'] ); |
| 1533 | 1533 | } else { |
| 1534 | - $where = $starts_with . $where; |
|
| 1535 | - } |
|
| 1534 | + $where = $starts_with . $where; |
|
| 1535 | + } |
|
| 1536 | 1536 | |
| 1537 | - return $where; |
|
| 1538 | - } |
|
| 1537 | + return $where; |
|
| 1538 | + } |
|
| 1539 | 1539 | |
| 1540 | - // Pagination Methods |
|
| 1540 | + // Pagination Methods |
|
| 1541 | 1541 | |
| 1542 | - /** |
|
| 1543 | - * @param integer $current_p |
|
| 1544 | - */ |
|
| 1542 | + /** |
|
| 1543 | + * @param integer $current_p |
|
| 1544 | + */ |
|
| 1545 | 1545 | public static function get_last_record_num( $r_count, $current_p, $p_size ) { |
| 1546 | 1546 | return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) ); |
| 1547 | 1547 | } |
| 1548 | 1548 | |
| 1549 | - /** |
|
| 1550 | - * @param integer $current_p |
|
| 1551 | - */ |
|
| 1552 | - public static function get_first_record_num( $r_count, $current_p, $p_size ) { |
|
| 1553 | - if ( $current_p == 1 ) { |
|
| 1554 | - return 1; |
|
| 1555 | - } else { |
|
| 1556 | - return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 ); |
|
| 1557 | - } |
|
| 1558 | - } |
|
| 1549 | + /** |
|
| 1550 | + * @param integer $current_p |
|
| 1551 | + */ |
|
| 1552 | + public static function get_first_record_num( $r_count, $current_p, $p_size ) { |
|
| 1553 | + if ( $current_p == 1 ) { |
|
| 1554 | + return 1; |
|
| 1555 | + } else { |
|
| 1556 | + return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 ); |
|
| 1557 | + } |
|
| 1558 | + } |
|
| 1559 | 1559 | |
| 1560 | 1560 | /** |
| 1561 | 1561 | * @return array |
| 1562 | 1562 | */ |
| 1563 | 1563 | public static function json_to_array( $json_vars ) { |
| 1564 | - $vars = array(); |
|
| 1565 | - foreach ( $json_vars as $jv ) { |
|
| 1566 | - $jv_name = explode('[', $jv['name']); |
|
| 1567 | - $last = count($jv_name) - 1; |
|
| 1568 | - foreach ( $jv_name as $p => $n ) { |
|
| 1569 | - $name = trim($n, ']'); |
|
| 1570 | - if ( ! isset($l1) ) { |
|
| 1571 | - $l1 = $name; |
|
| 1572 | - } |
|
| 1573 | - |
|
| 1574 | - if ( ! isset($l2) ) { |
|
| 1575 | - $l2 = $name; |
|
| 1576 | - } |
|
| 1577 | - |
|
| 1578 | - if ( ! isset($l3) ) { |
|
| 1579 | - $l3 = $name; |
|
| 1580 | - } |
|
| 1581 | - |
|
| 1582 | - $this_val = ( $p == $last ) ? $jv['value'] : array(); |
|
| 1583 | - |
|
| 1584 | - switch ( $p ) { |
|
| 1585 | - case 0: |
|
| 1586 | - $l1 = $name; |
|
| 1587 | - self::add_value_to_array( $name, $l1, $this_val, $vars ); |
|
| 1588 | - break; |
|
| 1589 | - |
|
| 1590 | - case 1: |
|
| 1591 | - $l2 = $name; |
|
| 1592 | - self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
| 1593 | - break; |
|
| 1594 | - |
|
| 1595 | - case 2: |
|
| 1596 | - $l3 = $name; |
|
| 1597 | - self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
| 1598 | - break; |
|
| 1599 | - |
|
| 1600 | - case 3: |
|
| 1601 | - $l4 = $name; |
|
| 1602 | - self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
| 1603 | - break; |
|
| 1604 | - } |
|
| 1605 | - |
|
| 1606 | - unset($this_val, $n); |
|
| 1607 | - } |
|
| 1608 | - |
|
| 1609 | - unset($last, $jv); |
|
| 1610 | - } |
|
| 1611 | - |
|
| 1612 | - return $vars; |
|
| 1613 | - } |
|
| 1614 | - |
|
| 1615 | - /** |
|
| 1616 | - * @param string $name |
|
| 1617 | - * @param string $l1 |
|
| 1618 | - */ |
|
| 1619 | - public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
|
| 1620 | - if ( $name == '' ) { |
|
| 1621 | - $vars[] = $val; |
|
| 1622 | - } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
| 1623 | - $vars[ $l1 ] = $val; |
|
| 1624 | - } |
|
| 1625 | - } |
|
| 1564 | + $vars = array(); |
|
| 1565 | + foreach ( $json_vars as $jv ) { |
|
| 1566 | + $jv_name = explode('[', $jv['name']); |
|
| 1567 | + $last = count($jv_name) - 1; |
|
| 1568 | + foreach ( $jv_name as $p => $n ) { |
|
| 1569 | + $name = trim($n, ']'); |
|
| 1570 | + if ( ! isset($l1) ) { |
|
| 1571 | + $l1 = $name; |
|
| 1572 | + } |
|
| 1573 | + |
|
| 1574 | + if ( ! isset($l2) ) { |
|
| 1575 | + $l2 = $name; |
|
| 1576 | + } |
|
| 1577 | + |
|
| 1578 | + if ( ! isset($l3) ) { |
|
| 1579 | + $l3 = $name; |
|
| 1580 | + } |
|
| 1581 | + |
|
| 1582 | + $this_val = ( $p == $last ) ? $jv['value'] : array(); |
|
| 1583 | + |
|
| 1584 | + switch ( $p ) { |
|
| 1585 | + case 0: |
|
| 1586 | + $l1 = $name; |
|
| 1587 | + self::add_value_to_array( $name, $l1, $this_val, $vars ); |
|
| 1588 | + break; |
|
| 1589 | + |
|
| 1590 | + case 1: |
|
| 1591 | + $l2 = $name; |
|
| 1592 | + self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
| 1593 | + break; |
|
| 1594 | + |
|
| 1595 | + case 2: |
|
| 1596 | + $l3 = $name; |
|
| 1597 | + self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
| 1598 | + break; |
|
| 1599 | + |
|
| 1600 | + case 3: |
|
| 1601 | + $l4 = $name; |
|
| 1602 | + self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
| 1603 | + break; |
|
| 1604 | + } |
|
| 1605 | + |
|
| 1606 | + unset($this_val, $n); |
|
| 1607 | + } |
|
| 1608 | + |
|
| 1609 | + unset($last, $jv); |
|
| 1610 | + } |
|
| 1611 | + |
|
| 1612 | + return $vars; |
|
| 1613 | + } |
|
| 1614 | + |
|
| 1615 | + /** |
|
| 1616 | + * @param string $name |
|
| 1617 | + * @param string $l1 |
|
| 1618 | + */ |
|
| 1619 | + public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
|
| 1620 | + if ( $name == '' ) { |
|
| 1621 | + $vars[] = $val; |
|
| 1622 | + } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
| 1623 | + $vars[ $l1 ] = $val; |
|
| 1624 | + } |
|
| 1625 | + } |
|
| 1626 | 1626 | |
| 1627 | 1627 | public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) { |
| 1628 | - $tooltips = array( |
|
| 1629 | - 'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ), |
|
| 1630 | - 'email_to' => __( 'Add one or more recipient addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected]. [admin_email] is the address set in WP General Settings.', 'formidable' ), |
|
| 1631 | - 'cc' => __( 'Add CC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1632 | - 'bcc' => __( 'Add BCC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1633 | - 'reply_to' => __( 'If you would like a different reply to address than the "from" address, add a single address here. FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1634 | - 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ), |
|
| 1635 | - 'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ), |
|
| 1636 | - ); |
|
| 1637 | - |
|
| 1638 | - if ( ! isset( $tooltips[ $name ] ) ) { |
|
| 1639 | - return; |
|
| 1640 | - } |
|
| 1641 | - |
|
| 1642 | - if ( 'open' == $class ) { |
|
| 1643 | - echo ' frm_help"'; |
|
| 1644 | - } else { |
|
| 1645 | - echo ' class="frm_help"'; |
|
| 1646 | - } |
|
| 1628 | + $tooltips = array( |
|
| 1629 | + 'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ), |
|
| 1630 | + 'email_to' => __( 'Add one or more recipient addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected]. [admin_email] is the address set in WP General Settings.', 'formidable' ), |
|
| 1631 | + 'cc' => __( 'Add CC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1632 | + 'bcc' => __( 'Add BCC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1633 | + 'reply_to' => __( 'If you would like a different reply to address than the "from" address, add a single address here. FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1634 | + 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ), |
|
| 1635 | + 'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ), |
|
| 1636 | + ); |
|
| 1637 | + |
|
| 1638 | + if ( ! isset( $tooltips[ $name ] ) ) { |
|
| 1639 | + return; |
|
| 1640 | + } |
|
| 1641 | + |
|
| 1642 | + if ( 'open' == $class ) { |
|
| 1643 | + echo ' frm_help"'; |
|
| 1644 | + } else { |
|
| 1645 | + echo ' class="frm_help"'; |
|
| 1646 | + } |
|
| 1647 | 1647 | |
| 1648 | 1648 | echo ' title="' . esc_attr( $tooltips[ $name ] ); |
| 1649 | 1649 | |
| 1650 | - if ( 'open' != $class ) { |
|
| 1651 | - echo '"'; |
|
| 1652 | - } |
|
| 1653 | - } |
|
| 1650 | + if ( 'open' != $class ) { |
|
| 1651 | + echo '"'; |
|
| 1652 | + } |
|
| 1653 | + } |
|
| 1654 | 1654 | |
| 1655 | 1655 | /** |
| 1656 | 1656 | * Add the current_page class to that page in the form nav |
@@ -1666,35 +1666,35 @@ discard block |
||
| 1666 | 1666 | } |
| 1667 | 1667 | } |
| 1668 | 1668 | |
| 1669 | - /** |
|
| 1670 | - * Prepare and json_encode post content |
|
| 1671 | - * |
|
| 1672 | - * @since 2.0 |
|
| 1673 | - * |
|
| 1674 | - * @param array $post_content |
|
| 1675 | - * @return string $post_content ( json encoded array ) |
|
| 1676 | - */ |
|
| 1677 | - public static function prepare_and_encode( $post_content ) { |
|
| 1678 | - //Loop through array to strip slashes and add only the needed ones |
|
| 1669 | + /** |
|
| 1670 | + * Prepare and json_encode post content |
|
| 1671 | + * |
|
| 1672 | + * @since 2.0 |
|
| 1673 | + * |
|
| 1674 | + * @param array $post_content |
|
| 1675 | + * @return string $post_content ( json encoded array ) |
|
| 1676 | + */ |
|
| 1677 | + public static function prepare_and_encode( $post_content ) { |
|
| 1678 | + //Loop through array to strip slashes and add only the needed ones |
|
| 1679 | 1679 | foreach ( $post_content as $key => $val ) { |
| 1680 | 1680 | // Replace problematic characters (like ") |
| 1681 | 1681 | $val = str_replace( '"', '"', $val ); |
| 1682 | 1682 | |
| 1683 | 1683 | self::prepare_action_slashes( $val, $key, $post_content ); |
| 1684 | - unset( $key, $val ); |
|
| 1685 | - } |
|
| 1684 | + unset( $key, $val ); |
|
| 1685 | + } |
|
| 1686 | 1686 | |
| 1687 | - // json_encode the array |
|
| 1688 | - $post_content = json_encode( $post_content ); |
|
| 1687 | + // json_encode the array |
|
| 1688 | + $post_content = json_encode( $post_content ); |
|
| 1689 | 1689 | |
| 1690 | - // add extra slashes for \r\n since WP strips them |
|
| 1690 | + // add extra slashes for \r\n since WP strips them |
|
| 1691 | 1691 | $post_content = str_replace( array( '\\r', '\\n', '\\u', '\\t' ), array( '\\\\r', '\\\\n', '\\\\u', '\\\\t' ), $post_content ); |
| 1692 | 1692 | |
| 1693 | - // allow for " |
|
| 1694 | - $post_content = str_replace( '"', '\\"', $post_content ); |
|
| 1693 | + // allow for " |
|
| 1694 | + $post_content = str_replace( '"', '\\"', $post_content ); |
|
| 1695 | 1695 | |
| 1696 | - return $post_content; |
|
| 1697 | - } |
|
| 1696 | + return $post_content; |
|
| 1697 | + } |
|
| 1698 | 1698 | |
| 1699 | 1699 | private static function prepare_action_slashes( $val, $key, &$post_content ) { |
| 1700 | 1700 | if ( ! isset( $post_content[ $key ] ) ) { |
@@ -1762,64 +1762,64 @@ discard block |
||
| 1762 | 1762 | } |
| 1763 | 1763 | |
| 1764 | 1764 | public static function maybe_json_decode( $string ) { |
| 1765 | - if ( is_array($string) ) { |
|
| 1766 | - return $string; |
|
| 1767 | - } |
|
| 1765 | + if ( is_array($string) ) { |
|
| 1766 | + return $string; |
|
| 1767 | + } |
|
| 1768 | 1768 | |
| 1769 | - $new_string = json_decode($string, true); |
|
| 1770 | - if ( function_exists('json_last_error') ) { |
|
| 1769 | + $new_string = json_decode($string, true); |
|
| 1770 | + if ( function_exists('json_last_error') ) { |
|
| 1771 | 1771 | // php 5.3+ |
| 1772 | - if ( json_last_error() == JSON_ERROR_NONE ) { |
|
| 1773 | - $string = $new_string; |
|
| 1774 | - } |
|
| 1775 | - } else if ( isset($new_string) ) { |
|
| 1772 | + if ( json_last_error() == JSON_ERROR_NONE ) { |
|
| 1773 | + $string = $new_string; |
|
| 1774 | + } |
|
| 1775 | + } else if ( isset($new_string) ) { |
|
| 1776 | 1776 | // php < 5.3 fallback |
| 1777 | - $string = $new_string; |
|
| 1778 | - } |
|
| 1779 | - return $string; |
|
| 1780 | - } |
|
| 1781 | - |
|
| 1782 | - /** |
|
| 1783 | - * @since 1.07.10 |
|
| 1784 | - * |
|
| 1785 | - * @param string $post_type The name of the post type that may need to be highlighted |
|
| 1786 | - * echo The javascript to open and highlight the Formidable menu |
|
| 1787 | - */ |
|
| 1777 | + $string = $new_string; |
|
| 1778 | + } |
|
| 1779 | + return $string; |
|
| 1780 | + } |
|
| 1781 | + |
|
| 1782 | + /** |
|
| 1783 | + * @since 1.07.10 |
|
| 1784 | + * |
|
| 1785 | + * @param string $post_type The name of the post type that may need to be highlighted |
|
| 1786 | + * echo The javascript to open and highlight the Formidable menu |
|
| 1787 | + */ |
|
| 1788 | 1788 | public static function maybe_highlight_menu( $post_type ) { |
| 1789 | - global $post; |
|
| 1789 | + global $post; |
|
| 1790 | 1790 | |
| 1791 | - if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) { |
|
| 1792 | - return; |
|
| 1793 | - } |
|
| 1791 | + if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) { |
|
| 1792 | + return; |
|
| 1793 | + } |
|
| 1794 | 1794 | |
| 1795 | - if ( is_object($post) && $post->post_type != $post_type ) { |
|
| 1796 | - return; |
|
| 1797 | - } |
|
| 1795 | + if ( is_object($post) && $post->post_type != $post_type ) { |
|
| 1796 | + return; |
|
| 1797 | + } |
|
| 1798 | 1798 | |
| 1799 | - self::load_admin_wide_js(); |
|
| 1800 | - echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>'; |
|
| 1801 | - } |
|
| 1799 | + self::load_admin_wide_js(); |
|
| 1800 | + echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>'; |
|
| 1801 | + } |
|
| 1802 | 1802 | |
| 1803 | - /** |
|
| 1804 | - * Load the JS file on non-Formidable pages in the admin area |
|
| 1805 | - * @since 2.0 |
|
| 1806 | - */ |
|
| 1803 | + /** |
|
| 1804 | + * Load the JS file on non-Formidable pages in the admin area |
|
| 1805 | + * @since 2.0 |
|
| 1806 | + */ |
|
| 1807 | 1807 | public static function load_admin_wide_js( $load = true ) { |
| 1808 | - $version = FrmAppHelper::plugin_version(); |
|
| 1808 | + $version = FrmAppHelper::plugin_version(); |
|
| 1809 | 1809 | wp_register_script( 'formidable_admin_global', FrmAppHelper::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version ); |
| 1810 | 1810 | |
| 1811 | - wp_localize_script( 'formidable_admin_global', 'frmGlobal', array( |
|
| 1811 | + wp_localize_script( 'formidable_admin_global', 'frmGlobal', array( |
|
| 1812 | 1812 | 'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ), |
| 1813 | - 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ), |
|
| 1813 | + 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ), |
|
| 1814 | 1814 | 'url' => FrmAppHelper::plugin_url(), |
| 1815 | 1815 | 'loading' => __( 'Loading…' ), |
| 1816 | 1816 | 'nonce' => wp_create_nonce( 'frm_ajax' ), |
| 1817 | - ) ); |
|
| 1817 | + ) ); |
|
| 1818 | 1818 | |
| 1819 | 1819 | if ( $load ) { |
| 1820 | 1820 | wp_enqueue_script( 'formidable_admin_global' ); |
| 1821 | 1821 | } |
| 1822 | - } |
|
| 1822 | + } |
|
| 1823 | 1823 | |
| 1824 | 1824 | /** |
| 1825 | 1825 | * @since 2.0.9 |
@@ -1828,9 +1828,9 @@ discard block |
||
| 1828 | 1828 | wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() ); |
| 1829 | 1829 | } |
| 1830 | 1830 | |
| 1831 | - /** |
|
| 1832 | - * @param string $location |
|
| 1833 | - */ |
|
| 1831 | + /** |
|
| 1832 | + * @param string $location |
|
| 1833 | + */ |
|
| 1834 | 1834 | public static function localize_script( $location ) { |
| 1835 | 1835 | $ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' ); |
| 1836 | 1836 | $ajax_url = apply_filters( 'frm_ajax_url', $ajax_url ); |
@@ -1886,81 +1886,81 @@ discard block |
||
| 1886 | 1886 | } |
| 1887 | 1887 | } |
| 1888 | 1888 | |
| 1889 | - /** |
|
| 1889 | + /** |
|
| 1890 | 1890 | * echo the message on the plugins listing page |
| 1891 | - * @since 1.07.10 |
|
| 1892 | - * |
|
| 1893 | - * @param float $min_version The version the add-on requires |
|
| 1894 | - */ |
|
| 1891 | + * @since 1.07.10 |
|
| 1892 | + * |
|
| 1893 | + * @param float $min_version The version the add-on requires |
|
| 1894 | + */ |
|
| 1895 | 1895 | public static function min_version_notice( $min_version ) { |
| 1896 | - $frm_version = self::plugin_version(); |
|
| 1896 | + $frm_version = self::plugin_version(); |
|
| 1897 | 1897 | |
| 1898 | - // check if Formidable meets minimum requirements |
|
| 1899 | - if ( version_compare($frm_version, $min_version, '>=') ) { |
|
| 1900 | - return; |
|
| 1901 | - } |
|
| 1898 | + // check if Formidable meets minimum requirements |
|
| 1899 | + if ( version_compare($frm_version, $min_version, '>=') ) { |
|
| 1900 | + return; |
|
| 1901 | + } |
|
| 1902 | 1902 | |
| 1903 | - $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
|
| 1903 | + $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
|
| 1904 | 1904 | echo '<tr class="plugin-update-tr active"><th colspan="' . absint( $wp_list_table->get_column_count() ) . '" class="check-column plugin-update colspanchange"><div class="update-message">' . |
| 1905 | - __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
|
| 1906 | - '</div></td></tr>'; |
|
| 1907 | - } |
|
| 1908 | - |
|
| 1909 | - public static function locales( $type = 'date' ) { |
|
| 1910 | - $locales = array( |
|
| 1911 | - 'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ), |
|
| 1912 | - 'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ), |
|
| 1913 | - 'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ), |
|
| 1914 | - 'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ), |
|
| 1915 | - 'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ), |
|
| 1916 | - 'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ), |
|
| 1917 | - 'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ), |
|
| 1918 | - 'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ), |
|
| 1919 | - 'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ), |
|
| 1920 | - 'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ), |
|
| 1921 | - 'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ), |
|
| 1922 | - 'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ), |
|
| 1923 | - 'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ), |
|
| 1924 | - 'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ), |
|
| 1925 | - 'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ), |
|
| 1926 | - 'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ), |
|
| 1927 | - 'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ), |
|
| 1928 | - 'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ), |
|
| 1929 | - 'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ), |
|
| 1930 | - 'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ), |
|
| 1931 | - 'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ), |
|
| 1932 | - 'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ), |
|
| 1933 | - 'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ), |
|
| 1934 | - 'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ), |
|
| 1935 | - 'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ), |
|
| 1936 | - 'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ), |
|
| 1937 | - 'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ), |
|
| 1938 | - 'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ), |
|
| 1939 | - 'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ), |
|
| 1940 | - 'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ), |
|
| 1941 | - 'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ), |
|
| 1942 | - 'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ), |
|
| 1943 | - ); |
|
| 1944 | - |
|
| 1945 | - if ( $type == 'captcha' ) { |
|
| 1946 | - // remove the languages unavailable for the captcha |
|
| 1947 | - $unset = array( |
|
| 1948 | - '', 'af', 'sq', 'hy', 'az', 'eu', 'bs', |
|
| 1949 | - 'zh-HK', 'eo', 'et', 'fo', 'fr-CH', |
|
| 1950 | - 'he', 'is', 'ms', 'sr-SR', 'ta', 'tu', |
|
| 1951 | - ); |
|
| 1952 | - } else { |
|
| 1953 | - // remove the languages unavailable for the datepicker |
|
| 1954 | - $unset = array( |
|
| 1955 | - 'en', 'fil', 'fr-CA', 'de-AT', 'de-AT', |
|
| 1956 | - 'de-CH', 'iw', 'hi', 'pt', 'pt-PT', |
|
| 1957 | - 'es-419', 'tr', |
|
| 1958 | - ); |
|
| 1959 | - } |
|
| 1960 | - |
|
| 1961 | - $locales = array_diff_key($locales, array_flip($unset)); |
|
| 1962 | - $locales = apply_filters('frm_locales', $locales); |
|
| 1963 | - |
|
| 1964 | - return $locales; |
|
| 1965 | - } |
|
| 1905 | + __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
|
| 1906 | + '</div></td></tr>'; |
|
| 1907 | + } |
|
| 1908 | + |
|
| 1909 | + public static function locales( $type = 'date' ) { |
|
| 1910 | + $locales = array( |
|
| 1911 | + 'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ), |
|
| 1912 | + 'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ), |
|
| 1913 | + 'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ), |
|
| 1914 | + 'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ), |
|
| 1915 | + 'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ), |
|
| 1916 | + 'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ), |
|
| 1917 | + 'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ), |
|
| 1918 | + 'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ), |
|
| 1919 | + 'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ), |
|
| 1920 | + 'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ), |
|
| 1921 | + 'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ), |
|
| 1922 | + 'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ), |
|
| 1923 | + 'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ), |
|
| 1924 | + 'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ), |
|
| 1925 | + 'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ), |
|
| 1926 | + 'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ), |
|
| 1927 | + 'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ), |
|
| 1928 | + 'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ), |
|
| 1929 | + 'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ), |
|
| 1930 | + 'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ), |
|
| 1931 | + 'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ), |
|
| 1932 | + 'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ), |
|
| 1933 | + 'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ), |
|
| 1934 | + 'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ), |
|
| 1935 | + 'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ), |
|
| 1936 | + 'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ), |
|
| 1937 | + 'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ), |
|
| 1938 | + 'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ), |
|
| 1939 | + 'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ), |
|
| 1940 | + 'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ), |
|
| 1941 | + 'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ), |
|
| 1942 | + 'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ), |
|
| 1943 | + ); |
|
| 1944 | + |
|
| 1945 | + if ( $type == 'captcha' ) { |
|
| 1946 | + // remove the languages unavailable for the captcha |
|
| 1947 | + $unset = array( |
|
| 1948 | + '', 'af', 'sq', 'hy', 'az', 'eu', 'bs', |
|
| 1949 | + 'zh-HK', 'eo', 'et', 'fo', 'fr-CH', |
|
| 1950 | + 'he', 'is', 'ms', 'sr-SR', 'ta', 'tu', |
|
| 1951 | + ); |
|
| 1952 | + } else { |
|
| 1953 | + // remove the languages unavailable for the datepicker |
|
| 1954 | + $unset = array( |
|
| 1955 | + 'en', 'fil', 'fr-CA', 'de-AT', 'de-AT', |
|
| 1956 | + 'de-CH', 'iw', 'hi', 'pt', 'pt-PT', |
|
| 1957 | + 'es-419', 'tr', |
|
| 1958 | + ); |
|
| 1959 | + } |
|
| 1960 | + |
|
| 1961 | + $locales = array_diff_key($locales, array_flip($unset)); |
|
| 1962 | + $locales = apply_filters('frm_locales', $locales); |
|
| 1963 | + |
|
| 1964 | + return $locales; |
|
| 1965 | + } |
|
| 1966 | 1966 | } |
@@ -1,89 +1,89 @@ 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 | - } |
|
| 47 | + if ( ! is_admin() ) { |
|
| 48 | + add_filter( 'the_content', 'FrmAppController::page_route', 10 ); |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - add_action( 'plugins_loaded', 'FrmAppController::load_lang' ); |
|
| 51 | + add_action( 'plugins_loaded', 'FrmAppController::load_lang' ); |
|
| 52 | 52 | add_filter( 'widget_text', 'do_shortcode' ); |
| 53 | 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 ); |
|
| 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 | 58 | |
| 59 | - // Form Actions Controller |
|
| 60 | - add_action( 'init', 'FrmFormActionsController::register_post_types', 1 ); |
|
| 59 | + // Form Actions Controller |
|
| 60 | + add_action( 'init', 'FrmFormActionsController::register_post_types', 1 ); |
|
| 61 | 61 | add_action( 'frm_after_create_entry', 'FrmFormActionsController::trigger_create_actions', 20, 3 ); |
| 62 | 62 | |
| 63 | - // Forms Controller |
|
| 64 | - add_action( 'widgets_init', 'FrmFormsController::register_widgets' ); |
|
| 63 | + // Forms Controller |
|
| 64 | + add_action( 'widgets_init', 'FrmFormsController::register_widgets' ); |
|
| 65 | 65 | add_action( 'init', 'FrmFormsController::front_head' ); |
| 66 | - add_filter( 'frm_content', 'FrmFormsController::filter_content', 10, 3 ); |
|
| 67 | - add_filter( 'frm_replace_content_shortcodes', 'FrmFormsController::replace_content_shortcodes', 20, 3 ); |
|
| 68 | - add_action( 'admin_bar_init', 'FrmFormsController::admin_bar_css' ); |
|
| 66 | + add_filter( 'frm_content', 'FrmFormsController::filter_content', 10, 3 ); |
|
| 67 | + add_filter( 'frm_replace_content_shortcodes', 'FrmFormsController::replace_content_shortcodes', 20, 3 ); |
|
| 68 | + add_action( 'admin_bar_init', 'FrmFormsController::admin_bar_css' ); |
|
| 69 | 69 | add_action( 'wp_footer', 'FrmFormsController::footer_js', 1, 0 ); |
| 70 | 70 | |
| 71 | 71 | add_action( 'wp_scheduled_delete', 'FrmForm::scheduled_delete' ); |
| 72 | 72 | |
| 73 | - // Form Shortcodes |
|
| 74 | - add_shortcode( 'formidable', 'FrmFormsController::get_form_shortcode' ); |
|
| 73 | + // Form Shortcodes |
|
| 74 | + add_shortcode( 'formidable', 'FrmFormsController::get_form_shortcode' ); |
|
| 75 | 75 | |
| 76 | - // Styles Controller |
|
| 77 | - add_action( 'init', 'FrmStylesController::register_post_types', 0 ); |
|
| 78 | - add_filter( 'frm_get_style_opts', 'FrmStylesController::get_style_opts' ); |
|
| 79 | - add_filter( 'frm_add_form_style_class', 'FrmStylesController::get_form_style_class', 10, 2 ); |
|
| 80 | - add_filter( 'frm_show_entry_styles', 'FrmStylesController::show_entry_styles' ); |
|
| 81 | - } |
|
| 76 | + // Styles Controller |
|
| 77 | + add_action( 'init', 'FrmStylesController::register_post_types', 0 ); |
|
| 78 | + add_filter( 'frm_get_style_opts', 'FrmStylesController::get_style_opts' ); |
|
| 79 | + add_filter( 'frm_add_form_style_class', 'FrmStylesController::get_form_style_class', 10, 2 ); |
|
| 80 | + add_filter( 'frm_show_entry_styles', 'FrmStylesController::show_entry_styles' ); |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | 83 | public static function load_admin_hooks() { |
| 84 | - add_action( 'admin_menu', 'FrmAppController::menu', 1 ); |
|
| 85 | - add_action( 'admin_enqueue_scripts', 'FrmAppController::load_wp_admin_style' ); |
|
| 86 | - add_action( 'admin_notices', 'FrmAppController::pro_get_started_headline' ); |
|
| 84 | + add_action( 'admin_menu', 'FrmAppController::menu', 1 ); |
|
| 85 | + add_action( 'admin_enqueue_scripts', 'FrmAppController::load_wp_admin_style' ); |
|
| 86 | + add_action( 'admin_notices', 'FrmAppController::pro_get_started_headline' ); |
|
| 87 | 87 | add_action( 'admin_init', 'FrmAppController::admin_init', 11 ); |
| 88 | 88 | add_filter( 'plugin_action_links_' . FrmAppHelper::plugin_folder() . '/formidable.php', 'FrmAppController::settings_link' ); |
| 89 | 89 | register_activation_hook( FrmAppHelper::plugin_folder() . '/formidable.php', 'FrmAppController::activation_install' ); |
@@ -92,120 +92,120 @@ discard block |
||
| 92 | 92 | add_action( 'admin_menu', 'FrmAddonsController::menu', 100 ); |
| 93 | 93 | add_filter( 'upgrader_pre_download', 'FrmAddonsController::add_shorten_edd_filename_filter', 10, 4 ); |
| 94 | 94 | |
| 95 | - // Entries Controller |
|
| 96 | - add_action( 'admin_menu', 'FrmEntriesController::menu', 12 ); |
|
| 97 | - add_filter( 'contextual_help', 'FrmEntriesController::contextual_help', 10, 3 ); |
|
| 98 | - add_filter( 'set-screen-option', 'FrmEntriesController::save_per_page', 10, 3 ); |
|
| 99 | - add_filter( 'update_user_metadata', 'FrmEntriesController::check_hidden_cols', 10, 5 ); |
|
| 100 | - add_action( 'updated_user_meta', 'FrmEntriesController::update_hidden_cols', 10, 4 ); |
|
| 95 | + // Entries Controller |
|
| 96 | + add_action( 'admin_menu', 'FrmEntriesController::menu', 12 ); |
|
| 97 | + add_filter( 'contextual_help', 'FrmEntriesController::contextual_help', 10, 3 ); |
|
| 98 | + add_filter( 'set-screen-option', 'FrmEntriesController::save_per_page', 10, 3 ); |
|
| 99 | + add_filter( 'update_user_metadata', 'FrmEntriesController::check_hidden_cols', 10, 5 ); |
|
| 100 | + add_action( 'updated_user_meta', 'FrmEntriesController::update_hidden_cols', 10, 4 ); |
|
| 101 | 101 | |
| 102 | - // Fields Controller |
|
| 103 | - add_filter( 'frm_display_field_options', 'FrmFieldsController::display_field_options' ); |
|
| 102 | + // Fields Controller |
|
| 103 | + add_filter( 'frm_display_field_options', 'FrmFieldsController::display_field_options' ); |
|
| 104 | 104 | |
| 105 | - // Form Actions Controller |
|
| 106 | - if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
|
| 107 | - add_action( 'frm_before_update_form_settings', 'FrmFormActionsController::update_settings' ); |
|
| 108 | - } |
|
| 109 | - add_action( 'frm_after_duplicate_form', 'FrmFormActionsController::duplicate_form_actions', 20, 3 ); |
|
| 105 | + // Form Actions Controller |
|
| 106 | + if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
|
| 107 | + add_action( 'frm_before_update_form_settings', 'FrmFormActionsController::update_settings' ); |
|
| 108 | + } |
|
| 109 | + add_action( 'frm_after_duplicate_form', 'FrmFormActionsController::duplicate_form_actions', 20, 3 ); |
|
| 110 | 110 | |
| 111 | - // Forms Controller |
|
| 112 | - add_action( 'admin_menu', 'FrmFormsController::menu', 10 ); |
|
| 113 | - add_action( 'admin_head-toplevel_page_formidable', 'FrmFormsController::head' ); |
|
| 111 | + // Forms Controller |
|
| 112 | + add_action( 'admin_menu', 'FrmFormsController::menu', 10 ); |
|
| 113 | + add_action( 'admin_head-toplevel_page_formidable', 'FrmFormsController::head' ); |
|
| 114 | 114 | |
| 115 | - add_filter( 'set-screen-option', 'FrmFormsController::save_per_page', 10, 3 ); |
|
| 116 | - add_action( 'admin_footer', 'FrmFormsController::insert_form_popup' ); |
|
| 115 | + add_filter( 'set-screen-option', 'FrmFormsController::save_per_page', 10, 3 ); |
|
| 116 | + add_action( 'admin_footer', 'FrmFormsController::insert_form_popup' ); |
|
| 117 | 117 | add_action( 'media_buttons', 'FrmFormsController::insert_form_button' ); |
| 118 | 118 | |
| 119 | - // Forms Model |
|
| 120 | - add_action( 'frm_after_duplicate_form', 'FrmForm::after_duplicate', 10, 2 ); |
|
| 119 | + // Forms Model |
|
| 120 | + add_action( 'frm_after_duplicate_form', 'FrmForm::after_duplicate', 10, 2 ); |
|
| 121 | 121 | |
| 122 | - // Settings Controller |
|
| 123 | - add_action( 'admin_menu', 'FrmSettingsController::menu', 45 ); |
|
| 124 | - add_action( 'frm_before_settings', 'FrmSettingsController::license_box' ); |
|
| 122 | + // Settings Controller |
|
| 123 | + add_action( 'admin_menu', 'FrmSettingsController::menu', 45 ); |
|
| 124 | + add_action( 'frm_before_settings', 'FrmSettingsController::license_box' ); |
|
| 125 | 125 | add_action( 'wp_ajax_frm_settings_tab', 'FrmSettingsController::load_settings_tab' ); |
| 126 | 126 | |
| 127 | - // Styles Controller |
|
| 128 | - add_action( 'admin_menu', 'FrmStylesController::menu', 14 ); |
|
| 129 | - add_action( 'admin_init', 'FrmStylesController::admin_init' ); |
|
| 127 | + // Styles Controller |
|
| 128 | + add_action( 'admin_menu', 'FrmStylesController::menu', 14 ); |
|
| 129 | + add_action( 'admin_init', 'FrmStylesController::admin_init' ); |
|
| 130 | 130 | |
| 131 | - // XML Controller |
|
| 132 | - add_action( 'admin_menu', 'FrmXMLController::menu', 41 ); |
|
| 133 | - } |
|
| 131 | + // XML Controller |
|
| 132 | + add_action( 'admin_menu', 'FrmXMLController::menu', 41 ); |
|
| 133 | + } |
|
| 134 | 134 | |
| 135 | 135 | public static function load_ajax_hooks() { |
| 136 | 136 | add_action( 'wp_ajax_frm_silent_upgrade', 'FrmAppController::ajax_install' ); |
| 137 | 137 | add_action( 'wp_ajax_nopriv_frm_silent_upgrade', 'FrmAppController::ajax_install' ); |
| 138 | 138 | add_action( 'wp_ajax_frm_install', 'FrmAppController::ajax_install' ); |
| 139 | - add_action( 'wp_ajax_frm_uninstall', 'FrmAppController::uninstall' ); |
|
| 140 | - add_action( 'wp_ajax_frm_deauthorize', 'FrmAppController::deauthorize' ); |
|
| 139 | + add_action( 'wp_ajax_frm_uninstall', 'FrmAppController::uninstall' ); |
|
| 140 | + add_action( 'wp_ajax_frm_deauthorize', 'FrmAppController::deauthorize' ); |
|
| 141 | 141 | |
| 142 | 142 | // Addons |
| 143 | 143 | add_action('wp_ajax_frm_addon_activate', 'FrmAddon::activate' ); |
| 144 | 144 | add_action('wp_ajax_frm_addon_deactivate', 'FrmAddon::deactivate' ); |
| 145 | 145 | add_action( 'wp_ajax_frm_fill_licenses', 'FrmAddonsController::get_licenses' ); |
| 146 | 146 | |
| 147 | - // Fields Controller |
|
| 148 | - add_action( 'wp_ajax_frm_load_field', 'FrmFieldsController::load_field' ); |
|
| 149 | - add_action( 'wp_ajax_frm_insert_field', 'FrmFieldsController::create' ); |
|
| 150 | - add_action( 'wp_ajax_frm_field_name_in_place_edit', 'FrmFieldsController::edit_name' ); |
|
| 151 | - add_action( 'wp_ajax_frm_update_ajax_option', 'FrmFieldsController::update_ajax_option' ); |
|
| 152 | - add_action( 'wp_ajax_frm_duplicate_field', 'FrmFieldsController::duplicate' ); |
|
| 153 | - add_action( 'wp_ajax_frm_delete_field', 'FrmFieldsController::destroy' ); |
|
| 154 | - add_action( 'wp_ajax_frm_add_field_option', 'FrmFieldsController::add_option' ); |
|
| 155 | - add_action( 'wp_ajax_frm_import_choices', 'FrmFieldsController::import_choices' ); |
|
| 156 | - add_action( 'wp_ajax_frm_import_options', 'FrmFieldsController::import_options' ); |
|
| 157 | - add_action( 'wp_ajax_frm_update_field_order', 'FrmFieldsController::update_order' ); |
|
| 158 | - |
|
| 159 | - // Form Actions Controller |
|
| 160 | - add_action( 'wp_ajax_frm_add_form_action', 'FrmFormActionsController::add_form_action' ); |
|
| 161 | - add_action( 'wp_ajax_frm_form_action_fill', 'FrmFormActionsController::fill_action' ); |
|
| 162 | - |
|
| 163 | - // Forms Controller |
|
| 147 | + // Fields Controller |
|
| 148 | + add_action( 'wp_ajax_frm_load_field', 'FrmFieldsController::load_field' ); |
|
| 149 | + add_action( 'wp_ajax_frm_insert_field', 'FrmFieldsController::create' ); |
|
| 150 | + add_action( 'wp_ajax_frm_field_name_in_place_edit', 'FrmFieldsController::edit_name' ); |
|
| 151 | + add_action( 'wp_ajax_frm_update_ajax_option', 'FrmFieldsController::update_ajax_option' ); |
|
| 152 | + add_action( 'wp_ajax_frm_duplicate_field', 'FrmFieldsController::duplicate' ); |
|
| 153 | + add_action( 'wp_ajax_frm_delete_field', 'FrmFieldsController::destroy' ); |
|
| 154 | + add_action( 'wp_ajax_frm_add_field_option', 'FrmFieldsController::add_option' ); |
|
| 155 | + add_action( 'wp_ajax_frm_import_choices', 'FrmFieldsController::import_choices' ); |
|
| 156 | + add_action( 'wp_ajax_frm_import_options', 'FrmFieldsController::import_options' ); |
|
| 157 | + add_action( 'wp_ajax_frm_update_field_order', 'FrmFieldsController::update_order' ); |
|
| 158 | + |
|
| 159 | + // Form Actions Controller |
|
| 160 | + add_action( 'wp_ajax_frm_add_form_action', 'FrmFormActionsController::add_form_action' ); |
|
| 161 | + add_action( 'wp_ajax_frm_form_action_fill', 'FrmFormActionsController::fill_action' ); |
|
| 162 | + |
|
| 163 | + // Forms Controller |
|
| 164 | 164 | add_action( 'wp_ajax_frm_create_from_template', 'FrmFormsController::_create_from_template' ); |
| 165 | 165 | add_action( 'wp_ajax_frm_save_form', 'FrmFormsController::route' ); |
| 166 | 166 | add_action( 'wp_ajax_frm_form_key_in_place_edit', 'FrmFormsController::edit_key' ); |
| 167 | 167 | add_action( 'wp_ajax_frm_form_desc_in_place_edit', 'FrmFormsController::edit_description' ); |
| 168 | - add_action( 'wp_ajax_frm_get_default_html', 'FrmFormsController::get_email_html' ); |
|
| 169 | - add_action( 'wp_ajax_frm_get_shortcode_opts', 'FrmFormsController::get_shortcode_opts' ); |
|
| 170 | - add_action( 'wp_ajax_frm_forms_preview', 'FrmFormsController::preview' ); |
|
| 171 | - add_action( 'wp_ajax_nopriv_frm_forms_preview', 'FrmFormsController::preview' ); |
|
| 172 | - |
|
| 173 | - // Styles Controller |
|
| 174 | - add_action( 'wp_ajax_frm_settings_reset', 'FrmStylesController::reset_styling' ); |
|
| 175 | - add_action( 'wp_ajax_frm_change_styling', 'FrmStylesController::change_styling' ); |
|
| 176 | - add_action( 'wp_ajax_frmpro_load_css', 'FrmStylesController::load_css' ); |
|
| 177 | - add_action( 'wp_ajax_nopriv_frmpro_load_css', 'FrmStylesController::load_css' ); |
|
| 168 | + add_action( 'wp_ajax_frm_get_default_html', 'FrmFormsController::get_email_html' ); |
|
| 169 | + add_action( 'wp_ajax_frm_get_shortcode_opts', 'FrmFormsController::get_shortcode_opts' ); |
|
| 170 | + add_action( 'wp_ajax_frm_forms_preview', 'FrmFormsController::preview' ); |
|
| 171 | + add_action( 'wp_ajax_nopriv_frm_forms_preview', 'FrmFormsController::preview' ); |
|
| 172 | + |
|
| 173 | + // Styles Controller |
|
| 174 | + add_action( 'wp_ajax_frm_settings_reset', 'FrmStylesController::reset_styling' ); |
|
| 175 | + add_action( 'wp_ajax_frm_change_styling', 'FrmStylesController::change_styling' ); |
|
| 176 | + add_action( 'wp_ajax_frmpro_load_css', 'FrmStylesController::load_css' ); |
|
| 177 | + add_action( 'wp_ajax_nopriv_frmpro_load_css', 'FrmStylesController::load_css' ); |
|
| 178 | 178 | add_action( 'wp_ajax_frmpro_css', 'FrmStylesController::load_saved_css' ); |
| 179 | 179 | add_action( 'wp_ajax_nopriv_frmpro_css', 'FrmStylesController::load_saved_css' ); |
| 180 | 180 | |
| 181 | - // XML Controller |
|
| 181 | + // XML Controller |
|
| 182 | 182 | add_action( 'wp_ajax_frm_entries_csv', 'FrmXMLController::csv' ); |
| 183 | 183 | add_action( 'wp_ajax_nopriv_frm_entries_csv', 'FrmXMLController::csv' ); |
| 184 | - add_action( 'wp_ajax_frm_export_xml', 'FrmXMLController::export_xml' ); |
|
| 185 | - } |
|
| 184 | + add_action( 'wp_ajax_frm_export_xml', 'FrmXMLController::export_xml' ); |
|
| 185 | + } |
|
| 186 | 186 | |
| 187 | 187 | public static function load_form_hooks() { |
| 188 | - // Fields Controller |
|
| 189 | - add_filter( 'frm_field_type', 'FrmFieldsController::change_type' ); |
|
| 190 | - add_action( 'frm_field_input_html', 'FrmFieldsController::input_html' ); |
|
| 191 | - add_filter( 'frm_field_value_saved', 'FrmFieldsController::check_value', 50, 3 ); |
|
| 192 | - add_filter( 'frm_field_label_seen', 'FrmFieldsController::check_label' ); |
|
| 188 | + // Fields Controller |
|
| 189 | + add_filter( 'frm_field_type', 'FrmFieldsController::change_type' ); |
|
| 190 | + add_action( 'frm_field_input_html', 'FrmFieldsController::input_html' ); |
|
| 191 | + add_filter( 'frm_field_value_saved', 'FrmFieldsController::check_value', 50, 3 ); |
|
| 192 | + add_filter( 'frm_field_label_seen', 'FrmFieldsController::check_label' ); |
|
| 193 | 193 | |
| 194 | 194 | // Forms Controller |
| 195 | 195 | add_filter( 'frm_form_classes', 'FrmFormsController::form_classes' ); |
| 196 | 196 | |
| 197 | - // Styles Controller |
|
| 198 | - add_filter( 'frm_use_important_width', 'FrmStylesController::important_style', 10, 2 ); |
|
| 199 | - } |
|
| 197 | + // Styles Controller |
|
| 198 | + add_filter( 'frm_use_important_width', 'FrmStylesController::important_style', 10, 2 ); |
|
| 199 | + } |
|
| 200 | 200 | |
| 201 | 201 | public static function load_view_hooks() { |
| 202 | - // Hooks go here when a view is loaded |
|
| 203 | - } |
|
| 202 | + // Hooks go here when a view is loaded |
|
| 203 | + } |
|
| 204 | 204 | |
| 205 | 205 | public static function load_multisite_hooks() { |
| 206 | 206 | add_action( 'wpmu_upgrade_site', 'FrmAppController::network_upgrade_site' ); |
| 207 | 207 | |
| 208 | - // drop tables when mu site is deleted |
|
| 209 | - add_filter( 'wpmu_drop_tables', 'FrmAppController::drop_tables' ); |
|
| 210 | - } |
|
| 208 | + // drop tables when mu site is deleted |
|
| 209 | + add_filter( 'wpmu_drop_tables', 'FrmAppController::drop_tables' ); |
|
| 210 | + } |
|
| 211 | 211 | } |
@@ -3,14 +3,14 @@ discard block |
||
| 3 | 3 | class FrmAppController { |
| 4 | 4 | |
| 5 | 5 | public static function menu() { |
| 6 | - FrmAppHelper::maybe_add_permissions(); |
|
| 7 | - if ( ! current_user_can( 'frm_view_forms' ) ) { |
|
| 8 | - return; |
|
| 9 | - } |
|
| 6 | + FrmAppHelper::maybe_add_permissions(); |
|
| 7 | + if ( ! current_user_can( 'frm_view_forms' ) ) { |
|
| 8 | + return; |
|
| 9 | + } |
|
| 10 | 10 | |
| 11 | 11 | $menu_name = FrmAppHelper::get_menu_name(); |
| 12 | 12 | add_menu_page( 'Formidable', $menu_name, 'frm_view_forms', 'formidable', 'FrmFormsController::route', '', self::get_menu_position() ); |
| 13 | - } |
|
| 13 | + } |
|
| 14 | 14 | |
| 15 | 15 | private static function get_menu_position() { |
| 16 | 16 | $count = count( get_post_types( array( 'show_ui' => true, '_builtin' => false, 'show_in_menu' => true ) ) ); |
@@ -19,15 +19,15 @@ discard block |
||
| 19 | 19 | return $pos; |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | - public static function load_wp_admin_style() { |
|
| 23 | - FrmAppHelper::load_font_style(); |
|
| 24 | - } |
|
| 22 | + public static function load_wp_admin_style() { |
|
| 23 | + FrmAppHelper::load_font_style(); |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | 26 | public static function get_form_nav( $form, $show_nav = false, $title = 'show' ) { |
| 27 | 27 | $show_nav = FrmAppHelper::get_param( 'show_nav', $show_nav, 'get', 'absint' ); |
| 28 | - if ( empty( $show_nav ) || ! $form ) { |
|
| 29 | - return; |
|
| 30 | - } |
|
| 28 | + if ( empty( $show_nav ) || ! $form ) { |
|
| 29 | + return; |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | 32 | FrmForm::maybe_get_form( $form ); |
| 33 | 33 | if ( ! is_object( $form ) ) { |
@@ -85,28 +85,28 @@ discard block |
||
| 85 | 85 | return $nav_items; |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - // Adds a settings link to the plugins page |
|
| 89 | - public static function settings_link( $links ) { |
|
| 88 | + // Adds a settings link to the plugins page |
|
| 89 | + public static function settings_link( $links ) { |
|
| 90 | 90 | $settings = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-settings' ) ) . '">' . __( 'Settings', 'formidable' ) . '</a>'; |
| 91 | - array_unshift( $links, $settings ); |
|
| 91 | + array_unshift( $links, $settings ); |
|
| 92 | 92 | |
| 93 | - return $links; |
|
| 94 | - } |
|
| 93 | + return $links; |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | - public static function pro_get_started_headline() { |
|
| 96 | + public static function pro_get_started_headline() { |
|
| 97 | 97 | self::maybe_show_upgrade_bar(); |
| 98 | 98 | |
| 99 | - // Don't display this error as we're upgrading the thing, or if the user shouldn't see the message |
|
| 100 | - if ( 'upgrade-plugin' == FrmAppHelper::simple_get( 'action', 'sanitize_title' ) || ! current_user_can( 'update_plugins' ) ) { |
|
| 101 | - return; |
|
| 102 | - } |
|
| 99 | + // Don't display this error as we're upgrading the thing, or if the user shouldn't see the message |
|
| 100 | + if ( 'upgrade-plugin' == FrmAppHelper::simple_get( 'action', 'sanitize_title' ) || ! current_user_can( 'update_plugins' ) ) { |
|
| 101 | + return; |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | 104 | if ( get_site_option( 'frmpro-authorized' ) && ! file_exists( FrmAppHelper::plugin_path() . '/pro/formidable-pro.php' ) ) { |
| 105 | - FrmAppHelper::load_admin_wide_js(); |
|
| 105 | + FrmAppHelper::load_admin_wide_js(); |
|
| 106 | 106 | |
| 107 | - // user is authorized, but running free version |
|
| 108 | - $inst_install_url = 'https://formidableforms.com/knowledgebase/install-formidable-forms/'; |
|
| 109 | - ?> |
|
| 107 | + // user is authorized, but running free version |
|
| 108 | + $inst_install_url = 'https://formidableforms.com/knowledgebase/install-formidable-forms/'; |
|
| 109 | + ?> |
|
| 110 | 110 | <div class="error" class="frm_previous_install"> |
| 111 | 111 | <?php |
| 112 | 112 | echo wp_kses_post( apply_filters( 'frm_pro_update_msg', |
@@ -118,8 +118,8 @@ discard block |
||
| 118 | 118 | ) ); ?> |
| 119 | 119 | </div> |
| 120 | 120 | <?php |
| 121 | - } |
|
| 122 | - } |
|
| 121 | + } |
|
| 122 | + } |
|
| 123 | 123 | |
| 124 | 124 | private static function maybe_show_upgrade_bar() { |
| 125 | 125 | $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' ); |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | } |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | - public static function admin_js() { |
|
| 227 | + public static function admin_js() { |
|
| 228 | 228 | $version = FrmAppHelper::plugin_version(); |
| 229 | 229 | FrmAppHelper::load_admin_wide_js( false ); |
| 230 | 230 | |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | 'bootstrap_tooltip', 'bootstrap-multiselect', |
| 236 | 236 | ), $version, true ); |
| 237 | 237 | wp_register_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css', array(), $version ); |
| 238 | - wp_register_script( 'bootstrap_tooltip', FrmAppHelper::plugin_url() . '/js/bootstrap.min.js', array( 'jquery' ), '3.3.4' ); |
|
| 238 | + wp_register_script( 'bootstrap_tooltip', FrmAppHelper::plugin_url() . '/js/bootstrap.min.js', array( 'jquery' ), '3.3.4' ); |
|
| 239 | 239 | wp_register_style( 'formidable-grids', FrmAppHelper::plugin_url() . '/css/frm_grids.css', array(), $version ); |
| 240 | 240 | |
| 241 | 241 | // load multselect js |
@@ -247,50 +247,50 @@ discard block |
||
| 247 | 247 | global $pagenow; |
| 248 | 248 | if ( strpos( $page, 'formidable' ) === 0 || ( $pagenow == 'edit.php' && $post_type == 'frm_display' ) ) { |
| 249 | 249 | |
| 250 | - wp_enqueue_script( 'admin-widgets' ); |
|
| 251 | - wp_enqueue_style( 'widgets' ); |
|
| 252 | - wp_enqueue_script( 'formidable' ); |
|
| 253 | - wp_enqueue_script( 'formidable_admin' ); |
|
| 250 | + wp_enqueue_script( 'admin-widgets' ); |
|
| 251 | + wp_enqueue_style( 'widgets' ); |
|
| 252 | + wp_enqueue_script( 'formidable' ); |
|
| 253 | + wp_enqueue_script( 'formidable_admin' ); |
|
| 254 | 254 | FrmAppHelper::localize_script( 'admin' ); |
| 255 | 255 | |
| 256 | - wp_enqueue_style( 'formidable-admin' ); |
|
| 256 | + wp_enqueue_style( 'formidable-admin' ); |
|
| 257 | 257 | wp_enqueue_style( 'formidable-grids' ); |
| 258 | 258 | wp_enqueue_style( 'formidable-dropzone' ); |
| 259 | - add_thickbox(); |
|
| 259 | + add_thickbox(); |
|
| 260 | 260 | |
| 261 | - wp_register_script( 'formidable-editinplace', FrmAppHelper::plugin_url() . '/js/jquery/jquery.editinplace.packed.js', array( 'jquery' ), '2.3.0' ); |
|
| 261 | + wp_register_script( 'formidable-editinplace', FrmAppHelper::plugin_url() . '/js/jquery/jquery.editinplace.packed.js', array( 'jquery' ), '2.3.0' ); |
|
| 262 | 262 | |
| 263 | - } else if ( $pagenow == 'post.php' || ( $pagenow == 'post-new.php' && $post_type == 'frm_display' ) ) { |
|
| 264 | - if ( isset( $_REQUEST['post_type'] ) ) { |
|
| 265 | - $post_type = sanitize_title( $_REQUEST['post_type'] ); |
|
| 263 | + } else if ( $pagenow == 'post.php' || ( $pagenow == 'post-new.php' && $post_type == 'frm_display' ) ) { |
|
| 264 | + if ( isset( $_REQUEST['post_type'] ) ) { |
|
| 265 | + $post_type = sanitize_title( $_REQUEST['post_type'] ); |
|
| 266 | 266 | } else if ( isset( $_REQUEST['post'] ) && absint( $_REQUEST['post'] ) ) { |
| 267 | 267 | $post = get_post( absint( $_REQUEST['post'] ) ); |
| 268 | - if ( ! $post ) { |
|
| 269 | - return; |
|
| 270 | - } |
|
| 271 | - $post_type = $post->post_type; |
|
| 272 | - } else { |
|
| 273 | - return; |
|
| 274 | - } |
|
| 275 | - |
|
| 276 | - if ( $post_type == 'frm_display' ) { |
|
| 277 | - wp_enqueue_script( 'jquery-ui-draggable' ); |
|
| 278 | - wp_enqueue_script( 'formidable_admin' ); |
|
| 279 | - wp_enqueue_style( 'formidable-admin' ); |
|
| 268 | + if ( ! $post ) { |
|
| 269 | + return; |
|
| 270 | + } |
|
| 271 | + $post_type = $post->post_type; |
|
| 272 | + } else { |
|
| 273 | + return; |
|
| 274 | + } |
|
| 275 | + |
|
| 276 | + if ( $post_type == 'frm_display' ) { |
|
| 277 | + wp_enqueue_script( 'jquery-ui-draggable' ); |
|
| 278 | + wp_enqueue_script( 'formidable_admin' ); |
|
| 279 | + wp_enqueue_style( 'formidable-admin' ); |
|
| 280 | 280 | FrmAppHelper::localize_script( 'admin' ); |
| 281 | - } |
|
| 282 | - } else if ( $pagenow == 'widgets.php' ) { |
|
| 283 | - FrmAppHelper::load_admin_wide_js(); |
|
| 284 | - } |
|
| 285 | - } |
|
| 286 | - |
|
| 287 | - public static function load_lang() { |
|
| 288 | - load_plugin_textdomain( 'formidable', false, FrmAppHelper::plugin_folder() . '/languages/' ); |
|
| 289 | - } |
|
| 290 | - |
|
| 291 | - /** |
|
| 292 | - * Filter shortcodes in text widgets |
|
| 293 | - */ |
|
| 281 | + } |
|
| 282 | + } else if ( $pagenow == 'widgets.php' ) { |
|
| 283 | + FrmAppHelper::load_admin_wide_js(); |
|
| 284 | + } |
|
| 285 | + } |
|
| 286 | + |
|
| 287 | + public static function load_lang() { |
|
| 288 | + load_plugin_textdomain( 'formidable', false, FrmAppHelper::plugin_folder() . '/languages/' ); |
|
| 289 | + } |
|
| 290 | + |
|
| 291 | + /** |
|
| 292 | + * Filter shortcodes in text widgets |
|
| 293 | + */ |
|
| 294 | 294 | public static function widget_text_filter( $content ) { |
| 295 | 295 | _deprecated_function( __METHOD__, '2.5.4' ); |
| 296 | 296 | $regex = '/\[\s*(formidable|display-frm-data|frm-stats|frm-graph|frm-entry-links|formresults|frm-search)\s+.*\]/'; |
@@ -360,20 +360,20 @@ discard block |
||
| 360 | 360 | wp_die(); |
| 361 | 361 | } |
| 362 | 362 | |
| 363 | - public static function activation_install() { |
|
| 364 | - FrmAppHelper::delete_cache_and_transient( 'frm_plugin_version' ); |
|
| 365 | - FrmFormActionsController::actions_init(); |
|
| 366 | - self::install(); |
|
| 367 | - } |
|
| 363 | + public static function activation_install() { |
|
| 364 | + FrmAppHelper::delete_cache_and_transient( 'frm_plugin_version' ); |
|
| 365 | + FrmFormActionsController::actions_init(); |
|
| 366 | + self::install(); |
|
| 367 | + } |
|
| 368 | 368 | |
| 369 | - public static function install( $old_db_version = false ) { |
|
| 370 | - $frmdb = new FrmDb(); |
|
| 371 | - $frmdb->upgrade( $old_db_version ); |
|
| 372 | - } |
|
| 369 | + public static function install( $old_db_version = false ) { |
|
| 370 | + $frmdb = new FrmDb(); |
|
| 371 | + $frmdb->upgrade( $old_db_version ); |
|
| 372 | + } |
|
| 373 | 373 | |
| 374 | - public static function uninstall() { |
|
| 374 | + public static function uninstall() { |
|
| 375 | 375 | FrmAppHelper::permission_check('administrator'); |
| 376 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 376 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 377 | 377 | |
| 378 | 378 | $frmdb = new FrmDb(); |
| 379 | 379 | $frmdb->uninstall(); |
@@ -382,43 +382,43 @@ discard block |
||
| 382 | 382 | deactivate_plugins( FrmAppHelper::plugin_folder() . '/formidable.php', false, false ); |
| 383 | 383 | echo esc_url_raw( admin_url( 'plugins.php?deactivate=true' ) ); |
| 384 | 384 | |
| 385 | - wp_die(); |
|
| 386 | - } |
|
| 385 | + wp_die(); |
|
| 386 | + } |
|
| 387 | 387 | |
| 388 | - public static function drop_tables( $tables ) { |
|
| 389 | - global $wpdb; |
|
| 390 | - $tables[] = $wpdb->prefix . 'frm_fields'; |
|
| 391 | - $tables[] = $wpdb->prefix . 'frm_forms'; |
|
| 392 | - $tables[] = $wpdb->prefix . 'frm_items'; |
|
| 393 | - $tables[] = $wpdb->prefix . 'frm_item_metas'; |
|
| 394 | - return $tables; |
|
| 395 | - } |
|
| 388 | + public static function drop_tables( $tables ) { |
|
| 389 | + global $wpdb; |
|
| 390 | + $tables[] = $wpdb->prefix . 'frm_fields'; |
|
| 391 | + $tables[] = $wpdb->prefix . 'frm_forms'; |
|
| 392 | + $tables[] = $wpdb->prefix . 'frm_items'; |
|
| 393 | + $tables[] = $wpdb->prefix . 'frm_item_metas'; |
|
| 394 | + return $tables; |
|
| 395 | + } |
|
| 396 | 396 | |
| 397 | - // Routes for wordpress pages -- we're just replacing content here folks. |
|
| 398 | - public static function page_route( $content ) { |
|
| 399 | - global $post; |
|
| 397 | + // Routes for wordpress pages -- we're just replacing content here folks. |
|
| 398 | + public static function page_route( $content ) { |
|
| 399 | + global $post; |
|
| 400 | 400 | |
| 401 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 402 | - if ( $post && $post->ID == $frm_settings->preview_page_id && isset( $_GET['form'] ) ) { |
|
| 403 | - $content = FrmFormsController::page_preview(); |
|
| 404 | - } |
|
| 401 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 402 | + if ( $post && $post->ID == $frm_settings->preview_page_id && isset( $_GET['form'] ) ) { |
|
| 403 | + $content = FrmFormsController::page_preview(); |
|
| 404 | + } |
|
| 405 | 405 | |
| 406 | - return $content; |
|
| 407 | - } |
|
| 406 | + return $content; |
|
| 407 | + } |
|
| 408 | 408 | |
| 409 | - public static function deauthorize() { |
|
| 409 | + public static function deauthorize() { |
|
| 410 | 410 | FrmAppHelper::permission_check('frm_change_settings'); |
| 411 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 412 | - |
|
| 413 | - delete_option( 'frmpro-credentials' ); |
|
| 414 | - delete_option( 'frmpro-authorized' ); |
|
| 415 | - delete_site_option( 'frmpro-credentials' ); |
|
| 416 | - delete_site_option( 'frmpro-authorized' ); |
|
| 417 | - wp_die(); |
|
| 418 | - } |
|
| 419 | - |
|
| 420 | - public static function get_form_shortcode( $atts ) { |
|
| 421 | - _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode()' ); |
|
| 422 | - return FrmFormsController::get_form_shortcode( $atts ); |
|
| 423 | - } |
|
| 411 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 412 | + |
|
| 413 | + delete_option( 'frmpro-credentials' ); |
|
| 414 | + delete_option( 'frmpro-authorized' ); |
|
| 415 | + delete_site_option( 'frmpro-credentials' ); |
|
| 416 | + delete_site_option( 'frmpro-authorized' ); |
|
| 417 | + wp_die(); |
|
| 418 | + } |
|
| 419 | + |
|
| 420 | + public static function get_form_shortcode( $atts ) { |
|
| 421 | + _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode()' ); |
|
| 422 | + return FrmFormsController::get_form_shortcode( $atts ); |
|
| 423 | + } |
|
| 424 | 424 | } |
@@ -1,21 +1,21 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | class FrmStylesController { |
| 4 | - public static $post_type = 'frm_styles'; |
|
| 5 | - public static $screen = 'formidable_page_formidable-styles'; |
|
| 6 | - |
|
| 7 | - public static function load_pro_hooks() { |
|
| 8 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
| 9 | - FrmProStylesController::load_pro_hooks(); |
|
| 10 | - } |
|
| 11 | - } |
|
| 12 | - |
|
| 13 | - public static function register_post_types() { |
|
| 14 | - register_post_type( self::$post_type, array( |
|
| 15 | - 'label' => __( 'Styles', 'formidable' ), |
|
| 16 | - 'public' => false, |
|
| 17 | - 'show_ui' => false, |
|
| 18 | - 'capability_type' => 'page', |
|
| 4 | + public static $post_type = 'frm_styles'; |
|
| 5 | + public static $screen = 'formidable_page_formidable-styles'; |
|
| 6 | + |
|
| 7 | + public static function load_pro_hooks() { |
|
| 8 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
| 9 | + FrmProStylesController::load_pro_hooks(); |
|
| 10 | + } |
|
| 11 | + } |
|
| 12 | + |
|
| 13 | + public static function register_post_types() { |
|
| 14 | + register_post_type( self::$post_type, array( |
|
| 15 | + 'label' => __( 'Styles', 'formidable' ), |
|
| 16 | + 'public' => false, |
|
| 17 | + 'show_ui' => false, |
|
| 18 | + 'capability_type' => 'page', |
|
| 19 | 19 | 'capabilities' => array( |
| 20 | 20 | 'edit_post' => 'frm_change_settings', |
| 21 | 21 | 'edit_posts' => 'frm_change_settings', |
@@ -25,11 +25,11 @@ discard block |
||
| 25 | 25 | 'delete_posts' => 'frm_change_settings', |
| 26 | 26 | 'read_private_posts' => 'read_private_posts', |
| 27 | 27 | ), |
| 28 | - 'supports' => array( |
|
| 28 | + 'supports' => array( |
|
| 29 | 29 | 'title', |
| 30 | - ), |
|
| 31 | - 'has_archive' => false, |
|
| 32 | - 'labels' => array( |
|
| 30 | + ), |
|
| 31 | + 'has_archive' => false, |
|
| 32 | + 'labels' => array( |
|
| 33 | 33 | 'name' => __( 'Styles', 'formidable' ), |
| 34 | 34 | 'singular_name' => __( 'Style', 'formidable' ), |
| 35 | 35 | 'menu_name' => __( 'Style', 'formidable' ), |
@@ -37,19 +37,19 @@ discard block |
||
| 37 | 37 | 'add_new_item' => __( 'Create a New Style', 'formidable' ), |
| 38 | 38 | 'edit_item' => __( 'Edit Style', 'formidable' ), |
| 39 | 39 | ), |
| 40 | - ) ); |
|
| 41 | - } |
|
| 40 | + ) ); |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - public static function menu() { |
|
| 43 | + public static function menu() { |
|
| 44 | 44 | add_submenu_page('formidable', 'Formidable | ' . __( 'Styles', 'formidable' ), __( 'Styles', 'formidable' ), 'frm_change_settings', 'formidable-styles', 'FrmStylesController::route' ); |
| 45 | - } |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - public static function admin_init() { |
|
| 48 | - if ( ! FrmAppHelper::is_admin_page('formidable-styles') ) { |
|
| 49 | - return; |
|
| 50 | - } |
|
| 47 | + public static function admin_init() { |
|
| 48 | + if ( ! FrmAppHelper::is_admin_page('formidable-styles') ) { |
|
| 49 | + return; |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - self::load_pro_hooks(); |
|
| 52 | + self::load_pro_hooks(); |
|
| 53 | 53 | |
| 54 | 54 | $style_tab = FrmAppHelper::get_param( 'frm_action', '', 'get', 'sanitize_title' ); |
| 55 | 55 | if ( $style_tab == 'manage' || $style_tab == 'custom_css' ) { |
@@ -57,19 +57,19 @@ discard block |
||
| 57 | 57 | return; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - wp_enqueue_script('jquery-ui-datepicker'); |
|
| 60 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
| 61 | 61 | |
| 62 | - $version = FrmAppHelper::plugin_version(); |
|
| 62 | + $version = FrmAppHelper::plugin_version(); |
|
| 63 | 63 | $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
| 64 | 64 | wp_enqueue_script( 'jquery-frm-themepicker', FrmAppHelper::plugin_url() . '/js/jquery/jquery-ui-themepicker' . $suffix . '.js', array( 'jquery' ), $version ); |
| 65 | 65 | |
| 66 | 66 | wp_enqueue_style( 'frm-custom-theme', admin_url('admin-ajax.php?action=frmpro_css' ) ); |
| 67 | 67 | |
| 68 | - $style = apply_filters('frm_style_head', false); |
|
| 69 | - if ( $style ) { |
|
| 68 | + $style = apply_filters('frm_style_head', false); |
|
| 69 | + if ( $style ) { |
|
| 70 | 70 | wp_enqueue_style( 'frm-single-custom-theme', admin_url( 'admin-ajax.php?action=frmpro_load_css&flat=1' ) . '&' . http_build_query( $style->post_content ) ); |
| 71 | - } |
|
| 72 | - } |
|
| 71 | + } |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | 74 | public static function enqueue_css( $register = 'enqueue' ) { |
| 75 | 75 | global $frm_vars; |
@@ -163,110 +163,110 @@ discard block |
||
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | public static function new_style( $return = '' ) { |
| 166 | - self::load_styler('default'); |
|
| 167 | - } |
|
| 166 | + self::load_styler('default'); |
|
| 167 | + } |
|
| 168 | 168 | |
| 169 | 169 | public static function duplicate() { |
| 170 | 170 | self::load_styler('default'); |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | public static function edit( $style_id = false, $message = '' ) { |
| 174 | - if ( ! $style_id ) { |
|
| 174 | + if ( ! $style_id ) { |
|
| 175 | 175 | $style_id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
| 176 | - if ( empty($style_id) ) { |
|
| 177 | - $style_id = 'default'; |
|
| 178 | - } |
|
| 179 | - } |
|
| 180 | - |
|
| 181 | - if ( 'default' == $style_id ) { |
|
| 182 | - $style = 'default'; |
|
| 183 | - } else { |
|
| 184 | - $frm_style = new FrmStyle($style_id); |
|
| 185 | - $style = $frm_style->get_one(); |
|
| 186 | - $style = $style->ID; |
|
| 187 | - } |
|
| 188 | - |
|
| 189 | - self::load_styler($style, $message); |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - public static function save() { |
|
| 193 | - $frm_style = new FrmStyle(); |
|
| 194 | - $message = ''; |
|
| 176 | + if ( empty($style_id) ) { |
|
| 177 | + $style_id = 'default'; |
|
| 178 | + } |
|
| 179 | + } |
|
| 180 | + |
|
| 181 | + if ( 'default' == $style_id ) { |
|
| 182 | + $style = 'default'; |
|
| 183 | + } else { |
|
| 184 | + $frm_style = new FrmStyle($style_id); |
|
| 185 | + $style = $frm_style->get_one(); |
|
| 186 | + $style = $style->ID; |
|
| 187 | + } |
|
| 188 | + |
|
| 189 | + self::load_styler($style, $message); |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + public static function save() { |
|
| 193 | + $frm_style = new FrmStyle(); |
|
| 194 | + $message = ''; |
|
| 195 | 195 | $post_id = FrmAppHelper::get_post_param( 'ID', false, 'sanitize_title' ); |
| 196 | 196 | $style_nonce = FrmAppHelper::get_post_param( 'frm_style', '', 'sanitize_text_field' ); |
| 197 | 197 | |
| 198 | 198 | if ( $post_id !== false && wp_verify_nonce( $style_nonce, 'frm_style_nonce' ) ) { |
| 199 | - $id = $frm_style->update($post_id); |
|
| 200 | - if ( empty($post_id) && ! empty($id) ) { |
|
| 201 | - // set the post id to the new style so it will be loaded for editing |
|
| 202 | - $post_id = reset($id); |
|
| 203 | - } |
|
| 204 | - // include the CSS that includes this style |
|
| 199 | + $id = $frm_style->update($post_id); |
|
| 200 | + if ( empty($post_id) && ! empty($id) ) { |
|
| 201 | + // set the post id to the new style so it will be loaded for editing |
|
| 202 | + $post_id = reset($id); |
|
| 203 | + } |
|
| 204 | + // include the CSS that includes this style |
|
| 205 | 205 | echo '<link href="' . esc_url( admin_url( 'admin-ajax.php?action=frmpro_css' ) ) . '" type="text/css" rel="Stylesheet" class="frm-custom-theme" />'; |
| 206 | - $message = __( 'Your styling settings have been saved.', 'formidable' ); |
|
| 207 | - } |
|
| 206 | + $message = __( 'Your styling settings have been saved.', 'formidable' ); |
|
| 207 | + } |
|
| 208 | 208 | |
| 209 | - return self::edit($post_id, $message); |
|
| 210 | - } |
|
| 209 | + return self::edit($post_id, $message); |
|
| 210 | + } |
|
| 211 | 211 | |
| 212 | 212 | public static function load_styler( $style, $message = '' ) { |
| 213 | - global $frm_settings; |
|
| 213 | + global $frm_settings; |
|
| 214 | 214 | |
| 215 | - $frm_style = new FrmStyle(); |
|
| 216 | - $styles = $frm_style->get_all(); |
|
| 215 | + $frm_style = new FrmStyle(); |
|
| 216 | + $styles = $frm_style->get_all(); |
|
| 217 | 217 | |
| 218 | - if ( is_numeric($style) ) { |
|
| 219 | - $style = $styles[ $style ]; |
|
| 220 | - } else if ( 'default' == $style ) { |
|
| 221 | - $style = $frm_style->get_default_style($styles); |
|
| 222 | - } |
|
| 218 | + if ( is_numeric($style) ) { |
|
| 219 | + $style = $styles[ $style ]; |
|
| 220 | + } else if ( 'default' == $style ) { |
|
| 221 | + $style = $frm_style->get_default_style($styles); |
|
| 222 | + } |
|
| 223 | 223 | |
| 224 | - self::add_meta_boxes(); |
|
| 224 | + self::add_meta_boxes(); |
|
| 225 | 225 | |
| 226 | 226 | include( FrmAppHelper::plugin_path() . '/classes/views/styles/show.php' ); |
| 227 | - } |
|
| 227 | + } |
|
| 228 | 228 | |
| 229 | 229 | /** |
| 230 | 230 | * @param string $message |
| 231 | 231 | * @param array|object $forms |
| 232 | 232 | */ |
| 233 | 233 | private static function manage( $message = '', $forms = array() ) { |
| 234 | - $frm_style = new FrmStyle(); |
|
| 235 | - $styles = $frm_style->get_all(); |
|
| 236 | - $default_style = $frm_style->get_default_style($styles); |
|
| 234 | + $frm_style = new FrmStyle(); |
|
| 235 | + $styles = $frm_style->get_all(); |
|
| 236 | + $default_style = $frm_style->get_default_style($styles); |
|
| 237 | 237 | |
| 238 | - if ( empty($forms) ) { |
|
| 239 | - $forms = FrmForm::get_published_forms(); |
|
| 240 | - } |
|
| 238 | + if ( empty($forms) ) { |
|
| 239 | + $forms = FrmForm::get_published_forms(); |
|
| 240 | + } |
|
| 241 | 241 | |
| 242 | 242 | include( FrmAppHelper::plugin_path() . '/classes/views/styles/manage.php' ); |
| 243 | - } |
|
| 243 | + } |
|
| 244 | 244 | |
| 245 | - private static function manage_styles() { |
|
| 245 | + private static function manage_styles() { |
|
| 246 | 246 | $style_nonce = FrmAppHelper::get_post_param( 'frm_manage_style', '', 'sanitize_text_field' ); |
| 247 | 247 | if ( ! $_POST || ! isset( $_POST['style'] ) || ! wp_verify_nonce( $style_nonce, 'frm_manage_style_nonce' ) ) { |
| 248 | - return self::manage(); |
|
| 249 | - } |
|
| 248 | + return self::manage(); |
|
| 249 | + } |
|
| 250 | 250 | |
| 251 | - global $wpdb; |
|
| 251 | + global $wpdb; |
|
| 252 | 252 | |
| 253 | 253 | $forms = FrmForm::get_published_forms(); |
| 254 | - foreach ( $forms as $form ) { |
|
| 255 | - if ( $_POST['style'][ $form->id ] == $_POST['prev_style'][ $form->id ] ) { |
|
| 256 | - continue; |
|
| 257 | - } |
|
| 254 | + foreach ( $forms as $form ) { |
|
| 255 | + if ( $_POST['style'][ $form->id ] == $_POST['prev_style'][ $form->id ] ) { |
|
| 256 | + continue; |
|
| 257 | + } |
|
| 258 | 258 | |
| 259 | - $form->options['custom_style'] = $_POST['style'][ $form->id ]; |
|
| 259 | + $form->options['custom_style'] = $_POST['style'][ $form->id ]; |
|
| 260 | 260 | |
| 261 | 261 | $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => maybe_serialize( $form->options ) ), array( 'id' => $form->id ) ); |
| 262 | - unset($form); |
|
| 263 | - } |
|
| 262 | + unset($form); |
|
| 263 | + } |
|
| 264 | 264 | |
| 265 | - $message = __( 'Your form styles have been saved.', 'formidable' ); |
|
| 266 | - return self::manage($message, $forms); |
|
| 267 | - } |
|
| 265 | + $message = __( 'Your form styles have been saved.', 'formidable' ); |
|
| 266 | + return self::manage($message, $forms); |
|
| 267 | + } |
|
| 268 | 268 | |
| 269 | - public static function custom_css( $message = '', $style = null ) { |
|
| 269 | + public static function custom_css( $message = '', $style = null ) { |
|
| 270 | 270 | if ( function_exists('wp_enqueue_code_editor') ) { |
| 271 | 271 | $id = 'frm_codemirror_box'; |
| 272 | 272 | $settings = wp_enqueue_code_editor( array( |
@@ -284,99 +284,99 @@ discard block |
||
| 284 | 284 | wp_enqueue_script( 'codemirror-css', FrmAppHelper::plugin_url() . '/js/codemirror/css.js', array( 'codemirror' ), '4.7' ); |
| 285 | 285 | } |
| 286 | 286 | |
| 287 | - if ( ! isset($style) ) { |
|
| 288 | - $frm_style = new FrmStyle(); |
|
| 289 | - $style = $frm_style->get_default_style(); |
|
| 290 | - } |
|
| 287 | + if ( ! isset($style) ) { |
|
| 288 | + $frm_style = new FrmStyle(); |
|
| 289 | + $style = $frm_style->get_default_style(); |
|
| 290 | + } |
|
| 291 | 291 | |
| 292 | 292 | include( FrmAppHelper::plugin_path() . '/classes/views/styles/custom_css.php' ); |
| 293 | - } |
|
| 293 | + } |
|
| 294 | 294 | |
| 295 | - public static function save_css() { |
|
| 296 | - $frm_style = new FrmStyle(); |
|
| 295 | + public static function save_css() { |
|
| 296 | + $frm_style = new FrmStyle(); |
|
| 297 | 297 | |
| 298 | - $message = ''; |
|
| 298 | + $message = ''; |
|
| 299 | 299 | $post_id = FrmAppHelper::get_post_param( 'ID', false, 'sanitize_text_field' ); |
| 300 | 300 | $nonce = FrmAppHelper::get_post_param( 'frm_custom_css', '', 'sanitize_text_field' ); |
| 301 | 301 | if ( wp_verify_nonce( $nonce, 'frm_custom_css_nonce' ) ) { |
| 302 | - $frm_style->update($post_id); |
|
| 303 | - $message = __( 'Your styling settings have been saved.', 'formidable' ); |
|
| 304 | - } |
|
| 302 | + $frm_style->update($post_id); |
|
| 303 | + $message = __( 'Your styling settings have been saved.', 'formidable' ); |
|
| 304 | + } |
|
| 305 | 305 | |
| 306 | - return self::custom_css($message); |
|
| 307 | - } |
|
| 306 | + return self::custom_css($message); |
|
| 307 | + } |
|
| 308 | 308 | |
| 309 | - public static function route() { |
|
| 309 | + public static function route() { |
|
| 310 | 310 | $action = FrmAppHelper::get_param( 'frm_action', '', 'get', 'sanitize_title' ); |
| 311 | 311 | |
| 312 | - switch ( $action ) { |
|
| 313 | - case 'edit': |
|
| 314 | - case 'save': |
|
| 315 | - case 'manage': |
|
| 316 | - case 'manage_styles': |
|
| 317 | - case 'custom_css': |
|
| 318 | - case 'save_css': |
|
| 312 | + switch ( $action ) { |
|
| 313 | + case 'edit': |
|
| 314 | + case 'save': |
|
| 315 | + case 'manage': |
|
| 316 | + case 'manage_styles': |
|
| 317 | + case 'custom_css': |
|
| 318 | + case 'save_css': |
|
| 319 | 319 | return self::$action(); |
| 320 | - default: |
|
| 321 | - do_action( 'frm_style_action_route', $action ); |
|
| 322 | - if ( apply_filters( 'frm_style_stop_action_route', false, $action ) ) { |
|
| 323 | - return; |
|
| 324 | - } |
|
| 320 | + default: |
|
| 321 | + do_action( 'frm_style_action_route', $action ); |
|
| 322 | + if ( apply_filters( 'frm_style_stop_action_route', false, $action ) ) { |
|
| 323 | + return; |
|
| 324 | + } |
|
| 325 | 325 | |
| 326 | - if ( 'new_style' == $action || 'duplicate' == $action ) { |
|
| 327 | - return self::$action(); |
|
| 328 | - } |
|
| 326 | + if ( 'new_style' == $action || 'duplicate' == $action ) { |
|
| 327 | + return self::$action(); |
|
| 328 | + } |
|
| 329 | 329 | |
| 330 | - return self::edit(); |
|
| 331 | - } |
|
| 332 | - } |
|
| 330 | + return self::edit(); |
|
| 331 | + } |
|
| 332 | + } |
|
| 333 | 333 | |
| 334 | - public static function reset_styling() { |
|
| 334 | + public static function reset_styling() { |
|
| 335 | 335 | FrmAppHelper::permission_check('frm_change_settings'); |
| 336 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 336 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 337 | 337 | |
| 338 | - $frm_style = new FrmStyle(); |
|
| 339 | - $defaults = $frm_style->get_defaults(); |
|
| 338 | + $frm_style = new FrmStyle(); |
|
| 339 | + $defaults = $frm_style->get_defaults(); |
|
| 340 | 340 | |
| 341 | - echo json_encode( $defaults ); |
|
| 342 | - wp_die(); |
|
| 343 | - } |
|
| 341 | + echo json_encode( $defaults ); |
|
| 342 | + wp_die(); |
|
| 343 | + } |
|
| 344 | 344 | |
| 345 | - public static function change_styling() { |
|
| 346 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 345 | + public static function change_styling() { |
|
| 346 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 347 | 347 | |
| 348 | - $frm_style = new FrmStyle(); |
|
| 349 | - $defaults = $frm_style->get_defaults(); |
|
| 348 | + $frm_style = new FrmStyle(); |
|
| 349 | + $defaults = $frm_style->get_defaults(); |
|
| 350 | 350 | $style = ''; |
| 351 | 351 | |
| 352 | - // remove the # from the colors |
|
| 353 | - foreach ( $_GET['frm_style_setting']['post_content'] as $k => $v ) { |
|
| 354 | - if ( ! is_array($v) && strpos($v, '#') === 0 ) { |
|
| 355 | - $_GET['frm_style_setting']['post_content'][ $k ] = str_replace( '#', '', $v ); |
|
| 356 | - } |
|
| 357 | - } |
|
| 352 | + // remove the # from the colors |
|
| 353 | + foreach ( $_GET['frm_style_setting']['post_content'] as $k => $v ) { |
|
| 354 | + if ( ! is_array($v) && strpos($v, '#') === 0 ) { |
|
| 355 | + $_GET['frm_style_setting']['post_content'][ $k ] = str_replace( '#', '', $v ); |
|
| 356 | + } |
|
| 357 | + } |
|
| 358 | 358 | |
| 359 | - echo '<style type="text/css">'; |
|
| 359 | + echo '<style type="text/css">'; |
|
| 360 | 360 | include( FrmAppHelper::plugin_path() . '/css/_single_theme.css.php' ); |
| 361 | - echo '</style>'; |
|
| 362 | - wp_die(); |
|
| 363 | - } |
|
| 364 | - |
|
| 365 | - private static function add_meta_boxes() { |
|
| 366 | - |
|
| 367 | - // setup meta boxes |
|
| 368 | - $meta_boxes = array( |
|
| 369 | - 'general' => __( 'General', 'formidable' ), |
|
| 370 | - 'form-title' => __( 'Form Title', 'formidable' ), |
|
| 371 | - 'form-description' => __( 'Form Description', 'formidable' ), |
|
| 372 | - 'field-labels' => __( 'Field Labels', 'formidable' ), |
|
| 373 | - 'field-description' => __( 'Field Description', 'formidable' ), |
|
| 374 | - 'field-colors' => __( 'Field Colors', 'formidable' ), |
|
| 375 | - 'field-sizes' => __( 'Field Settings', 'formidable' ), |
|
| 376 | - 'check-box-radio-fields' => __( 'Check Box & Radio Fields', 'formidable' ), |
|
| 377 | - 'buttons' => __( 'Buttons', 'formidable' ), |
|
| 378 | - 'form-messages' => __( 'Form Messages', 'formidable' ), |
|
| 379 | - ); |
|
| 361 | + echo '</style>'; |
|
| 362 | + wp_die(); |
|
| 363 | + } |
|
| 364 | + |
|
| 365 | + private static function add_meta_boxes() { |
|
| 366 | + |
|
| 367 | + // setup meta boxes |
|
| 368 | + $meta_boxes = array( |
|
| 369 | + 'general' => __( 'General', 'formidable' ), |
|
| 370 | + 'form-title' => __( 'Form Title', 'formidable' ), |
|
| 371 | + 'form-description' => __( 'Form Description', 'formidable' ), |
|
| 372 | + 'field-labels' => __( 'Field Labels', 'formidable' ), |
|
| 373 | + 'field-description' => __( 'Field Description', 'formidable' ), |
|
| 374 | + 'field-colors' => __( 'Field Colors', 'formidable' ), |
|
| 375 | + 'field-sizes' => __( 'Field Settings', 'formidable' ), |
|
| 376 | + 'check-box-radio-fields' => __( 'Check Box & Radio Fields', 'formidable' ), |
|
| 377 | + 'buttons' => __( 'Buttons', 'formidable' ), |
|
| 378 | + 'form-messages' => __( 'Form Messages', 'formidable' ), |
|
| 379 | + ); |
|
| 380 | 380 | |
| 381 | 381 | /** |
| 382 | 382 | * Add custom boxes to the styling settings |
@@ -384,14 +384,14 @@ discard block |
||
| 384 | 384 | */ |
| 385 | 385 | $meta_boxes = apply_filters( 'frm_style_boxes', $meta_boxes ); |
| 386 | 386 | |
| 387 | - foreach ( $meta_boxes as $nicename => $name ) { |
|
| 387 | + foreach ( $meta_boxes as $nicename => $name ) { |
|
| 388 | 388 | add_meta_box( $nicename . '-style', $name, 'FrmStylesController::include_style_section', self::$screen, 'side', 'default', $nicename ); |
| 389 | - unset($nicename, $name); |
|
| 390 | - } |
|
| 391 | - } |
|
| 389 | + unset($nicename, $name); |
|
| 390 | + } |
|
| 391 | + } |
|
| 392 | 392 | |
| 393 | 393 | public static function include_style_section( $atts, $sec ) { |
| 394 | - extract($atts); |
|
| 394 | + extract($atts); |
|
| 395 | 395 | $current_tab = FrmAppHelper::simple_get( 'page-tab', 'sanitize_title', 'default' ); |
| 396 | 396 | $file_name = FrmAppHelper::plugin_path() . '/classes/views/styles/_' . $sec['args'] . '.php'; |
| 397 | 397 | |
@@ -405,18 +405,18 @@ discard block |
||
| 405 | 405 | $file_name = apply_filters( 'frm_style_settings_' . $sec['args'], $file_name ); |
| 406 | 406 | |
| 407 | 407 | include( $file_name ); |
| 408 | - } |
|
| 408 | + } |
|
| 409 | 409 | |
| 410 | - public static function load_css() { |
|
| 411 | - header('Content-type: text/css'); |
|
| 410 | + public static function load_css() { |
|
| 411 | + header('Content-type: text/css'); |
|
| 412 | 412 | |
| 413 | - $frm_style = new FrmStyle(); |
|
| 414 | - $defaults = $frm_style->get_defaults(); |
|
| 413 | + $frm_style = new FrmStyle(); |
|
| 414 | + $defaults = $frm_style->get_defaults(); |
|
| 415 | 415 | $style = ''; |
| 416 | 416 | |
| 417 | 417 | include( FrmAppHelper::plugin_path() . '/css/_single_theme.css.php' ); |
| 418 | - wp_die(); |
|
| 419 | - } |
|
| 418 | + wp_die(); |
|
| 419 | + } |
|
| 420 | 420 | |
| 421 | 421 | public static function load_saved_css() { |
| 422 | 422 | $css = get_transient( 'frmpro_css' ); |
@@ -425,142 +425,142 @@ discard block |
||
| 425 | 425 | wp_die(); |
| 426 | 426 | } |
| 427 | 427 | |
| 428 | - /** |
|
| 429 | - * Check if the Formidable styling should be loaded, |
|
| 430 | - * then enqueue it for the footer |
|
| 431 | - * @since 2.0 |
|
| 432 | - */ |
|
| 433 | - public static function enqueue_style() { |
|
| 434 | - global $frm_vars; |
|
| 435 | - |
|
| 436 | - if ( isset( $frm_vars['css_loaded'] ) && $frm_vars['css_loaded'] ) { |
|
| 437 | - // the CSS has already been loaded |
|
| 438 | - return; |
|
| 439 | - } |
|
| 440 | - |
|
| 441 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 442 | - if ( $frm_settings->load_style != 'none' ) { |
|
| 443 | - wp_enqueue_style( 'formidable' ); |
|
| 444 | - $frm_vars['css_loaded'] = true; |
|
| 445 | - } |
|
| 446 | - } |
|
| 447 | - |
|
| 448 | - // Get the stylesheets for the form settings page |
|
| 449 | - public static function get_style_opts() { |
|
| 450 | - $frm_style = new FrmStyle(); |
|
| 451 | - $styles = $frm_style->get_all(); |
|
| 452 | - |
|
| 453 | - return $styles; |
|
| 454 | - } |
|
| 455 | - |
|
| 456 | - public static function get_form_style( $form = 'default' ) { |
|
| 457 | - $style = FrmFormsHelper::get_form_style( $form ); |
|
| 458 | - |
|
| 459 | - if ( empty( $style ) || 1 == $style ) { |
|
| 460 | - $style = 'default'; |
|
| 461 | - } |
|
| 462 | - |
|
| 463 | - $frm_style = new FrmStyle( $style ); |
|
| 464 | - return $frm_style->get_one(); |
|
| 465 | - } |
|
| 466 | - |
|
| 467 | - /** |
|
| 468 | - * @param string $class |
|
| 469 | - * @param string $style |
|
| 470 | - */ |
|
| 428 | + /** |
|
| 429 | + * Check if the Formidable styling should be loaded, |
|
| 430 | + * then enqueue it for the footer |
|
| 431 | + * @since 2.0 |
|
| 432 | + */ |
|
| 433 | + public static function enqueue_style() { |
|
| 434 | + global $frm_vars; |
|
| 435 | + |
|
| 436 | + if ( isset( $frm_vars['css_loaded'] ) && $frm_vars['css_loaded'] ) { |
|
| 437 | + // the CSS has already been loaded |
|
| 438 | + return; |
|
| 439 | + } |
|
| 440 | + |
|
| 441 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 442 | + if ( $frm_settings->load_style != 'none' ) { |
|
| 443 | + wp_enqueue_style( 'formidable' ); |
|
| 444 | + $frm_vars['css_loaded'] = true; |
|
| 445 | + } |
|
| 446 | + } |
|
| 447 | + |
|
| 448 | + // Get the stylesheets for the form settings page |
|
| 449 | + public static function get_style_opts() { |
|
| 450 | + $frm_style = new FrmStyle(); |
|
| 451 | + $styles = $frm_style->get_all(); |
|
| 452 | + |
|
| 453 | + return $styles; |
|
| 454 | + } |
|
| 455 | + |
|
| 456 | + public static function get_form_style( $form = 'default' ) { |
|
| 457 | + $style = FrmFormsHelper::get_form_style( $form ); |
|
| 458 | + |
|
| 459 | + if ( empty( $style ) || 1 == $style ) { |
|
| 460 | + $style = 'default'; |
|
| 461 | + } |
|
| 462 | + |
|
| 463 | + $frm_style = new FrmStyle( $style ); |
|
| 464 | + return $frm_style->get_one(); |
|
| 465 | + } |
|
| 466 | + |
|
| 467 | + /** |
|
| 468 | + * @param string $class |
|
| 469 | + * @param string $style |
|
| 470 | + */ |
|
| 471 | 471 | public static function get_form_style_class( $class, $style ) { |
| 472 | - if ( 1 == $style ) { |
|
| 473 | - $style = 'default'; |
|
| 474 | - } |
|
| 472 | + if ( 1 == $style ) { |
|
| 473 | + $style = 'default'; |
|
| 474 | + } |
|
| 475 | 475 | |
| 476 | - $frm_style = new FrmStyle($style); |
|
| 477 | - $style = $frm_style->get_one(); |
|
| 476 | + $frm_style = new FrmStyle($style); |
|
| 477 | + $style = $frm_style->get_one(); |
|
| 478 | 478 | |
| 479 | - if ( $style ) { |
|
| 479 | + if ( $style ) { |
|
| 480 | 480 | $class .= ' frm_style_' . $style->post_name; |
| 481 | - } |
|
| 481 | + } |
|
| 482 | 482 | |
| 483 | - return $class; |
|
| 484 | - } |
|
| 483 | + return $class; |
|
| 484 | + } |
|
| 485 | 485 | |
| 486 | - /** |
|
| 487 | - * @param string $val |
|
| 488 | - */ |
|
| 486 | + /** |
|
| 487 | + * @param string $val |
|
| 488 | + */ |
|
| 489 | 489 | public static function get_style_val( $val, $form = 'default' ) { |
| 490 | - $style = self::get_form_style($form); |
|
| 491 | - if ( $style && isset( $style->post_content[ $val ] ) ) { |
|
| 492 | - return $style->post_content[ $val ]; |
|
| 493 | - } |
|
| 494 | - } |
|
| 490 | + $style = self::get_form_style($form); |
|
| 491 | + if ( $style && isset( $style->post_content[ $val ] ) ) { |
|
| 492 | + return $style->post_content[ $val ]; |
|
| 493 | + } |
|
| 494 | + } |
|
| 495 | 495 | |
| 496 | 496 | public static function show_entry_styles( $default_styles ) { |
| 497 | - $frm_style = new FrmStyle('default'); |
|
| 498 | - $style = $frm_style->get_one(); |
|
| 499 | - |
|
| 500 | - if ( ! $style ) { |
|
| 501 | - return $default_styles; |
|
| 502 | - } |
|
| 503 | - |
|
| 504 | - foreach ( $default_styles as $name => $val ) { |
|
| 505 | - $setting = $name; |
|
| 506 | - if ( 'border_width' == $name ) { |
|
| 507 | - $setting = 'field_border_width'; |
|
| 508 | - } else if ( 'alt_bg_color' == $name ) { |
|
| 509 | - $setting = 'bg_color_active'; |
|
| 510 | - } |
|
| 511 | - $default_styles[ $name ] = $style->post_content[ $setting ]; |
|
| 512 | - unset($name, $val); |
|
| 513 | - } |
|
| 514 | - |
|
| 515 | - return $default_styles; |
|
| 516 | - } |
|
| 497 | + $frm_style = new FrmStyle('default'); |
|
| 498 | + $style = $frm_style->get_one(); |
|
| 499 | + |
|
| 500 | + if ( ! $style ) { |
|
| 501 | + return $default_styles; |
|
| 502 | + } |
|
| 503 | + |
|
| 504 | + foreach ( $default_styles as $name => $val ) { |
|
| 505 | + $setting = $name; |
|
| 506 | + if ( 'border_width' == $name ) { |
|
| 507 | + $setting = 'field_border_width'; |
|
| 508 | + } else if ( 'alt_bg_color' == $name ) { |
|
| 509 | + $setting = 'bg_color_active'; |
|
| 510 | + } |
|
| 511 | + $default_styles[ $name ] = $style->post_content[ $setting ]; |
|
| 512 | + unset($name, $val); |
|
| 513 | + } |
|
| 514 | + |
|
| 515 | + return $default_styles; |
|
| 516 | + } |
|
| 517 | 517 | |
| 518 | 518 | public static function &important_style( $important, $field ) { |
| 519 | - $important = self::get_style_val('important_style', $field['form_id']); |
|
| 520 | - return $important; |
|
| 521 | - } |
|
| 519 | + $important = self::get_style_val('important_style', $field['form_id']); |
|
| 520 | + return $important; |
|
| 521 | + } |
|
| 522 | 522 | |
| 523 | - /** |
|
| 524 | - * Fallback for WP < 3.6 |
|
| 525 | - */ |
|
| 526 | - public static function do_accordion_sections( $screen, $context, $object ) { |
|
| 527 | - if ( function_exists( 'do_accordion_sections' ) ) { |
|
| 528 | - return do_accordion_sections( $screen, $context, $object ); |
|
| 529 | - } |
|
| 523 | + /** |
|
| 524 | + * Fallback for WP < 3.6 |
|
| 525 | + */ |
|
| 526 | + public static function do_accordion_sections( $screen, $context, $object ) { |
|
| 527 | + if ( function_exists( 'do_accordion_sections' ) ) { |
|
| 528 | + return do_accordion_sections( $screen, $context, $object ); |
|
| 529 | + } |
|
| 530 | 530 | |
| 531 | - global $wp_meta_boxes; |
|
| 531 | + global $wp_meta_boxes; |
|
| 532 | 532 | |
| 533 | - $screen = 'formidable_page_formidable-styles'; |
|
| 534 | - $screen = convert_to_screen( $screen ); |
|
| 533 | + $screen = 'formidable_page_formidable-styles'; |
|
| 534 | + $screen = convert_to_screen( $screen ); |
|
| 535 | 535 | |
| 536 | - $page = $screen->id; |
|
| 536 | + $page = $screen->id; |
|
| 537 | 537 | |
| 538 | - $hidden = get_hidden_meta_boxes( $screen ); |
|
| 539 | - ?> |
|
| 538 | + $hidden = get_hidden_meta_boxes( $screen ); |
|
| 539 | + ?> |
|
| 540 | 540 | <div id="side-sortables" class="accordion-container"> |
| 541 | 541 | <?php |
| 542 | - $i = 0; |
|
| 543 | - $first_open = false; |
|
| 544 | - do { |
|
| 542 | + $i = 0; |
|
| 543 | + $first_open = false; |
|
| 544 | + do { |
|
| 545 | 545 | if ( ! isset( $wp_meta_boxes ) || ! isset( $wp_meta_boxes[ $page ] ) || ! isset( $wp_meta_boxes[ $page ][ $context ] ) ) { |
| 546 | 546 | break; |
| 547 | 547 | } |
| 548 | 548 | |
| 549 | - foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) { |
|
| 550 | - if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) { |
|
| 551 | - foreach ( $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) { |
|
| 552 | - if ( false == $box || ! $box['title'] ) { |
|
| 553 | - continue; |
|
| 549 | + foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) { |
|
| 550 | + if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) { |
|
| 551 | + foreach ( $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) { |
|
| 552 | + if ( false == $box || ! $box['title'] ) { |
|
| 553 | + continue; |
|
| 554 | 554 | } |
| 555 | 555 | |
| 556 | - $i++; |
|
| 557 | - $hidden_class = in_array( $box['id'], $hidden ) ? 'hide-if-js' : ''; |
|
| 556 | + $i++; |
|
| 557 | + $hidden_class = in_array( $box['id'], $hidden ) ? 'hide-if-js' : ''; |
|
| 558 | 558 | |
| 559 | - if ( ! $first_open && empty( $hidden_class ) ) { |
|
| 560 | - $first_open = true; |
|
| 561 | - } |
|
| 559 | + if ( ! $first_open && empty( $hidden_class ) ) { |
|
| 560 | + $first_open = true; |
|
| 561 | + } |
|
| 562 | 562 | |
| 563 | - ?> |
|
| 563 | + ?> |
|
| 564 | 564 | <div class="postbox <?php echo esc_attr( $box['id'] ); ?>"> |
| 565 | 565 | <div class="handlediv" title="<?php esc_attr_e( 'Click to toggle', 'formidable' ) ?>"><br/></div> |
| 566 | 566 | <h3 class='hndle'><span><?php echo esc_html( $box['title'] ); ?></span></h3> |
@@ -571,13 +571,13 @@ discard block |
||
| 571 | 571 | </div><!-- .accordion-section-content --> |
| 572 | 572 | </div><!-- .postbox --> |
| 573 | 573 | <?php |
| 574 | - } |
|
| 575 | - } |
|
| 576 | - } |
|
| 577 | - } while ( 0 ); |
|
| 578 | - ?> |
|
| 574 | + } |
|
| 575 | + } |
|
| 576 | + } |
|
| 577 | + } while ( 0 ); |
|
| 578 | + ?> |
|
| 579 | 579 | </div><!-- .accordion-container --> |
| 580 | 580 | <?php |
| 581 | - return $i; |
|
| 582 | - } |
|
| 581 | + return $i; |
|
| 582 | + } |
|
| 583 | 583 | } |
@@ -41,11 +41,11 @@ discard block |
||
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | public static function menu() { |
| 44 | - add_submenu_page('formidable', 'Formidable | ' . __( 'Styles', 'formidable' ), __( 'Styles', 'formidable' ), 'frm_change_settings', 'formidable-styles', 'FrmStylesController::route' ); |
|
| 44 | + add_submenu_page( 'formidable', 'Formidable | ' . __( 'Styles', 'formidable' ), __( 'Styles', 'formidable' ), 'frm_change_settings', 'formidable-styles', 'FrmStylesController::route' ); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | public static function admin_init() { |
| 48 | - if ( ! FrmAppHelper::is_admin_page('formidable-styles') ) { |
|
| 48 | + if ( ! FrmAppHelper::is_admin_page( 'formidable-styles' ) ) { |
|
| 49 | 49 | return; |
| 50 | 50 | } |
| 51 | 51 | |
@@ -57,15 +57,15 @@ discard block |
||
| 57 | 57 | return; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - wp_enqueue_script('jquery-ui-datepicker'); |
|
| 60 | + wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
| 61 | 61 | |
| 62 | 62 | $version = FrmAppHelper::plugin_version(); |
| 63 | 63 | $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
| 64 | 64 | wp_enqueue_script( 'jquery-frm-themepicker', FrmAppHelper::plugin_url() . '/js/jquery/jquery-ui-themepicker' . $suffix . '.js', array( 'jquery' ), $version ); |
| 65 | 65 | |
| 66 | - wp_enqueue_style( 'frm-custom-theme', admin_url('admin-ajax.php?action=frmpro_css' ) ); |
|
| 66 | + wp_enqueue_style( 'frm-custom-theme', admin_url( 'admin-ajax.php?action=frmpro_css' ) ); |
|
| 67 | 67 | |
| 68 | - $style = apply_filters('frm_style_head', false); |
|
| 68 | + $style = apply_filters( 'frm_style_head', false ); |
|
| 69 | 69 | if ( $style ) { |
| 70 | 70 | wp_enqueue_style( 'frm-single-custom-theme', admin_url( 'admin-ajax.php?action=frmpro_load_css&flat=1' ) . '&' . http_build_query( $style->post_content ) ); |
| 71 | 71 | } |
@@ -163,17 +163,17 @@ discard block |
||
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | public static function new_style( $return = '' ) { |
| 166 | - self::load_styler('default'); |
|
| 166 | + self::load_styler( 'default' ); |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | public static function duplicate() { |
| 170 | - self::load_styler('default'); |
|
| 170 | + self::load_styler( 'default' ); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | public static function edit( $style_id = false, $message = '' ) { |
| 174 | 174 | if ( ! $style_id ) { |
| 175 | 175 | $style_id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
| 176 | - if ( empty($style_id) ) { |
|
| 176 | + if ( empty( $style_id ) ) { |
|
| 177 | 177 | $style_id = 'default'; |
| 178 | 178 | } |
| 179 | 179 | } |
@@ -181,12 +181,12 @@ discard block |
||
| 181 | 181 | if ( 'default' == $style_id ) { |
| 182 | 182 | $style = 'default'; |
| 183 | 183 | } else { |
| 184 | - $frm_style = new FrmStyle($style_id); |
|
| 184 | + $frm_style = new FrmStyle( $style_id ); |
|
| 185 | 185 | $style = $frm_style->get_one(); |
| 186 | 186 | $style = $style->ID; |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | - self::load_styler($style, $message); |
|
| 189 | + self::load_styler( $style, $message ); |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | public static function save() { |
@@ -196,17 +196,17 @@ discard block |
||
| 196 | 196 | $style_nonce = FrmAppHelper::get_post_param( 'frm_style', '', 'sanitize_text_field' ); |
| 197 | 197 | |
| 198 | 198 | if ( $post_id !== false && wp_verify_nonce( $style_nonce, 'frm_style_nonce' ) ) { |
| 199 | - $id = $frm_style->update($post_id); |
|
| 200 | - if ( empty($post_id) && ! empty($id) ) { |
|
| 199 | + $id = $frm_style->update( $post_id ); |
|
| 200 | + if ( empty( $post_id ) && ! empty( $id ) ) { |
|
| 201 | 201 | // set the post id to the new style so it will be loaded for editing |
| 202 | - $post_id = reset($id); |
|
| 202 | + $post_id = reset( $id ); |
|
| 203 | 203 | } |
| 204 | 204 | // include the CSS that includes this style |
| 205 | 205 | echo '<link href="' . esc_url( admin_url( 'admin-ajax.php?action=frmpro_css' ) ) . '" type="text/css" rel="Stylesheet" class="frm-custom-theme" />'; |
| 206 | 206 | $message = __( 'Your styling settings have been saved.', 'formidable' ); |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | - return self::edit($post_id, $message); |
|
| 209 | + return self::edit( $post_id, $message ); |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | public static function load_styler( $style, $message = '' ) { |
@@ -215,10 +215,10 @@ discard block |
||
| 215 | 215 | $frm_style = new FrmStyle(); |
| 216 | 216 | $styles = $frm_style->get_all(); |
| 217 | 217 | |
| 218 | - if ( is_numeric($style) ) { |
|
| 219 | - $style = $styles[ $style ]; |
|
| 218 | + if ( is_numeric( $style ) ) { |
|
| 219 | + $style = $styles[$style]; |
|
| 220 | 220 | } else if ( 'default' == $style ) { |
| 221 | - $style = $frm_style->get_default_style($styles); |
|
| 221 | + $style = $frm_style->get_default_style( $styles ); |
|
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | self::add_meta_boxes(); |
@@ -233,9 +233,9 @@ discard block |
||
| 233 | 233 | private static function manage( $message = '', $forms = array() ) { |
| 234 | 234 | $frm_style = new FrmStyle(); |
| 235 | 235 | $styles = $frm_style->get_all(); |
| 236 | - $default_style = $frm_style->get_default_style($styles); |
|
| 236 | + $default_style = $frm_style->get_default_style( $styles ); |
|
| 237 | 237 | |
| 238 | - if ( empty($forms) ) { |
|
| 238 | + if ( empty( $forms ) ) { |
|
| 239 | 239 | $forms = FrmForm::get_published_forms(); |
| 240 | 240 | } |
| 241 | 241 | |
@@ -252,22 +252,22 @@ discard block |
||
| 252 | 252 | |
| 253 | 253 | $forms = FrmForm::get_published_forms(); |
| 254 | 254 | foreach ( $forms as $form ) { |
| 255 | - if ( $_POST['style'][ $form->id ] == $_POST['prev_style'][ $form->id ] ) { |
|
| 255 | + if ( $_POST['style'][$form->id] == $_POST['prev_style'][$form->id] ) { |
|
| 256 | 256 | continue; |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | - $form->options['custom_style'] = $_POST['style'][ $form->id ]; |
|
| 259 | + $form->options['custom_style'] = $_POST['style'][$form->id]; |
|
| 260 | 260 | |
| 261 | 261 | $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => maybe_serialize( $form->options ) ), array( 'id' => $form->id ) ); |
| 262 | - unset($form); |
|
| 262 | + unset( $form ); |
|
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | $message = __( 'Your form styles have been saved.', 'formidable' ); |
| 266 | - return self::manage($message, $forms); |
|
| 266 | + return self::manage( $message, $forms ); |
|
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | public static function custom_css( $message = '', $style = null ) { |
| 270 | - if ( function_exists('wp_enqueue_code_editor') ) { |
|
| 270 | + if ( function_exists( 'wp_enqueue_code_editor' ) ) { |
|
| 271 | 271 | $id = 'frm_codemirror_box'; |
| 272 | 272 | $settings = wp_enqueue_code_editor( array( |
| 273 | 273 | 'type' => 'text/css', |
@@ -279,12 +279,12 @@ discard block |
||
| 279 | 279 | } else { |
| 280 | 280 | $id = 'frm_custom_css_box'; |
| 281 | 281 | $settings = array(); |
| 282 | - wp_enqueue_style('codemirror', FrmAppHelper::plugin_url() . '/css/codemirror.css'); |
|
| 283 | - wp_enqueue_script('codemirror', FrmAppHelper::plugin_url() . '/js/codemirror/codemirror.js', array(), '4.7'); |
|
| 282 | + wp_enqueue_style( 'codemirror', FrmAppHelper::plugin_url() . '/css/codemirror.css' ); |
|
| 283 | + wp_enqueue_script( 'codemirror', FrmAppHelper::plugin_url() . '/js/codemirror/codemirror.js', array(), '4.7' ); |
|
| 284 | 284 | wp_enqueue_script( 'codemirror-css', FrmAppHelper::plugin_url() . '/js/codemirror/css.js', array( 'codemirror' ), '4.7' ); |
| 285 | 285 | } |
| 286 | 286 | |
| 287 | - if ( ! isset($style) ) { |
|
| 287 | + if ( ! isset( $style ) ) { |
|
| 288 | 288 | $frm_style = new FrmStyle(); |
| 289 | 289 | $style = $frm_style->get_default_style(); |
| 290 | 290 | } |
@@ -299,11 +299,11 @@ discard block |
||
| 299 | 299 | $post_id = FrmAppHelper::get_post_param( 'ID', false, 'sanitize_text_field' ); |
| 300 | 300 | $nonce = FrmAppHelper::get_post_param( 'frm_custom_css', '', 'sanitize_text_field' ); |
| 301 | 301 | if ( wp_verify_nonce( $nonce, 'frm_custom_css_nonce' ) ) { |
| 302 | - $frm_style->update($post_id); |
|
| 302 | + $frm_style->update( $post_id ); |
|
| 303 | 303 | $message = __( 'Your styling settings have been saved.', 'formidable' ); |
| 304 | 304 | } |
| 305 | 305 | |
| 306 | - return self::custom_css($message); |
|
| 306 | + return self::custom_css( $message ); |
|
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | public static function route() { |
@@ -332,7 +332,7 @@ discard block |
||
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | public static function reset_styling() { |
| 335 | - FrmAppHelper::permission_check('frm_change_settings'); |
|
| 335 | + FrmAppHelper::permission_check( 'frm_change_settings' ); |
|
| 336 | 336 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 337 | 337 | |
| 338 | 338 | $frm_style = new FrmStyle(); |
@@ -351,8 +351,8 @@ discard block |
||
| 351 | 351 | |
| 352 | 352 | // remove the # from the colors |
| 353 | 353 | foreach ( $_GET['frm_style_setting']['post_content'] as $k => $v ) { |
| 354 | - if ( ! is_array($v) && strpos($v, '#') === 0 ) { |
|
| 355 | - $_GET['frm_style_setting']['post_content'][ $k ] = str_replace( '#', '', $v ); |
|
| 354 | + if ( ! is_array( $v ) && strpos( $v, '#' ) === 0 ) { |
|
| 355 | + $_GET['frm_style_setting']['post_content'][$k] = str_replace( '#', '', $v ); |
|
| 356 | 356 | } |
| 357 | 357 | } |
| 358 | 358 | |
@@ -386,12 +386,12 @@ discard block |
||
| 386 | 386 | |
| 387 | 387 | foreach ( $meta_boxes as $nicename => $name ) { |
| 388 | 388 | add_meta_box( $nicename . '-style', $name, 'FrmStylesController::include_style_section', self::$screen, 'side', 'default', $nicename ); |
| 389 | - unset($nicename, $name); |
|
| 389 | + unset( $nicename, $name ); |
|
| 390 | 390 | } |
| 391 | 391 | } |
| 392 | 392 | |
| 393 | 393 | public static function include_style_section( $atts, $sec ) { |
| 394 | - extract($atts); |
|
| 394 | + extract( $atts ); |
|
| 395 | 395 | $current_tab = FrmAppHelper::simple_get( 'page-tab', 'sanitize_title', 'default' ); |
| 396 | 396 | $file_name = FrmAppHelper::plugin_path() . '/classes/views/styles/_' . $sec['args'] . '.php'; |
| 397 | 397 | |
@@ -408,7 +408,7 @@ discard block |
||
| 408 | 408 | } |
| 409 | 409 | |
| 410 | 410 | public static function load_css() { |
| 411 | - header('Content-type: text/css'); |
|
| 411 | + header( 'Content-type: text/css' ); |
|
| 412 | 412 | |
| 413 | 413 | $frm_style = new FrmStyle(); |
| 414 | 414 | $defaults = $frm_style->get_defaults(); |
@@ -473,7 +473,7 @@ discard block |
||
| 473 | 473 | $style = 'default'; |
| 474 | 474 | } |
| 475 | 475 | |
| 476 | - $frm_style = new FrmStyle($style); |
|
| 476 | + $frm_style = new FrmStyle( $style ); |
|
| 477 | 477 | $style = $frm_style->get_one(); |
| 478 | 478 | |
| 479 | 479 | if ( $style ) { |
@@ -487,14 +487,14 @@ discard block |
||
| 487 | 487 | * @param string $val |
| 488 | 488 | */ |
| 489 | 489 | public static function get_style_val( $val, $form = 'default' ) { |
| 490 | - $style = self::get_form_style($form); |
|
| 491 | - if ( $style && isset( $style->post_content[ $val ] ) ) { |
|
| 492 | - return $style->post_content[ $val ]; |
|
| 490 | + $style = self::get_form_style( $form ); |
|
| 491 | + if ( $style && isset( $style->post_content[$val] ) ) { |
|
| 492 | + return $style->post_content[$val]; |
|
| 493 | 493 | } |
| 494 | 494 | } |
| 495 | 495 | |
| 496 | 496 | public static function show_entry_styles( $default_styles ) { |
| 497 | - $frm_style = new FrmStyle('default'); |
|
| 497 | + $frm_style = new FrmStyle( 'default' ); |
|
| 498 | 498 | $style = $frm_style->get_one(); |
| 499 | 499 | |
| 500 | 500 | if ( ! $style ) { |
@@ -508,15 +508,15 @@ discard block |
||
| 508 | 508 | } else if ( 'alt_bg_color' == $name ) { |
| 509 | 509 | $setting = 'bg_color_active'; |
| 510 | 510 | } |
| 511 | - $default_styles[ $name ] = $style->post_content[ $setting ]; |
|
| 512 | - unset($name, $val); |
|
| 511 | + $default_styles[$name] = $style->post_content[$setting]; |
|
| 512 | + unset( $name, $val ); |
|
| 513 | 513 | } |
| 514 | 514 | |
| 515 | 515 | return $default_styles; |
| 516 | 516 | } |
| 517 | 517 | |
| 518 | 518 | public static function &important_style( $important, $field ) { |
| 519 | - $important = self::get_style_val('important_style', $field['form_id']); |
|
| 519 | + $important = self::get_style_val( 'important_style', $field['form_id'] ); |
|
| 520 | 520 | return $important; |
| 521 | 521 | } |
| 522 | 522 | |
@@ -542,18 +542,18 @@ discard block |
||
| 542 | 542 | $i = 0; |
| 543 | 543 | $first_open = false; |
| 544 | 544 | do { |
| 545 | - if ( ! isset( $wp_meta_boxes ) || ! isset( $wp_meta_boxes[ $page ] ) || ! isset( $wp_meta_boxes[ $page ][ $context ] ) ) { |
|
| 545 | + if ( ! isset( $wp_meta_boxes ) || ! isset( $wp_meta_boxes[$page] ) || ! isset( $wp_meta_boxes[$page][$context] ) ) { |
|
| 546 | 546 | break; |
| 547 | 547 | } |
| 548 | 548 | |
| 549 | 549 | foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) { |
| 550 | - if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) { |
|
| 551 | - foreach ( $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) { |
|
| 550 | + if ( isset( $wp_meta_boxes[$page][$context][$priority] ) ) { |
|
| 551 | + foreach ( $wp_meta_boxes[$page][$context][$priority] as $box ) { |
|
| 552 | 552 | if ( false == $box || ! $box['title'] ) { |
| 553 | 553 | continue; |
| 554 | 554 | } |
| 555 | 555 | |
| 556 | - $i++; |
|
| 556 | + $i ++; |
|
| 557 | 557 | $hidden_class = in_array( $box['id'], $hidden ) ? 'hide-if-js' : ''; |
| 558 | 558 | |
| 559 | 559 | if ( ! $first_open && empty( $hidden_class ) ) { |