@@ -1,66 +1,66 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | class FrmDb { |
| 4 | - var $fields; |
|
| 5 | - var $forms; |
|
| 6 | - var $entries; |
|
| 7 | - var $entry_metas; |
|
| 8 | - |
|
| 9 | - public function __construct() { |
|
| 10 | - if ( ! defined('ABSPATH') ) { |
|
| 11 | - die('You are not allowed to call this page directly.'); |
|
| 12 | - } |
|
| 13 | - |
|
| 14 | - global $wpdb; |
|
| 15 | - $this->fields = $wpdb->prefix . 'frm_fields'; |
|
| 16 | - $this->forms = $wpdb->prefix . 'frm_forms'; |
|
| 17 | - $this->entries = $wpdb->prefix . 'frm_items'; |
|
| 18 | - $this->entry_metas = $wpdb->prefix . 'frm_item_metas'; |
|
| 19 | - } |
|
| 20 | - |
|
| 21 | - public function upgrade( $old_db_version = false ) { |
|
| 22 | - do_action( 'frm_before_install' ); |
|
| 23 | - |
|
| 24 | - global $wpdb; |
|
| 25 | - //$frm_db_version is the version of the database we're moving to |
|
| 26 | - $frm_db_version = FrmAppHelper::$db_version; |
|
| 27 | - $old_db_version = (float) $old_db_version; |
|
| 28 | - if ( ! $old_db_version ) { |
|
| 29 | - $old_db_version = get_option('frm_db_version'); |
|
| 30 | - } |
|
| 31 | - |
|
| 32 | - if ( $frm_db_version != $old_db_version ) { |
|
| 4 | + var $fields; |
|
| 5 | + var $forms; |
|
| 6 | + var $entries; |
|
| 7 | + var $entry_metas; |
|
| 8 | + |
|
| 9 | + public function __construct() { |
|
| 10 | + if ( ! defined('ABSPATH') ) { |
|
| 11 | + die('You are not allowed to call this page directly.'); |
|
| 12 | + } |
|
| 13 | + |
|
| 14 | + global $wpdb; |
|
| 15 | + $this->fields = $wpdb->prefix . 'frm_fields'; |
|
| 16 | + $this->forms = $wpdb->prefix . 'frm_forms'; |
|
| 17 | + $this->entries = $wpdb->prefix . 'frm_items'; |
|
| 18 | + $this->entry_metas = $wpdb->prefix . 'frm_item_metas'; |
|
| 19 | + } |
|
| 20 | + |
|
| 21 | + public function upgrade( $old_db_version = false ) { |
|
| 22 | + do_action( 'frm_before_install' ); |
|
| 23 | + |
|
| 24 | + global $wpdb; |
|
| 25 | + //$frm_db_version is the version of the database we're moving to |
|
| 26 | + $frm_db_version = FrmAppHelper::$db_version; |
|
| 27 | + $old_db_version = (float) $old_db_version; |
|
| 28 | + if ( ! $old_db_version ) { |
|
| 29 | + $old_db_version = get_option('frm_db_version'); |
|
| 30 | + } |
|
| 31 | + |
|
| 32 | + if ( $frm_db_version != $old_db_version ) { |
|
| 33 | 33 | // update rewrite rules for views and other custom post types |
| 34 | 34 | flush_rewrite_rules(); |
| 35 | 35 | |
| 36 | 36 | require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
| 37 | 37 | |
| 38 | - $this->create_tables(); |
|
| 39 | - $this->migrate_data($frm_db_version, $old_db_version); |
|
| 38 | + $this->create_tables(); |
|
| 39 | + $this->migrate_data($frm_db_version, $old_db_version); |
|
| 40 | 40 | |
| 41 | - /***** SAVE DB VERSION *****/ |
|
| 42 | - update_option('frm_db_version', $frm_db_version); |
|
| 41 | + /***** SAVE DB VERSION *****/ |
|
| 42 | + update_option('frm_db_version', $frm_db_version); |
|
| 43 | 43 | |
| 44 | - /**** ADD/UPDATE DEFAULT TEMPLATES ****/ |
|
| 45 | - FrmXMLController::add_default_templates(); |
|
| 46 | - } |
|
| 44 | + /**** ADD/UPDATE DEFAULT TEMPLATES ****/ |
|
| 45 | + FrmXMLController::add_default_templates(); |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - do_action('frm_after_install'); |
|
| 48 | + do_action('frm_after_install'); |
|
| 49 | 49 | |
| 50 | - /**** update the styling settings ****/ |
|
| 50 | + /**** update the styling settings ****/ |
|
| 51 | 51 | if ( is_admin() && function_exists( 'get_filesystem_method' ) ) { |
| 52 | 52 | $frm_style = new FrmStyle(); |
| 53 | 53 | $frm_style->update( 'default' ); |
| 54 | 54 | } |
| 55 | - } |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - public function collation() { |
|
| 58 | - global $wpdb; |
|
| 59 | - if ( ! $wpdb->has_cap( 'collation' ) ) { |
|
| 60 | - return ''; |
|
| 61 | - } |
|
| 57 | + public function collation() { |
|
| 58 | + global $wpdb; |
|
| 59 | + if ( ! $wpdb->has_cap( 'collation' ) ) { |
|
| 60 | + return ''; |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - $charset_collate = ''; |
|
| 63 | + $charset_collate = ''; |
|
| 64 | 64 | if ( ! empty( $wpdb->charset ) ) { |
| 65 | 65 | $charset_collate .= ' DEFAULT CHARACTER SET ' . $wpdb->charset; |
| 66 | 66 | } |
@@ -69,14 +69,14 @@ discard block |
||
| 69 | 69 | $charset_collate .= ' COLLATE ' . $wpdb->collate; |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - return $charset_collate; |
|
| 73 | - } |
|
| 72 | + return $charset_collate; |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - private function create_tables() { |
|
| 76 | - $charset_collate = $this->collation(); |
|
| 77 | - $sql = array(); |
|
| 75 | + private function create_tables() { |
|
| 76 | + $charset_collate = $this->collation(); |
|
| 77 | + $sql = array(); |
|
| 78 | 78 | |
| 79 | - /* Create/Upgrade Fields Table */ |
|
| 79 | + /* Create/Upgrade Fields Table */ |
|
| 80 | 80 | $sql[] = 'CREATE TABLE ' . $this->fields . ' ( |
| 81 | 81 | id int(11) NOT NULL auto_increment, |
| 82 | 82 | field_key varchar(100) default NULL, |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | UNIQUE KEY field_key (field_key) |
| 96 | 96 | )'; |
| 97 | 97 | |
| 98 | - /* Create/Upgrade Forms Table */ |
|
| 98 | + /* Create/Upgrade Forms Table */ |
|
| 99 | 99 | $sql[] = 'CREATE TABLE ' . $this->forms . ' ( |
| 100 | 100 | id int(11) NOT NULL auto_increment, |
| 101 | 101 | form_key varchar(100) default NULL, |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | UNIQUE KEY form_key (form_key) |
| 114 | 114 | )'; |
| 115 | 115 | |
| 116 | - /* Create/Upgrade Items Table */ |
|
| 116 | + /* Create/Upgrade Items Table */ |
|
| 117 | 117 | $sql[] = 'CREATE TABLE ' . $this->entries . ' ( |
| 118 | 118 | id int(11) NOT NULL auto_increment, |
| 119 | 119 | item_key varchar(100) default NULL, |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | UNIQUE KEY item_key (item_key) |
| 137 | 137 | )'; |
| 138 | 138 | |
| 139 | - /* Create/Upgrade Meta Table */ |
|
| 139 | + /* Create/Upgrade Meta Table */ |
|
| 140 | 140 | $sql[] = 'CREATE TABLE ' . $this->entry_metas . ' ( |
| 141 | 141 | id int(11) NOT NULL auto_increment, |
| 142 | 142 | meta_value longtext default NULL, |
@@ -148,43 +148,43 @@ discard block |
||
| 148 | 148 | KEY item_id (item_id) |
| 149 | 149 | )'; |
| 150 | 150 | |
| 151 | - foreach ( $sql as $q ) { |
|
| 151 | + foreach ( $sql as $q ) { |
|
| 152 | 152 | if ( function_exists( 'dbDelta' ) ) { |
| 153 | 153 | dbDelta( $q . $charset_collate . ';' ); |
| 154 | 154 | } else { |
| 155 | 155 | global $wpdb; |
| 156 | 156 | $wpdb->query( $q . $charset_collate ); |
| 157 | 157 | } |
| 158 | - unset($q); |
|
| 159 | - } |
|
| 160 | - } |
|
| 158 | + unset($q); |
|
| 159 | + } |
|
| 160 | + } |
|
| 161 | 161 | |
| 162 | - /** |
|
| 163 | - * @param integer $frm_db_version |
|
| 162 | + /** |
|
| 163 | + * @param integer $frm_db_version |
|
| 164 | 164 | * @param int $old_db_version |
| 165 | - */ |
|
| 165 | + */ |
|
| 166 | 166 | private function migrate_data( $frm_db_version, $old_db_version ) { |
| 167 | 167 | $migrations = array( 4, 6, 11, 16, 17, 23, 25 ); |
| 168 | - foreach ( $migrations as $migration ) { |
|
| 169 | - if ( $frm_db_version >= $migration && $old_db_version < $migration ) { |
|
| 168 | + foreach ( $migrations as $migration ) { |
|
| 169 | + if ( $frm_db_version >= $migration && $old_db_version < $migration ) { |
|
| 170 | 170 | $function_name = 'migrate_to_' . $migration; |
| 171 | - $this->$function_name(); |
|
| 172 | - } |
|
| 173 | - } |
|
| 174 | - } |
|
| 171 | + $this->$function_name(); |
|
| 172 | + } |
|
| 173 | + } |
|
| 174 | + } |
|
| 175 | 175 | |
| 176 | - /** |
|
| 177 | - * Change array into format $wpdb->prepare can use |
|
| 176 | + /** |
|
| 177 | + * Change array into format $wpdb->prepare can use |
|
| 178 | 178 | * |
| 179 | 179 | * @param array $args |
| 180 | 180 | * @param string $starts_with |
| 181 | - */ |
|
| 182 | - public static function get_where_clause_and_values( &$args, $starts_with = ' WHERE ' ) { |
|
| 183 | - if ( empty($args) ) { |
|
| 181 | + */ |
|
| 182 | + public static function get_where_clause_and_values( &$args, $starts_with = ' WHERE ' ) { |
|
| 183 | + if ( empty($args) ) { |
|
| 184 | 184 | // add an arg to prevent prepare from failing |
| 185 | 185 | $args = array( 'where' => $starts_with . '1=%d', 'values' => array( 1 ) ); |
| 186 | 186 | return; |
| 187 | - } |
|
| 187 | + } |
|
| 188 | 188 | |
| 189 | 189 | $where = ''; |
| 190 | 190 | $values = array(); |
@@ -195,64 +195,64 @@ discard block |
||
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | $args = compact( 'where', 'values' ); |
| 198 | - } |
|
| 198 | + } |
|
| 199 | 199 | |
| 200 | - /** |
|
| 200 | + /** |
|
| 201 | 201 | * @param array $args |
| 202 | - * @param string $base_where |
|
| 203 | - * @param string $where |
|
| 202 | + * @param string $base_where |
|
| 203 | + * @param string $where |
|
| 204 | 204 | * @param array $values |
| 205 | - */ |
|
| 206 | - public static function parse_where_from_array( $args, $base_where, &$where, &$values ) { |
|
| 207 | - $condition = ' AND'; |
|
| 208 | - if ( isset( $args['or'] ) ) { |
|
| 209 | - $condition = ' OR'; |
|
| 210 | - unset( $args['or'] ); |
|
| 211 | - } |
|
| 212 | - |
|
| 213 | - foreach ( $args as $key => $value ) { |
|
| 214 | - $where .= empty( $where ) ? $base_where : $condition; |
|
| 215 | - $array_inc_null = ( ! is_numeric( $key ) && is_array( $value ) && in_array( null, $value ) ); |
|
| 216 | - if ( is_numeric( $key ) || $array_inc_null ) { |
|
| 217 | - $where .= ' ( '; |
|
| 218 | - $nested_where = ''; |
|
| 219 | - if ( $array_inc_null ) { |
|
| 220 | - foreach ( $value as $val ) { |
|
| 221 | - self::parse_where_from_array( array( $key => $val, 'or' => 1 ), '', $nested_where, $values ); |
|
| 222 | - } |
|
| 223 | - } else { |
|
| 224 | - self::parse_where_from_array( $value, '', $nested_where, $values ); |
|
| 225 | - } |
|
| 226 | - $where .= $nested_where; |
|
| 227 | - $where .= ' ) '; |
|
| 228 | - } else { |
|
| 229 | - self::interpret_array_to_sql( $key, $value, $where, $values ); |
|
| 230 | - } |
|
| 231 | - } |
|
| 232 | - } |
|
| 233 | - |
|
| 234 | - /** |
|
| 235 | - * @param string $key |
|
| 205 | + */ |
|
| 206 | + public static function parse_where_from_array( $args, $base_where, &$where, &$values ) { |
|
| 207 | + $condition = ' AND'; |
|
| 208 | + if ( isset( $args['or'] ) ) { |
|
| 209 | + $condition = ' OR'; |
|
| 210 | + unset( $args['or'] ); |
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + foreach ( $args as $key => $value ) { |
|
| 214 | + $where .= empty( $where ) ? $base_where : $condition; |
|
| 215 | + $array_inc_null = ( ! is_numeric( $key ) && is_array( $value ) && in_array( null, $value ) ); |
|
| 216 | + if ( is_numeric( $key ) || $array_inc_null ) { |
|
| 217 | + $where .= ' ( '; |
|
| 218 | + $nested_where = ''; |
|
| 219 | + if ( $array_inc_null ) { |
|
| 220 | + foreach ( $value as $val ) { |
|
| 221 | + self::parse_where_from_array( array( $key => $val, 'or' => 1 ), '', $nested_where, $values ); |
|
| 222 | + } |
|
| 223 | + } else { |
|
| 224 | + self::parse_where_from_array( $value, '', $nested_where, $values ); |
|
| 225 | + } |
|
| 226 | + $where .= $nested_where; |
|
| 227 | + $where .= ' ) '; |
|
| 228 | + } else { |
|
| 229 | + self::interpret_array_to_sql( $key, $value, $where, $values ); |
|
| 230 | + } |
|
| 231 | + } |
|
| 232 | + } |
|
| 233 | + |
|
| 234 | + /** |
|
| 235 | + * @param string $key |
|
| 236 | 236 | * @param string|array $value |
| 237 | - * @param string $where |
|
| 237 | + * @param string $where |
|
| 238 | 238 | * @param array $values |
| 239 | - */ |
|
| 240 | - private static function interpret_array_to_sql( $key, $value, &$where, &$values ) { |
|
| 239 | + */ |
|
| 240 | + private static function interpret_array_to_sql( $key, $value, &$where, &$values ) { |
|
| 241 | 241 | $key = trim( $key ); |
| 242 | 242 | |
| 243 | - if ( strpos( $key, 'created_at' ) !== false || strpos( $key, 'updated_at' ) !== false ) { |
|
| 244 | - $k = explode(' ', $key); |
|
| 245 | - $where .= ' DATE_FORMAT(' . reset( $k ) . ', %s) ' . str_replace( reset( $k ), '', $key ); |
|
| 246 | - $values[] = '%Y-%m-%d %H:%i:%s'; |
|
| 247 | - } else { |
|
| 243 | + if ( strpos( $key, 'created_at' ) !== false || strpos( $key, 'updated_at' ) !== false ) { |
|
| 244 | + $k = explode(' ', $key); |
|
| 245 | + $where .= ' DATE_FORMAT(' . reset( $k ) . ', %s) ' . str_replace( reset( $k ), '', $key ); |
|
| 246 | + $values[] = '%Y-%m-%d %H:%i:%s'; |
|
| 247 | + } else { |
|
| 248 | 248 | $where .= ' ' . $key; |
| 249 | - } |
|
| 249 | + } |
|
| 250 | 250 | |
| 251 | 251 | $lowercase_key = explode( ' ', strtolower( $key ) ); |
| 252 | 252 | $lowercase_key = end( $lowercase_key ); |
| 253 | 253 | |
| 254 | - if ( is_array( $value ) ) { |
|
| 255 | - // translate array of values to "in" |
|
| 254 | + if ( is_array( $value ) ) { |
|
| 255 | + // translate array of values to "in" |
|
| 256 | 256 | if ( strpos( $lowercase_key, 'like' ) !== false ) { |
| 257 | 257 | $where = preg_replace('/' . $key . '$/', '', $where); |
| 258 | 258 | $where .= '('; |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | $where .= ' in (' . FrmAppHelper::prepare_array_values( $value, '%s' ) . ')'; |
| 271 | 271 | $values = array_merge( $values, $value ); |
| 272 | 272 | } |
| 273 | - } else if ( strpos( $lowercase_key, 'like' ) !== false ) { |
|
| 273 | + } else if ( strpos( $lowercase_key, 'like' ) !== false ) { |
|
| 274 | 274 | /** |
| 275 | 275 | * Allow string to start or end with the value |
| 276 | 276 | * If the key is like% then skip the first % for starts with |
@@ -289,9 +289,9 @@ discard block |
||
| 289 | 289 | $where .= ' %s'; |
| 290 | 290 | $values[] = $start . FrmAppHelper::esc_like( $value ) . $end; |
| 291 | 291 | |
| 292 | - } else if ( $value === null ) { |
|
| 293 | - $where .= ' IS NULL'; |
|
| 294 | - } else { |
|
| 292 | + } else if ( $value === null ) { |
|
| 293 | + $where .= ' IS NULL'; |
|
| 294 | + } else { |
|
| 295 | 295 | // allow a - to prevent = from being added |
| 296 | 296 | if ( substr( $key, -1 ) == '-' ) { |
| 297 | 297 | $where = rtrim( $where, '-' ); |
@@ -301,9 +301,9 @@ discard block |
||
| 301 | 301 | |
| 302 | 302 | self::add_query_placeholder( $key, $value, $where ); |
| 303 | 303 | |
| 304 | - $values[] = $value; |
|
| 305 | - } |
|
| 306 | - } |
|
| 304 | + $values[] = $value; |
|
| 305 | + } |
|
| 306 | + } |
|
| 307 | 307 | |
| 308 | 308 | /** |
| 309 | 309 | * Add %d, or %s to query |
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | * @param int|string $value |
| 314 | 314 | * @param string $where |
| 315 | 315 | */ |
| 316 | - private static function add_query_placeholder( $key, $value, &$where ) { |
|
| 316 | + private static function add_query_placeholder( $key, $value, &$where ) { |
|
| 317 | 317 | if ( is_numeric( $value ) && strpos( $key, 'meta_value' ) === false ) { |
| 318 | 318 | $where .= '%d'; |
| 319 | 319 | } else { |
@@ -321,16 +321,16 @@ discard block |
||
| 321 | 321 | } |
| 322 | 322 | } |
| 323 | 323 | |
| 324 | - /** |
|
| 325 | - * @param string $table |
|
| 324 | + /** |
|
| 325 | + * @param string $table |
|
| 326 | 326 | * @param array $where |
| 327 | 327 | * @param array $args |
| 328 | 328 | * @return int |
| 329 | - */ |
|
| 330 | - public static function get_count( $table, $where = array(), $args = array() ) { |
|
| 331 | - $count = self::get_var( $table, $where, 'COUNT(*)', $args ); |
|
| 332 | - return $count; |
|
| 333 | - } |
|
| 329 | + */ |
|
| 330 | + public static function get_count( $table, $where = array(), $args = array() ) { |
|
| 331 | + $count = self::get_var( $table, $where, 'COUNT(*)', $args ); |
|
| 332 | + return $count; |
|
| 333 | + } |
|
| 334 | 334 | |
| 335 | 335 | /** |
| 336 | 336 | * @param string $table |
@@ -341,56 +341,56 @@ discard block |
||
| 341 | 341 | * @param string $type |
| 342 | 342 | * @return array|null|string|object |
| 343 | 343 | */ |
| 344 | - public static function get_var( $table, $where = array(), $field = 'id', $args = array(), $limit = '', $type = 'var' ) { |
|
| 345 | - $group = ''; |
|
| 346 | - self::get_group_and_table_name( $table, $group ); |
|
| 344 | + public static function get_var( $table, $where = array(), $field = 'id', $args = array(), $limit = '', $type = 'var' ) { |
|
| 345 | + $group = ''; |
|
| 346 | + self::get_group_and_table_name( $table, $group ); |
|
| 347 | 347 | self::convert_options_to_array( $args, '', $limit ); |
| 348 | 348 | |
| 349 | 349 | $query = self::generate_query_string_from_pieces( $field, $table, $where, $args ); |
| 350 | 350 | |
| 351 | 351 | $cache_key = str_replace( array( ' ', ',' ), '_', trim( implode( '_', FrmAppHelper::array_flatten( $where ) ) . implode( '_', $args ) . $field . '_' . $type, ' WHERE' ) ); |
| 352 | 352 | $results = FrmAppHelper::check_cache( $cache_key, $group, $query, 'get_' . $type ); |
| 353 | - return $results; |
|
| 354 | - } |
|
| 353 | + return $results; |
|
| 354 | + } |
|
| 355 | 355 | |
| 356 | - /** |
|
| 357 | - * @param string $table |
|
| 358 | - * @param array $where |
|
| 356 | + /** |
|
| 357 | + * @param string $table |
|
| 358 | + * @param array $where |
|
| 359 | 359 | * @param string $field |
| 360 | 360 | * @param array $args |
| 361 | 361 | * @param string $limit |
| 362 | 362 | * @return mixed |
| 363 | - */ |
|
| 364 | - public static function get_col( $table, $where = array(), $field = 'id', $args = array(), $limit = '' ) { |
|
| 365 | - return self::get_var( $table, $where, $field, $args, $limit, 'col' ); |
|
| 366 | - } |
|
| 367 | - |
|
| 368 | - /** |
|
| 369 | - * @since 2.0 |
|
| 370 | - * @param string $table |
|
| 363 | + */ |
|
| 364 | + public static function get_col( $table, $where = array(), $field = 'id', $args = array(), $limit = '' ) { |
|
| 365 | + return self::get_var( $table, $where, $field, $args, $limit, 'col' ); |
|
| 366 | + } |
|
| 367 | + |
|
| 368 | + /** |
|
| 369 | + * @since 2.0 |
|
| 370 | + * @param string $table |
|
| 371 | 371 | * @param array $where |
| 372 | 372 | * @param string $fields |
| 373 | 373 | * @param array $args |
| 374 | 374 | * @return mixed |
| 375 | - */ |
|
| 376 | - public static function get_row( $table, $where = array(), $fields = '*', $args = array() ) { |
|
| 377 | - $args['limit'] = 1; |
|
| 378 | - return self::get_var( $table, $where, $fields, $args, '', 'row' ); |
|
| 379 | - } |
|
| 380 | - |
|
| 381 | - /** |
|
| 382 | - * Prepare a key/value array before DB call |
|
| 375 | + */ |
|
| 376 | + public static function get_row( $table, $where = array(), $fields = '*', $args = array() ) { |
|
| 377 | + $args['limit'] = 1; |
|
| 378 | + return self::get_var( $table, $where, $fields, $args, '', 'row' ); |
|
| 379 | + } |
|
| 380 | + |
|
| 381 | + /** |
|
| 382 | + * Prepare a key/value array before DB call |
|
| 383 | 383 | * |
| 384 | - * @since 2.0 |
|
| 385 | - * @param string $table |
|
| 384 | + * @since 2.0 |
|
| 385 | + * @param string $table |
|
| 386 | 386 | * @param array $where |
| 387 | 387 | * @param string $fields |
| 388 | 388 | * @param array $args |
| 389 | 389 | * @return mixed |
| 390 | - */ |
|
| 391 | - public static function get_results( $table, $where = array(), $fields = '*', $args = array() ) { |
|
| 392 | - return self::get_var( $table, $where, $fields, $args, '', 'results' ); |
|
| 393 | - } |
|
| 390 | + */ |
|
| 391 | + public static function get_results( $table, $where = array(), $fields = '*', $args = array() ) { |
|
| 392 | + return self::get_var( $table, $where, $fields, $args, '', 'results' ); |
|
| 393 | + } |
|
| 394 | 394 | |
| 395 | 395 | /** |
| 396 | 396 | * Check for like, not like, in, not in, =, !=, >, <, <=, >= |
@@ -427,59 +427,59 @@ discard block |
||
| 427 | 427 | return ''; |
| 428 | 428 | } |
| 429 | 429 | |
| 430 | - /** |
|
| 431 | - * Get 'frm_forms' from wp_frm_forms or a longer table param that includes a join |
|
| 432 | - * Also add the wpdb->prefix to the table if it's missing |
|
| 433 | - * |
|
| 434 | - * @param string $table |
|
| 435 | - * @param string $group |
|
| 436 | - */ |
|
| 437 | - private static function get_group_and_table_name( &$table, &$group ) { |
|
| 430 | + /** |
|
| 431 | + * Get 'frm_forms' from wp_frm_forms or a longer table param that includes a join |
|
| 432 | + * Also add the wpdb->prefix to the table if it's missing |
|
| 433 | + * |
|
| 434 | + * @param string $table |
|
| 435 | + * @param string $group |
|
| 436 | + */ |
|
| 437 | + private static function get_group_and_table_name( &$table, &$group ) { |
|
| 438 | 438 | global $wpdb, $wpmuBaseTablePrefix; |
| 439 | 439 | |
| 440 | - $table_parts = explode(' ', $table); |
|
| 441 | - $group = reset($table_parts); |
|
| 442 | - $group = str_replace( $wpdb->prefix, '', $group ); |
|
| 440 | + $table_parts = explode(' ', $table); |
|
| 441 | + $group = reset($table_parts); |
|
| 442 | + $group = str_replace( $wpdb->prefix, '', $group ); |
|
| 443 | 443 | |
| 444 | 444 | $prefix = $wpmuBaseTablePrefix ? $wpmuBaseTablePrefix : $wpdb->base_prefix; |
| 445 | 445 | $group = str_replace( $prefix, '', $group ); |
| 446 | 446 | |
| 447 | - if ( $group == $table ) { |
|
| 448 | - $table = $wpdb->prefix . $table; |
|
| 449 | - } |
|
| 447 | + if ( $group == $table ) { |
|
| 448 | + $table = $wpdb->prefix . $table; |
|
| 449 | + } |
|
| 450 | 450 | |
| 451 | 451 | // switch to singular group name |
| 452 | 452 | $group = rtrim( $group, 's' ); |
| 453 | - } |
|
| 453 | + } |
|
| 454 | 454 | |
| 455 | - private static function convert_options_to_array( &$args, $order_by = '', $limit = '' ) { |
|
| 456 | - if ( ! is_array($args) ) { |
|
| 455 | + private static function convert_options_to_array( &$args, $order_by = '', $limit = '' ) { |
|
| 456 | + if ( ! is_array($args) ) { |
|
| 457 | 457 | $args = array( 'order_by' => $args ); |
| 458 | - } |
|
| 458 | + } |
|
| 459 | 459 | |
| 460 | - if ( ! empty( $order_by ) ) { |
|
| 461 | - $args['order_by'] = $order_by; |
|
| 462 | - } |
|
| 460 | + if ( ! empty( $order_by ) ) { |
|
| 461 | + $args['order_by'] = $order_by; |
|
| 462 | + } |
|
| 463 | 463 | |
| 464 | - if ( ! empty( $limit ) ) { |
|
| 465 | - $args['limit'] = $limit; |
|
| 466 | - } |
|
| 464 | + if ( ! empty( $limit ) ) { |
|
| 465 | + $args['limit'] = $limit; |
|
| 466 | + } |
|
| 467 | 467 | |
| 468 | - $temp_args = $args; |
|
| 469 | - foreach ( $temp_args as $k => $v ) { |
|
| 470 | - if ( $v == '' ) { |
|
| 468 | + $temp_args = $args; |
|
| 469 | + foreach ( $temp_args as $k => $v ) { |
|
| 470 | + if ( $v == '' ) { |
|
| 471 | 471 | unset( $args[ $k ] ); |
| 472 | - continue; |
|
| 473 | - } |
|
| 472 | + continue; |
|
| 473 | + } |
|
| 474 | 474 | |
| 475 | - if ( $k == 'limit' ) { |
|
| 475 | + if ( $k == 'limit' ) { |
|
| 476 | 476 | $args[ $k ] = FrmAppHelper::esc_limit( $v ); |
| 477 | - } |
|
| 478 | - $db_name = strtoupper( str_replace( '_', ' ', $k ) ); |
|
| 479 | - if ( strpos( $v, $db_name ) === false ) { |
|
| 477 | + } |
|
| 478 | + $db_name = strtoupper( str_replace( '_', ' ', $k ) ); |
|
| 479 | + if ( strpos( $v, $db_name ) === false ) { |
|
| 480 | 480 | $args[ $k ] = $db_name . ' ' . $v; |
| 481 | - } |
|
| 482 | - } |
|
| 481 | + } |
|
| 482 | + } |
|
| 483 | 483 | |
| 484 | 484 | // Make sure LIMIT is the last argument |
| 485 | 485 | if ( isset( $args['order_by'] ) && isset( $args['limit'] ) ) { |
@@ -487,7 +487,7 @@ discard block |
||
| 487 | 487 | unset( $args['limit'] ); |
| 488 | 488 | $args['limit'] = $temp_limit; |
| 489 | 489 | } |
| 490 | - } |
|
| 490 | + } |
|
| 491 | 491 | |
| 492 | 492 | /** |
| 493 | 493 | * Get the associative array results for the given columns, table, and where query |
@@ -540,31 +540,31 @@ discard block |
||
| 540 | 540 | return $query; |
| 541 | 541 | } |
| 542 | 542 | |
| 543 | - public function uninstall() { |
|
| 543 | + public function uninstall() { |
|
| 544 | 544 | if ( ! current_user_can( 'administrator' ) ) { |
| 545 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 546 | - wp_die($frm_settings->admin_permission); |
|
| 547 | - } |
|
| 545 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 546 | + wp_die($frm_settings->admin_permission); |
|
| 547 | + } |
|
| 548 | 548 | |
| 549 | - global $wpdb, $wp_roles; |
|
| 549 | + global $wpdb, $wp_roles; |
|
| 550 | 550 | |
| 551 | 551 | $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->fields ); |
| 552 | 552 | $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->forms ); |
| 553 | 553 | $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entries ); |
| 554 | 554 | $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entry_metas ); |
| 555 | 555 | |
| 556 | - delete_option('frm_options'); |
|
| 557 | - delete_option('frm_db_version'); |
|
| 556 | + delete_option('frm_options'); |
|
| 557 | + delete_option('frm_db_version'); |
|
| 558 | 558 | |
| 559 | - //delete roles |
|
| 560 | - $frm_roles = FrmAppHelper::frm_capabilities(); |
|
| 561 | - $roles = get_editable_roles(); |
|
| 562 | - foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 563 | - foreach ( $roles as $role => $details ) { |
|
| 564 | - $wp_roles->remove_cap( $role, $frm_role ); |
|
| 565 | - unset($role, $details); |
|
| 566 | - } |
|
| 567 | - unset($frm_role, $frm_role_description); |
|
| 559 | + //delete roles |
|
| 560 | + $frm_roles = FrmAppHelper::frm_capabilities(); |
|
| 561 | + $roles = get_editable_roles(); |
|
| 562 | + foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 563 | + foreach ( $roles as $role => $details ) { |
|
| 564 | + $wp_roles->remove_cap( $role, $frm_role ); |
|
| 565 | + unset($role, $details); |
|
| 566 | + } |
|
| 567 | + unset($frm_role, $frm_role_description); |
|
| 568 | 568 | } |
| 569 | 569 | unset($roles, $frm_roles); |
| 570 | 570 | |
@@ -588,9 +588,9 @@ discard block |
||
| 588 | 588 | |
| 589 | 589 | $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->options . ' WHERE option_name LIKE %s OR option_name LIKE %s', '_transient_timeout_frm_form_fields_%', '_transient_frm_form_fields_%' ) ); |
| 590 | 590 | |
| 591 | - do_action('frm_after_uninstall'); |
|
| 592 | - return true; |
|
| 593 | - } |
|
| 591 | + do_action('frm_after_uninstall'); |
|
| 592 | + return true; |
|
| 593 | + } |
|
| 594 | 594 | |
| 595 | 595 | /** |
| 596 | 596 | * Migrate old styling settings. If sites are using the old |
@@ -629,150 +629,150 @@ discard block |
||
| 629 | 629 | } |
| 630 | 630 | } |
| 631 | 631 | |
| 632 | - /** |
|
| 633 | - * Change field size from character to pixel -- Multiply by 9 |
|
| 634 | - */ |
|
| 635 | - private function migrate_to_17() { |
|
| 636 | - global $wpdb; |
|
| 632 | + /** |
|
| 633 | + * Change field size from character to pixel -- Multiply by 9 |
|
| 634 | + */ |
|
| 635 | + private function migrate_to_17() { |
|
| 636 | + global $wpdb; |
|
| 637 | 637 | $pixel_conversion = 9; |
| 638 | 638 | |
| 639 | - // Get query arguments |
|
| 639 | + // Get query arguments |
|
| 640 | 640 | $field_types = array( 'textarea', 'text', 'number', 'email', 'url', 'rte', 'date', 'phone', 'password', 'image', 'tag', 'file' ); |
| 641 | 641 | $query = array( 'type' => $field_types, 'field_options like' => 's:4:"size";', 'field_options not like' => 's:4:"size";s:0:' ); |
| 642 | 642 | |
| 643 | - // Get results |
|
| 643 | + // Get results |
|
| 644 | 644 | $fields = FrmDb::get_results( $this->fields, $query, 'id, field_options' ); |
| 645 | 645 | |
| 646 | - $updated = 0; |
|
| 647 | - foreach ( $fields as $f ) { |
|
| 648 | - $f->field_options = maybe_unserialize($f->field_options); |
|
| 649 | - if ( empty($f->field_options['size']) || ! is_numeric($f->field_options['size']) ) { |
|
| 650 | - continue; |
|
| 651 | - } |
|
| 646 | + $updated = 0; |
|
| 647 | + foreach ( $fields as $f ) { |
|
| 648 | + $f->field_options = maybe_unserialize($f->field_options); |
|
| 649 | + if ( empty($f->field_options['size']) || ! is_numeric($f->field_options['size']) ) { |
|
| 650 | + continue; |
|
| 651 | + } |
|
| 652 | 652 | |
| 653 | 653 | $f->field_options['size'] = round( $pixel_conversion * (int) $f->field_options['size'] ); |
| 654 | - $f->field_options['size'] .= 'px'; |
|
| 655 | - $u = FrmField::update( $f->id, array( 'field_options' => $f->field_options ) ); |
|
| 656 | - if ( $u ) { |
|
| 657 | - $updated++; |
|
| 658 | - } |
|
| 659 | - unset($f); |
|
| 660 | - } |
|
| 661 | - |
|
| 662 | - // Change the characters in widgets to pixels |
|
| 663 | - $widgets = get_option('widget_frm_show_form'); |
|
| 664 | - if ( empty($widgets) ) { |
|
| 665 | - return; |
|
| 666 | - } |
|
| 667 | - |
|
| 668 | - $widgets = maybe_unserialize($widgets); |
|
| 669 | - foreach ( $widgets as $k => $widget ) { |
|
| 670 | - if ( ! is_array($widget) || ! isset($widget['size']) ) { |
|
| 671 | - continue; |
|
| 672 | - } |
|
| 654 | + $f->field_options['size'] .= 'px'; |
|
| 655 | + $u = FrmField::update( $f->id, array( 'field_options' => $f->field_options ) ); |
|
| 656 | + if ( $u ) { |
|
| 657 | + $updated++; |
|
| 658 | + } |
|
| 659 | + unset($f); |
|
| 660 | + } |
|
| 661 | + |
|
| 662 | + // Change the characters in widgets to pixels |
|
| 663 | + $widgets = get_option('widget_frm_show_form'); |
|
| 664 | + if ( empty($widgets) ) { |
|
| 665 | + return; |
|
| 666 | + } |
|
| 667 | + |
|
| 668 | + $widgets = maybe_unserialize($widgets); |
|
| 669 | + foreach ( $widgets as $k => $widget ) { |
|
| 670 | + if ( ! is_array($widget) || ! isset($widget['size']) ) { |
|
| 671 | + continue; |
|
| 672 | + } |
|
| 673 | 673 | $size = round( $pixel_conversion * (int) $widget['size'] ); |
| 674 | - $size .= 'px'; |
|
| 674 | + $size .= 'px'; |
|
| 675 | 675 | $widgets[ $k ]['size'] = $size; |
| 676 | - } |
|
| 677 | - update_option('widget_frm_show_form', $widgets); |
|
| 678 | - } |
|
| 679 | - |
|
| 680 | - /** |
|
| 681 | - * Migrate post and email notification settings into actions |
|
| 682 | - */ |
|
| 683 | - private function migrate_to_16() { |
|
| 684 | - global $wpdb; |
|
| 685 | - |
|
| 686 | - $forms = FrmDb::get_results( $this->forms, array(), 'id, options, is_template, default_template' ); |
|
| 687 | - |
|
| 688 | - /** |
|
| 689 | - * Old email settings format: |
|
| 690 | - * email_to: Email or field id |
|
| 691 | - * also_email_to: array of fields ids |
|
| 692 | - * reply_to: Email, field id, 'custom' |
|
| 693 | - * cust_reply_to: string |
|
| 694 | - * reply_to_name: field id, 'custom' |
|
| 695 | - * cust_reply_to_name: string |
|
| 696 | - * plain_text: 0|1 |
|
| 697 | - * email_message: string or '' |
|
| 698 | - * email_subject: string or '' |
|
| 699 | - * inc_user_info: 0|1 |
|
| 700 | - * update_email: 0, 1, 2 |
|
| 701 | - * |
|
| 702 | - * Old autoresponder settings format: |
|
| 703 | - * auto_responder: 0|1 |
|
| 704 | - * ar_email_message: string or '' |
|
| 705 | - * ar_email_to: field id |
|
| 706 | - * ar_plain_text: 0|1 |
|
| 707 | - * ar_reply_to_name: string |
|
| 708 | - * ar_reply_to: string |
|
| 709 | - * ar_email_subject: string |
|
| 710 | - * ar_update_email: 0, 1, 2 |
|
| 711 | - * |
|
| 712 | - * New email settings: |
|
| 713 | - * post_content: json settings |
|
| 714 | - * post_title: form id |
|
| 715 | - * post_excerpt: message |
|
| 716 | - * |
|
| 717 | - */ |
|
| 718 | - |
|
| 719 | - foreach ( $forms as $form ) { |
|
| 676 | + } |
|
| 677 | + update_option('widget_frm_show_form', $widgets); |
|
| 678 | + } |
|
| 679 | + |
|
| 680 | + /** |
|
| 681 | + * Migrate post and email notification settings into actions |
|
| 682 | + */ |
|
| 683 | + private function migrate_to_16() { |
|
| 684 | + global $wpdb; |
|
| 685 | + |
|
| 686 | + $forms = FrmDb::get_results( $this->forms, array(), 'id, options, is_template, default_template' ); |
|
| 687 | + |
|
| 688 | + /** |
|
| 689 | + * Old email settings format: |
|
| 690 | + * email_to: Email or field id |
|
| 691 | + * also_email_to: array of fields ids |
|
| 692 | + * reply_to: Email, field id, 'custom' |
|
| 693 | + * cust_reply_to: string |
|
| 694 | + * reply_to_name: field id, 'custom' |
|
| 695 | + * cust_reply_to_name: string |
|
| 696 | + * plain_text: 0|1 |
|
| 697 | + * email_message: string or '' |
|
| 698 | + * email_subject: string or '' |
|
| 699 | + * inc_user_info: 0|1 |
|
| 700 | + * update_email: 0, 1, 2 |
|
| 701 | + * |
|
| 702 | + * Old autoresponder settings format: |
|
| 703 | + * auto_responder: 0|1 |
|
| 704 | + * ar_email_message: string or '' |
|
| 705 | + * ar_email_to: field id |
|
| 706 | + * ar_plain_text: 0|1 |
|
| 707 | + * ar_reply_to_name: string |
|
| 708 | + * ar_reply_to: string |
|
| 709 | + * ar_email_subject: string |
|
| 710 | + * ar_update_email: 0, 1, 2 |
|
| 711 | + * |
|
| 712 | + * New email settings: |
|
| 713 | + * post_content: json settings |
|
| 714 | + * post_title: form id |
|
| 715 | + * post_excerpt: message |
|
| 716 | + * |
|
| 717 | + */ |
|
| 718 | + |
|
| 719 | + foreach ( $forms as $form ) { |
|
| 720 | 720 | if ( $form->is_template && $form->default_template ) { |
| 721 | 721 | // don't migrate the default templates since the email will be added anyway |
| 722 | 722 | continue; |
| 723 | 723 | } |
| 724 | 724 | |
| 725 | - // Format form options |
|
| 726 | - $form_options = maybe_unserialize($form->options); |
|
| 725 | + // Format form options |
|
| 726 | + $form_options = maybe_unserialize($form->options); |
|
| 727 | 727 | |
| 728 | - // Migrate settings to actions |
|
| 729 | - FrmXMLHelper::migrate_form_settings_to_actions( $form_options, $form->id ); |
|
| 730 | - } |
|
| 731 | - } |
|
| 728 | + // Migrate settings to actions |
|
| 729 | + FrmXMLHelper::migrate_form_settings_to_actions( $form_options, $form->id ); |
|
| 730 | + } |
|
| 731 | + } |
|
| 732 | 732 | |
| 733 | - private function migrate_to_11() { |
|
| 734 | - global $wpdb; |
|
| 733 | + private function migrate_to_11() { |
|
| 734 | + global $wpdb; |
|
| 735 | 735 | |
| 736 | - $forms = FrmDb::get_results( $this->forms, array(), 'id, options'); |
|
| 736 | + $forms = FrmDb::get_results( $this->forms, array(), 'id, options'); |
|
| 737 | 737 | |
| 738 | - $sending = __( 'Sending', 'formidable' ); |
|
| 738 | + $sending = __( 'Sending', 'formidable' ); |
|
| 739 | 739 | $img = FrmAppHelper::plugin_url() . '/images/ajax_loader.gif'; |
| 740 | - $old_default_html = <<<DEFAULT_HTML |
|
| 740 | + $old_default_html = <<<DEFAULT_HTML |
|
| 741 | 741 | <div class="frm_submit"> |
| 742 | 742 | [if back_button]<input type="submit" value="[back_label]" name="frm_prev_page" formnovalidate="formnovalidate" [back_hook] />[/if back_button] |
| 743 | 743 | <input type="submit" value="[button_label]" [button_action] /> |
| 744 | 744 | <img class="frm_ajax_loading" src="$img" alt="$sending" style="visibility:hidden;" /> |
| 745 | 745 | </div> |
| 746 | 746 | DEFAULT_HTML; |
| 747 | - unset($sending, $img); |
|
| 747 | + unset($sending, $img); |
|
| 748 | 748 | |
| 749 | - $new_default_html = FrmFormsHelper::get_default_html('submit'); |
|
| 750 | - $draft_link = FrmFormsHelper::get_draft_link(); |
|
| 749 | + $new_default_html = FrmFormsHelper::get_default_html('submit'); |
|
| 750 | + $draft_link = FrmFormsHelper::get_draft_link(); |
|
| 751 | 751 | foreach ( $forms as $form ) { |
| 752 | - $form->options = maybe_unserialize($form->options); |
|
| 753 | - if ( ! isset($form->options['submit_html']) || empty($form->options['submit_html']) ) { |
|
| 754 | - continue; |
|
| 755 | - } |
|
| 752 | + $form->options = maybe_unserialize($form->options); |
|
| 753 | + if ( ! isset($form->options['submit_html']) || empty($form->options['submit_html']) ) { |
|
| 754 | + continue; |
|
| 755 | + } |
|
| 756 | 756 | |
| 757 | - if ( $form->options['submit_html'] != $new_default_html && $form->options['submit_html'] == $old_default_html ) { |
|
| 758 | - $form->options['submit_html'] = $new_default_html; |
|
| 757 | + if ( $form->options['submit_html'] != $new_default_html && $form->options['submit_html'] == $old_default_html ) { |
|
| 758 | + $form->options['submit_html'] = $new_default_html; |
|
| 759 | 759 | $wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) ); |
| 760 | 760 | } else if ( ! strpos( $form->options['submit_html'], 'save_draft' ) ) { |
| 761 | 761 | $form->options['submit_html'] = preg_replace( '~\<\/div\>(?!.*\<\/div\>)~', $draft_link . "\r\n</div>", $form->options['submit_html'] ); |
| 762 | 762 | $wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) ); |
| 763 | - } |
|
| 764 | - unset($form); |
|
| 765 | - } |
|
| 766 | - unset($forms); |
|
| 767 | - } |
|
| 763 | + } |
|
| 764 | + unset($form); |
|
| 765 | + } |
|
| 766 | + unset($forms); |
|
| 767 | + } |
|
| 768 | 768 | |
| 769 | - private function migrate_to_6() { |
|
| 770 | - global $wpdb; |
|
| 769 | + private function migrate_to_6() { |
|
| 770 | + global $wpdb; |
|
| 771 | 771 | |
| 772 | 772 | $no_save = array_merge( FrmField::no_save_fields(), array( 'form', 'hidden', 'user_id' ) ); |
| 773 | 773 | $fields = FrmDb::get_results( $this->fields, array( 'type NOT' => $no_save ), 'id, field_options' ); |
| 774 | 774 | |
| 775 | - $default_html = <<<DEFAULT_HTML |
|
| 775 | + $default_html = <<<DEFAULT_HTML |
|
| 776 | 776 | <div id="frm_field_[id]_container" class="form-field [required_class] [error_class]"> |
| 777 | 777 | <label class="frm_pos_[label_position]">[field_name] |
| 778 | 778 | <span class="frm_required">[required_label]</span> |
@@ -782,7 +782,7 @@ discard block |
||
| 782 | 782 | </div> |
| 783 | 783 | DEFAULT_HTML; |
| 784 | 784 | |
| 785 | - $old_default_html = <<<DEFAULT_HTML |
|
| 785 | + $old_default_html = <<<DEFAULT_HTML |
|
| 786 | 786 | <div id="frm_field_[id]_container" class="form-field [required_class] [error_class]"> |
| 787 | 787 | <label class="frm_pos_[label_position]">[field_name] |
| 788 | 788 | <span class="frm_required">[required_label]</span> |
@@ -792,25 +792,25 @@ discard block |
||
| 792 | 792 | </div> |
| 793 | 793 | DEFAULT_HTML; |
| 794 | 794 | |
| 795 | - $new_default_html = FrmFieldsHelper::get_default_html('text'); |
|
| 796 | - foreach ( $fields as $field ) { |
|
| 797 | - $field->field_options = maybe_unserialize($field->field_options); |
|
| 795 | + $new_default_html = FrmFieldsHelper::get_default_html('text'); |
|
| 796 | + foreach ( $fields as $field ) { |
|
| 797 | + $field->field_options = maybe_unserialize($field->field_options); |
|
| 798 | 798 | if ( ! FrmField::is_option_empty( $field, 'custom_html' ) || $field->field_options['custom_html'] == $default_html || $field->field_options['custom_html'] == $old_default_html ) { |
| 799 | - $field->field_options['custom_html'] = $new_default_html; |
|
| 799 | + $field->field_options['custom_html'] = $new_default_html; |
|
| 800 | 800 | $wpdb->update( $this->fields, array( 'field_options' => maybe_serialize( $field->field_options ) ), array( 'id' => $field->id ) ); |
| 801 | - } |
|
| 802 | - unset($field); |
|
| 803 | - } |
|
| 804 | - unset($default_html, $old_default_html, $fields); |
|
| 805 | - } |
|
| 806 | - |
|
| 807 | - private function migrate_to_4() { |
|
| 808 | - global $wpdb; |
|
| 801 | + } |
|
| 802 | + unset($field); |
|
| 803 | + } |
|
| 804 | + unset($default_html, $old_default_html, $fields); |
|
| 805 | + } |
|
| 806 | + |
|
| 807 | + private function migrate_to_4() { |
|
| 808 | + global $wpdb; |
|
| 809 | 809 | $user_ids = FrmEntryMeta::getAll( array( 'fi.type' => 'user_id' ) ); |
| 810 | - foreach ( $user_ids as $user_id ) { |
|
| 810 | + foreach ( $user_ids as $user_id ) { |
|
| 811 | 811 | $wpdb->update( $this->entries, array( 'user_id' => $user_id->meta_value ), array( 'id' => $user_id->item_id ) ); |
| 812 | - } |
|
| 813 | - } |
|
| 812 | + } |
|
| 813 | + } |
|
| 814 | 814 | |
| 815 | 815 | public static function get_one_record( $table, $args = array(), $fields = '*', $order_by = '' ) { |
| 816 | 816 | _deprecated_function( __FUNCTION__, '2.0', 'FrmDb::get_row' ); |