/**
 * Plugin Activation Function
 *
 * @since 1.0.0
 * @package GeoDirectory_Location_Manager
 */
function geodir_location_activation()
{
    if (get_option('geodir_installed')) {
        geodir_location_activation_script();
        geodir_update_options(geodir_location_default_options(), true);
        add_option('geodir_location_manager_activation_redirect', 1);
    }
}
function geodir_claim_manager_ajax()
{
    if (isset($_POST['geodir_sendact']) && $_POST['geodir_sendact'] == 'add_claim') {
        geodir_user_add_claim();
    }
    if (isset($_REQUEST['claimact']) && $_REQUEST['claimact'] == 'addclaim') {
        geodir_claim_add_comment();
    }
    if (isset($_REQUEST['subtab']) && $_REQUEST['subtab'] == 'geodir_claim_options') {
        geodir_update_options(geodir_claim_default_options());
        $msg = CLAIM_LISTING_OPTIONS_SAVE;
        $msg = urlencode($msg);
        $location = admin_url() . "admin.php?page=geodirectory&tab=claimlisting_fields&subtab=geodir_claim_options&claim_success=" . $msg;
        wp_redirect($location);
        exit;
    }
    if (isset($_REQUEST['manage_action']) && $_REQUEST['manage_action'] == 'true') {
        geodir_manage_claim_listing_actions();
    }
    if (isset($_REQUEST['subtab']) && $_REQUEST['subtab'] == 'geodir_claim_notification') {
        geodir_update_options(geodir_claim_notifications());
        $msg = CLAIM_NOTIFY_SAVE_SUCCESS;
        $msg = urlencode($msg);
        $location = admin_url() . "admin.php?page=geodirectory&tab=claimlisting_fields&subtab=geodir_claim_notification&claim_success=" . $msg;
        wp_redirect($location);
        exit;
    }
    if (isset($_REQUEST['popuptype']) && $_REQUEST['popuptype'] != '' && isset($_REQUEST['post_id']) && $_REQUEST['post_id'] != '') {
        if ($_REQUEST['popuptype'] == 'geodir_claim_enable') {
            geodir_claim_popup_form($_REQUEST['post_id']);
        }
        exit;
    }
}
Example #3
0
/**
 * Default options.
 *
 * Adds the default options. Modify at your own risk.
 *
 * @since 1.0.0
 * @package GeoDirectory
 * @global array $geodir_settings Geodirectory settings array.
 */
function geodir_set_default_options()
{
    global $geodir_settings;
    /**
     * Contains settings array for general tab.
     *
     * @since 1.0.0
     * @package GeoDirectory
     */
    include_once "option-pages/general_settings_array.php";
    /**
     * Contains settings array for design tab.
     *
     * @since 1.0.0
     * @package GeoDirectory
     */
    include_once "option-pages/design_settings_array.php";
    /**
     * Contains settings array for notifications tab.
     *
     * @since 1.0.0
     * @package GeoDirectory
     */
    include_once "option-pages/notifications_settings_array.php";
    /**
     * Contains settings array for permalink tab.
     *
     * @since 1.0.0
     * @package GeoDirectory
     */
    include_once "option-pages/permalink_settings_array.php";
    foreach ($geodir_settings as $value) {
        geodir_update_options($value, true);
    }
}
function geodir_autocompleter_from_submit_handler()
{
    if (isset($_REQUEST['geodir_autocompleter_save'])) {
        geodir_update_options(geodir_autocompleter_options());
    }
}
function geodir_payment_manager_ajax()
{
    if (isset($_REQUEST['gd_add_price']) && $_REQUEST['gd_add_price'] == 'addprice') {
        geodir_add_edit_price();
    }
    if (isset($_REQUEST['action_del']) && $_REQUEST['action_del'] == 'true') {
        geodir_del_price();
    }
    if (isset($_REQUEST['paymentsetting']) && $_REQUEST['paymentsetting'] == 'update_setting') {
        geodir_change_payment_method_setting();
    }
    if (isset($_REQUEST['gdaction']) && $_REQUEST['gdaction'] == 'change_status') {
        geodir_change_payment_method_status();
    }
    if (isset($_REQUEST['invoice_action']) && $_REQUEST['invoice_action'] == 'invoice') {
        geodir_change_invoice_status();
    }
    if (isset($_REQUEST['gd_add_coupon']) && $_REQUEST['gd_add_coupon'] == 'addprice') {
        geodir_add_edit_coupon();
    }
    if (isset($_REQUEST['coupon_del']) && $_REQUEST['coupon_del'] == 'true') {
        geodir_del_coupon();
    }
    if (isset($_REQUEST['allow_coupon']) && $_REQUEST['allow_coupon'] == 'true') {
        geodir_allow_coupon_code();
    }
    if (isset($_REQUEST['subtab']) && $_REQUEST['subtab'] == 'geodir_payment_general_options') {
        geodir_update_options(geodir_payment_general_options());
        $msg = 'Your settings have been saved.';
        $msg = urlencode($msg);
        $location = admin_url() . "admin.php?page=geodirectory&tab=paymentmanager_fields&subtab=geodir_payment_general_options&success_msg=" . $msg;
        wp_redirect($location);
        exit;
    }
    if (isset($_REQUEST['subtab']) && $_REQUEST['subtab'] == 'payment_notifications') {
        geodir_update_options(geodir_payment_notifications());
        $msg = 'Notifications updated successfully.';
        $msg = urlencode($msg);
        $location = admin_url() . "admin.php?page=geodirectory&tab=paymentmanager_fields&subtab=payment_notifications&success_msg=" . $msg;
        wp_redirect($location);
        exit;
    }
    if (isset($_REQUEST['payment_ajax_data']) && $_REQUEST['payment_ajax_data'] != '') {
        geodir_fields_list_by_posttype($_REQUEST['post_type'], $_REQUEST['pkg_id'], $_REQUEST['cats'], $_REQUEST['payment_ajax_data']);
        exit;
    }
    if (isset($_REQUEST['payaction']) && $_REQUEST['payaction'] == 'trouble_shoot') {
        geodir_payment_method_update();
    }
}
/**
 * Handles location form data.
 *
 * @since 1.0.0
 * @package GeoDirectory_Location_Manager
 */
function geodir_location_form_submit_handler()
{
    if (isset($_REQUEST['geodir_location_merge']) && $_REQUEST['geodir_location_merge'] == 'merge') {
        include_once 'geodir_merge_field.php';
        exit;
    }
    if (isset($_REQUEST['location_ajax_action'])) {
        switch ($_REQUEST['location_ajax_action']) {
            case 'settings':
                geodir_update_options(geodir_location_default_options());
                $msg = GD_LOCATION_SETTINGS_SAVED;
                $msg = urlencode($msg);
                $location = admin_url() . "admin.php?page=geodirectory&tab=managelocation_fields&subtab=geodir_location_setting&location_success=" . $msg;
                wp_redirect($location);
                exit;
                break;
            case 'location':
                geodir_add_location();
                break;
            case 'add_hood':
                geodir_add_neighbourhood();
                break;
            case 'set_default':
                geodir_set_default();
                break;
            case 'merge':
                geodir_merge_location();
                break;
            case 'delete':
                geodir_delete_location();
                break;
            case 'delete_hood':
                geodir_delete_hood();
                break;
            case 'merge_cities':
                include_once 'geodir_merge_field.php';
                exit;
                break;
            case 'set_region_on_map':
                geodir_get_region_on_map();
                break;
            case 'geodir_set_location_seo':
                geodir_get_location_seo_settings();
                break;
            case 'geodir_save_cat_location':
                geodir_save_cat_location();
                break;
            case 'geodir_change_cat_location':
                geodir_change_cat_location();
                break;
        }
    }
}
/**
 * main ajax function.
 *
 * @since 1.0.0
 * @package GeoDirectory_BuddyPress_Integration
 */
function geodir_buddypress_ajax()
{
    $subtab = geodir_buddypress_current_subtab();
    if ($subtab == 'gdbuddypress_settings') {
        geodir_update_options(geodir_buddypress_settings());
        $msg = urlencode_deep(__('Settings saved.', GDBUDDYPRESS_TEXTDOMAIN));
        wp_redirect(admin_url() . 'admin.php?page=geodirectory&tab=geodir_buddypress&subtab=gdbuddypress_settings&success_msg=' . $msg);
        exit;
    }
}
/**
 * Handles data posted from GeoDirectory settings form.
 *
 * @since 1.0.0
 * @package GeoDirectory
 * @global array $geodir_settings Geodirectory settings array.
 * @param string $current_tab The current settings tab name.
 */
function geodir_handle_option_form_submit($current_tab)
{
    global $geodir_settings;
    if (file_exists(dirname(__FILE__) . '/option-pages/' . $current_tab . '_array.php')) {
        /**
         * Contains settings array for current tab.
         *
         * @since 1.0.0
         * @package GeoDirectory
         */
        include_once 'option-pages/' . $current_tab . '_array.php';
    }
    if (isset($_POST) && $_POST && isset($_REQUEST['page']) && $_REQUEST['page'] == 'geodirectory') {
        if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'geodir-settings')) {
            die(__('Action failed. Please refresh the page and retry.', GEODIRECTORY_TEXTDOMAIN));
        }
        if (!wp_verify_nonce($_REQUEST['_wpnonce-' . $current_tab], 'geodir-settings-' . $current_tab)) {
            die(__('Action failed. Please refresh the page and retry.', GEODIRECTORY_TEXTDOMAIN));
        }
        /**
         * Fires before updating geodirectory admin settings.
         *
         * @since 1.4.2
         *
         * @param string $current_tab Current tab in geodirectory settings.
         * @param array  $geodir_settings Array of geodirectory settings.
         */
        do_action('geodir_before_update_options', $current_tab, $geodir_settings);
        if (!empty($geodir_settings[$current_tab])) {
            geodir_update_options($geodir_settings[$current_tab]);
        }
        /**
         * Called after GeoDirectory options settings are updated.
         *
         * @since 1.0.0
         * @param array $geodir_settings The array of GeoDirectory settings.
         * @see 'geodir_before_update_options'
         */
        do_action('geodir_update_options', $geodir_settings);
        /**
         * Called after GeoDirectory options settings are updated.
         *
         * Provides tab specific settings.
         *
         * @since 1.0.0
         * @param string $current_tab The current settings tab name.
         * @param array $geodir_settings[$current_tab] The array of settings for the current settings tab.
         */
        do_action('geodir_update_options_' . $current_tab, $geodir_settings[$current_tab]);
        flush_rewrite_rules(false);
        $current_tab = isset($_REQUEST['tab']) ? $_REQUEST['tab'] : '';
        $redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $_REQUEST['active_tab'] . '&msg=success');
        wp_redirect($redirect_url);
        exit;
    }
}
/**
 * Review Rating ajax submit function.
 *
 * @since 1.0.0
 * @package GeoDirectory_Review_Rating_Manager
 */
function geodir_reviewrating_ajax_actions()
{
    global $wpdb;
    $url = admin_url('admin.php');
    if (isset($_REQUEST['subtab']) && $_REQUEST['subtab'] == 'geodir_multirating_options') {
        geodir_update_options(geodir_reviewrating_default_options());
        $msg = __('Your settings have been saved.', GEODIRREVIEWRATING_TEXTDOMAIN);
        $msg = urlencode($msg);
        $url = add_query_arg(array('page' => 'geodirectory', 'tab' => 'multirating_fields', 'subtab' => 'geodir_multirating_options', 'gdrr_success' => $msg), esc_url($url));
        wp_redirect($url);
        exit;
    }
    if ($_REQUEST['ajax_action'] == 'update_overall_setting') {
        geodir_reviewrating_update_overall_settings();
        $msg = __('Your settings have been saved.', GEODIRREVIEWRATING_TEXTDOMAIN);
        $msg = urlencode($msg);
        $url = add_query_arg(array('page' => 'geodirectory&tab=multirating_fields&subtab=geodir_rating_settings&gdrr_success=' . $msg), esc_url($url));
        wp_redirect($url);
        exit;
    }
    if ($_REQUEST['ajax_action'] == 'update_review_setting') {
        geodir_reviewrating_update_review_setting();
        $msg = __('Your settings have been saved.', GEODIRREVIEWRATING_TEXTDOMAIN);
        $msg = urlencode($msg);
        $url = add_query_arg(array('page' => 'geodirectory&tab=multirating_fields&subtab=geodir_manage_review&gdrr_success=' . $msg), esc_url($url));
        wp_redirect($url);
        exit;
    }
    if ($_REQUEST['ajax_action'] == 'update_styles' || $_REQUEST['ajax_action'] == 'delete_style') {
        geodir_reviewrating_update_rating_styles();
        $msg = __('Your settings have been saved.', GEODIRREVIEWRATING_TEXTDOMAIN);
        if ($_REQUEST['ajax_action'] == 'delete_style') {
            $msg = __('Rating Style Delete successfully.', GEODIRREVIEWRATING_TEXTDOMAIN);
        }
        $msg = urlencode($msg);
        $url = add_query_arg(array('page' => 'geodirectory&tab=multirating_fields&subtab=geodir_rating_style&gdrr_success=' . $msg), esc_url($url));
        wp_redirect($url);
        exit;
    }
    if ($_REQUEST['ajax_action'] == 'update_rating_category' || $_REQUEST['ajax_action'] == 'delete_rating_category') {
        geodir_reviewrating_add_update_ratings();
        $msg = __('Your settings have been saved.', GEODIRREVIEWRATING_TEXTDOMAIN);
        if ($_REQUEST['ajax_action'] == 'delete_rating_category') {
            $msg = __('Rating Delete successfully.', GEODIRREVIEWRATING_TEXTDOMAIN);
        }
        $msg = urlencode($msg);
        $url = add_query_arg(array('page' => 'geodirectory&tab=multirating_fields&subtab=geodir_create_rating&gdrr_success=' . $msg), esc_url($url));
        wp_redirect($url);
        exit;
    }
    if ($_REQUEST['ajax_action'] == 'ajax_tax_cat') {
        if (isset($_REQUEST['post_type'])) {
            global $cat_display;
            $cat_display = 'select';
            echo geodir_custom_taxonomy_walker($_REQUEST['post_type'] . 'category');
        }
        exit;
    }
    if ($_REQUEST['ajax_action'] == 'review_update_frontend') {
        geodir_reviewrating_save_like_unlike($_REQUEST['ajaxcommentid']);
    }
    if ($_REQUEST['ajax_action'] == 'comment_actions' || $_REQUEST['ajax_action'] == 'show_tab_head') {
        geodir_reviewrating_comment_action($_REQUEST);
    }
    if (isset($_REQUEST['ajax_action']) && $_REQUEST['ajax_action'] == 'remove_images_by_url') {
        geodir_reviewrating_delete_comment_images_by_url();
    }
}