function bepro_listings_install_table($blog_id = false)
{
    global $wpdb;
    $bepro_listings_version = BEPRO_LISTINGS_VERSION;
    //Manage Multi Site
    if ($blog_id && $blog_id != 1) {
        $table_name = $wpdb->prefix . $blog_id . "_" . BEPRO_LISTINGS_TABLE_BASE;
        $meta_table = $wpdb->prefix . $blog_id . "_" . "bepro_listing_typesmeta";
    } else {
        $table_name = $wpdb->prefix . BEPRO_LISTINGS_TABLE_BASE;
        $meta_table = $wpdb->prefix . "bepro_listing_typesmeta";
    }
    if ($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'") != $table_name) {
        $sql = "CREATE TABLE " . $table_name . " (\n\t\t\t\tid mediumint(9) NOT NULL AUTO_INCREMENT,\n\t\t\t\temail tinytext DEFAULT NULL,\n\t\t\t\tphone tinytext DEFAULT NULL,\n\t\t\t\tcost float DEFAULT NULL,\n\t\t\t\tpost_id int(9) NOT NULL,\n\t\t\t\tfirst_name tinytext DEFAULT NULL,\n\t\t\t\tlast_name tinytext DEFAULT NULL,\n\t\t\t\taddress_line1 tinytext DEFAULT NULL,\n\t\t\t\tcity tinytext DEFAULT NULL,\n\t\t\t\tstate tinytext DEFAULT NULL,\n\t\t\t\tcountry tinytext DEFAULT NULL,\n\t\t\t\tpostcode tinytext DEFAULT NULL,\n\t\t\t\twebsite varchar(155) DEFAULT NULL,\n\t\t\t\tlat varchar(15) DEFAULT NULL,\n\t\t\t\tlon varchar(15) DEFAULT NULL,\n\t\t\t\tcreated timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\n\t\t\t\tPRIMARY KEY  (id),\n\t\t\t\tUNIQUE KEY `post_id` (`post_id`)\n\t\t\t);";
        require_once ABSPATH . 'wp-admin/includes/upgrade.php';
        dbDelta($sql);
        //Switch to new blog
        if ($blog_id) {
            switch_to_blog($blog_id);
        }
        //initial bepro listing
        $user_id = get_current_user_id();
        $post = array('post_author' => $user_id, 'post_content' => "<p>This is your first listing. Delete this one in your admin and create one of your own. If you need help, our <a href='http://www.beprosoftware.com/services/'>North American Wordpress Web Development</a> team can help. Also note we have tons of <a href='beprosoftware.com/products/bepro-listings'>Wordpress Directory</a> and <a href='beprosoftware.com/products/bepro-listings'>Wordpress classifieds plugin</a> addons for this plugin like: </p>\n\t\t\t\t  <ul>\n\t\t\t\t\t<li><a href='http://www.beprosoftware.com/shop/bepro-listings-tags/'>Tags</a> - This was definitely an achilles heel for this plugin. Now you and your members can tag your listings and allow users to search them via the tag widget</li>\n\t\t\t\t\t<li><a href='http://www.beprosoftware.com/shop/bepro-listings-contact/'>Contact</a> - Add a contact form to your listing pages. This provides the option to have all emails go to one address or the address for the person who created the listing</li>\n\t\t\t\t\t<li><a href='www.beprosoftware.com/shop/bepro-listings-galleries/'>Gallery</a> - Three 3 gallery options including slider &amp; lightbox, plus three new listings templates</li>\n\t\t\t\t\t<li><a href='www.beprosoftware.com/shop/bepro-listings-videos/'>Video</a> - Improve on the Gallery plugin with the ability to add and feature videos in your listings from website like youtube and uploaded documents (mp4, mpeg, avi, wmv, webm, etc)</li>\n\t\t\t\t\t<li><a href='www.beprosoftware.com/shop/bepro-listings-documents/'>Documents</a> - Allow users to add and manage document listings on your website from the front end (zip, doc, pdf, odt, csv, etc)</li>\n\t\t\t\t\t<li><a href='www.beprosoftware.com/shop/bepro-listings-icons/'>Icons</a> - Tons of google map icons from the 'Map Icons Collection' by Nicolas Mollet</li>\n\t\t\t\t\t<li><a href='www.beprosoftware.com/shop/bepro-listings-realestate/'>Real Estate</a> - Everything needed to run a realestate website, including related info (# rooms, #baths, etc) and search options</li>\n\t\t\t\t\t<li><a href='www.beprosoftware.com/shop/bepro-listings-s2member/'>S2Member</a> - For those interested in running a paid directory/classifieds, this plugin integrates with the popular membershp plugin 's2member'</li>\n\t\t\t\t\t<li><a href='www.beprosoftware.com/shop/bepro-listings-audio/'>Audio</a> - Create a, podcasts, music, or any other type of audio focused website. We support, wav, mp3, and several file types</li>\n\t\t\t\t\t<li><a href='www.beprosoftware.com/shop/bepro-listings-favorites/'>Favorites</a> - Allow visitors and registered users to interact with listings. They can record their likes/dislikes and view them via shortcodes</li>\n\t\t\t\t\t<li><a href='www.beprosoftware.com/shop/bepro-listings-authors/'>Authors</a> - Give your Blog writers and their listings more visibility. With this plugin you add their profile info to their listing pages.</li>\n\t\t\t\t\t<li><a href='http://www.beprosoftware.com/shop/bepro-listings-pmpro/'>PMPro</a> (New) - Use Paid Membership Pro to charge users to post listings on your website, with this integration.</li>\n\t\t\t\t\t<li><a href='http://www.beprosoftware.com/shop/bepro-listings-bookings/'>Booking</a> (New) - Setup your availability and allow users to schedule time. Perfect for real estate, vehicle, hotel, and other niche sites</li>\n\t\t\t\t\t<li><a href='http://www.beprosoftware.com/shop/bepro-listings-business-directory/'>Business Directory</a> (New) - Use our business and staff focused listing templates with alphabetic filter. Typical phone book type layout.</li>\n\t\t\t\t\t<li><a href='www.beprosoftware.com/shop/bepro-listings-vehicles/'>Vehicles</a> (New) - Lists cars, boats, trucks, planes, and other automobiles with their details</li>\n\t\t\t\t\t<li><a href='http://www.beprosoftware.com/shop/bepro-listings-reviews/'>Reviews</a> (New) - Users can leave and search by star ratings</li>\n\t\t\t\t</ul>\n\t\t\t\t<h2>Classifieds / Porfolio / Directory Themes</h2>\n\t\t\t\t<p>We also have several \$1 one dollar wordpress themes you can purchase with free data. This provides a great tutorial and / or way to get setup quickly</p>\n\t\t\t\t<ul>\n\t\t\t\t\t<li><a href='http://www.beprosoftware.com/shop/bycater/'>ByCater</a> - Vertile theme for any <strong>wordpress lisings</strong></li>\n\t\t\t\t\t<li><a href='http://www.beprosoftware.com/shop/folioprojects/'>FolioProjects</a> - Best used for <strong>Wordpress portfolios</strong></li>\n\t\t\t\t\t<li><a href='http://www.beprosoftware.com/shop/mt-classifieds/'>MT CLassifieds</a> - Great <strong>Wordpress Classifieds Theme</strong></li>\n\t\t\t\t\t<li><a href='http://www.beprosoftware.com/shop/whatlocalscallit/'>WhatLocalsCallIt</a> - Perfect <strong>Wordpress Directory Theme</strong></li>\n\t\t\t\t</ul>\n\t\t\t\t\n\t\t\t\t<p>Check them all out on the <a href='http://www.beprosoftware.com/products/bepro-listings/'>BePro Lisitngs documentation</a> page along with <b>shortcodes</b> and <b>instructions</b></p>\n\t\t\t\t\n\t\t\t\t<iframe width='560' height='315' src='//www.youtube.com/embed/zg2o1XK7vKk' frameborder='0' allowfullscreen></iframe>", 'post_status' => "publish", 'post_title' => "Your First Wordpress Listing", 'post_category' => array($my_cat_id), 'post_type' => "bepro_listings");
        //Create post
        $post_id = wp_insert_post($post, $wp_error);
        //setup category
        $my_cat_id = term_exists("Business", "bepro_listing_types");
        if (is_array($my_cat_id)) {
            $my_cat_id = $my_cat_id["term_id"];
        }
        wp_set_post_terms($post_id, array($my_cat_id), "bepro_listing_types", false);
        wp_set_object_terms($post_id, $my_cat_id, "bepro_listing_types", false);
        //add first image
        $upload_dir = wp_upload_dir();
        $to_filename = $upload_dir['path'] . "/no_img.jpg";
        $full_filename = plugins_url("images/no_img.jpg", __FILE__);
        $attachment = array('post_mime_type' => "image/jpeg", 'post_title' => "No Image", 'post_content' => '', 'post_status' => 'inherit');
        if (@copy($full_filename, $to_filename)) {
            $attach_id = wp_insert_attachment($attachment, $to_filename, $post_id);
            $attach_data = wp_generate_attachment_metadata($attach_id, $to_filename);
            wp_update_attachment_metadata($attach_id, $attach_data);
        }
        if ($blog_id) {
            restore_current_blog();
        }
    }
    if ($wpdb->get_var("SHOW TABLES LIKE '{$meta_table}'") != $meta_table) {
        create_metadata_table($meta_table, "bepro_listing_types");
    }
    $var_name = "bepro_listing_typesmeta";
    $wpdb->{$var_name} = $meta_table;
    //set version
    update_option('bepro_listings_version', $bepro_listings_version);
    //add first post
    $lat = floatval('44.6470678');
    $lon = floatval('-63.5747943');
    if (!empty($post_id)) {
        $wpdb->query("INSERT INTO " . $table_name . " (email, phone, cost, address_line1, city, postcode, state, country, website, lat, lon, first_name, last_name, post_id) VALUES('*****@*****.**','561-555-4321', 0, '','halifax', '', 'NS','Canada', 'beprosoftware.com', '{$lat}', '{$lon}', 'Lead', 'Tester', {$post_id})");
    }
}
Ejemplo n.º 2
0
        $portfolio_cat_meta_boxes = array_merge($portfolio_cat_meta_boxes, porto_ct_default_meta_skin_boxes());
    }
}
add_action('add_meta_boxes', 'porto_add_portfolio_meta_box');
add_action('admin_menu', 'porto_portfolio_get_postdata');
add_action('save_post', 'porto_portfolio_save_postdata');
add_action('save_post', 'porto_portfolio_view_save_postdata');
add_action('save_post', 'porto_portfolio_skin_save_postdata');
// Create Category Meta
global $wpdb;
$type = 'portfolio_cat';
$table_name = $wpdb->prefix . $type . 'meta';
$variable_name = $type . 'meta';
$wpdb->{$variable_name} = $table_name;
// Create Category Meta Table
create_metadata_table($table_name, $type);
// category meta
add_action('portfolio_cat_add_form_fields', 'porto_add_portfolio_cat', 10, 2);
function porto_add_portfolio_cat()
{
    global $portfolio_cat_meta_boxes;
    porto_show_tax_add_meta_boxes($portfolio_cat_meta_boxes);
}
add_action('portfolio_cat_edit_form_fields', 'porto_edit_portfolio_cat', 10, 2);
function porto_edit_portfolio_cat($tag, $taxonomy)
{
    global $portfolio_cat_meta_boxes;
    porto_show_tax_edit_meta_boxes($tag, $taxonomy, $portfolio_cat_meta_boxes);
}
add_action('created_term', 'porto_save_portfolio_cat', 10, 3);
add_action('edit_term', 'porto_save_portfolio_cat', 10, 3);