Function Reference: geodir_cpt_submit_general_settings

Summary

Filter the general settings saved.

Description

After general settings saved it process the option of enable/disable location
for CPT.

Global Values

$wpdb
(object) (required) WordPress Database object.

Default: None
$plugin_prefix
(string) (required) Geodirectory plugin table prefix.

Default: None

Change Log

Since: 1.1.6

Source File

geodir_cpt_submit_general_settings() is located in geodir_custom_posts/geodir_cp_functions.php [Line: 1037]

Source Code

function geodir_cpt_submit_general_settings() {
	global $wpdb, $plugin_prefix;
	
	$cpt_disable_location = !empty( $_REQUEST['geodir_cpt_disable_location'] ) ? $_REQUEST['geodir_cpt_disable_location'] : NULL;
    $gd_posttypes = geodir_get_posttypes();
	
	foreach ( $gd_posttypes as $gd_posttype ) {
		if ( !empty( $cpt_disable_location ) && in_array( $gd_posttype, $cpt_disable_location ) ) {
			$sql = $wpdb->prepare( "UPDATE " . GEODIR_CUSTOM_FIELDS_TABLE . " SET is_active = '0' WHERE post_type=%s AND field_type=%s AND htmlvar_name=%s AND is_active != '0'", array( $gd_posttype, 'address', 'post' ) );
		} else {
			$sql = $wpdb->prepare( "UPDATE " . GEODIR_CUSTOM_FIELDS_TABLE . " SET is_active = '1' WHERE post_type=%s AND field_type=%s AND htmlvar_name=%s AND is_active != '1'", array( $gd_posttype, 'address', 'post' ) );
		}

		$wpdb->query( $sql );
	}

	if ( !empty( $cpt_disable_location ) ) {

		$exclude_post_types = get_option( 'geodir_exclude_post_type_on_map' );
		$exclude_post_types = !empty( $cpt_disable_location ) ? array_unique( array_merge( $exclude_post_types, $cpt_disable_location ) ) : $exclude_post_types;

		update_option( 'geodir_exclude_post_type_on_map', $exclude_post_types );

	}
}