function load_constants() { // The main slug if (!defined('BEPRO_LISTINGS_SLUG')) { define('BEPRO_LISTINGS_SLUG', 'Listings'); } // The slug used when editing a doc if (!defined('BEPRO_LISTINGS_LIST_SLUG')) { define('BEPRO_LISTINGS_LIST_SLUG', 'List'); } // The slug used when editing a doc if (!defined('BEPRO_LISTINGS_EDIT_SLUG')) { define('BEPRO_LISTINGS_EDIT_SLUG', 'edit'); } // The slug used when creating a new doc if (!defined('BEPRO_LISTINGS_CREATE_SLUG')) { define('BEPRO_LISTINGS_CREATE_SLUG', 'Create'); } // The slug used when saving new docs if (!defined('BEPRO_LISTINGSS_SAVE_SLUG')) { define('BEPRO_UPLOADS_SAVE_SLUG', 'save'); } // The slug used when deleting a doc if (!defined('BEPRO_LISTINGS_DELETE_SLUG')) { define('BEPRO_LISTINGS_DELETE_SLUG', 'delete'); } // The slug used when deleting a doc if (!defined('BEPRO_LISTINGS_SEARCH_SLUG')) { define('BEPRO_LISTINGS_SEARCH_SLUG', 'listings'); } // The plugin path if (!defined('BEPRO_LISTINGS_PLUGIN_PATH')) { define('BEPRO_LISTINGS_PLUGIN_PATH', plugins_url("", __FILE__)); } // Plugin Slug if (!defined('BEPRO_LISTINGS_CATEGORY')) { define('BEPRO_LISTINGS_CATEGORY', "bepro_listing_types"); } // Category Slug if (!defined('BEPRO_LISTINGS_CATEGORY')) { define('BEPRO_LISTINGS_CATEGORY', "bepro_listing_types"); } // The Main table name (check if multisite) if (function_exists('is_multisite') && is_multisite()) { global $wpdb; $cur_blog_id = $wpdb->blogid == 1 ? "" : $wpdb->blogid . '_'; define('BEPRO_LISTINGS_TABLE_NAME', $cur_blog_id . 'bepro_listings'); } else { if (!defined('BEPRO_LISTINGS_TABLE_NAME')) { define('BEPRO_LISTINGS_TABLE_NAME', 'bepro_listings'); } } // Base Table Name if (!defined('BEPRO_LISTINGS_TABLE_BASE')) { define('BEPRO_LISTINGS_TABLE_BASE', 'bepro_listings'); } // Current version if (!defined('BEPRO_LISTINGS_VERSION')) { define('BEPRO_LISTINGS_VERSION', '2.1.28'); } $data = get_option("bepro_listings"); if (empty($data)) { Bepro_listings::bepro_listings_activate(); } //Load Languages load_plugin_textdomain('bepro-listings', false, dirname(plugin_basename(__FILE__)) . '/languages/'); //load default options if they dont already exist if (empty($data["bepro_listings_list_template_1"])) { //general $data["show_cost"] = "on"; $data["show_con"] = "on"; $data["show_geo"] = "on"; $data["num_images"] = 3; $data["cat_heading"] = "Categories"; $data["cat_empty"] = "No Categories"; $data["cat_singular"] = "Category"; //forms $data["validate_form"] = "on"; $data["success_message"] = 'Listing Created and pending admin approval.'; $data["default_status"] = 'pending'; $data["default_user_id"] = get_current_user_id(); $data["fail_message"] = "Issue saving listing. Try again or contact the Admin"; $data["bepro_listings_cat_required"] = ""; $data["bepro_listings_cat_exclude"] = ""; //search listings $data["default_image"] = plugins_url("images/no_img.jpg", __FILE__); $data["link_new_page"] = 1; $data["ajax_on"] = "on"; $data["num_listings"] = 3; $data["distance"] = 150; $data["details_link"] = "Item"; $data["show_web_link"] = ""; $data["currency_sign"] = "\$"; $data["show_date"] = 1; //Page/post $data["gallery_size"] = "thumbnail"; $data["gallery_cols"] = 3; $data["show_details"] = "on"; $data["add_detail_links"] = "on"; $data["show_content"] = "on"; //map $data["map_query_type"] = "curl"; //buddypress $data["buddypress"] = 0; //Support $data["footer_link"] = 0; //item page template $data['bepro_listings_item_title_template'] = 'bepro_listings_item_title'; $data['bepro_listings_item_gallery_template'] = "bepro_listings_item_gallery"; $data['bepro_listings_item_after_gallery_template'] = "bepro_listings_item_after_gallery"; $data['bepro_listings_item_details_template'] = 'bepro_listings_item_details'; $data['bepro_listings_item_content_template'] = 'bepro_listings_item_content_info'; //item list template $data['bepro_listings_list_template_1'] = array("bepro_listings_list_title" => "bepro_listings_list_title_template", "bepro_listings_list_above_image" => "bepro_listings_list_featured_template", "bepro_listings_list_below_title" => "bepro_listings_list_category_template", "bepro_listings_list_image" => "bepro_listings_list_image_template", "bepro_listings_list_content" => "bepro_listings_list_content_template", "bepro_listings_list_end" => "bepro_listings_list_cost_template", "bepro_listings_list_end" => "bepro_listings_list_links_template", "style" => plugins_url("css/generic_listings_1.css", __FILE__), "template_file" => plugin_dir_path(__FILE__) . '/templates/listings/generic_1.php'); $data['bepro_listings_list_template_2'] = array("bepro_listings_list_title" => "bepro_listings_list_title_template", "bepro_listings_list_above_image" => "bepro_listings_list_featured_template", "bepro_listings_list_below_title" => "bepro_listings_list_category_template", "bepro_listings_list_above_title" => "bepro_listings_list_image_template", "bepro_listings_list_image" => "bepro_listings_list_geo_template", "bepro_listings_list_content" => "bepro_listings_list_content_template", "bepro_listings_list_end" => "bepro_listings_list_cost_template", "bepro_listings_list_end" => "bepro_listings_list_links_template", "style" => plugins_url("css/generic_listings_2.css", __FILE__), "template_file" => plugin_dir_path(__FILE__) . '/templates/listings/generic_2.php'); //save update_option("bepro_listings", $data); } //Things that need to change only if there is an upgrade $bepro_listings_version = get_option("bepro_listings_version"); if ($bepro_listings_version != BEPRO_LISTINGS_VERSION) { $bepro_listings_version = get_option("bepro_listings_version"); $data["cat_heading"] = "Categories"; $data["cat_empty"] = "No Categories"; $data["cat_singular"] = "Category"; update_option("bepro_listings", $data); } }
function bl_complete_startup() { global $wpdb; $data = get_option("bepro_listings"); if (empty($data)) { Bepro_listings::bepro_listings_activate(); } //Load Languages load_plugin_textdomain('bepro-listings', false, dirname(plugin_basename(__FILE__)) . '/languages/'); //load default options if they dont already exist if (empty($data["bepro_listings_list_template_1"])) { //general $data["show_cost"] = 1; $data["show_con"] = 1; $data["show_geo"] = 1; $data["show_imgs"] = 1; $data["num_images"] = 3; $data["cat_heading"] = __("Categories", "bepro-listings"); $data["cat_empty"] = __("No Sub Categories", "bepro-listings"); $data["cat_singular"] = __("Category", "bepro-listings"); $data["permalink"] = "/" . BEPRO_LISTINGS_SEARCH_SLUG; $data["cat_permalink"] = "/" . BEPRO_LISTINGS_CATEGORY_SLUG; //forms $data["validate_form"] = "on"; $data["success_message"] = __('Listing Created and pending admin approval.', "bepro-listings"); $data["use_tiny_mce"] = ""; $data["default_status"] = 'pending'; $data["default_user_id"] = get_current_user_id(); $data["fail_message"] = __("Issue saving listing. Try again or contact the Admin", "bepro-listings"); $data["form_cat_style"] = 2; $data["bepro_listings_cat_required"] = ""; $data["bepro_listings_cat_exclude"] = ""; //search listings $data["default_image"] = plugins_url("images/no_img.jpg", __FILE__); $data["link_new_page"] = 1; $data["ajax_on"] = "on"; $data["num_listings"] = 8; $data["distance"] = 150; $data["dist_measurement"] = 1; $data["search_names"] = 1; $data["title_length"] = 18; $data["desc_length"] = 80; $data["details_link"] = __("Item", "bepro-listings"); $data["show_web_link"] = ""; $data["currency_sign"] = "\$"; $data["show_date"] = 1; //Page/post $data["gallery_size"] = "thumbnail"; $data["gallery_cols"] = 3; $data["gallery_cols"] = 1; $data["show_details"] = 2; $data["add_detail_links"] = "on"; $data["protect_contact"] = ""; $data["show_content"] = 1; $data["tabs_type"] = 1; //map $data["map_query_type"] = "curl"; $data["map_use_api"] = 1; $data["map_zoom"] = "10"; //3rd party $data["buddypress"] = 0; //Payment $data["require_payment"] = ""; $data["publish_after_payment"] = ""; $data["redirect_need_funds"] = 1; $data["charge_amount"] = 1; //Support $data["footer_link"] = 0; //item page template $data['bepro_listings_item_title_template'] = 'bepro_listings_item_title'; $data['bepro_listings_item_gallery_template'] = "bepro_listings_item_gallery"; $data['bepro_listings_item_after_gallery_template'] = "bepro_listings_item_after_gallery"; $data['bepro_listings_item_details_template'] = 'bepro_listings_item_details'; $data['bepro_listings_item_content_template'] = 'bepro_listings_item_content_info'; //item list template $data = create_result_listing_templates($data); //save update_option("bepro_listings", $data); } //Things that need to change only if there is an upgrade $bepro_listings_version = get_option("bepro_listings_version"); if (version_compare($bepro_listings_version, '2.1.5', '<')) { //upgrade tables to utf8 if (is_numeric(substr($wpdb->prefix, -2, 1)) && is_multisite()) { $blogids = $wpdb->get_col("SELECT blog_id FROM {$wpdb->blogs}"); foreach ($blogids as $blogid_x) { $wpdb->query("ALTER TABLE " . $wpdb->base_prefix . $blogid_x . "_" . BEPRO_LISTINGS_TABLE_BASE . " CONVERT TO CHARACTER SET utf8;"); } } else { $wpdb->query("ALTER TABLE " . $wpdb->base_prefix . BEPRO_LISTINGS_TABLE_BASE . " CONVERT TO CHARACTER SET utf8;"); } } if (version_compare($bepro_listings_version, '2.1.90', '<')) { $data["map_use_api"] = 1; $data["map_zoom"] = "10"; $data["show_imgs"] = 1; } if (version_compare($bepro_listings_version, '2.1.992', '<')) { //support for BePro Cart if (is_numeric(substr($wpdb->prefix, -2, 1)) && is_multisite()) { $blogids = $wpdb->get_col("SELECT blog_id FROM {$wpdb->blogs}"); foreach ($blogids as $blogid_x) { if ($blogid_x == 1) { $blogid_x = ""; } else { $blogid_x = $blogid_x . "_"; } $wpdb->query("ALTER TABLE " . $wpdb->base_prefix . $blogid_x . BEPRO_LISTINGS_TABLE_BASE . " ADD COLUMN bl_order_id int(9) DEFAULT NULL AFTER lon, DROP COLUMN bepro_cart_id;"); //install new payments table create_bl_order_table($wpdb->base_prefix . $blogid_x . BEPRO_LISTINGS_ORDERS_TABLE_BASE); } } else { $wpdb->query("ALTER TABLE " . $wpdb->base_prefix . BEPRO_LISTINGS_TABLE_BASE . " ADD COLUMN bl_order_id int(9) DEFAULT NULL AFTER lon, DROP COLUMN bepro_cart_id;"); //install new payments table create_bl_order_table($wpdb->base_prefix . BEPRO_LISTINGS_ORDERS_TABLE_BASE); } //flat fee now works differently if ($data["flat_fee"]) { unset($data["flat_fee"]); } } if (version_compare($bepro_listings_version, '2.1.999', '<')) { if (is_numeric(substr($wpdb->prefix, -2, 1)) && is_multisite()) { $blogids = $wpdb->get_col("SELECT blog_id FROM {$wpdb->blogs}"); foreach ($blogids as $blogid_x) { if ($blogid_x == 1) { $blogid_x = ""; } else { $blogid_x = $blogid_x . "_"; } $tbl_1 = $wpdb->base_prefix . $blogid_x . BEPRO_LISTINGS_ORDERS_TABLE_BASE; $tbl_2 = $wpdb->base_prefix . $blogid_x . BEPRO_LISTINGS_TABLE_BASE; $wpdb->query("ALTER TABLE " . $tbl_1 . " ADD COLUMN expires DATETIME DEFAULT NULL AFTER date_paid;"); $orders = $wpdb->get_results("SELECT * FROM " . $tbl_1); foreach ($orders as $order) { $record = $wpdb->get_row("SELECT * FROM " . $tbl_2 . " WHERE bl_order_id = " . $order->bl_order_id . " LIMIT 1"); if ($record) { $wpdb->query("UPDATE " . $tbl_1 . " SET expires = '" . $record->expires . "' WHERE bl_order_id = " . $record->bl_order_id); } } $wpdb->query("ALTER TABLE " . $tbl_2 . " DROP COLUMN expires;"); } } else { $tbl_1 = $wpdb->prefix . BEPRO_LISTINGS_ORDERS_TABLE_BASE; $tbl_2 = $wpdb->prefix . BEPRO_LISTINGS_TABLE_BASE; $wpdb->query("ALTER TABLE " . $tbl_1 . " ADD COLUMN expires DATETIME DEFAULT NULL AFTER date_paid;"); $orders = $wpdb->get_results("SELECT * FROM " . $tbl_1); foreach ($orders as $order) { $record = $wpdb->get_row("SELECT * FROM " . $tbl_2 . " WHERE bl_order_id = " . $order->bl_order_id . " LIMIT 1"); if (@$record) { $wpdb->query("UPDATE " . $tbl_1 . " SET expires = '" . $record->expires . "' WHERE bl_order_id = " . $record->bl_order_id); } } $wpdb->query("ALTER TABLE " . $tbl_2 . " DROP COLUMN expires;"); } } if (version_compare($bepro_listings_version, '2.1.9994', '<')) { if (!empty($data["show_cost"])) { $data["show_cost"] = 1; } if (!empty($data["show_con"])) { $data["show_con"] = 1; } if (!empty($data["show_geo"])) { $data["show_geo"] = 1; } if (!empty($data["show_imgs"])) { $data["show_imgs"] = 1; } $data["show_details"] = 2; $data["show_content"] = 1; } if (version_compare($bepro_listings_version, '2.1.99995', '<')) { if ($data["show_details"] == "on") { $data["show_details"] = 2; } if ($data["show_content"] == "on") { $data["show_content"] = 1; } if ($data["show_geo"] == "on") { $data["show_geo"] = 1; } if ($data["show_con"] == "on") { $data["show_con"] = 1; } } if (version_compare($bepro_listings_version, '2.2.0004', '<')) { if (empty($data["desc_length"])) { $data["desc_length"] = 80; } } if ($bepro_listings_version != BEPRO_LISTINGS_VERSION) { $bepro_listings_version = BEPRO_LISTINGS_VERSION; //new features //show welcome screen to users who are updating set_transient('_bepro_listings_activation_redirect', 1, HOUR_IN_SECONDS); //set version update_option('bepro_listings_version', $bepro_listings_version); } }