@@ -302,6 +302,9 @@ |
||
| 302 | 302 | return $count; |
| 303 | 303 | } |
| 304 | 304 | |
| 305 | + /** |
|
| 306 | + * @param string $table |
|
| 307 | + */ |
|
| 305 | 308 | public static function get_var( $table, $where = array(), $field = 'id', $args = array(), $limit = '', $type = 'var' ) { |
| 306 | 309 | $group = ''; |
| 307 | 310 | self::get_group_and_table_name( $table, $group ); |
@@ -7,8 +7,8 @@ discard block |
||
| 7 | 7 | var $entry_metas; |
| 8 | 8 | |
| 9 | 9 | public function __construct() { |
| 10 | - if ( ! defined('ABSPATH') ) { |
|
| 11 | - die('You are not allowed to call this page directly.'); |
|
| 10 | + if ( ! defined( 'ABSPATH' ) ) { |
|
| 11 | + die( 'You are not allowed to call this page directly.' ); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | global $wpdb; |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | $frm_db_version = FrmAppHelper::$db_version; |
| 25 | 25 | $old_db_version = (float) $old_db_version; |
| 26 | 26 | if ( ! $old_db_version ) { |
| 27 | - $old_db_version = get_option('frm_db_version'); |
|
| 27 | + $old_db_version = get_option( 'frm_db_version' ); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | if ( $frm_db_version != $old_db_version ) { |
@@ -34,16 +34,16 @@ discard block |
||
| 34 | 34 | require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
| 35 | 35 | |
| 36 | 36 | $this->create_tables(); |
| 37 | - $this->migrate_data($frm_db_version, $old_db_version); |
|
| 37 | + $this->migrate_data( $frm_db_version, $old_db_version ); |
|
| 38 | 38 | |
| 39 | 39 | /***** SAVE DB VERSION *****/ |
| 40 | - update_option('frm_db_version', $frm_db_version); |
|
| 40 | + update_option( 'frm_db_version', $frm_db_version ); |
|
| 41 | 41 | |
| 42 | 42 | /**** ADD/UPDATE DEFAULT TEMPLATES ****/ |
| 43 | 43 | FrmXMLController::add_default_templates(); |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - do_action('frm_after_install'); |
|
| 46 | + do_action( 'frm_after_install' ); |
|
| 47 | 47 | |
| 48 | 48 | /**** update the styling settings ****/ |
| 49 | 49 | if ( is_admin() && function_exists( 'get_filesystem_method' ) ) { |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | global $wpdb; |
| 154 | 154 | $wpdb->query( $q . $charset_collate ); |
| 155 | 155 | } |
| 156 | - unset($q); |
|
| 156 | + unset( $q ); |
|
| 157 | 157 | } |
| 158 | 158 | } |
| 159 | 159 | |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | * Change array into format $wpdb->prepare can use |
| 175 | 175 | */ |
| 176 | 176 | public static function get_where_clause_and_values( &$args, $starts_with = ' WHERE ' ) { |
| 177 | - if ( empty($args) ) { |
|
| 177 | + if ( empty( $args ) ) { |
|
| 178 | 178 | // add an arg to prevent prepare from failing |
| 179 | 179 | $args = array( 'where' => $starts_with . '1=%d', 'values' => array( 1 ) ); |
| 180 | 180 | return; |
@@ -230,8 +230,8 @@ discard block |
||
| 230 | 230 | private static function interpret_array_to_sql( $key, $value, &$where, &$values ) { |
| 231 | 231 | $key = trim( $key ); |
| 232 | 232 | |
| 233 | - if ( strpos( $key, 'created_at' ) !== false || strpos( $key, 'updated_at' ) !== false ) { |
|
| 234 | - $k = explode(' ', $key); |
|
| 233 | + if ( strpos( $key, 'created_at' ) !== false || strpos( $key, 'updated_at' ) !== false ) { |
|
| 234 | + $k = explode( ' ', $key ); |
|
| 235 | 235 | $where .= ' DATE_FORMAT(' . reset( $k ) . ', %s) ' . str_replace( reset( $k ), '', $key ); |
| 236 | 236 | $values[] = '%Y-%m-%d %H:%i:%s'; |
| 237 | 237 | } else { |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | if ( is_array( $value ) ) { |
| 245 | 245 | // translate array of values to "in" |
| 246 | 246 | if ( strpos( $lowercase_key, 'like' ) !== false ) { |
| 247 | - $where = preg_replace('/' . $key . '$/', '', $where); |
|
| 247 | + $where = preg_replace( '/' . $key . '$/', '', $where ); |
|
| 248 | 248 | $where .= '('; |
| 249 | 249 | $start = true; |
| 250 | 250 | foreach ( $value as $v ) { |
@@ -354,7 +354,7 @@ discard block |
||
| 354 | 354 | |
| 355 | 355 | public static function get_records( $table, $args = array(), $order_by = '', $limit = '', $fields = '*' ) { |
| 356 | 356 | _deprecated_function( __FUNCTION__, '2.0', 'FrmDb::get_results' ); |
| 357 | - return self::get_results( $table, $args, $fields, compact('order_by', 'limit') ); |
|
| 357 | + return self::get_results( $table, $args, $fields, compact( 'order_by', 'limit' ) ); |
|
| 358 | 358 | } |
| 359 | 359 | |
| 360 | 360 | /** |
@@ -387,8 +387,8 @@ discard block |
||
| 387 | 387 | ); |
| 388 | 388 | |
| 389 | 389 | $where_is = strtolower( $where_is ); |
| 390 | - if ( isset( $switch_to[ $where_is ] ) ) { |
|
| 391 | - return ' ' . $switch_to[ $where_is ]; |
|
| 390 | + if ( isset( $switch_to[$where_is] ) ) { |
|
| 391 | + return ' ' . $switch_to[$where_is]; |
|
| 392 | 392 | } |
| 393 | 393 | |
| 394 | 394 | // > and < need a little more work since we don't want them switched to >= and <= |
@@ -410,8 +410,8 @@ discard block |
||
| 410 | 410 | private static function get_group_and_table_name( &$table, &$group ) { |
| 411 | 411 | global $wpdb, $wpmuBaseTablePrefix; |
| 412 | 412 | |
| 413 | - $table_parts = explode(' ', $table); |
|
| 414 | - $group = reset($table_parts); |
|
| 413 | + $table_parts = explode( ' ', $table ); |
|
| 414 | + $group = reset( $table_parts ); |
|
| 415 | 415 | $group = str_replace( $wpdb->prefix, '', $group ); |
| 416 | 416 | |
| 417 | 417 | $prefix = $wpmuBaseTablePrefix ? $wpmuBaseTablePrefix : $wpdb->base_prefix; |
@@ -426,7 +426,7 @@ discard block |
||
| 426 | 426 | } |
| 427 | 427 | |
| 428 | 428 | private static function convert_options_to_array( &$args, $order_by = '', $limit = '' ) { |
| 429 | - if ( ! is_array($args) ) { |
|
| 429 | + if ( ! is_array( $args ) ) { |
|
| 430 | 430 | $args = array( 'order_by' => $args ); |
| 431 | 431 | } |
| 432 | 432 | |
@@ -441,16 +441,16 @@ discard block |
||
| 441 | 441 | $temp_args = $args; |
| 442 | 442 | foreach ( $temp_args as $k => $v ) { |
| 443 | 443 | if ( $v == '' ) { |
| 444 | - unset( $args[ $k ] ); |
|
| 444 | + unset( $args[$k] ); |
|
| 445 | 445 | continue; |
| 446 | 446 | } |
| 447 | 447 | |
| 448 | 448 | if ( $k == 'limit' ) { |
| 449 | - $args[ $k ] = FrmAppHelper::esc_limit( $v ); |
|
| 449 | + $args[$k] = FrmAppHelper::esc_limit( $v ); |
|
| 450 | 450 | } |
| 451 | 451 | $db_name = strtoupper( str_replace( '_', ' ', $k ) ); |
| 452 | 452 | if ( strpos( $v, $db_name ) === false ) { |
| 453 | - $args[ $k ] = $db_name . ' ' . $v; |
|
| 453 | + $args[$k] = $db_name . ' ' . $v; |
|
| 454 | 454 | } |
| 455 | 455 | } |
| 456 | 456 | |
@@ -465,7 +465,7 @@ discard block |
||
| 465 | 465 | public function uninstall() { |
| 466 | 466 | if ( ! current_user_can( 'administrator' ) ) { |
| 467 | 467 | $frm_settings = FrmAppHelper::get_settings(); |
| 468 | - wp_die($frm_settings->admin_permission); |
|
| 468 | + wp_die( $frm_settings->admin_permission ); |
|
| 469 | 469 | } |
| 470 | 470 | |
| 471 | 471 | global $wpdb, $wp_roles; |
@@ -475,8 +475,8 @@ discard block |
||
| 475 | 475 | $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entries ); |
| 476 | 476 | $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entry_metas ); |
| 477 | 477 | |
| 478 | - delete_option('frm_options'); |
|
| 479 | - delete_option('frm_db_version'); |
|
| 478 | + delete_option( 'frm_options' ); |
|
| 479 | + delete_option( 'frm_db_version' ); |
|
| 480 | 480 | |
| 481 | 481 | //delete roles |
| 482 | 482 | $frm_roles = FrmAppHelper::frm_capabilities(); |
@@ -484,11 +484,11 @@ discard block |
||
| 484 | 484 | foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
| 485 | 485 | foreach ( $roles as $role => $details ) { |
| 486 | 486 | $wp_roles->remove_cap( $role, $frm_role ); |
| 487 | - unset($role, $details); |
|
| 487 | + unset( $role, $details ); |
|
| 488 | 488 | } |
| 489 | - unset($frm_role, $frm_role_description); |
|
| 489 | + unset( $frm_role, $frm_role_description ); |
|
| 490 | 490 | } |
| 491 | - unset($roles, $frm_roles); |
|
| 491 | + unset( $roles, $frm_roles ); |
|
| 492 | 492 | |
| 493 | 493 | // delete actions, views, and styles |
| 494 | 494 | |
@@ -510,7 +510,7 @@ discard block |
||
| 510 | 510 | |
| 511 | 511 | $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_%' ) ); |
| 512 | 512 | |
| 513 | - do_action('frm_after_uninstall'); |
|
| 513 | + do_action( 'frm_after_uninstall' ); |
|
| 514 | 514 | return true; |
| 515 | 515 | } |
| 516 | 516 | |
@@ -567,8 +567,8 @@ discard block |
||
| 567 | 567 | |
| 568 | 568 | $updated = 0; |
| 569 | 569 | foreach ( $fields as $f ) { |
| 570 | - $f->field_options = maybe_unserialize($f->field_options); |
|
| 571 | - if ( empty($f->field_options['size']) || ! is_numeric($f->field_options['size']) ) { |
|
| 570 | + $f->field_options = maybe_unserialize( $f->field_options ); |
|
| 571 | + if ( empty( $f->field_options['size'] ) || ! is_numeric( $f->field_options['size'] ) ) { |
|
| 572 | 572 | continue; |
| 573 | 573 | } |
| 574 | 574 | |
@@ -576,27 +576,27 @@ discard block |
||
| 576 | 576 | $f->field_options['size'] .= 'px'; |
| 577 | 577 | $u = FrmField::update( $f->id, array( 'field_options' => $f->field_options ) ); |
| 578 | 578 | if ( $u ) { |
| 579 | - $updated++; |
|
| 579 | + $updated ++; |
|
| 580 | 580 | } |
| 581 | - unset($f); |
|
| 581 | + unset( $f ); |
|
| 582 | 582 | } |
| 583 | 583 | |
| 584 | 584 | // Change the characters in widgets to pixels |
| 585 | - $widgets = get_option('widget_frm_show_form'); |
|
| 586 | - if ( empty($widgets) ) { |
|
| 585 | + $widgets = get_option( 'widget_frm_show_form' ); |
|
| 586 | + if ( empty( $widgets ) ) { |
|
| 587 | 587 | return; |
| 588 | 588 | } |
| 589 | 589 | |
| 590 | - $widgets = maybe_unserialize($widgets); |
|
| 590 | + $widgets = maybe_unserialize( $widgets ); |
|
| 591 | 591 | foreach ( $widgets as $k => $widget ) { |
| 592 | - if ( ! is_array($widget) || ! isset($widget['size']) ) { |
|
| 592 | + if ( ! is_array( $widget ) || ! isset( $widget['size'] ) ) { |
|
| 593 | 593 | continue; |
| 594 | 594 | } |
| 595 | 595 | $size = round( $pixel_conversion * (int) $widget['size'] ); |
| 596 | 596 | $size .= 'px'; |
| 597 | - $widgets[ $k ]['size'] = $size; |
|
| 597 | + $widgets[$k]['size'] = $size; |
|
| 598 | 598 | } |
| 599 | - update_option('widget_frm_show_form', $widgets); |
|
| 599 | + update_option( 'widget_frm_show_form', $widgets ); |
|
| 600 | 600 | } |
| 601 | 601 | |
| 602 | 602 | /** |
@@ -645,7 +645,7 @@ discard block |
||
| 645 | 645 | } |
| 646 | 646 | |
| 647 | 647 | // Format form options |
| 648 | - $form_options = maybe_unserialize($form->options); |
|
| 648 | + $form_options = maybe_unserialize( $form->options ); |
|
| 649 | 649 | |
| 650 | 650 | // Migrate settings to actions |
| 651 | 651 | FrmXMLHelper::migrate_form_settings_to_actions( $form_options, $form->id ); |
@@ -655,7 +655,7 @@ discard block |
||
| 655 | 655 | private function migrate_to_11() { |
| 656 | 656 | global $wpdb; |
| 657 | 657 | |
| 658 | - $forms = FrmDb::get_results( $this->forms, array(), 'id, options'); |
|
| 658 | + $forms = FrmDb::get_results( $this->forms, array(), 'id, options' ); |
|
| 659 | 659 | |
| 660 | 660 | $sending = __( 'Sending', 'formidable' ); |
| 661 | 661 | $img = FrmAppHelper::plugin_url() . '/images/ajax_loader.gif'; |
@@ -666,13 +666,13 @@ discard block |
||
| 666 | 666 | <img class="frm_ajax_loading" src="$img" alt="$sending" style="visibility:hidden;" /> |
| 667 | 667 | </div> |
| 668 | 668 | DEFAULT_HTML; |
| 669 | - unset($sending, $img); |
|
| 669 | + unset( $sending, $img ); |
|
| 670 | 670 | |
| 671 | - $new_default_html = FrmFormsHelper::get_default_html('submit'); |
|
| 671 | + $new_default_html = FrmFormsHelper::get_default_html( 'submit' ); |
|
| 672 | 672 | $draft_link = FrmFormsHelper::get_draft_link(); |
| 673 | 673 | foreach ( $forms as $form ) { |
| 674 | - $form->options = maybe_unserialize($form->options); |
|
| 675 | - if ( ! isset($form->options['submit_html']) || empty($form->options['submit_html']) ) { |
|
| 674 | + $form->options = maybe_unserialize( $form->options ); |
|
| 675 | + if ( ! isset( $form->options['submit_html'] ) || empty( $form->options['submit_html'] ) ) { |
|
| 676 | 676 | continue; |
| 677 | 677 | } |
| 678 | 678 | |
@@ -683,9 +683,9 @@ discard block |
||
| 683 | 683 | $form->options['submit_html'] = preg_replace( '~\<\/div\>(?!.*\<\/div\>)~', $draft_link . "\r\n</div>", $form->options['submit_html'] ); |
| 684 | 684 | $wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) ); |
| 685 | 685 | } |
| 686 | - unset($form); |
|
| 686 | + unset( $form ); |
|
| 687 | 687 | } |
| 688 | - unset($forms); |
|
| 688 | + unset( $forms ); |
|
| 689 | 689 | } |
| 690 | 690 | |
| 691 | 691 | private function migrate_to_6() { |
@@ -714,16 +714,16 @@ discard block |
||
| 714 | 714 | </div> |
| 715 | 715 | DEFAULT_HTML; |
| 716 | 716 | |
| 717 | - $new_default_html = FrmFieldsHelper::get_default_html('text'); |
|
| 717 | + $new_default_html = FrmFieldsHelper::get_default_html( 'text' ); |
|
| 718 | 718 | foreach ( $fields as $field ) { |
| 719 | - $field->field_options = maybe_unserialize($field->field_options); |
|
| 719 | + $field->field_options = maybe_unserialize( $field->field_options ); |
|
| 720 | 720 | if ( ! FrmField::is_option_empty( $field, 'custom_html' ) || $field->field_options['custom_html'] == $default_html || $field->field_options['custom_html'] == $old_default_html ) { |
| 721 | 721 | $field->field_options['custom_html'] = $new_default_html; |
| 722 | 722 | $wpdb->update( $this->fields, array( 'field_options' => maybe_serialize( $field->field_options ) ), array( 'id' => $field->id ) ); |
| 723 | 723 | } |
| 724 | - unset($field); |
|
| 724 | + unset( $field ); |
|
| 725 | 725 | } |
| 726 | - unset($default_html, $old_default_html, $fields); |
|
| 726 | + unset( $default_html, $old_default_html, $fields ); |
|
| 727 | 727 | } |
| 728 | 728 | |
| 729 | 729 | private function migrate_to_4() { |