function wpt_search_result_set() { global $post; // Noncename needed to verify where the data originated echo '<input type="hidden" name="eventmeta_noncename" id="eventmeta_noncename" value="' . wp_create_nonce(plugin_basename(__FILE__)) . '" />'; $reslt_search_name = get_post_meta($post->ID, 'reslt_search_name', true); $reslt_agent = get_post_meta($post->ID, 'reslt_agent', true); $reslt_offc_loc = get_post_meta($post->ID, 'reslt_offc_loc', true); $geo_area = get_post_meta($post->ID, 'geo_area', true); $reslt_property_typ = get_post_meta($post->ID, 'reslt_property_typ', true); $reslt_property_style = get_post_meta($post->ID, 'reslt_property_style', true); $reslt_property_status = get_post_meta($post->ID, 'reslt_property_status', true); $reslt_min_price = get_post_meta($post->ID, 'reslt_min_price', true); $reslt_max_price = get_post_meta($post->ID, 'reslt_max_price', true); $reslt_min_square = get_post_meta($post->ID, 'reslt_min_square', true); $reslt_max_square = get_post_meta($post->ID, 'reslt_max_square', true); $reslt_beds = get_post_meta($post->ID, 'reslt_beds', true); $reslt_baths = get_post_meta($post->ID, 'reslt_baths', true); $reslt_waterfront = get_post_meta($post->ID, 'reslt_waterfront', true); $reslt_features = get_post_meta($post->ID, 'reslt_features', true); $reslt_gallery = get_post_meta($post->ID, 'reslt_gallery', true); $reslt_list = get_post_meta($post->ID, 'reslt_list', true); $reslt_carousel = get_post_meta($post->ID, 'reslt_carousel', true); $reslt_peg_width = get_post_meta($post->ID, 'reslt_peg_width', true); $reslt_sidebar_width = get_post_meta($post->ID, 'reslt_sidebar_width', true); $reslt_bgcolor = get_post_meta($post->ID, 'reslt_bgcolor', true); $reslt_map = get_post_meta($post->ID, 'reslt_map', true); $reslt_sort_order = get_post_meta($post->ID, 'reslt_sort_order', true); $reslt_featur_list = get_post_meta($post->ID, 'reslt_featur_list', true); ?> <div> <label><b>Name of Search</b></label> <input type="text" name="reslt_search_name" value="<?php echo $reslt_search_name; ?> "class="widefat" required /> </div> <div> </br> <label><b>Agent/Agents</b></label> <select id="reslt_agent" name="reslt_agent" required> <?php $parent = $post->ID; query_posts('order=ASC&post_type=agent'); while (have_posts()) { the_post(); $post_title = get_the_title(); ?> <option <?php if ($reslt_agent == $post_title) { echo "selected='selected'"; } ?> value="<?php the_title(); ?> "><?php the_title(); ?> </option> <?php } ?> </select> </div> <div> </br> <label><b>Office Locations</b></label> <select id="reslt_offc_loc" name="reslt_offc_loc"> <?php function get_meta_values($key = '', $type = 'post', $status = 'publish') { global $wpdb; if (empty($key)) { return; } $r = $wpdb->get_col($wpdb->prepare("\n\t\t\t\tSELECT pm.meta_value FROM {$wpdb->postmeta} pm\n\t\t\t\tLEFT JOIN {$wpdb->posts} p ON p.ID = pm.post_id\n\t\t\t\tWHERE pm.meta_key = '%s' \n\t\t\t\tAND p.post_status = '%s' \n\t\t\t\tAND p.post_type = '%s'\n\t\t\t", $key, $status, $type)); return $r; } $city = get_meta_values('offc_city', 'office'); //print_r($movie_ratings); foreach ($city as $citty) { ?> <option <?php if ($reslt_offc_loc == $citty) { echo "selected='selected'"; } ?> value="<?php echo $citty; ?> "><?php echo $citty; ?> </option> <?php } ?> </select> </div> <div> </br> <label><b>Geographic Areas </b></label> <select id="geo_area" name="geo_area" > <option <?php if ($geo_area == "ZIP Codes") { echo "selected='selected'"; } ?> value="ZIP Codes">ZIP Codes</option> <option <?php if ($geo_area == "Countries") { echo "selected='selected'"; } ?> value="Countries">Countries</option> <option <?php if ($geo_area == "Cities") { echo "selected='selected'"; } ?> value="Cities">Cities</option> <option <?php if ($geo_area == "Neighbourhood") { echo "selected='selected'"; } ?> value="Neighbourhood">Neighbourhood</option> <option <?php if ($geo_area == "Map Boundaries") { echo "selected='selected'"; } ?> value="Map Boundaries">Map Boundaries</option> <option <?php if ($geo_area == "GPS") { echo "selected='selected'"; } ?> value="GPS">GPS</option> </select> </div> <div> </br> <label><b>Property Type </b></label> <select id="reslt_property_typ" name="reslt_property_typ" required> <option <?php if ($reslt_property_typ == "Commercial") { echo "selected='selected'"; } ?> value="Commercial">Commercial</option> <option <?php if ($reslt_property_typ == "Income") { echo "selected='selected'"; } ?> value="Income">Income</option> <option <?php if ($reslt_property_typ == "Lot & Land") { echo "selected='selected'"; } ?> value="Lot & Land">Lot & Land</option> <option <?php if ($reslt_property_typ == "Rental") { echo "selected='selected'"; } ?> value="Rental">Rental</option> <option <?php if ($reslt_property_typ == "Residential") { echo "selected='selected'"; } ?> value="Residential">Residential</option> <option <?php if ($reslt_property_typ == "Residential Rental") { echo "selected='selected'"; } ?> value="Residential Rental">Residential Rental</option> <option <?php if ($reslt_property_typ == "Residential Income") { echo "selected='selected'"; } ?> value="Residential Income">Residential Income</option> <option <?php if ($reslt_property_typ == "Vacant Land") { echo "selected='selected'"; } ?> value="Vacant Land">Vacant Land</option> </select> </div> <div> </br> <label><b>Property Style</b></label> <select id="reslt_property_style" name="reslt_property_style" required> <option <?php if ($reslt_property_style == "1/2 Duplex") { echo "selected='selected'"; } ?> value="1/2 Duplex" >1/2 Duplex</option> <option <?php if ($reslt_property_style == "Condo") { echo "selected='selected'"; } ?> value="Condo">Condo</option> <option <?php if ($reslt_property_style == "Manufactured/Mobile House") { echo "selected='selected'"; } ?> value="Manufactured/Mobile House">Manufactured/Mobile House</option> <option <?php if ($reslt_property_style == "Modular") { echo "selected='selected'"; } ?> value="Modular">Modular</option> <option <?php if ($reslt_property_style == "Single Family House") { echo "selected='selected'"; } ?> value="Single Family House">Single Family House</option> <option <?php if ($reslt_property_style == "Townhouse") { echo "selected='selected'"; } ?> value="Townhouse">Townhouse</option> <option <?php if ($reslt_property_style == "Villa") { echo "selected='selected'"; } ?> value="Villa">Villa</option> </select> </div> <div> </br> <label><b>Property Status</b></label> <select id="reslt_property_status" name="reslt_property_status" required> <option <?php if ($reslt_property_status == "All") { echo "selected='selected'"; } ?> value="All">All</option> <option <?php if ($reslt_property_status == "Available") { echo "selected='selected'"; } ?> value="Available" >Available</option> <option <?php if ($reslt_property_status == "Sold") { echo "selected='selected'"; } ?> value="Sold">Sold</option> </select> </div> </br> <label><b>Additional Features</b></label> <div> </br> <label><b>Min Price</b></label> <input type="text" name="reslt_min_price" value="<?php echo $reslt_min_price; ?> "class="widefat" required> </div> <div> </br> <label><b>Max Price</b></label> <input type="text" name="reslt_max_price" value="<?php echo $reslt_max_price; ?> "class="widefat" required> </div> <div> </br> <label><b>Min Square Footage</b></label> <input type="text" name="reslt_min_square" value="<?php echo $reslt_min_square; ?> "class="widefat"> </div> <div> </br> <label><b>Max Square Footage</b></label> <input type="text" name="reslt_max_square" value="<?php echo $reslt_max_square; ?> "class="widefat"> </div> <div> </br> <label><b>Number Bedrooms</b></label> <select id="reslt_beds" name="reslt_beds" > <option <?php if ($reslt_beds == "0") { echo "selected='selected'"; } ?> value="0">0</option> <option <?php if ($reslt_beds == "1+") { echo "selected='selected'"; } ?> value="1+">1+</option> <option <?php if ($reslt_beds == "2+") { echo "selected='selected'"; } ?> value="2+">2+</option> <option <?php if ($reslt_beds == "3+") { echo "selected='selected'"; } ?> value="3+">3+</option> <option <?php if ($reslt_beds == "4+") { echo "selected='selected'"; } ?> value="4+">4+</option> </select> </div> <div> </br> <label><b>Number Bathrooms</b></label> <select id="reslt_baths" name="reslt_baths"> <option <?php if ($reslt_baths == "0") { echo "selected='selected'"; } ?> value="0">0</option> <option <?php if ($reslt_baths == "1+") { echo "selected='selected'"; } ?> value="1+">1+</option> <option <?php if ($reslt_baths == "2+") { echo "selected='selected'"; } ?> value="2+">2+</option> <option <?php if ($reslt_baths == "3+") { echo "selected='selected'"; } ?> value="3+">3+</option> <option <?php if ($reslt_baths == "4+") { echo "selected='selected'"; } ?> value="4+">4+</option> </select> </div> <div> </br> <label><b>Waterfront</b></label> <select id="reslt_waterfront" name="reslt_waterfront" > <option <?php if ($reslt_waterfront == "Yes") { echo "selected='selected'"; } ?> value="Yes">Yes</option> <option <?php if ($reslt_waterfront == "No") { echo "selected='selected'"; } ?> value="No">No</option> </select> </div> <div> </br> <label><b>Features</b></label> <select id="reslt_features" name="reslt_features" > <option <?php if ($reslt_features == "Single Story") { echo "selected='selected'"; } ?> value="Single Story">Single Story</option> <option <?php if ($reslt_features == "Fireplace") { echo "selected='selected'"; } ?> value="Fireplace">Fireplace</option> <option <?php if ($reslt_features == "Basement") { echo "selected='selected'"; } ?> value="Basement">Basement</option> </select> </div> </br> <label><h3>Display Options</h3></label> </br> <label><b>Display Type</b></label> <div> </br> <label><b>Gallery</b></label> <select id="reslt_gallery" name="reslt_gallery" > <option <?php if ($reslt_gallery == "1") { echo "selected='selected'"; } ?> value="1">1</option> <option <?php if ($reslt_gallery == "2") { echo "selected='selected'"; } ?> value="2">2</option> <option <?php if ($reslt_gallery == "3") { echo "selected='selected'"; } ?> value="3">3</option> <option <?php if ($reslt_gallery == "4") { echo "selected='selected'"; } ?> value="4">4</option> <option <?php if ($reslt_gallery == "5") { echo "selected='selected'"; } ?> value="5">5</option> </select><label><b>Result Per Page</b></label> </div> <div> </br> <label><b>List</b></label> <select id="reslt_list" name="reslt_list" > <option <?php if ($reslt_list == "1") { echo "selected='selected'"; } ?> value="1">1</option> <option <?php if ($reslt_list == "2") { echo "selected='selected'"; } ?> value="2">2</option> <option <?php if ($reslt_list == "3") { echo "selected='selected'"; } ?> value="3">3</option> <option <?php if ($reslt_list == "4") { echo "selected='selected'"; } ?> value="4">4</option> <option <?php if ($reslt_list == "5") { echo "selected='selected'"; } ?> value="5">5</option> </select><label><b>Result Per Page</b></label> </div> <div> </br> <label><b>Carousel</b></label> <select id="reslt_carousel" name="reslt_carousel" > <option <?php if ($reslt_carousel == "1") { echo "selected='selected'"; } ?> value="1">1</option> <option <?php if ($reslt_carousel == "2") { echo "selected='selected'"; } ?> value="2">2</option> <option <?php if ($reslt_carousel == "3") { echo "selected='selected'"; } ?> value="3">3</option> <option <?php if ($reslt_carousel == "4") { echo "selected='selected'"; } ?> value="4">4</option> <option <?php if ($reslt_carousel == "5") { echo "selected='selected'"; } ?> value="5">5</option> </select><label><b>Result Per Page</b></label> </div> <div> </br> <label><b>Page Width</b></label> <input type="text" name="reslt_peg_width" value="<?php echo $reslt_peg_width; ?> "class="widefat"> </div> <div> </br> <label><b>Sidebar Width</b></label> <input type="text" name="reslt_sidebar_width" value="<?php echo $reslt_sidebar_width; ?> "class="widefat"> </div> <div> </br> <label><b>Background</b></label> <script type="text/javascript" <?php echo '<script src="' . plugins_url('js/jscolor.js', __FILE__) . '" > '; ?> </script> <input class="color" name="reslt_bgcolor" value="<?php if ($reslt_bgcolor != "66ff00") { echo $reslt_bgcolor; } else { echo "66ff00"; } ?> "> </div> <!-- # Visible Results (1-3?) Not Include here need to implement --> <div> </br> <label><b>Map</b></label> <input type="checkbox" name="reslt_map" value="active" class="widefat" <?php if ($reslt_map == 'active') { echo 'checked'; } ?> /> </div> <div> </br> <label><b>Sort Order</b></label> <input type="checkbox" name="reslt_sort_order" value="active" class="widefat" <?php if ($reslt_sort_order == 'active') { echo 'checked'; } ?> /> </div> <div> </br> <label><b>Featured Listings first</b></label> <input type="checkbox" name="reslt_featur_list" value="active" class="widefat" <?php if ($reslt_featur_list == 'active') { echo 'checked'; } ?> /> </div> <?php }
function arc_meta_box_save($post_id) { // Check if our nonce is set. This verifies it's from the correct screen if (!isset($_POST['arc_meta_box_nonce'])) { return; } // Check if the nonce is valid if (!wp_verify_nonce($_POST['arc_meta_box_nonce'], 'Awl\\arc_meta_box_save')) { return; } // If this is an autosave, our form has not been submitted, so we don't want to do anything. if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return; } // Check the user's permissions. if (isset($_POST['post_type']) && 'page' == $_POST['post_type']) { if (!current_user_can('edit_page', $post_id)) { return; } } else { if (!current_user_can('edit_post', $post_id)) { return; } } // Section to save the information $meta_values = get_meta_values(); $meta_count = count($meta_values); for ($i = 0; $i < $meta_count; ++$i) { $meta_value = $meta_values[$i]; $value = sanitize_text_field($_POST[$meta_value["meta"]]); update_post_meta($post_id, $meta_value["meta"], $value); } }
function get_posts_by_category($category = "", $limit = 100, $random = false, $order = "desc") { global $wpdb; $meta_values = get_meta_values(); $meta_count = count($meta_values); $first_meta_name = $meta_values[0]["meta"] . "meta"; $order = strtolower($order); if ($order != "desc" && $order != "asc") { $order = "desc"; } $query = "\n SELECT DISTINCT \n posts.post_title,\n posts.post_content,\n posts.guid "; for ($i = 0; $i < $meta_count; ++$i) { $meta_value = $meta_values[$i]; $query .= ", " . $meta_value["meta"] . "meta.meta_value AS " . $meta_value["meta"]; } $query .= " FROM (SELECT p.* FROM {$wpdb->posts} p"; // This has been moved to a select statement where we limit the content inititally. This greatly improves the speed of the query. $query .= " INNER JOIN\n {$wpdb->term_relationships} term_relationships\n ON term_relationships.object_id = p.ID\n INNER JOIN\n {$wpdb->term_taxonomy} term_taxonomy\n ON term_taxonomy.term_taxonomy_id = term_relationships.term_taxonomy_id\n INNER JOIN\n {$wpdb->terms} terms\n ON terms.term_id = term_taxonomy.term_id\n AND terms.name = '" . $category . "'\n AND term_taxonomy = 'category'\n WHERE\n p.post_status = 'publish'\n AND p.post_type = 'post' "; if ($random) { $query .= "ORDER BY " . rand() . " ^ ID "; // An exclusive or is used with a rand to keep meta-data grouped together. } else { $query .= "ORDER BY ID " . $order . ", post_date " . $order . " "; } $query .= "LIMIT " . $limit; $query .= ") posts "; for ($i = 0; $i < $meta_count; ++$i) { $meta_value = $meta_values[$i]; $meta_name = $meta_value["meta"] . "meta "; $query .= " INNER JOIN {$wpdb->postmeta} " . $meta_name; $query .= " ON " . $meta_name . ".post_id = posts.ID"; $query .= " AND " . $meta_name . ".meta_key = " . "'" . $meta_value["meta"] . "'"; } $query .= ";"; // error_log($query); return $wpdb->get_results($query); }
return; $r = $wpdb->get_results( $wpdb->prepare( " SELECT p.ID, pm.meta_value FROM {$wpdb->postmeta} pm LEFT JOIN {$wpdb->posts} p ON p.ID = pm.post_id WHERE pm.meta_key = '%s' AND p.post_status = '%s' AND p.post_type = '%s' ", $key, $status, $type )); foreach ( $r as $my_r ) $metas[$my_r->ID] = $my_r->meta_value; return $metas; } $metas = get_meta_values('_ilosc', 'zgloszenia'); foreach($metas as $meta) { $totalCount += $meta ? $meta : 1; } /* $query = new WP_Query(array('post_type'=>'zgloszenia', 'posts_per_page'=>99999)); foreach($query->posts as $post) { $count = get_post_meta($post->ID, '_ilosc'); $totalCount += $count[0]; } */ ?> <b><?= (int)$totalCount; ?></b>