18 add_action(
'admin_init', array( $this,
'update_settings' ), 1 );
20 add_action(
'admin_menu', array( $this,
'redirect_old_admin_pages' ) );
43 if ( ! $pagenow || ! is_admin() ) {
48 if(
'edit.php' !== $pagenow ) {
52 switch ( \
GV\Utils::_GET(
'page' ) ) {
53 case 'gravityview_settings':
54 wp_safe_redirect( admin_url(
'admin.php?page=gk_settings&p=gravityview&s=0' ) );
56 case 'grant-gravityview-access':
57 wp_safe_redirect( admin_url(
'admin.php?page=gk_foundation_trustedlogin' ) );
59 case 'gv-admin-installer':
60 wp_safe_redirect( admin_url(
'admin.php?page=gk_licenses' ) );
73 $is_updated = get_option(
'gv_migrated_approved_meta' );
92 if ( ! class_exists(
'GFFormsModel' ) ) {
93 gravityview()->log->error(
'GFFormsModel does not exist.' );
97 if ( version_compare( GFFormsModel::get_database_version(),
'2.3-dev-1',
'>=' ) ) {
98 $table_name = GFFormsModel::get_entry_meta_table_name();
100 $table_name = GFFormsModel::get_lead_meta_table_name();
103 $sql =
"UPDATE {$table_name} SET `meta_value` = %s WHERE `meta_key` = 'is_approved' AND `meta_value` = %s";
109 if(
false === $approved_result ||
false === $disapproved_result ) {
110 gravityview()->log->error(
'There was an error processing the query. {error}', array(
'error' => $wpdb->last_error ) );
113 update_option(
'gv_migrated_approved_meta',
true );
123 $is_updated = get_option(
'gv_migrate_searchwidget' );
142 if(
false === $redux_settings ) {
150 $updated_settings = wp_parse_args( $redux_settings, $current );
153 gravityview()->plugin->settings->update( $updated_settings );
156 delete_option(
'gravityview_settings');
157 delete_option(
'gravityview_settings-transients');
168 $redux_option = get_option(
'gravityview_settings');
171 if(
false === $redux_option ) {
175 $redux_settings = array(
176 'support-email' => \
GV\Utils::get( $redux_option,
'support-email' ),
177 'no-conflict-mode' => \
GV\Utils::get( $redux_option,
'no-conflict-mode' ) ?
'1' :
'0',
180 return $redux_settings;
187 if( !class_exists(
'GravityView_Widget_Search') ) {
188 include_once(
GRAVITYVIEW_DIR .
'includes/extensions/search-widget/class-search-widget.php' );
193 'post_type' =>
'gravityview',
194 'post_status' =>
'any',
195 'posts_per_page' => -1,
198 $views = get_posts( $query_args );
200 foreach( $views as $view ) {
203 $search_fields = null;
205 if( empty( $widgets ) || !is_array( $widgets ) ) {
continue; }
207 gravityview()->log->debug(
'[GravityView_Migrate/update_search_on_views] Loading View ID: {view_id}', array(
'view_id' => $view->ID ) );
209 foreach( $widgets as $area => $ws ) {
210 foreach( $ws as $k => $widget ) {
211 if( $widget[
'id'] !==
'search_bar' ) {
continue; }
213 if( is_null( $search_fields ) ) {
220 $search_generic = array();
221 if( !empty( $widget[
'search_free'] ) ) {
222 $search_generic[] = array(
'field' =>
'search_all',
'input' =>
'input_text' );
224 if( !empty( $widget[
'search_date'] ) ) {
225 $search_generic[] = array(
'field' =>
'entry_date',
'input' =>
'date' );
228 $search_config = array_merge( $search_generic, $search_fields );
231 if( empty( $search_config ) ) {
234 $search_config = json_encode( $search_config );
237 $widgets[ $area ][ $k ][
'search_fields'] = $search_config;
238 $widgets[ $area ][ $k ][
'search_layout'] =
'horizontal';
240 gravityview()->log->debug(
'[GravityView_Migrate/update_search_on_views] Updated Widget: ', array(
'data' => $widgets[ $area ][ $k ] ) );
250 update_option(
'gv_migrate_searchwidget',
true );
252 gravityview()->log->debug(
'[GravityView_Migrate/update_search_on_views] All done! enjoy the new Search Widget!' );
261 $search_fields = array();
266 if( !empty( $fields ) && is_array( $fields ) ) {
268 foreach( $fields as $t => $fs ) {
270 foreach( $fs as $k =>
$field ) {
272 if( empty(
$field[
'search_filter'] ) ) {
continue; }
277 if( empty( $form_field[
'type'] ) ) {
285 $search_fields[] = array(
'field' =>
$field[
'id'],
'input' => $type );
291 return $search_fields;
get_redux_settings()
Get Redux settings, if they exist.
const GRAVITYVIEW_DIR
"GRAVITYVIEW_DIR" "./" The absolute path to the plugin directory, with trailing slash ...
gravityview_set_directory_widgets( $post_id, $widgets=array())
Set the widgets, as configured for a View.
redirect_old_admin_pages()
Redirects old GravityView admin pages to the new ones.
maybe_migrate_approved_meta()
Convert approval meta values to enumerated values.
get_search_fields( $view_id)
gravityview_get_form( $form_id)
Returns the form object for a given Form ID.
gravityview_get_directory_widgets( $post_id)
Get the widgets, as configured for a View.
gravityview_get_directory_fields( $post_id, $apply_filter=true, $form_id=0)
Get the field configuration for the View.
maybe_migrate_search_widget()
update_search_on_views()
-— Migrate from old search widget to new search widget -—
if(gravityview() ->plugin->is_GF_25()) $form
gravityview_get_field( $form, $field_id)
Returns the field details array of a specific form given the field id.
gravityview_get_form_id( $view_id)
Get the connected form ID from a View ID.
migrate_redux_settings()
Set app settings from prior Redux settings, if exists.
if(empty( $created_by)) $form_id
gravityview()
The main GravityView wrapper function.
update_approved_meta()
Convert "Approved" approval status to "1".