@@ -47,11 +47,11 @@ discard block |
||
| 47 | 47 | function modify_entry_value_workflow_step( $output, $entry, $field_settings, $field ) { |
| 48 | 48 | |
| 49 | 49 | // If not set, the entry hasn't started a workflow |
| 50 | - $has_workflow_step = isset( $entry['workflow_step'] ); |
|
| 50 | + $has_workflow_step = isset( $entry[ 'workflow_step' ] ); |
|
| 51 | 51 | |
| 52 | - if( $has_workflow_step ) { |
|
| 52 | + if ( $has_workflow_step ) { |
|
| 53 | 53 | |
| 54 | - $GFlow = new Gravity_Flow_API( $entry['form_id'] ); |
|
| 54 | + $GFlow = new Gravity_Flow_API( $entry[ 'form_id' ] ); |
|
| 55 | 55 | |
| 56 | 56 | if ( $current_step = $GFlow->get_current_step( $entry ) ) { |
| 57 | 57 | $output = esc_html( $current_step->get_name() ); |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | preg_match( '/workflow_step_status_(\d+)/', $key, $matches ); |
| 80 | 80 | |
| 81 | 81 | if ( ! empty( $matches ) ) { |
| 82 | - $workflow_step_id = intval( $matches[1] ); |
|
| 82 | + $workflow_step_id = intval( $matches[ 1 ] ); |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | return $workflow_step_id; |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | |
| 99 | 99 | $return = $label; |
| 100 | 100 | |
| 101 | - if ( '' === $label && $workflow_step_id = $this->get_step_id_from_key( $field['field'] ) ) { |
|
| 101 | + if ( '' === $label && $workflow_step_id = $this->get_step_id_from_key( $field[ 'field' ] ) ) { |
|
| 102 | 102 | |
| 103 | 103 | $step = $this->get_workflow_step( $workflow_step_id ); |
| 104 | 104 | |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | |
| 129 | 129 | $workflow_step = $GFlow->get_step( $workflow_step_id ); |
| 130 | 130 | |
| 131 | - if( ! $GFlow || ! $workflow_step ) { |
|
| 131 | + if ( ! $GFlow || ! $workflow_step ) { |
|
| 132 | 132 | return false; |
| 133 | 133 | } |
| 134 | 134 | |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | |
| 151 | 151 | foreach ( $search_fields as & $search_field ) { |
| 152 | 152 | |
| 153 | - if ( $this->name === $search_field['key'] ) { |
|
| 153 | + if ( $this->name === $search_field[ 'key' ] ) { |
|
| 154 | 154 | |
| 155 | 155 | $form_id = GravityView_View::getInstance()->getFormId(); |
| 156 | 156 | |
@@ -159,21 +159,21 @@ discard block |
||
| 159 | 159 | $choices = array(); |
| 160 | 160 | |
| 161 | 161 | foreach ( $workflow_steps as $step ) { |
| 162 | - $choices[] = array( |
|
| 162 | + $choices[ ] = array( |
|
| 163 | 163 | 'text' => $step->get_name(), |
| 164 | 164 | 'value' => $step->get_id(), |
| 165 | 165 | ); |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | - $search_field['choices'] = $choices; |
|
| 168 | + $search_field[ 'choices' ] = $choices; |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | // Workflow Step Statuses |
| 172 | - else if ( $workflow_step_id = $this->get_step_id_from_key( $search_field['key'] ) ) { |
|
| 172 | + else if ( $workflow_step_id = $this->get_step_id_from_key( $search_field[ 'key' ] ) ) { |
|
| 173 | 173 | |
| 174 | 174 | $status_key = sprintf( 'workflow_step_status_%d', $workflow_step_id ); |
| 175 | 175 | |
| 176 | - $search_field['choices'] = GravityView_Plugin_Hooks_Gravity_Flow::get_status_options( null, $status_key ); |
|
| 176 | + $search_field[ 'choices' ] = GravityView_Plugin_Hooks_Gravity_Flow::get_status_options( null, $status_key ); |
|
| 177 | 177 | } |
| 178 | 178 | } |
| 179 | 179 | |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | */ |
| 42 | 42 | function modify_entry_value_workflow_final_status( $output, $entry, $field_settings, $field ) { |
| 43 | 43 | |
| 44 | - if( ! empty( $output ) ) { |
|
| 44 | + if ( ! empty( $output ) ) { |
|
| 45 | 45 | $output = gravity_flow()->translate_status_label( $output ); |
| 46 | 46 | } |
| 47 | 47 | |
@@ -59,8 +59,8 @@ discard block |
||
| 59 | 59 | function modify_search_filters( $search_fields = array(), GravityView_Widget_Search $widget, $widget_args = array() ) { |
| 60 | 60 | |
| 61 | 61 | foreach ( $search_fields as & $search_field ) { |
| 62 | - if ( $this->name === $search_field['key'] ) { |
|
| 63 | - $search_field['choices'] = GravityView_Plugin_Hooks_Gravity_Flow::get_status_options(); |
|
| 62 | + if ( $this->name === $search_field[ 'key' ] ) { |
|
| 63 | + $search_field[ 'choices' ] = GravityView_Plugin_Hooks_Gravity_Flow::get_status_options(); |
|
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | parent::add_hooks(); |
| 35 | 35 | |
| 36 | - add_filter( 'gravityview/search/searchable_fields', array( $this, 'modify_search_bar_fields_dropdown'), 10, 2 ); |
|
| 36 | + add_filter( 'gravityview/search/searchable_fields', array( $this, 'modify_search_bar_fields_dropdown' ), 10, 2 ); |
|
| 37 | 37 | |
| 38 | 38 | } |
| 39 | 39 | |
@@ -52,13 +52,13 @@ discard block |
||
| 52 | 52 | */ |
| 53 | 53 | public static function get_status_options( $form_id = 0, $status_key = 'workflow_final_status' ) { |
| 54 | 54 | |
| 55 | - if( empty( $form_id ) ) { |
|
| 55 | + if ( empty( $form_id ) ) { |
|
| 56 | 56 | $form_id = GravityView_View::getInstance()->getFormId(); |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | $entry_meta = gravity_flow()->get_entry_meta( array(), $form_id ); |
| 60 | 60 | |
| 61 | - return (array) rgars( $entry_meta, $status_key . '/filter/choices' ); |
|
| 61 | + return (array)rgars( $entry_meta, $status_key . '/filter/choices' ); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | |
| 81 | 81 | $workflow_steps = $GFlow->get_steps(); |
| 82 | 82 | |
| 83 | - if( $workflow_steps ) { |
|
| 83 | + if ( $workflow_steps ) { |
|
| 84 | 84 | |
| 85 | 85 | foreach ( $workflow_steps as $step ) { |
| 86 | 86 | |
@@ -92,12 +92,12 @@ discard block |
||
| 92 | 92 | ); |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - $fields['workflow_step'] = array( |
|
| 95 | + $fields[ 'workflow_step' ] = array( |
|
| 96 | 96 | 'label' => esc_html__( 'Workflow Step', 'gravityview' ), |
| 97 | 97 | 'type' => 'select', |
| 98 | 98 | ); |
| 99 | 99 | |
| 100 | - $fields['workflow_final_status'] = array( |
|
| 100 | + $fields[ 'workflow_final_status' ] = array( |
|
| 101 | 101 | 'label' => esc_html__( 'Workflow Status', 'gravityview' ), |
| 102 | 102 | 'type' => 'select', |
| 103 | 103 | ); |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | $return = $input_type; |
| 47 | 47 | |
| 48 | - if( 'survey' === $field_type ) { |
|
| 48 | + if ( 'survey' === $field_type ) { |
|
| 49 | 49 | $return = 'select'; |
| 50 | 50 | } |
| 51 | 51 | |
@@ -65,8 +65,8 @@ discard block |
||
| 65 | 65 | public function fix_survey_fields( $fields ) { |
| 66 | 66 | |
| 67 | 67 | /** @var GF_Field $field */ |
| 68 | - foreach( $fields as &$field ) { |
|
| 69 | - if( 'survey' === $field->type ) { |
|
| 68 | + foreach ( $fields as &$field ) { |
|
| 69 | + if ( 'survey' === $field->type ) { |
|
| 70 | 70 | $field->allowsPrepopulate = true; |
| 71 | 71 | } |
| 72 | 72 | } |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | * @return void |
| 83 | 83 | */ |
| 84 | 84 | function add_render_hooks() { |
| 85 | - add_filter( 'gform_field_value', array( $this, 'fix_survey_field_value'), 10, 3 ); |
|
| 85 | + add_filter( 'gform_field_value', array( $this, 'fix_survey_field_value' ), 10, 3 ); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | /** |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | * @return void |
| 96 | 96 | */ |
| 97 | 97 | function remove_render_hooks() { |
| 98 | - remove_filter( 'gform_field_value', array( $this, 'fix_survey_field_value'), 10 ); |
|
| 98 | + remove_filter( 'gform_field_value', array( $this, 'fix_survey_field_value' ), 10 ); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | /** |
@@ -113,9 +113,9 @@ discard block |
||
| 113 | 113 | */ |
| 114 | 114 | public function fix_survey_field_value( $value, $field, $name ) { |
| 115 | 115 | |
| 116 | - if( 'survey' === $field->type ) { |
|
| 116 | + if ( 'survey' === $field->type ) { |
|
| 117 | 117 | |
| 118 | - $entry = GravityView_Edit_Entry::getInstance()->instances['render']->get_entry(); |
|
| 118 | + $entry = GravityView_Edit_Entry::getInstance()->instances[ 'render' ]->get_entry(); |
|
| 119 | 119 | |
| 120 | 120 | // We need to run through each survey row until we find a match for expected values |
| 121 | 121 | foreach ( $entry as $field_id => $field_value ) { |
@@ -124,11 +124,11 @@ discard block |
||
| 124 | 124 | continue; |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - if( rgar( $field, 'gsurveyLikertEnableMultipleRows' ) ) { |
|
| 127 | + if ( rgar( $field, 'gsurveyLikertEnableMultipleRows' ) ) { |
|
| 128 | 128 | list( $row_val, $col_val ) = explode( ':', $field_value, 2 ); |
| 129 | 129 | |
| 130 | 130 | // If the $name matches the $row_val, we are processing the correct row |
| 131 | - if( $row_val === $name ) { |
|
| 131 | + if ( $row_val === $name ) { |
|
| 132 | 132 | $value = $field_value; |
| 133 | 133 | break; |
| 134 | 134 | } |
@@ -42,9 +42,9 @@ discard block |
||
| 42 | 42 | function __construct( $title = '', $item_id, $item = array(), $settings = array() ) { |
| 43 | 43 | |
| 44 | 44 | // Backward compat |
| 45 | - if ( ! empty( $item['type'] ) ) { |
|
| 46 | - $item['input_type'] = $item['type']; |
|
| 47 | - unset( $item['type'] ); |
|
| 45 | + if ( ! empty( $item[ 'type' ] ) ) { |
|
| 46 | + $item[ 'input_type' ] = $item[ 'type' ]; |
|
| 47 | + unset( $item[ 'type' ] ); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | // Prevent items from not having index set |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | $this->item = $item; |
| 65 | 65 | $this->id = $item_id; |
| 66 | 66 | $this->settings = $settings; |
| 67 | - $this->label_type = $item['label_type']; |
|
| 67 | + $this->label_type = $item[ 'label_type' ]; |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
@@ -107,10 +107,10 @@ discard block |
||
| 107 | 107 | if ( $html ) { |
| 108 | 108 | |
| 109 | 109 | foreach ( $field_info_items as $item ) { |
| 110 | - $class = isset( $item['class'] ) ? sanitize_html_class( $item['class'] ) . ' description' : 'description'; |
|
| 110 | + $class = isset( $item[ 'class' ] ) ? sanitize_html_class( $item[ 'class' ] ) . ' description' : 'description'; |
|
| 111 | 111 | // Add the title in case the value's long, in which case, it'll be truncated by CSS. |
| 112 | 112 | $output .= '<span class="' . $class . '">'; |
| 113 | - $output .= esc_html( $item['value'] ); |
|
| 113 | + $output .= esc_html( $item[ 'value' ] ); |
|
| 114 | 114 | $output .= '</span>'; |
| 115 | 115 | } |
| 116 | 116 | |
@@ -138,29 +138,29 @@ discard block |
||
| 138 | 138 | |
| 139 | 139 | // $settings_html will just be hidden inputs if empty. Otherwise, it'll have an <ul>. Ugly hack, I know. |
| 140 | 140 | // TODO: Un-hack this |
| 141 | - $hide_settings_link = ( empty( $this->item['settings_html'] ) || strpos( $this->item['settings_html'], '<!-- No Options -->' ) > 0 ) ? 'hide-if-js' : ''; |
|
| 141 | + $hide_settings_link = ( empty( $this->item[ 'settings_html' ] ) || strpos( $this->item[ 'settings_html' ], '<!-- No Options -->' ) > 0 ) ? 'hide-if-js' : ''; |
|
| 142 | 142 | $settings_link = sprintf( '<a href="#settings" class="dashicons-admin-generic dashicons %s" title="%s"></a>', $hide_settings_link, esc_attr( $settings_title ) ); |
| 143 | 143 | |
| 144 | 144 | // Should we show the icon that the field is being used as a link to single entry? |
| 145 | - $hide_show_as_link_class = empty( $this->settings['show_as_link'] ) ? 'hide-if-js' : ''; |
|
| 145 | + $hide_show_as_link_class = empty( $this->settings[ 'show_as_link' ] ) ? 'hide-if-js' : ''; |
|
| 146 | 146 | $show_as_link = '<span class="dashicons dashicons-admin-links ' . $hide_show_as_link_class . '" title="' . esc_attr( $single_link_title ) . '"></span>'; |
| 147 | 147 | |
| 148 | 148 | // When a field label is empty, use the Field ID |
| 149 | 149 | $label = empty( $this->title ) ? sprintf( _x( 'Field #%s (No Label)', 'Label in field picker for empty label', 'gravityview' ), $this->id ) : $this->title; |
| 150 | 150 | |
| 151 | 151 | // If there's a custom label, and show label is checked, use that as the field heading |
| 152 | - if ( ! empty( $this->settings['custom_label'] ) && ! empty( $this->settings['show_label'] ) ) { |
|
| 153 | - $label = $this->settings['custom_label']; |
|
| 154 | - } else if ( ! empty( $this->item['customLabel'] ) ) { |
|
| 155 | - $label = $this->item['customLabel']; |
|
| 152 | + if ( ! empty( $this->settings[ 'custom_label' ] ) && ! empty( $this->settings[ 'show_label' ] ) ) { |
|
| 153 | + $label = $this->settings[ 'custom_label' ]; |
|
| 154 | + } else if ( ! empty( $this->item[ 'customLabel' ] ) ) { |
|
| 155 | + $label = $this->item[ 'customLabel' ]; |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | $output = '<h5 class="selectable gfield field-id-' . esc_attr( $this->id ) . '">'; |
| 159 | 159 | |
| 160 | 160 | $label = esc_attr( $label ); |
| 161 | 161 | |
| 162 | - if ( ! empty( $this->item['parent'] ) ) { |
|
| 163 | - $label .= ' <small>(' . esc_attr( $this->item['parent']['label'] ) . ')</small>'; |
|
| 162 | + if ( ! empty( $this->item[ 'parent' ] ) ) { |
|
| 163 | + $label .= ' <small>(' . esc_attr( $this->item[ 'parent' ][ 'label' ] ) . ')</small>'; |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | // Name of field / widget |
@@ -176,9 +176,9 @@ discard block |
||
| 176 | 176 | |
| 177 | 177 | $output .= '</h5>'; |
| 178 | 178 | |
| 179 | - $container_class = ! empty( $this->item['parent'] ) ? ' gv-child-field' : ''; |
|
| 179 | + $container_class = ! empty( $this->item[ 'parent' ] ) ? ' gv-child-field' : ''; |
|
| 180 | 180 | |
| 181 | - $output = '<div data-fieldid="' . esc_attr( $this->id ) . '" data-inputtype="' . esc_attr( $this->item['input_type'] ) . '" class="gv-fields' . $container_class . '">' . $output . $this->item['settings_html'] . '</div>'; |
|
| 181 | + $output = '<div data-fieldid="' . esc_attr( $this->id ) . '" data-inputtype="' . esc_attr( $this->item[ 'input_type' ] ) . '" class="gv-fields' . $container_class . '">' . $output . $this->item[ 'settings_html' ] . '</div>'; |
|
| 182 | 182 | |
| 183 | 183 | return $output; |
| 184 | 184 | } |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | $disapproved_result = $wpdb->query( $wpdb->prepare( $sql, GravityView_Entry_Approval_Status::DISAPPROVED, '0' ) ); |
| 65 | 65 | |
| 66 | - if( false === $approved_result || false === $disapproved_result ) { |
|
| 66 | + if ( false === $approved_result || false === $disapproved_result ) { |
|
| 67 | 67 | do_action( 'gravityview_log_error', __METHOD__ . ': There was an error processing the query.', $wpdb->last_error ); |
| 68 | 68 | } else { |
| 69 | 69 | // All done: Meta values are migrated |
@@ -96,11 +96,11 @@ discard block |
||
| 96 | 96 | $redux_settings = $this->get_redux_settings(); |
| 97 | 97 | |
| 98 | 98 | // No need to process |
| 99 | - if( false === $redux_settings ) { |
|
| 99 | + if ( false === $redux_settings ) { |
|
| 100 | 100 | return; |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - if( empty( $redux_settings['license_key_status'] ) ) { |
|
| 103 | + if ( empty( $redux_settings[ 'license_key_status' ] ) ) { |
|
| 104 | 104 | $redux_settings = $this->get_redux_license_status( $redux_settings ); |
| 105 | 105 | } |
| 106 | 106 | |
@@ -114,8 +114,8 @@ discard block |
||
| 114 | 114 | GravityView_Settings::get_instance()->update_app_settings( $updated_settings ); |
| 115 | 115 | |
| 116 | 116 | // And now remove the previous option, so this is a one-time thing. |
| 117 | - delete_option('gravityview_settings'); |
|
| 118 | - delete_option('gravityview_settings-transients'); |
|
| 117 | + delete_option( 'gravityview_settings' ); |
|
| 118 | + delete_option( 'gravityview_settings-transients' ); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | /** |
@@ -131,16 +131,16 @@ discard block |
||
| 131 | 131 | |
| 132 | 132 | $data = array( |
| 133 | 133 | 'edd_action' => 'check_license', |
| 134 | - 'license' => rgget('license_key', $redux_settings ), |
|
| 134 | + 'license' => rgget( 'license_key', $redux_settings ), |
|
| 135 | 135 | 'update' => false, |
| 136 | 136 | 'format' => 'object', |
| 137 | 137 | ); |
| 138 | 138 | |
| 139 | 139 | $license_call = GravityView_Settings::get_instance()->get_license_handler()->license_call( $data ); |
| 140 | 140 | |
| 141 | - if( is_object( $license_call ) && isset( $license_call->license ) ) { |
|
| 142 | - $redux_settings['license_key_status'] = $license_call->license; |
|
| 143 | - $redux_settings['license_key_response'] = json_encode( $license_call ); |
|
| 141 | + if ( is_object( $license_call ) && isset( $license_call->license ) ) { |
|
| 142 | + $redux_settings[ 'license_key_status' ] = $license_call->license; |
|
| 143 | + $redux_settings[ 'license_key_response' ] = json_encode( $license_call ); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | return $redux_settings; |
@@ -154,10 +154,10 @@ discard block |
||
| 154 | 154 | function get_redux_settings() { |
| 155 | 155 | |
| 156 | 156 | // Previous settings set by Redux |
| 157 | - $redux_option = get_option('gravityview_settings'); |
|
| 157 | + $redux_option = get_option( 'gravityview_settings' ); |
|
| 158 | 158 | |
| 159 | 159 | // No Redux settings? Don't proceed. |
| 160 | - if( false === $redux_option ) { |
|
| 160 | + if ( false === $redux_option ) { |
|
| 161 | 161 | return false; |
| 162 | 162 | } |
| 163 | 163 | |
@@ -167,21 +167,21 @@ discard block |
||
| 167 | 167 | 'no-conflict-mode' => ( rgget( 'no-conflict-mode', $redux_option ) ? '1' : '0' ), |
| 168 | 168 | ); |
| 169 | 169 | |
| 170 | - if( $license_array = rgget( 'license', $redux_option ) ) { |
|
| 170 | + if ( $license_array = rgget( 'license', $redux_option ) ) { |
|
| 171 | 171 | |
| 172 | - $redux_settings['license_key'] = $license_key = rgget( 'license', $license_array ); |
|
| 172 | + $redux_settings[ 'license_key' ] = $license_key = rgget( 'license', $license_array ); |
|
| 173 | 173 | |
| 174 | - $redux_last_changed_values = get_option('gravityview_settings-transients'); |
|
| 174 | + $redux_last_changed_values = get_option( 'gravityview_settings-transients' ); |
|
| 175 | 175 | |
| 176 | 176 | // This contains the last response for license validation |
| 177 | - if( !empty( $redux_last_changed_values ) && $saved_values = rgget( 'changed_values', $redux_last_changed_values ) ) { |
|
| 177 | + if ( ! empty( $redux_last_changed_values ) && $saved_values = rgget( 'changed_values', $redux_last_changed_values ) ) { |
|
| 178 | 178 | |
| 179 | - $saved_license = rgget('license', $saved_values ); |
|
| 179 | + $saved_license = rgget( 'license', $saved_values ); |
|
| 180 | 180 | |
| 181 | 181 | // Only use the last-saved values if they are for the same license |
| 182 | - if( $saved_license && rgget( 'license', $saved_license ) === $license_key ) { |
|
| 183 | - $redux_settings['license_key_status'] = rgget( 'status', $saved_license ); |
|
| 184 | - $redux_settings['license_key_response'] = rgget( 'response', $saved_license ); |
|
| 182 | + if ( $saved_license && rgget( 'license', $saved_license ) === $license_key ) { |
|
| 183 | + $redux_settings[ 'license_key_status' ] = rgget( 'status', $saved_license ); |
|
| 184 | + $redux_settings[ 'license_key_response' ] = rgget( 'response', $saved_license ); |
|
| 185 | 185 | } |
| 186 | 186 | } |
| 187 | 187 | } |
@@ -193,8 +193,8 @@ discard block |
||
| 193 | 193 | /** ---- Migrate from old search widget to new search widget ---- */ |
| 194 | 194 | function update_search_on_views() { |
| 195 | 195 | |
| 196 | - if( !class_exists('GravityView_Widget_Search') ) { |
|
| 197 | - include_once( GRAVITYVIEW_DIR .'includes/extensions/search-widget/class-search-widget.php' ); |
|
| 196 | + if ( ! class_exists( 'GravityView_Widget_Search' ) ) { |
|
| 197 | + include_once( GRAVITYVIEW_DIR . 'includes/extensions/search-widget/class-search-widget.php' ); |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | // Loop through all the views |
@@ -206,20 +206,20 @@ discard block |
||
| 206 | 206 | |
| 207 | 207 | $views = get_posts( $query_args ); |
| 208 | 208 | |
| 209 | - foreach( $views as $view ) { |
|
| 209 | + foreach ( $views as $view ) { |
|
| 210 | 210 | |
| 211 | 211 | $widgets = gravityview_get_directory_widgets( $view->ID ); |
| 212 | 212 | $search_fields = null; |
| 213 | 213 | |
| 214 | - if( empty( $widgets ) || !is_array( $widgets ) ) { continue; } |
|
| 214 | + if ( empty( $widgets ) || ! is_array( $widgets ) ) { continue; } |
|
| 215 | 215 | |
| 216 | 216 | do_action( 'gravityview_log_debug', '[GravityView_Migrate/update_search_on_views] Loading View ID: ', $view->ID ); |
| 217 | 217 | |
| 218 | - foreach( $widgets as $area => $ws ) { |
|
| 219 | - foreach( $ws as $k => $widget ) { |
|
| 220 | - if( $widget['id'] !== 'search_bar' ) { continue; } |
|
| 218 | + foreach ( $widgets as $area => $ws ) { |
|
| 219 | + foreach ( $ws as $k => $widget ) { |
|
| 220 | + if ( $widget[ 'id' ] !== 'search_bar' ) { continue; } |
|
| 221 | 221 | |
| 222 | - if( is_null( $search_fields ) ) { |
|
| 222 | + if ( is_null( $search_fields ) ) { |
|
| 223 | 223 | $search_fields = $this->get_search_fields( $view->ID ); |
| 224 | 224 | } |
| 225 | 225 | |
@@ -227,24 +227,24 @@ discard block |
||
| 227 | 227 | // [search_free] => 1 |
| 228 | 228 | // [search_date] => 1 |
| 229 | 229 | $search_generic = array(); |
| 230 | - if( !empty( $widget['search_free'] ) ) { |
|
| 231 | - $search_generic[] = array( 'field' => 'search_all', 'input' => 'input_text' ); |
|
| 230 | + if ( ! empty( $widget[ 'search_free' ] ) ) { |
|
| 231 | + $search_generic[ ] = array( 'field' => 'search_all', 'input' => 'input_text' ); |
|
| 232 | 232 | } |
| 233 | - if( !empty( $widget['search_date'] ) ) { |
|
| 234 | - $search_generic[] = array( 'field' => 'entry_date', 'input' => 'date' ); |
|
| 233 | + if ( ! empty( $widget[ 'search_date' ] ) ) { |
|
| 234 | + $search_generic[ ] = array( 'field' => 'entry_date', 'input' => 'date' ); |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | $search_config = array_merge( $search_generic, $search_fields ); |
| 238 | 238 | |
| 239 | 239 | // don't throw '[]' when json_encode an empty array |
| 240 | - if( empty( $search_config ) ) { |
|
| 240 | + if ( empty( $search_config ) ) { |
|
| 241 | 241 | $search_config = ''; |
| 242 | 242 | } else { |
| 243 | 243 | $search_config = json_encode( $search_config ); |
| 244 | 244 | } |
| 245 | 245 | |
| 246 | - $widgets[ $area ][ $k ]['search_fields'] = $search_config; |
|
| 247 | - $widgets[ $area ][ $k ]['search_layout'] = 'horizontal'; |
|
| 246 | + $widgets[ $area ][ $k ][ 'search_fields' ] = $search_config; |
|
| 247 | + $widgets[ $area ][ $k ][ 'search_layout' ] = 'horizontal'; |
|
| 248 | 248 | |
| 249 | 249 | do_action( 'gravityview_log_debug', '[GravityView_Migrate/update_search_on_views] Updated Widget: ', $widgets[ $area ][ $k ] ); |
| 250 | 250 | } |
@@ -272,26 +272,26 @@ discard block |
||
| 272 | 272 | // check view fields' settings |
| 273 | 273 | $fields = gravityview_get_directory_fields( $view_id, false ); |
| 274 | 274 | |
| 275 | - if( !empty( $fields ) && is_array( $fields ) ) { |
|
| 275 | + if ( ! empty( $fields ) && is_array( $fields ) ) { |
|
| 276 | 276 | |
| 277 | - foreach( $fields as $t => $fs ) { |
|
| 277 | + foreach ( $fields as $t => $fs ) { |
|
| 278 | 278 | |
| 279 | - foreach( $fs as $k => $field ) { |
|
| 279 | + foreach ( $fs as $k => $field ) { |
|
| 280 | 280 | // is field a search_filter ? |
| 281 | - if( empty( $field['search_filter'] ) ) { continue; } |
|
| 281 | + if ( empty( $field[ 'search_filter' ] ) ) { continue; } |
|
| 282 | 282 | |
| 283 | 283 | // get field type & calculate the input type (by default) |
| 284 | - $form_field = gravityview_get_field( $form, $field['id'] ); |
|
| 284 | + $form_field = gravityview_get_field( $form, $field[ 'id' ] ); |
|
| 285 | 285 | |
| 286 | - if( empty( $form_field['type'] ) ) { |
|
| 286 | + if ( empty( $form_field[ 'type' ] ) ) { |
|
| 287 | 287 | continue; |
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | // depending on the field type assign a group of possible search field types |
| 291 | - $type = GravityView_Widget_Search::get_search_input_types( $field['id'], $form_field['type'] ); |
|
| 291 | + $type = GravityView_Widget_Search::get_search_input_types( $field[ 'id' ], $form_field[ 'type' ] ); |
|
| 292 | 292 | |
| 293 | 293 | // add field to config |
| 294 | - $search_fields[] = array( 'field' => $field['id'], 'input' => $type ); |
|
| 294 | + $search_fields[ ] = array( 'field' => $field[ 'id' ], 'input' => $type ); |
|
| 295 | 295 | |
| 296 | 296 | } |
| 297 | 297 | } |
@@ -20,12 +20,12 @@ discard block |
||
| 20 | 20 | |
| 21 | 21 | function __construct() { |
| 22 | 22 | |
| 23 | - add_action( 'media_buttons', array( $this, 'add_shortcode_button'), 30); |
|
| 23 | + add_action( 'media_buttons', array( $this, 'add_shortcode_button' ), 30 ); |
|
| 24 | 24 | |
| 25 | - add_action( 'admin_footer', array( $this, 'add_shortcode_popup') ); |
|
| 25 | + add_action( 'admin_footer', array( $this, 'add_shortcode_popup' ) ); |
|
| 26 | 26 | |
| 27 | 27 | // adding styles and scripts |
| 28 | - add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_and_styles') ); |
|
| 28 | + add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_and_styles' ) ); |
|
| 29 | 29 | |
| 30 | 30 | // ajax - populate sort fields based on the selected view |
| 31 | 31 | add_action( 'wp_ajax_gv_sortable_fields', array( $this, 'get_sortable_fields' ) ); |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | function is_post_editor_screen() { |
| 42 | 42 | global $current_screen, $pagenow; |
| 43 | - return !empty( $current_screen->post_type ) && 'gravityview' != $current_screen->post_type && in_array( $pagenow , array( 'post.php' , 'post-new.php' ) ); |
|
| 43 | + return ! empty( $current_screen->post_type ) && 'gravityview' != $current_screen->post_type && in_array( $pagenow, array( 'post.php', 'post-new.php' ) ); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | |
@@ -55,15 +55,15 @@ discard block |
||
| 55 | 55 | /** |
| 56 | 56 | * @since 1.15.3 |
| 57 | 57 | */ |
| 58 | - if( ! GVCommon::has_cap( array( 'publish_gravityviews' ) ) ) { |
|
| 58 | + if ( ! GVCommon::has_cap( array( 'publish_gravityviews' ) ) ) { |
|
| 59 | 59 | return; |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - if( !$this->is_post_editor_screen() ) { |
|
| 62 | + if ( ! $this->is_post_editor_screen() ) { |
|
| 63 | 63 | return; |
| 64 | 64 | } |
| 65 | 65 | ?> |
| 66 | - <a href="#TB_inline?width=600&height=800&inlineId=select_gravityview_view" class="thickbox hide-if-no-js button gform_media_link" id="add_gravityview" title="<?php esc_attr_e("Insert View", 'gravityview'); ?>"><span class="icon gv-icon-astronaut-head"></span><?php esc_html_e( 'Add View', 'gravityview' ); ?></a> |
|
| 66 | + <a href="#TB_inline?width=600&height=800&inlineId=select_gravityview_view" class="thickbox hide-if-no-js button gform_media_link" id="add_gravityview" title="<?php esc_attr_e( "Insert View", 'gravityview' ); ?>"><span class="icon gv-icon-astronaut-head"></span><?php esc_html_e( 'Add View', 'gravityview' ); ?></a> |
|
| 67 | 67 | <?php |
| 68 | 68 | |
| 69 | 69 | } |
@@ -79,16 +79,16 @@ discard block |
||
| 79 | 79 | function add_shortcode_popup() { |
| 80 | 80 | global $post; |
| 81 | 81 | |
| 82 | - if( !$this->is_post_editor_screen() ) { |
|
| 82 | + if ( ! $this->is_post_editor_screen() ) { |
|
| 83 | 83 | return; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - $post_type = get_post_type_object($post->post_type); |
|
| 86 | + $post_type = get_post_type_object( $post->post_type ); |
|
| 87 | 87 | |
| 88 | - $views = get_posts( array('post_type' => 'gravityview', 'posts_per_page' => -1 ) ); |
|
| 88 | + $views = get_posts( array( 'post_type' => 'gravityview', 'posts_per_page' => -1 ) ); |
|
| 89 | 89 | |
| 90 | 90 | // If there are no views set up yet, we get outta here. |
| 91 | - if( empty( $views ) ) { |
|
| 91 | + if ( empty( $views ) ) { |
|
| 92 | 92 | echo '<div id="select_gravityview_view"><div class="wrap">' . GravityView_Admin::no_views_text() . '</div></div>'; |
| 93 | 93 | return; |
| 94 | 94 | } |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | <div class="wrap"> |
| 100 | 100 | |
| 101 | 101 | <h2 class=""><?php esc_html_e( 'Embed a View', 'gravityview' ); ?></h2> |
| 102 | - <p class="subtitle"><?php printf( esc_attr ( __( 'Use this form to embed a View into this %s. %sLearn more about using shortcodes.%s', 'gravityview') ), $post_type->labels->singular_name, '<a href="http://docs.gravityview.co/article/73-using-the-shortcode" target="_blank" rel="noopener noreferrer">', '</a>' ); ?></p> |
|
| 102 | + <p class="subtitle"><?php printf( esc_attr( __( 'Use this form to embed a View into this %s. %sLearn more about using shortcodes.%s', 'gravityview' ) ), $post_type->labels->singular_name, '<a href="http://docs.gravityview.co/article/73-using-the-shortcode" target="_blank" rel="noopener noreferrer">', '</a>' ); ?></p> |
|
| 103 | 103 | |
| 104 | 104 | <div> |
| 105 | 105 | <h3><label for="gravityview_id"><?php esc_html_e( 'Select a View', 'gravityview' ); ?></label></h3> |
@@ -107,9 +107,9 @@ discard block |
||
| 107 | 107 | <select name="gravityview_id" id="gravityview_id"> |
| 108 | 108 | <option value=""><?php esc_html_e( '— Select a View to Insert —', 'gravityview' ); ?></option> |
| 109 | 109 | <?php |
| 110 | - foreach( $views as $view ) { |
|
| 111 | - $title = empty( $view->post_title ) ? __('(no title)', 'gravityview') : $view->post_title; |
|
| 112 | - echo '<option value="'. $view->ID .'">'. esc_html( sprintf('%s #%d', $title, $view->ID ) ) .'</option>'; |
|
| 110 | + foreach ( $views as $view ) { |
|
| 111 | + $title = empty( $view->post_title ) ? __( '(no title)', 'gravityview' ) : $view->post_title; |
|
| 112 | + echo '<option value="' . $view->ID . '">' . esc_html( sprintf( '%s #%d', $title, $view->ID ) ) . '</option>'; |
|
| 113 | 113 | } |
| 114 | 114 | ?> |
| 115 | 115 | </select> |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | |
| 126 | 126 | foreach ( $settings as $key => $setting ) { |
| 127 | 127 | |
| 128 | - if( empty( $setting['show_in_shortcode'] ) ) { continue; } |
|
| 128 | + if ( empty( $setting[ 'show_in_shortcode' ] ) ) { continue; } |
|
| 129 | 129 | |
| 130 | 130 | GravityView_Render_Settings::render_setting_row( $key, array(), NULL, 'gravityview_%s', 'gravityview_%s' ); |
| 131 | 131 | } |
@@ -134,8 +134,8 @@ discard block |
||
| 134 | 134 | </table> |
| 135 | 135 | |
| 136 | 136 | <div class="submit"> |
| 137 | - <input type="submit" class="button button-primary button-large alignleft hide-if-js" value="<?php esc_attr_e('Insert View', 'gravityview' ); ?>" id="insert_gravityview_view" /> |
|
| 138 | - <input class="button button-secondary alignright" type="submit" onclick="tb_remove(); return false;" value="<?php esc_attr_e("Cancel", 'gravityview'); ?>" /> |
|
| 137 | + <input type="submit" class="button button-primary button-large alignleft hide-if-js" value="<?php esc_attr_e( 'Insert View', 'gravityview' ); ?>" id="insert_gravityview_view" /> |
|
| 138 | + <input class="button button-secondary alignright" type="submit" onclick="tb_remove(); return false;" value="<?php esc_attr_e( "Cancel", 'gravityview' ); ?>" /> |
|
| 139 | 139 | </div> |
| 140 | 140 | |
| 141 | 141 | </div> |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | */ |
| 157 | 157 | function add_scripts_and_styles() { |
| 158 | 158 | |
| 159 | - if( ! $this->is_post_editor_screen() ) { |
|
| 159 | + if ( ! $this->is_post_editor_screen() ) { |
|
| 160 | 160 | return; |
| 161 | 161 | } |
| 162 | 162 | |
@@ -167,22 +167,22 @@ discard block |
||
| 167 | 167 | |
| 168 | 168 | $protocol = is_ssl() ? 'https://' : 'http://'; |
| 169 | 169 | |
| 170 | - wp_enqueue_style( 'jquery-ui-datepicker', $protocol.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css', array(), GravityView_Plugin::version ); |
|
| 170 | + wp_enqueue_style( 'jquery-ui-datepicker', $protocol . 'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css', array(), GravityView_Plugin::version ); |
|
| 171 | 171 | |
| 172 | 172 | //enqueue styles |
| 173 | - wp_register_style( 'gravityview_postedit_styles', plugins_url('assets/css/admin-post-edit.css', GRAVITYVIEW_FILE), array(), GravityView_Plugin::version ); |
|
| 173 | + wp_register_style( 'gravityview_postedit_styles', plugins_url( 'assets/css/admin-post-edit.css', GRAVITYVIEW_FILE ), array(), GravityView_Plugin::version ); |
|
| 174 | 174 | wp_enqueue_style( 'gravityview_postedit_styles' ); |
| 175 | 175 | |
| 176 | - $script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
| 176 | + $script_debug = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
| 177 | 177 | |
| 178 | 178 | // custom js |
| 179 | - wp_register_script( 'gravityview_postedit_scripts', plugins_url('assets/js/admin-post-edit'.$script_debug.'.js', GRAVITYVIEW_FILE), array( 'jquery', 'jquery-ui-datepicker' ), GravityView_Plugin::version ); |
|
| 179 | + wp_register_script( 'gravityview_postedit_scripts', plugins_url( 'assets/js/admin-post-edit' . $script_debug . '.js', GRAVITYVIEW_FILE ), array( 'jquery', 'jquery-ui-datepicker' ), GravityView_Plugin::version ); |
|
| 180 | 180 | wp_enqueue_script( 'gravityview_postedit_scripts' ); |
| 181 | - wp_localize_script('gravityview_postedit_scripts', 'gvGlobals', array( |
|
| 182 | - 'nonce' => wp_create_nonce( 'gravityview_ajaxaddshortcode'), |
|
| 181 | + wp_localize_script( 'gravityview_postedit_scripts', 'gvGlobals', array( |
|
| 182 | + 'nonce' => wp_create_nonce( 'gravityview_ajaxaddshortcode' ), |
|
| 183 | 183 | 'loading_text' => esc_html__( 'Loading…', 'gravityview' ), |
| 184 | - 'alert_1' => esc_html__( 'Please select a View', 'gravityview'), |
|
| 185 | - )); |
|
| 184 | + 'alert_1' => esc_html__( 'Please select a View', 'gravityview' ), |
|
| 185 | + ) ); |
|
| 186 | 186 | |
| 187 | 187 | } |
| 188 | 188 | |
@@ -198,16 +198,16 @@ discard block |
||
| 198 | 198 | function get_sortable_fields() { |
| 199 | 199 | |
| 200 | 200 | // Not properly formatted request |
| 201 | - if ( empty( $_POST['viewid'] ) || !is_numeric( $_POST['viewid'] ) ) { |
|
| 201 | + if ( empty( $_POST[ 'viewid' ] ) || ! is_numeric( $_POST[ 'viewid' ] ) ) { |
|
| 202 | 202 | exit( false ); |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | // Not valid request |
| 206 | - if( empty( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxaddshortcode' ) ) { |
|
| 206 | + if ( empty( $_POST[ 'nonce' ] ) || ! wp_verify_nonce( $_POST[ 'nonce' ], 'gravityview_ajaxaddshortcode' ) ) { |
|
| 207 | 207 | exit( false ); |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | - $viewid = (int)$_POST['viewid']; |
|
| 210 | + $viewid = (int)$_POST[ 'viewid' ]; |
|
| 211 | 211 | |
| 212 | 212 | // fetch form id assigned to the view |
| 213 | 213 | $formid = gravityview_get_form_id( $viewid ); |
@@ -113,16 +113,16 @@ discard block |
||
| 113 | 113 | $new_value = $old_value; |
| 114 | 114 | |
| 115 | 115 | // Meta value does not exist yet |
| 116 | - if( false === $old_value ) { |
|
| 116 | + if ( false === $old_value ) { |
|
| 117 | 117 | return self::UNAPPROVED; |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | // Meta value does not exist yet |
| 121 | - if( true === $old_value ) { |
|
| 121 | + if ( true === $old_value ) { |
|
| 122 | 122 | return self::APPROVED; |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - switch ( (string) $old_value ) { |
|
| 125 | + switch ( (string)$old_value ) { |
|
| 126 | 126 | |
| 127 | 127 | // Approved values |
| 128 | 128 | case 'Approved': |
@@ -247,9 +247,9 @@ discard block |
||
| 247 | 247 | foreach ( $choices as $key => $choice ) { |
| 248 | 248 | |
| 249 | 249 | // Is the passed status value the same as the choice value or key? |
| 250 | - if ( $status === $choice['value'] || $status === $key ) { |
|
| 250 | + if ( $status === $choice[ 'value' ] || $status === $key ) { |
|
| 251 | 251 | |
| 252 | - if( 'key' === $attr_key ) { |
|
| 252 | + if ( 'key' === $attr_key ) { |
|
| 253 | 253 | return $key; |
| 254 | 254 | } else { |
| 255 | 255 | return rgar( $choice, $attr_key, false ); |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | // Load even when invalid to allow for export |
| 20 | 20 | add_action( 'init', array( 'GravityView_Post_Types', 'init_post_types' ) ); |
| 21 | 21 | |
| 22 | - if( GravityView_Compatibility::is_valid() ) { |
|
| 22 | + if ( GravityView_Compatibility::is_valid() ) { |
|
| 23 | 23 | add_action( 'init', array( 'GravityView_Post_Types', 'init_rewrite' ) ); |
| 24 | 24 | } |
| 25 | 25 | } |
@@ -43,8 +43,8 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | $supports = array( 'title', 'revisions' ); |
| 45 | 45 | |
| 46 | - if( $is_hierarchical ) { |
|
| 47 | - $supports[] = 'page-attributes'; |
|
| 46 | + if ( $is_hierarchical ) { |
|
| 47 | + $supports[ ] = 'page-attributes'; |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /** |