Example #1
0
/**
 * wpsc_update_page_urls gets the permalinks for products pages and stores them in the options for quick reference
 * @public
 *
 * @since 3.6
 * @param $auto (Boolean) true if coming from WordPress Permalink Page, false otherwise
 * @return nothing
 */
function wpsc_update_page_urls($auto = false)
{
    global $wpdb;
    wpsc_update_permalink_slugs();
    wpsc_core_load_page_titles();
    wpsc_register_post_types();
    if (!$auto) {
        $sendback = wp_get_referer();
        if (isset($updated)) {
            $sendback = add_query_arg('updated', $updated, $sendback);
        }
        if (isset($_SESSION['wpsc_settings_curr_page'])) {
            $sendback = add_query_arg('tab', $_SESSION['wpsc_settings_curr_page'], $sendback);
        }
        wp_redirect($sendback);
        exit;
    }
}
Example #2
0
function wpsc_install()
{
    global $wpdb, $user_level, $wp_rewrite, $wp_version, $wpsc_page_titles;
    $table_name = $wpdb->prefix . "wpsc_product_list";
    $first_install = false;
    if ($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'") !== $table_name) {
        // Table doesn't exist
        $first_install = true;
        add_option('wpsc_purchaselogs_fixed', true);
    }
    // run the create or update code here.
    wpsc_create_or_update_tables();
    wpsc_create_upload_directories();
    // All code to add new database tables and columns must be above here
    $wpsc_version = get_option('wpsc_version', 0);
    $wpsc_minor_version = get_option('wspc_minor_version', 0);
    if ($wpsc_version === false) {
        add_option('wpsc_version', WPSC_VERSION, '', 'yes');
    } else {
        update_option('wpsc_version', WPSC_VERSION);
    }
    if ($wpsc_minor_version === false) {
        add_option('wpsc_minor_version', WPSC_MINOR_VERSION, '', 'yes');
    } else {
        update_option('wpsc_minor_version', WPSC_MINOR_VERSION);
    }
    if (version_compare($wpsc_version, '3.8', '<')) {
        update_option('wpsc_needs_update', true);
    } else {
        update_option('wpsc_needs_update', false);
    }
    if ('' == get_option('show_subcatsprods_in_cat')) {
        update_option('show_subcatsprods_in_cat', 0);
    }
    if ('' == get_option('wpsc_share_this')) {
        update_option('wpsc_share_this', 0);
    }
    if ('' == get_option('wpsc_crop_thumbnails')) {
        update_option('wpsc_crop_thumbnails', 0);
    }
    if ('' == get_option('wpsc_products_per_page')) {
        update_option('wpsc_products_per_page', 0);
    }
    if ('' == get_option('wpsc_force_ssl')) {
        update_option('wpsc_force_ssl', 0);
    }
    if ('' == get_option('use_pagination')) {
        update_option('use_pagination', 0);
    }
    if ('' == get_option('hide_name_link')) {
        update_option('hide_name_link', 0);
    }
    if ('' == get_option('wpsc_enable_comments')) {
        update_option('wpsc_enable_comments', 0);
    }
    if ('' == get_option('multi_add')) {
        update_option('multi_add', 0);
    }
    if ('' == get_option('hide_addtocart_button')) {
        update_option('hide_addtocart_button', 0);
    }
    if ('' == get_option('wpsc_addtocart_or_buynow')) {
        update_option('wpsc_addtocart_or_buynow', 0);
    }
    add_option('show_thumbnails', 1, '', "yes");
    add_option('show_thumbnails_thickbox', 1, '', "yes");
    add_option('product_list_url', '', '', 'yes');
    add_option('shopping_cart_url', '', '', 'yes');
    add_option('checkout_url', '', '', 'yes');
    add_option('transact_url', '', '', 'yes');
    add_option('payment_gateway', '', '', 'yes');
    $default_payment_gateways_names = array('chronopay' => '', 'google' => '', 'wpsc_merchant_paypal_express' => '', 'wpsc_merchant_paypal_pro' => '', 'wpsc_merchant_paypal_standard' => '');
    $existing_payment_gateways_names = get_option('payment_gateway_names');
    $new_payment_gatewats_name = array_merge($default_payment_gateways_names, (array) $existing_payment_gateways_names);
    update_option('payment_gateway_names', $new_payment_gatewats_name);
    if (function_exists('register_sidebar')) {
        add_option('cart_location', '4', '', 'yes');
    } else {
        add_option('cart_location', '1', '', 'yes');
    }
    add_option('currency_type', '156', '', 'yes');
    add_option('currency_sign_location', '3', '', 'yes');
    add_option('gst_rate', '1', '', 'yes');
    add_option('max_downloads', '1', '', 'yes');
    add_option('display_pnp', '1', '', 'yes');
    add_option('display_specials', '1', '', 'yes');
    add_option('do_not_use_shipping', '1', '', 'yes');
    add_option('postage_and_packaging', '0', '', 'yes');
    add_option('purch_log_email', '', '', 'yes');
    add_option('return_email', '', '', 'yes');
    add_option('terms_and_conditions', '', '', 'yes');
    add_option('google_key', 'none', '', 'yes');
    add_option('google_id', 'none', '', 'yes');
    add_option('default_brand', 'none', '', 'yes');
    add_option('wpsc_default_category', 'all', '', 'yes');
    add_option('product_view', 'default', "", 'yes');
    add_option('add_plustax', 'default', "", '1');
    add_option('nzshpcrt_first_load', '0', "", 'yes');
    if (!(get_option('show_categorybrands') > 0 && get_option('show_categorybrands') < 3)) {
        update_option('show_categorybrands', 2);
    }
    // PayPal options
    add_option('paypal_business', '', '', 'yes');
    add_option('paypal_url', '', '', 'yes');
    add_option('paypal_ipn', '1', '', 'yes');
    add_option('paypal_multiple_business', '', '', 'yes');
    add_option('paypal_multiple_url', "https://www.paypal.com/cgi-bin/webscr");
    add_option('product_ratings', '0', '', 'yes');
    add_option('wpsc_email_receipt', __('Thank you for purchasing with %shop_name%, any items to be shipped will be processed as soon as possible, any items that can be downloaded can be downloaded using the links on this page.All prices include tax and postage and packaging where applicable.
	You ordered these items:
	%product_list%%total_shipping%%total_price%', 'wpsc'), '', 'yes');
    add_option('wpsc_email_admin', __('%product_list%%total_shipping%%total_price%', 'wpsc'), '', 'yes');
    add_option('wpsc_selected_theme', 'default', '', 'yes');
    add_option('product_image_height', 148);
    add_option('product_image_width', 148);
    add_option('category_image_height', 148);
    add_option('category_image_width', 148);
    add_option('single_view_image_height', 148);
    add_option('single_view_image_width', 148);
    add_option('wpsc_gallery_image_height', 31);
    add_option('wpsc_gallery_image_width', 31);
    add_option('wpsc_thousands_separator', ',');
    add_option('wpsc_decimal_separator', '.');
    add_option('custom_gateway_options', array('wpsc_merchant_testmode'), '', 'yes');
    add_option('wpsc_category_url_cache', array(), '', 'yes');
    // add in some default tax settings
    add_option('wpec_taxes_inprice', 'exclusive');
    add_option('wpec_taxes_product', 'replace');
    add_option('wpec_taxes_logic', 'billing');
    wpsc_product_files_htaccess();
    /*
     * This part creates the pages and automatically puts their URLs into the options page.
     * As you can probably see, it is very easily extendable, just pop in your page and the deafult content in the array and you are good to go.
     */
    $post_date = date("Y-m-d H:i:s");
    $post_date_gmt = gmdate("Y-m-d H:i:s");
    $pages = array('products-page' => array('name' => 'products-page', 'title' => __('Products Page', 'wpsc'), 'tag' => '[productspage]', 'option' => 'product_list_url'), 'checkout' => array('name' => 'checkout', 'title' => __('Checkout', 'wpsc'), 'tag' => '[shoppingcart]', 'option' => 'shopping_cart_url'), 'transaction-results' => array('name' => 'transaction-results', 'title' => __('Transaction Results', 'wpsc'), 'tag' => '[transactionresults]', 'option' => 'transact_url'), 'your-account' => array('name' => 'your-account', 'title' => __('Your Account', 'wpsc'), 'tag' => '[userlog]', 'option' => 'user_account_url'));
    //indicator. if we will create any new pages we need to flush.. :)
    $newpages = false;
    //get products page id. if there's no products page then create one
    $products_page_id = $wpdb->get_var("SELECT id FROM `" . $wpdb->posts . "` WHERE `post_content` LIKE '%" . $pages['products-page']['tag'] . "%'\tAND `post_type` != 'revision'");
    if (empty($products_page_id)) {
        $products_page_id = wp_insert_post(array('post_title' => $pages['products-page']['title'], 'post_type' => 'page', 'post_name' => $pages['products-page']['name'], 'comment_status' => 'closed', 'ping_status' => 'closed', 'post_content' => $pages['products-page']['tag'], 'post_status' => 'publish', 'post_author' => 1, 'menu_order' => 0));
        $newpages = true;
    }
    update_option($pages['products-page']['option'], _get_page_link($products_page_id));
    //done. products page created. no we can unset products page data and create all other pages.
    //unset products page
    unset($pages['products-page']);
    //create other pages
    foreach ((array) $pages as $page) {
        //check if page exists and get it's ID
        $page_id = $wpdb->get_var("SELECT id FROM `" . $wpdb->posts . "` WHERE `post_content` LIKE '%" . $page['tag'] . "%'\tAND `post_type` != 'revision'");
        //if there's no page - create
        if (empty($page_id)) {
            $page_id = wp_insert_post(array('post_title' => $page['title'], 'post_type' => 'page', 'post_name' => $page['name'], 'comment_status' => 'closed', 'ping_status' => 'closed', 'post_content' => $page['tag'], 'post_status' => 'publish', 'post_author' => 1, 'menu_order' => 0, 'post_parent' => $products_page_id));
            $newpages = true;
        }
        //update option
        update_option($page['option'], get_permalink($page_id));
        //also if this is shopping_cart, then update checkout url option
        if ($page['option'] == 'shopping_cart_url') {
            update_option('checkout_url', get_permalink($page_id));
        }
    }
    //if we have created any new pages, then flush... do we need to do this? probably should be removed
    if ($newpages) {
        wp_cache_delete('all_page_ids', 'pages');
        $wp_rewrite->flush_rules();
    }
    // Product categories, temporarily register them to create first default category if none exist
    // @todo: investigate those require once lines and move them to right place (not from here, but from their original location, which seems to be wrong, since i cant access wpsc_register_post_types and wpsc_update_categorymeta here) - Vales <*****@*****.**>
    require_once WPSC_FILE_PATH . '/wpsc-core/wpsc-functions.php';
    wpsc_register_post_types();
    $category_list = get_terms('wpsc_product_category', 'hide_empty=0&parent=0');
    if (count($category_list) == 0) {
        require_once WPSC_FILE_PATH . '/wpsc-includes/meta.functions.php';
        $new_category = wp_insert_term(__('Product Category', 'wpsc'), 'wpsc_product_category', "parent=0");
        $category_id = $new_category['term_id'];
        $term = get_term_by('id', $new_category['term_id'], 'wpsc_product_category');
        $url_name = $term->slug;
        $wp_rewrite->flush_rules();
        wpsc_update_categorymeta($category_id, 'nice-name', $url_name);
        wpsc_update_categorymeta($category_id, 'description', __("This is a description", 'wpsc'));
        wpsc_update_categorymeta($category_id, 'image', '');
        wpsc_update_categorymeta($category_id, 'fee', '0');
        wpsc_update_categorymeta($category_id, 'active', '1');
        wpsc_update_categorymeta($category_id, 'order', '0');
    }
}
function wpsc_theme_engine_v2_activate()
{
    $path = WPSC_FILE_PATH . '/wpsc-components/theme-engine-v2';
    require_once $path . '/core.php';
    _wpsc_te_v2_includes();
    wpsc_register_post_types();
    flush_rewrite_rules(true);
    update_option('transact_url', wpsc_get_checkout_url('results'));
    WPSC_Settings::get_instance();
    do_action('wpsc_theme_engine_v2_activate');
}
Example #4
0
/**
 * Provide compatibility between 'show_on_front' and 'store_as_front_page' options.
 *
 * WordPress currently doesn't allow any values for 'show_on_front' other than
 * 'page' and 'posts'.
 *
 * {@link _wpsc_te2_action_admin_enqueue_script()} is used to dynamically inject
 * a radio box in Settings->Reading so that it's more user friendly to select
 * 'Main store as front page' as an option.
 *
 * Behind the scene, it doesn't really matter what the value of 'show_on_front'
 * is. What really matters is the 'wpsc_store_as_front_page' option.
 *
 * Filter hook: sanitize_option_show_on_front
 *
 * @access private
 *
 * @since  0.1
 * @param  mixed $value
 * @return mixed
 */
function _wpsc_te2_action_sanitize_show_on_front($value)
{
    // if the value is 'wpsc_main_store', just reset it back to 'posts' or
    // 'page'.
    if ($value == 'wpsc_main_store') {
        $value = 'page';
        wpsc_update_option('store_as_front_page', true);
    } else {
        // if the user selected something other than main store as front page,
        // reset 'wpsc_store_as_front_page' to false
        wpsc_update_option('store_as_front_page', false);
    }
    // regenerate rewrite rules again because wpsc-product post type archive
    // slug has possibly changed
    wpsc_register_post_types();
    flush_rewrite_rules();
    return $value;
}