예제 #1
0
/**
 * Displays the non-custom fields below the main listing submission form.
 *
 * @param int $listing_id
 *
 * @return void
 */
function cp_other_fields($listing_id)
{
    global $cp_options;
    // are images on ads allowed
    if ($cp_options->ad_images) {
        if (appthemes_plupload_is_enabled()) {
            echo html('div class="ad-details-images-sep"', ' ');
            appthemes_plupload_form($listing_id);
        } else {
            $images_count = cp_get_ad_images($listing_id);
            cp_ad_edit_image_input_fields($images_count);
        }
    }
    // show the chargeable options if enabled
    if (cp_payments_is_enabled()) {
        // show the featured ad box if enabled
        if ($cp_options->sys_feat_price) {
            ?>

			<div class="ad-details-featured-sep"></div>

			<li id="list_featured_ad" class="withborder">
				<div class="labelwrapper">
					<label><?php 
            printf(__('Featured Listing %s', APP_TD), appthemes_get_price($cp_options->sys_feat_price));
            ?>
</label>
				</div>
				<div class="clr"></div>
				<input name="featured_ad" value="1" type="checkbox" <?php 
            checked(is_sticky($listing_id));
            ?>
 />
				<?php 
            _e('Your listing will appear in the featured slider section at the top of the front page.', APP_TD);
            ?>
				<div class="clr"></div>
			</li>

		<?php 
        }
        if ($cp_options->price_scheme == 'single') {
            ?>

			<li>
				<div class="labelwrapper">
					<label><?php 
            _e('Ad Package:', APP_TD);
            ?>
</label>
				</div>

				<?php 
            // go get all the active ad packs and create a drop-down of options
            $packages = cp_get_listing_packages();
            if ($packages) {
                ?>

					<select name="ad_pack_id" class="dropdownlist required">

					<?php 
                foreach ($packages as $package) {
                    // external plugins can modify or disable field
                    $result = apply_filters('cp_package_field', $package, 'ad');
                    if (!$package) {
                        continue;
                    }
                    ?>
							<option value="<?php 
                    echo esc_attr($package->ID);
                    ?>
"><?php 
                    echo esc_attr($package->pack_name);
                    ?>
</option>
						<?php 
                }
                ?>

					</select>

				<?php 
            } else {
                _e('Error: no ad pack has been defined. Please contact the site administrator.', APP_TD);
            }
            ?>

				<div class="clr"></div>
			</li>

		<?php 
        }
        ?>

	<?php 
    }
}
예제 #2
0
파일: install.php 프로젝트: kalushta/darom
function cp_populate_tables()
{
    global $wpdb;
    /**
     * Insert default data into tables
     *
     * Flag values for the cp_ad_fields table
     * =======================================
     * Field permissions (field name - field_perm) are 0,1,2 and are as follows:
     * 0 = rename label, remove from form layout, reorder, change values, delete
     * 1 = rename label, reorder
     * 2 = rename label, remove from form layout, reorder, change values
     *
     * please don't ask about the logic of the order. :-)
     *
     * field_core can be 1 or 0. 1 means it's a core field and will be included
     * in the default form if no custom form has been created
     *
     * field_req in this table is only used for the default form meaning if no
     * custom form has been created, use these fields with 1 meaning mandatory field
     *
     *
     */
    $field_sql = "SELECT field_id FROM {$wpdb->cp_ad_fields} WHERE field_name = %s LIMIT 1";
    // DO NOT CHANGE THE ORDER OF THE FIRST 9 RECORDS!
    // admin-options.php cp_add_core_fields() depends on these fields
    // add more records after the post_content row insert statement
    // Title field
    $wpdb->get_results($wpdb->prepare($field_sql, 'post_title'));
    if ($wpdb->num_rows == 0) {
        $wpdb->insert($wpdb->cp_ad_fields, array('field_name' => 'post_title', 'field_label' => 'Title', 'field_desc' => 'This is the name of the ad and is mandatory on all forms. It is a core ClassiPress field and cannot be deleted.', 'field_type' => 'text box', 'field_values' => '', 'field_search' => '0', 'field_perm' => '1', 'field_core' => '1', 'field_req' => '1', 'field_owner' => 'ClassiPress', 'field_created' => current_time('mysql'), 'field_modified' => current_time('mysql'), 'field_min_length' => '0'));
    }
    // Price field
    $wpdb->get_results($wpdb->prepare($field_sql, 'cp_price'));
    if ($wpdb->num_rows == 0) {
        $wpdb->insert($wpdb->cp_ad_fields, array('field_name' => 'cp_price', 'field_label' => 'Price', 'field_desc' => 'This is the price field for the ad. It is a core ClassiPress field and cannot be deleted.', 'field_type' => 'text box', 'field_values' => '', 'field_search' => '0', 'field_perm' => '2', 'field_core' => '1', 'field_req' => '1', 'field_owner' => 'ClassiPress', 'field_created' => current_time('mysql'), 'field_modified' => current_time('mysql'), 'field_min_length' => '0'));
    }
    // Street field
    $wpdb->get_results($wpdb->prepare($field_sql, 'cp_street'));
    if ($wpdb->num_rows == 0) {
        $wpdb->insert($wpdb->cp_ad_fields, array('field_name' => 'cp_street', 'field_label' => 'Street', 'field_desc' => 'This is the street address text field. It is a core ClassiPress field and cannot be deleted. (Needed on your forms for Google maps to work best.)', 'field_type' => 'text box', 'field_values' => '', 'field_search' => '0', 'field_perm' => '2', 'field_core' => '1', 'field_req' => '0', 'field_owner' => 'ClassiPress', 'field_created' => current_time('mysql'), 'field_modified' => current_time('mysql'), 'field_min_length' => '0'));
    }
    // City field
    $wpdb->get_results($wpdb->prepare($field_sql, 'cp_city'));
    if ($wpdb->num_rows == 0) {
        $wpdb->insert($wpdb->cp_ad_fields, array('field_name' => 'cp_city', 'field_label' => 'City', 'field_desc' => 'This is the city field for the ad listing. It is a core ClassiPress field and cannot be deleted. (Needed on your forms for Google maps to work best.)', 'field_type' => 'text box', 'field_values' => '', 'field_search' => '1', 'field_perm' => '2', 'field_core' => '1', 'field_req' => '0', 'field_owner' => 'ClassiPress', 'field_created' => current_time('mysql'), 'field_modified' => current_time('mysql'), 'field_min_length' => '0'));
    }
    // State field
    $wpdb->get_results($wpdb->prepare($field_sql, 'cp_state'));
    if ($wpdb->num_rows == 0) {
        $wpdb->insert($wpdb->cp_ad_fields, array('field_name' => 'cp_state', 'field_label' => 'State', 'field_desc' => 'This is the state/province drop-down select box for the ad. It is a core ClassiPress field and cannot be deleted. (Needed on your forms for Google maps to work best.)', 'field_type' => 'drop-down', 'field_values' => 'Alabama,Alaska,Arizona,Arkansas,California,Colorado,Connecticut,Delaware,District of Columbia,Florida,Georgia,Hawaii,Idaho,Illinois,Indiana,Iowa,Kansas,Kentucky,Louisiana,Maine,Maryland,Massachusetts,Michigan,Minnesota,Mississippi,Missouri,Montana,Nebraska,Nevada,New Hampshire,New Jersey,New Mexico,New York,North Carolina,North Dakota,Ohio,Oklahoma,Oregon,Pennsylvania,Rhode Island,South Carolina,South Dakota,Tennessee,Texas,Utah,Vermont,Virginia,Washington,West Virginia,Wisconsin,Wyoming', 'field_search' => '1', 'field_perm' => '2', 'field_core' => '1', 'field_req' => '1', 'field_owner' => 'ClassiPress', 'field_created' => current_time('mysql'), 'field_modified' => current_time('mysql'), 'field_min_length' => '0'));
    }
    // Country field
    $wpdb->get_results($wpdb->prepare($field_sql, 'cp_country'));
    if ($wpdb->num_rows == 0) {
        $wpdb->insert($wpdb->cp_ad_fields, array('field_name' => 'cp_country', 'field_label' => 'Country', 'field_desc' => 'This is the country drop-down select box for the ad. It is a core ClassiPress field and cannot be deleted.', 'field_type' => 'drop-down', 'field_values' => 'United States,United Kingdom,Afghanistan,Albania,Algeria,American Samoa,Angola,Anguilla,Antarctica,Antigua and Barbuda,Argentina,Armenia,Aruba,Ashmore and Cartier Island,Australia,Austria,Azerbaijan,Bahamas,Bahrain,Bangladesh,Barbados,Belarus,Belgium,Belize,Benin,Bermuda,Bhutan,Bolivia,Bosnia and Herzegovina,Botswana,Brazil,British Virgin Islands,Brunei,Bulgaria,Burkina Faso,Burma,Burundi,Cambodia,Cameroon,Canada,Cape Verde,Cayman Islands,Central African Republic,Chad,Chile,China,Christmas Island,Colombia,Comoros,Congo,Cook Islands,Costa Rica,Cote dIvoire,Croatia,Cuba,Cyprus,Czeck Republic,Denmark,Djibouti,Dominica,Dominican Republic,Ecuador,Egypt,El Salvador,Equatorial Guinea,Eritrea,Estonia,Ethiopia,Europa Island,Falkland Islands,Faroe Islands,Fiji,Finland,France,French Guiana,French Polynesia,French Southern and Antarctic Lands,Gabon,Gambia,Gaza Strip,Georgia,Germany,Ghana,Gibraltar,Glorioso Islands,Greece,Greenland,Grenada,Guadeloupe,Guam,Guatemala,Guernsey,Guinea,Guinea-Bissau,Guyana,Haiti,Heard Island and McDonald Islands,Honduras,Hong Kong,Howland Island,Hungary,Iceland,India,Indonesia,Iran,Iraq,Ireland,Ireland Northern,Isle of Man,Israel,Italy,Jamaica,Jan Mayen,Japan,Jarvis Island,Jersey,Johnston Atoll,Jordan,Juan de Nova Island,Kazakhstan,Kenya,Kiribati,Korea North,Korea South,Kuwait,Kyrgyzstan,Laos,Latvia,Lebanon,Lesotho,Liberia,Libya,Liechtenstein,Lithuania,Luxembourg,Macau,Macedonia,Madagascar,Malawi,Malaysia,Maldives,Mali,Malta,Marshall Islands,Martinique,Mauritania,Mauritius,Mayotte,Mexico,Micronesia,Midway Islands,Moldova,Monaco,Mongolia,Montserrat,Morocco,Mozambique,Namibia,Nauru,Nepal,Netherlands,Netherlands Antilles,New Caledonia,New Zealand,Nicaragua,Niger,Nigeria,Niue,Norfolk Island,Northern Mariana Islands,Norway,Oman,Pakistan,Palau,Panama,Papua New Guinea,Paraguay,Peru,Philippines,Pitcaim Islands,Poland,Portugal,Puerto Rico,Qatar,Reunion,Romania,Russia,Rwanda,Saint Helena,Saint Kitts and Nevis,Saint Lucia,Saint Pierre and Miquelon,Saint Vincent and the Grenadines,Samoa,San Marino,Sao Tome and Principe,Saudi Arabia,Scotland,Senegal,Seychelles,Sierra Leone,Singapore,Slovakia,Slovenia,Solomon Islands,Somalia,South Africa,South Georgia,Spain,Spratly Islands,Sri Lanka,Sudan,Suriname,Svalbard,Swaziland,Sweden,Switzerland,Syria,Taiwan,Tajikistan,Tanzania,Thailand,Tobago,Toga,Tokelau,Tonga,Trinidad,Tunisia,Turkey,Turkmenistan,Tuvalu,Uganda,Ukraine,United Arab Emirates,Uruguay,Uzbekistan,Vanuatu,Vatican City,Venezuela,Vietnam,Virgin Islands,Wales,Wallis and Futuna,West Bank,Western Sahara,Yemen,Yugoslavia,Zambia,Zimbabwe', 'field_search' => '1', 'field_perm' => '2', 'field_core' => '1', 'field_req' => '1', 'field_owner' => 'ClassiPress', 'field_created' => current_time('mysql'), 'field_modified' => current_time('mysql'), 'field_min_length' => '0'));
    }
    // Zip/Postal Code field
    $wpdb->get_results($wpdb->prepare($field_sql, 'cp_zipcode'));
    if ($wpdb->num_rows == 0) {
        $wpdb->insert($wpdb->cp_ad_fields, array('field_name' => 'cp_zipcode', 'field_label' => 'Zip/Postal Code', 'field_desc' => 'This is the zip/postal code text field. It is a core ClassiPress field and cannot be deleted. (Needed on your forms for Google maps to work best.)', 'field_type' => 'text box', 'field_values' => '', 'field_search' => '0', 'field_perm' => '2', 'field_core' => '1', 'field_req' => '0', 'field_owner' => 'ClassiPress', 'field_created' => current_time('mysql'), 'field_modified' => current_time('mysql'), 'field_min_length' => '0'));
    }
    // Tags field
    $wpdb->get_results($wpdb->prepare($field_sql, 'tags_input'));
    if ($wpdb->num_rows == 0) {
        $wpdb->insert($wpdb->cp_ad_fields, array('field_name' => 'tags_input', 'field_label' => 'Tags', 'field_desc' => 'This is for inputting tags for the ad. It is a core ClassiPress field and cannot be deleted.', 'field_type' => 'text box', 'field_values' => '', 'field_search' => '0', 'field_perm' => '2', 'field_core' => '1', 'field_req' => '0', 'field_owner' => 'ClassiPress', 'field_created' => current_time('mysql'), 'field_modified' => current_time('mysql'), 'field_min_length' => '0'));
    }
    // Description field
    $wpdb->get_results($wpdb->prepare($field_sql, 'post_content'));
    if ($wpdb->num_rows == 0) {
        $wpdb->insert($wpdb->cp_ad_fields, array('field_name' => 'post_content', 'field_label' => 'Description', 'field_desc' => 'This is the main description box for the ad. It is a core ClassiPress field and cannot be deleted.', 'field_type' => 'text area', 'field_values' => '', 'field_search' => '0', 'field_perm' => '1', 'field_core' => '1', 'field_req' => '1', 'field_owner' => 'ClassiPress', 'field_created' => current_time('mysql'), 'field_modified' => current_time('mysql'), 'field_min_length' => '0'));
    }
    // Region field
    $wpdb->get_results($wpdb->prepare($field_sql, 'cp_region'));
    if ($wpdb->num_rows == 0) {
        $wpdb->insert($wpdb->cp_ad_fields, array('field_name' => 'cp_region', 'field_label' => 'Region', 'field_desc' => 'This is the region drop-down select box for the ad.', 'field_type' => 'drop-down', 'field_values' => 'San Francisco Bay Area,Orange County,Central Valley,Northern CA,Southern CA', 'field_search' => '1', 'field_perm' => '2', 'field_core' => '0', 'field_req' => '0', 'field_owner' => 'ClassiPress', 'field_created' => current_time('mysql'), 'field_modified' => current_time('mysql'), 'field_min_length' => '0'));
    }
    // Size field
    $wpdb->get_results($wpdb->prepare($field_sql, 'cp_size'));
    if ($wpdb->num_rows == 0) {
        $wpdb->insert($wpdb->cp_ad_fields, array('field_name' => 'cp_size', 'field_label' => 'Size', 'field_desc' => 'This is an example of a custom drop-down field.', 'field_type' => 'drop-down', 'field_values' => 'XS,S,M,L,XL,XXL', 'field_search' => '0', 'field_perm' => '0', 'field_core' => '0', 'field_req' => '0', 'field_owner' => 'ClassiPress', 'field_created' => current_time('mysql'), 'field_modified' => current_time('mysql'), 'field_min_length' => '0'));
    }
    // Feedback field
    $wpdb->get_results($wpdb->prepare($field_sql, 'cp_feedback'));
    if ($wpdb->num_rows == 0) {
        $wpdb->insert($wpdb->cp_ad_fields, array('field_name' => 'cp_feedback', 'field_label' => 'Feedback', 'field_desc' => 'This is an example of a custom text area field.', 'field_type' => 'text area', 'field_values' => '', 'field_search' => '0', 'field_perm' => '0', 'field_core' => '0', 'field_req' => '0', 'field_owner' => 'ClassiPress', 'field_created' => current_time('mysql'), 'field_modified' => current_time('mysql'), 'field_min_length' => '0'));
    }
    // Currency field
    $wpdb->get_results($wpdb->prepare($field_sql, 'cp_currency'));
    if ($wpdb->num_rows == 0) {
        $wpdb->insert($wpdb->cp_ad_fields, array('field_name' => 'cp_currency', 'field_label' => 'Currency', 'field_desc' => 'This is the currency drop-down select box for the ad. Add it to the form below the price to allow users to choose the currency for the ad price.', 'field_type' => 'drop-down', 'field_values' => '$,€,£,¥', 'field_search' => '0', 'field_perm' => '0', 'field_core' => '0', 'field_req' => '0', 'field_owner' => 'ClassiPress', 'field_created' => current_time('mysql'), 'field_modified' => current_time('mysql'), 'field_min_length' => '0'));
    }
    // Example Ad Pack
    $listing_packages = cp_get_listing_packages(array('post_status' => 'any'));
    if (!$listing_packages) {
        $package_meta = array('pack_name' => '30 days for only $5', 'description' => 'This is the default price per ad package created by ClassiPress.', 'price' => '5.00', 'duration' => '30');
        $package_id = wp_insert_post(array('post_status' => 'publish', 'post_type' => CP_PACKAGE_LISTING_PTYPE, 'post_author' => 1, 'post_name' => sanitize_title_with_dashes($package_meta['pack_name']), 'post_title' => $package_meta['pack_name']));
        foreach ($package_meta as $meta_key => $meta_value) {
            add_post_meta($package_id, $meta_key, $meta_value, true);
        }
    }
    // Example Membership Pack
    $membership_packages = cp_get_membership_packages(array('post_status' => 'any'));
    if (!$membership_packages) {
        $package_meta = array('pack_name' => '30 days publishing for only $2', 'description' => 'This is the default membership package created by ClassiPress.', 'price' => '15.00', 'price_modifier' => '2.00', 'duration' => '30', 'pack_type' => 'static', 'pack_satisfies_required' => '1');
        $package_id = wp_insert_post(array('post_status' => 'publish', 'post_type' => CP_PACKAGE_MEMBERSHIP_PTYPE, 'post_author' => 1, 'post_name' => sanitize_title_with_dashes($package_meta['pack_name']), 'post_title' => $package_meta['pack_name']));
        foreach ($package_meta as $meta_key => $meta_value) {
            add_post_meta($package_id, $meta_key, $meta_value, true);
        }
    }
}