/** * function for post type settings. * * @since 1.0.0 * @package GeoDirectory */ function geodir_post_type_setting_fun() { $post_type_arr = array(); $post_types = geodir_get_posttypes('object'); foreach ($post_types as $key => $post_types_obj) { $post_type_arr[$key] = $post_types_obj->labels->singular_name; } return $post_type_arr; }
function geodir_add_claim_option_metabox() { global $post; $geodir_post_types = geodir_get_posttypes('array'); $geodir_posttypes = array_keys($geodir_post_types); if (isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)) { $geodir_posttype = $post->post_type; $post_typename = ucwords($geodir_post_types[$geodir_posttype]['labels']['singular_name']); add_meta_box('geodir_claim_listing_information', $post_typename . ' Claim Settings', 'geodir_claim_listing_information', $geodir_posttype, 'side', 'high'); } }
/** * Get the cpt texts for translation. * * @since 1.5.5 * @package GeoDirectory * * @param array $translation_texts Array of text strings. * @return array Translation texts. */ function geodir_load_cpt_text_translation($translation_texts = array()) { $gd_post_types = geodir_get_posttypes('array'); if (!empty($gd_post_types)) { foreach ($gd_post_types as $post_type => $cpt_info) { $labels = isset($cpt_info['labels']) ? $cpt_info['labels'] : ''; $description = isset($cpt_info['description']) ? $cpt_info['description'] : ''; $seo = isset($cpt_info['seo']) ? $cpt_info['seo'] : ''; if (!empty($labels)) { if ($labels['name'] != '' && !in_array($labels['name'], $translation_texts)) { $translation_texts[] = $labels['name']; } if ($labels['singular_name'] != '' && !in_array($labels['singular_name'], $translation_texts)) { $translation_texts[] = $labels['singular_name']; } if ($labels['add_new'] != '' && !in_array($labels['add_new'], $translation_texts)) { $translation_texts[] = $labels['add_new']; } if ($labels['add_new_item'] != '' && !in_array($labels['add_new_item'], $translation_texts)) { $translation_texts[] = $labels['add_new_item']; } if ($labels['edit_item'] != '' && !in_array($labels['edit_item'], $translation_texts)) { $translation_texts[] = $labels['edit_item']; } if ($labels['new_item'] != '' && !in_array($labels['new_item'], $translation_texts)) { $translation_texts[] = $labels['new_item']; } if ($labels['view_item'] != '' && !in_array($labels['view_item'], $translation_texts)) { $translation_texts[] = $labels['view_item']; } if ($labels['search_items'] != '' && !in_array($labels['search_items'], $translation_texts)) { $translation_texts[] = $labels['search_items']; } if ($labels['not_found'] != '' && !in_array($labels['not_found'], $translation_texts)) { $translation_texts[] = $labels['not_found']; } if ($labels['not_found_in_trash'] != '' && !in_array($labels['not_found_in_trash'], $translation_texts)) { $translation_texts[] = $labels['not_found_in_trash']; } if (isset($labels['label_post_profile']) && $labels['label_post_profile'] != '' && !in_array($labels['label_post_profile'], $translation_texts)) { $translation_texts[] = $labels['label_post_profile']; } if (isset($labels['label_post_info']) && $labels['label_post_info'] != '' && !in_array($labels['label_post_info'], $translation_texts)) { $translation_texts[] = $labels['label_post_info']; } if (isset($labels['label_post_images']) && $labels['label_post_images'] != '' && !in_array($labels['label_post_images'], $translation_texts)) { $translation_texts[] = $labels['label_post_images']; } if (isset($labels['label_post_map']) && $labels['label_post_map'] != '' && !in_array($labels['label_post_map'], $translation_texts)) { $translation_texts[] = $labels['label_post_map']; } if (isset($labels['label_reviews']) && $labels['label_reviews'] != '' && !in_array($labels['label_reviews'], $translation_texts)) { $translation_texts[] = $labels['label_reviews']; } if (isset($labels['label_related_listing']) && $labels['label_related_listing'] != '' && !in_array($labels['label_related_listing'], $translation_texts)) { $translation_texts[] = $labels['label_related_listing']; } } if ($description != '' && !in_array($description, $translation_texts)) { $translation_texts[] = normalize_whitespace($description); } if (!empty($seo)) { if (isset($seo['meta_keyword']) && $seo['meta_keyword'] != '' && !in_array($seo['meta_keyword'], $translation_texts)) { $translation_texts[] = normalize_whitespace($seo['meta_keyword']); } if (isset($seo['meta_description']) && $seo['meta_description'] != '' && !in_array($seo['meta_description'], $translation_texts)) { $translation_texts[] = normalize_whitespace($seo['meta_description']); } } } } $translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts; return $translation_texts; }
/** * Display price package list in claim lisitng form. * * @since 1.1.4 * * @param string $field Claim listing field name. * @return string Display price package list. */ function geodir_claim_after_claim_form_field($field = '') { if ($field == 'geodir_user_comments' && geodir_claim_force_upgrade()) { $gd_post_types = geodir_get_posttypes(); $post_id = isset($_REQUEST['post_id']) ? $_REQUEST['post_id'] : ''; $post_type = get_post_type($post_id); if ($post_type != '' && in_array($post_type, $gd_post_types)) { $package_list = geodir_claim_payment_package_list($post_type); $payment_methods = geodir_claim_payment_methods(); if (empty($package_list) || empty($payment_methods)) { return; } $package_id = geodir_get_post_meta('package_id', true); if (empty($package_id)) { $default_package = geodir_get_default_package($post_type); $package_id = $default_package->pid; } $js_script = ''; ?> <div id="gd_claim_pkgs" class="row clearfix gd-claim-pkgs gd-chosen-outer"> <label><?php _e('Select Package', GEODIRCLAIM_TEXTDOMAIN); ?> : <span>*</span></label> <select name="geodir_claim_pkg" id="geodir_claim_pkg" field_type="select" class="is_required chosen_select"> <?php foreach ($package_list as $package) { ?> <option value="<?php echo $package->pid; ?> "><?php echo stripslashes_deep($package->title_desc); ?> </option> <?php } ?> </select> <span class="message_error2" id="geodir_claim_pkgInfo"></span> </div> <div id="gd_claim_payments" class="row clearfix gd-claim-payments gd-chosen-outer"> <label><?php _e('Select Payment Method', GEODIRCLAIM_TEXTDOMAIN); ?> : <span>*</span></label> <select name="geodir_claim_payment" id="geodir_claim_payment" field_type="select" class="is_required chosen_select"> <?php $file_content = ''; $keys = array(); foreach ($payment_methods as $payment_method) { $keys[] = $payment_method['key']; if (file_exists(GEODIR_PAYMENT_MANAGER_PATH . $payment_method['key'] . '/' . $payment_method['key'] . '.php')) { ob_start(); include_once GEODIR_PAYMENT_MANAGER_PATH . $payment_method['key'] . '/' . $payment_method['key'] . '.php'; $file_content .= ob_get_clean(); } ?> <option value="<?php echo $payment_method['key']; ?> "><?php echo stripslashes_deep($payment_method['name']); ?> </option> <?php } $gd_claim_pmkeys = "['" . implode("', '", $keys) . "']"; $js_script .= 'jQuery("#geodir_claim_payment").attr("onchange", "javascript:gd_claim_change_pmethod(this, ' . $gd_claim_pmkeys . ');"); jQuery("#geodir_claim_payment").trigger("change");'; ?> </select> <span class="message_error2" id="geodir_claim_paymentInfo"></span> <?php echo $file_content; ?> <?php $js_script .= ''; ?> </div> <script type="text/javascript"><?php echo $js_script; ?> jQuery("#geodir_claim_form").addClass('gd-claimfrm-upgrade');jQuery(".chosen_select", "#geodir_claim_form").chosen({"disable_search":true});</script> <?php } } }
/** * Returns All post categories from all GD post types. * * @since 1.0.0 * @package GeoDirectory * @return array Returns post categories as an array. */ function geodir_home_map_cats_key_value_array() { $post_types = geodir_get_posttypes('object'); $return = array(); if (!empty($post_types)) { foreach ($post_types as $key => $post_type) { $cpt_name = __($post_type->labels->singular_name, 'geodirectory'); $post_type_name = sprintf(__('%s Categories', 'geodirectory'), $cpt_name); $taxonomies = geodir_get_taxonomies($key); $cat_taxonomy = !empty($taxonomies[0]) ? $taxonomies[0] : NULL; $cat_terms = $cat_taxonomy ? get_terms($cat_taxonomy) : NULL; if (!empty($cat_terms)) { $return['optgroup_start-' . $key] = $post_type_name; foreach ($cat_terms as $cat_term) { $return[$key . '_' . $cat_term->term_id] = $cat_term->name; } $return['optgroup_end-' . $key] = $post_type_name; } } } return $return; }
/** * Count reviews by terms. * * @since 1.0.0 * @package GeoDirectory * @param bool $force_update Force update option value?. Default.false. * @return array Term array data. */ function geodir_count_reviews_by_terms($force_update = false) { /** * Filter review count option data. * * @since 1.0.0 * @param bool $force_update Force update option value?. Default.false. */ $option_data = apply_filters('geodir_count_reviews_by_terms_before', '', $force_update); if (!empty($option_data)) { return $option_data; } $option_data = get_option('geodir_global_review_count'); if (!$option_data or $force_update) { $post_types = geodir_get_posttypes(); $term_array = array(); foreach ($post_types as $post_type) { $taxonomy = geodir_get_taxonomies($post_type); $taxonomy = $taxonomy[0]; $args = array('hide_empty' => false); $terms = get_terms($taxonomy, $args); foreach ($terms as $term) { $count = geodir_count_reviews_by_term_id($term->term_id, $taxonomy, $post_type); $children = get_term_children($term->term_id, $taxonomy); /*if ( is_array( $children ) ) { foreach ( $children as $child_id ) { $child_count = geodir_count_reviews_by_term_id($child_id, $taxonomy, $post_type); $count = $count + $child_count; } }*/ $term_array[$term->term_id] = $count; } } update_option('geodir_global_review_count', $term_array); //clear cache wp_cache_delete('geodir_global_review_count'); return $term_array; } else { return $option_data; } }
/** * Filters the adjacent post url. * * @since 1.0.0 * @package GeoDirectory_Location_Manager * * @global object $wpdb WordPress Database object. * @global string $plugin_prefix Geodirectory plugin table prefix. * @global object $post The current post object. * * @param string $url The adjacent post url. * @param string $link Link permalink format. * @param string $direction Direction. Ex: Next or Previous. * @param object $post The Post object. * @return mixed Post url. */ function geodir_single_next_previous_fix($url, $link, $direction, $post) { global $wpdb, $plugin_prefix, $post; $post_type_array = geodir_get_posttypes(); if (isset($post->post_type) && in_array($post->post_type, $post_type_array)) { $post_date = $timestamp = strtotime($post->post_date); $where = ''; $prep_arr = array($post_date); if (isset($post->country_slug) && $post->country_slug != '') { $where .= " AND post_locations LIKE %s "; $prep_arr[] = "%,[" . $post->country_slug . "]"; } if (isset($post->region_slug) && $post->region_slug != '') { $where .= " AND post_locations LIKE %s "; $prep_arr[] = "%,[" . $post->region_slug . "],%"; } if (isset($post->city_slug) && $post->city_slug != '') { $where .= " AND post_locations LIKE %s "; $prep_arr[] = "[" . $post->city_slug . "],%"; } $prep_arr[] = $post->ID; if ($direction == __('Next', GEODIRLOCATION_TEXTDOMAIN)) { $op = '>'; } else { $op = '<'; } $table = $plugin_prefix . $post->post_type . '_detail'; $pid = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM " . $table . " WHERE submit_time {$op} %d AND post_status='publish' {$where} AND post_id !=%d LIMIT 1", $prep_arr)); if ($pid) { $just_url = preg_match("/href=\"([^\"]*)\"/", $url, $matches); if (is_array($matches) && isset($matches[1])) { return str_replace($matches[1], get_permalink($pid), $url); } } } return $url; }
public function form($instance) { $instance = wp_parse_args((array) $instance, array('title' => '', 'hood_post_type' => '', 'hood_category' => '', 'category_title' => '', 'list_sort' => '', 'list_order' => '', 'post_number' => '5', 'layout' => 'gridview_onehalf', 'add_location_filter' => '1', 'character_count' => '20')); $title = strip_tags($instance['title']); $hood_post_type = strip_tags($instance['hood_post_type']); $hood_category = strip_tags($instance['hood_category']); $category_title = strip_tags($instance['category_title']); $list_sort = strip_tags($instance['list_sort']); $list_order = strip_tags($instance['list_order']); $post_number = strip_tags($instance['post_number']); $layout = strip_tags($instance['layout']); $add_location_filter = strip_tags($instance['add_location_filter']); $character_count = $instance['character_count']; ?> <p> <label for="<?php echo $this->get_field_id('title'); ?> "><?php _e('Title:', GEODIRLOCATION_TEXTDOMAIN); ?> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?> " name="<?php echo $this->get_field_name('title'); ?> " type="text" value="<?php echo esc_attr($title); ?> " /> </label> </p> <p> <label for="<?php echo $this->get_field_id('hood_post_type'); ?> "><?php _e('Post Type:', GEODIRLOCATION_TEXTDOMAIN); ?> <?php $postypes = geodir_get_posttypes(); ?> <select class="widefat" id="<?php echo $this->get_field_id('hood_post_type'); ?> " name="<?php echo $this->get_field_name('hood_post_type'); ?> " onchange="geodir_change_hood_category_list(this)"> <?php foreach ($postypes as $postypes_obj) { ?> <option <?php if ($hood_post_type == $postypes_obj) { echo 'selected="selected"'; } ?> value="<?php echo $postypes_obj; ?> "><?php $extvalue = explode('_', $postypes_obj); echo ucfirst($extvalue[1]); ?> </option> <?php } ?> </select> </label> </p> <p id="hood_post_categories"> <label for="<?php echo $this->get_field_id('hood_category'); ?> "><?php _e('Post Category:', GEODIRLOCATION_TEXTDOMAIN); ?> <?php $hood_post_type = $hood_post_type != '' ? $hood_post_type : 'gd_place'; $category_taxonomy = geodir_get_taxonomies($hood_post_type); $categories = get_terms($category_taxonomy, array('orderby' => 'count', 'order' => 'DESC')); ?> <select class="widefat" id="<?php echo $this->get_field_id('hood_category'); ?> " name="<?php echo $this->get_field_name('hood_category'); ?> " onchange="jQuery('#<?php echo $this->get_field_id('category_title'); ?> ').val(jQuery('#<?php echo $this->get_field_id('hood_category'); ?> option:selected').text());" > <option <?php if ($hood_category == '0') { echo 'selected="selected"'; } ?> value="0"><?php _e('All', GEODIRLOCATION_TEXTDOMAIN); ?> </option> <?php foreach ($categories as $category_obj) { ?> <option <?php if ($hood_category == $category_obj->term_id) { echo 'selected="selected"'; } ?> value="<?php echo $category_obj->term_id; ?> "><?php echo ucfirst($category_obj->name); ?> </option> <?php } ?> </select> <input type="hidden" name="<?php echo $this->get_field_name('category_title'); ?> " id="<?php echo $this->get_field_id('category_title'); ?> " value="<?php if ($category_title != '') { echo $category_title; } else { echo __('All', GEODIRLOCATION_TEXTDOMAIN); } ?> " /> </label> </p> <p> <label for="<?php echo $this->get_field_id('list_sort'); ?> "><?php _e('Sort by:', GEODIRLOCATION_TEXTDOMAIN); ?> <select class="widefat" id="<?php echo $this->get_field_id('list_sort'); ?> " name="<?php echo $this->get_field_name('list_sort'); ?> "> <option <?php if ($list_sort == 'latest') { echo 'selected="selected"'; } ?> value="latest"><?php _e('Latest', GEODIRLOCATION_TEXTDOMAIN); ?> </option> <option <?php if ($list_sort == 'featured') { echo 'selected="selected"'; } ?> value="featured"><?php _e('Featured', GEODIRLOCATION_TEXTDOMAIN); ?> </option> <option <?php if ($list_sort == 'high_review') { echo 'selected="selected"'; } ?> value="high_review"><?php _e('Review', GEODIRLOCATION_TEXTDOMAIN); ?> </option> <option <?php if ($list_sort == 'high_rating') { echo 'selected="selected"'; } ?> value="high_rating"><?php _e('Rating', GEODIRLOCATION_TEXTDOMAIN); ?> </option> </select> </label> </p> <p> <label for="<?php echo $this->get_field_id('post_number'); ?> "><?php _e('Number of posts:', GEODIRLOCATION_TEXTDOMAIN); ?> <input class="widefat" id="<?php echo $this->get_field_id('post_number'); ?> " name="<?php echo $this->get_field_name('post_number'); ?> " type="text" value="<?php echo esc_attr($post_number); ?> " /> </label> </p> <p> <label for="<?php echo $this->get_field_id('layout'); ?> "> <?php _e('Layout:', GEODIRLOCATION_TEXTDOMAIN); ?> <select class="widefat" id="<?php echo $this->get_field_id('layout'); ?> " name="<?php echo $this->get_field_name('layout'); ?> "> <option <?php if ($layout == 'gridview_onehalf') { echo 'selected="selected"'; } ?> value="gridview_onehalf"><?php _e('Grid View (Two Columns)', GEODIRLOCATION_TEXTDOMAIN); ?> </option> <option <?php if ($layout == 'gridview_onethird') { echo 'selected="selected"'; } ?> value="gridview_onethird"><?php _e('Grid View (Three Columns)', GEODIRLOCATION_TEXTDOMAIN); ?> </option> <option <?php if ($layout == 'gridview_onefourth') { echo 'selected="selected"'; } ?> value="gridview_onefourth"><?php _e('Grid View (Four Columns)', GEODIRLOCATION_TEXTDOMAIN); ?> </option> <option <?php if ($layout == 'gridview_onefifth') { echo 'selected="selected"'; } ?> value="gridview_onefifth"><?php _e('Grid View (Five Columns)', GEODIRLOCATION_TEXTDOMAIN); ?> </option> <option <?php if ($layout == 'list') { echo 'selected="selected"'; } ?> value="list"><?php _e('List view', GEODIRLOCATION_TEXTDOMAIN); ?> </option> </select> </label> </p> <p> <label for="<?php echo $this->get_field_id('character_count'); ?> "><?php _e('Post Content excerpt character count :', GEODIRLOCATION_TEXTDOMAIN); ?> <input class="widefat" id="<?php echo $this->get_field_id('character_count'); ?> " name="<?php echo $this->get_field_name('character_count'); ?> " type="text" value="<?php echo esc_attr($character_count); ?> " /> </label> </p> <p style="display:none;"> <label for="<?php echo $this->get_field_id('add_location_filter'); ?> "> <?php _e('Enable Location Filter:', GEODIRLOCATION_TEXTDOMAIN); ?> <input type="checkbox" id="<?php echo $this->get_field_id('add_location_filter'); ?> " name="<?php echo $this->get_field_name('add_location_filter'); ?> " <?php if ($add_location_filter) { echo 'checked="checked"'; } ?> value="1" /> </label> </p> <script type="text/javascript"> function geodir_change_hood_category_list(obj,selected){ var ajax_url = '<?php echo geodir_get_ajax_url(); ?> ' var hood_post_type = obj.value; var myurl = ajax_url+"&geodir_ajax=admin_ajax&ajax_action=get_cat_dl&post_type="+hood_post_type+"&selected="+selected; jQuery.ajax({ type: "GET", url: myurl, success: function(data){ jQuery(obj).closest('form').find('#hood_post_categories select').html(data); } }); } <?php if (is_active_widget(false, false, $this->id_base, true)) { ?> var hood_post_type = jQuery('#<?php echo $this->get_field_id('hood_post_type'); ?> ').val(); <?php } ?> </script> <?php }
/** * Imports data from CSV file using ajax. * * @since 1.0.0 * @package GeoDirectory * @global object $wpdb WordPress Database object. * @global string $plugin_prefix Geodirectory plugin table prefix. * @global object $current_user Current user object. */ function geodir_ajax_import_csv() { error_reporting(0); // hide error to get clean json response global $wpdb, $plugin_prefix, $current_user; $uploads = wp_upload_dir(); ini_set('auto_detect_line_endings', true); $wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses. $task = isset($_POST['task']) ? $_POST['task'] : ''; $uploadedFile = isset($_POST['gddata']['uploadedFile']) ? $_POST['gddata']['uploadedFile'] : NULL; $filename = $uploadedFile; $uploads = wp_upload_dir(); $uploads_dir = $uploads['path']; $image_name_arr = explode('/', $filename); $filename = end($image_name_arr); $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename; $return = array(); $return['file'] = $uploadedFile; $return['error'] = __('The uploaded file is not a valid csv file. Please try again.', 'geodirectory'); if (is_file($target_path) && file_exists($target_path) && $uploadedFile) { $wp_filetype = wp_check_filetype_and_ext($target_path, $filename); if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') { $return['error'] = NULL; $return['rows'] = 0; if (($handle = fopen($target_path, "r")) !== FALSE) { while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { if (is_array($data) && !empty($data)) { $file[] = '"' . implode('","', $data) . '"'; } } fclose($handle); $file = $file; } $return['rows'] = !empty($file) && count($file) > 1 ? count($file) - 1 : 0; if (!$return['rows'] > 0) { $return['error'] = __('No data found in csv file.', 'geodirectory'); } } } if ($task == 'prepare' || !empty($return['error'])) { echo json_encode($return); exit; } $totRecords = isset($_POST['gddata']['totRecords']) ? $_POST['gddata']['totRecords'] : NULL; $importlimit = isset($_POST['gddata']['importlimit']) ? $_POST['gddata']['importlimit'] : 1; $count = $importlimit; $requested_limit = $importlimit; $tmpCnt = isset($_POST['gddata']['tmpcount']) ? $_POST['gddata']['tmpcount'] : 0; if ($count < $totRecords) { $count = $tmpCnt + $count; if ($count > $totRecords) { $count = $totRecords; } } else { $count = $totRecords; } $total_records = 0; $rowcount = 0; $address_invalid = 0; $blank_address = 0; $upload_files = 0; $invalid_post_type = 0; $invalid_title = 0; $customKeyarray = array(); $gd_post_info = array(); $post_location = array(); $countpost = 0; if (!empty($file)) { $columns = isset($file[0]) ? geodir_str_getcsv($file[0]) : NULL; $customKeyarray = $columns; if (empty($columns) || !empty($columns) && $columns[0] == '') { $return['error'] = CSV_INVAILD_FILE; echo json_encode($return); exit; } for ($i = 1; $i <= $importlimit; $i++) { $current_index = $tmpCnt + $i; if (isset($file[$current_index])) { $total_records++; $buffer = geodir_str_getcsv($file[$current_index]); $post_title = addslashes($buffer[0]); $current_post_author = $buffer[1]; $post_desc = addslashes($buffer[2]); $post_cat = array(); $catids_arr = array(); $post_cat = trim($buffer[3]); // comma seperated category name if ($post_cat) { $post_cat_arr = explode(',', $post_cat); for ($c = 0; $c < count($post_cat_arr); $c++) { $catid = wp_kses_normalize_entities(trim($post_cat_arr[$c])); if (!empty($buffer[5])) { if (in_array($buffer[5], geodir_get_posttypes())) { $p_taxonomy = geodir_get_taxonomies(addslashes($buffer[5])); if (get_term_by('name', $catid, $p_taxonomy[0])) { $cat = get_term_by('name', $catid, $p_taxonomy[0]); $catids_arr[] = $cat->slug; } else { if (get_term_by('slug', $catid, $p_taxonomy[0])) { $cat = get_term_by('slug', $catid, $p_taxonomy[0]); $catids_arr[] = $cat->slug; } else { $ret = wp_insert_term($catid, $p_taxonomy[0]); if ($ret && !is_wp_error($ret)) { if (get_term_by('name', $catid, $p_taxonomy[0])) { $cat = get_term_by('name', $catid, $p_taxonomy[0]); $catids_arr[] = $cat->slug; } elseif (get_term_by('slug', $catid, $p_taxonomy[0])) { $cat = get_term_by('slug', $catid, $p_taxonomy[0]); $catids_arr[] = $cat->slug; } } } } } } } } if (!$catids_arr) { $catids_arr[] = 1; } $post_tags = trim($buffer[4]); // comma seperated tags $tag_arr = ''; if ($post_tags) { $tag_arr = explode(',', $post_tags); } $table = $plugin_prefix . $buffer[5] . '_detail'; // check table in database $error = ''; if ($wpdb->get_var("SHOW TABLES LIKE '" . $table . "'") != $table) { $invalid_post_type++; continue; } if ($post_title != '') { $menu_order = 0; $image_folder_name = 'uplaod/'; $image_names = array(); for ($c = 5; $c < count($customKeyarray); $c++) { $gd_post_info[$customKeyarray[$c]] = addslashes($buffer[$c]); if ($customKeyarray[$c] == 'IMAGE') { $buffer[$c] = trim($buffer[$c]); if (!empty($buffer[$c])) { $image_names[] = $buffer[$c]; } } if ($customKeyarray[$c] == 'alive_days') { if ($buffer[$c] != '0' && $buffer[$c] != '') { $submitdata = date('Y-m-d'); $gd_post_info['expire_date'] = date('Y-m-d', strtotime($submitdata . "+" . addslashes($buffer[$c]) . " days")); } else { $gd_post_info['expire_date'] = 'Never'; } } if ($customKeyarray[$c] == 'post_city') { $post_city = addslashes($buffer[$c]); } if ($customKeyarray[$c] == 'post_region') { $post_region = addslashes($buffer[$c]); } if ($customKeyarray[$c] == 'post_country') { $post_country = addslashes($buffer[$c]); } if ($customKeyarray[$c] == 'post_latitude') { $post_latitude = addslashes($buffer[$c]); } if ($customKeyarray[$c] == 'post_longitude') { $post_longitude = addslashes($buffer[$c]); } // Post status if ($customKeyarray[$c] == 'post_status') { $post_status = sanitize_key($buffer[$c]); } } /* ================ before array create ============== */ $location_result = geodir_get_default_location(); if (!isset($gd_post_info['post_city']) || $gd_post_info['post_city'] == '' || (!isset($gd_post_info['post_region']) || $gd_post_info['post_region'] == '') || (!isset($gd_post_info['post_country']) || $gd_post_info['post_country'] == '') || (!isset($gd_post_info['post_address']) || $gd_post_info['post_address'] == '') || (!isset($gd_post_info['post_latitude']) || $gd_post_info['post_latitude'] == '') || (!isset($gd_post_info['post_longitude']) || $gd_post_info['post_longitude'] == '')) { $blank_address++; continue; } else { if ($location_result->location_id == 0) { if (geodir_strtolower($gd_post_info['post_city']) != geodir_strtolower($location_result->city) || geodir_strtolower($gd_post_info['post_region']) != geodir_strtolower($location_result->region) || geodir_strtolower($gd_post_info['post_country']) != geodir_strtolower($location_result->country)) { $address_invalid++; continue; } } } // Default post status $default_status = 'publish'; $post_status = !empty($post_status) ? sanitize_key($post_status) : $default_status; $post_status = !empty($wp_post_statuses) && !isset($wp_post_statuses[$post_status]) ? $default_status : $post_status; $my_post['post_title'] = $post_title; $my_post['post_content'] = $post_desc; $my_post['post_type'] = addslashes($buffer[5]); $my_post['post_author'] = $current_post_author; $my_post['post_status'] = $post_status; $my_post['post_category'] = $catids_arr; $my_post['post_tags'] = $tag_arr; $gd_post_info['post_tags'] = $tag_arr; $gd_post_info['post_title'] = $post_title; $gd_post_info['post_status'] = $post_status; $gd_post_info['submit_time'] = time(); $gd_post_info['submit_ip'] = $_SERVER['REMOTE_ADDR']; $last_postid = wp_insert_post($my_post); $countpost++; // Check if we need to save post location as new location if ($location_result->location_id > 0) { if (isset($post_city) && isset($post_region)) { $request_info['post_location'] = array('city' => $post_city, 'region' => $post_region, 'country' => $post_country, 'geo_lat' => $post_latitude, 'geo_lng' => $post_longitude); $post_location_info = $request_info['post_location']; if ($location_id = geodir_add_new_location($post_location_info)) { $post_location_id = $location_id; } } else { $post_location_id = 0; } } else { $post_location_id = 0; } /* ------- get default package info ----- */ $payment_info = array(); $package_info = array(); $package_info = (array) geodir_post_package_info($package_info, '', $buffer[5]); $package_id = ''; if (isset($gd_post_info['package_id']) && $gd_post_info['package_id'] != '') { $package_id = $gd_post_info['package_id']; } if (!empty($package_info)) { $payment_info['package_id'] = $package_info['pid']; if (isset($package_info['alive_days']) && $package_info['alive_days'] != 0) { $payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['alive_days'] . " days")); } else { $payment_info['expire_date'] = 'Never'; } $gd_post_info = array_merge($gd_post_info, $payment_info); } $gd_post_info['post_location_id'] = $post_location_id; $post_type = get_post_type($last_postid); $table = $plugin_prefix . $post_type . '_detail'; geodir_save_post_info($last_postid, $gd_post_info); if (!empty($image_names)) { $upload_files++; $menu_order = 1; foreach ($image_names as $image_name) { $img_name_arr = explode('.', $image_name); $uploads = wp_upload_dir(); $sub_dir = $uploads['subdir']; $arr_file_type = wp_check_filetype($image_name); $uploaded_file_type = $arr_file_type['type']; $attachment = array(); $attachment['post_id'] = $last_postid; $attachment['title'] = $img_name_arr[0]; $attachment['content'] = ''; $attachment['file'] = $sub_dir . '/' . $image_name; $attachment['mime_type'] = $uploaded_file_type; $attachment['menu_order'] = $menu_order; $attachment['is_featured'] = 0; $attachment_set = ''; foreach ($attachment as $key => $val) { if ($val != '') { $attachment_set .= $key . " = '" . $val . "', "; } } $attachment_set = trim($attachment_set, ", "); $wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set); if ($menu_order == 1) { $post_type = get_post_type($last_postid); $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($sub_dir . '/' . $image_name, $last_postid))); } $menu_order++; } } $gd_post_info['package_id'] = $package_id; /** This action is documented in geodirectory-functions/post-functions.php */ do_action('geodir_after_save_listing', $last_postid, $gd_post_info); if (!empty($buffer[5])) { if (in_array($buffer[5], geodir_get_posttypes())) { $taxonomies = geodir_get_posttype_info(addslashes($buffer[5])); wp_set_object_terms($last_postid, $my_post['post_tags'], $taxonomy = $taxonomies['taxonomies'][1]); wp_set_object_terms($last_postid, $my_post['post_category'], $taxonomy = $taxonomies['taxonomies'][0]); $post_default_category = isset($my_post['post_default_category']) ? $my_post['post_default_category'] : ''; $post_category_str = isset($my_post['post_category_str']) ? $my_post['post_category_str'] : ''; geodir_set_postcat_structure($last_postid, $taxonomy, $post_default_category, $post_category_str); } } } else { $invalid_title++; } } } } $return['rowcount'] = $countpost; $return['invalidcount'] = $address_invalid; $return['blank_address'] = $blank_address; $return['upload_files'] = $upload_files; $return['invalid_post_type'] = $invalid_post_type; $return['invalid_title'] = $invalid_title; $return['total_records'] = $total_records; echo json_encode($return); exit; }
function geodir_package_meta_box_add() { global $post; $geodir_post_types = geodir_get_posttypes('array'); $geodir_posttypes = array_keys($geodir_post_types); if (isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)) { $geodir_posttype = $post->post_type; $post_typename = ucwords($geodir_post_types[$geodir_posttype]['labels']['singular_name']); add_meta_box('geodir_post_package_setting', $post_typename . ' Package Settings', 'geodir_post_package_setting', $geodir_posttype, 'side', 'high'); } }
/** * Appends extra HTML classes to the post class. * * @since 1.0.0 * @package GeoDirectory * @global object $post The current post object. * @param string $class The old class string. * @param string|array $all_postypes The GD post types. * @return string The modified post class. */ function geodir_core_post_view_extra_class($class, $all_postypes = '') { global $post; if (!$all_postypes) { $all_postypes = geodir_get_posttypes(); } $gdp_post_id = !empty($post) && isset($post->ID) ? $post->ID : NULL; $gdp_post_type = $gdp_post_id > 0 && isset($post->post_type) ? $post->post_type : NULL; $gdp_post_type = $gdp_post_type != '' && !empty($all_postypes) && in_array($gdp_post_type, $all_postypes) ? $gdp_post_type : NULL; if ($gdp_post_id && $gdp_post_type) { $append_class = 'gd-post-' . $gdp_post_type; $append_class .= isset($post->is_featured) && $post->is_featured > 0 ? ' gd-post-featured' : ''; $class = $class != '' ? $class . ' ' . $append_class : $append_class; } return $class; }
/** * set parent activity_id to 1 if listing comment has not parent activity_id. * * @since 1.0.0 * @package GeoDirectory_BuddyPress_Integration * * @param int $activity_id BP activity ID. * @return int BP activity ID. */ function geodir_buddypress_get_activity_id($activity_id) { if (!$activity_id) { $gd_post_types = geodir_get_posttypes('array'); $comment_post_ID = isset($_POST['comment_post_ID']) ? $_POST['comment_post_ID'] : 0; $comment_post = get_post($comment_post_ID); if (!empty($comment_post) && isset($comment_post->post_type) && $comment_post->post_type && !empty($gd_post_types) && array_key_exists($comment_post->post_type, $gd_post_types)) { $activity_id = 1; } } return $activity_id; }
/** * Check the post type valid or not. * * @since 1.0.0 * * @param string $incoming_post_type Post type. * @return bool The boolean equivalent or null. */ function gdsc_is_post_type_valid($incoming_post_type) { $post_types = geodir_get_posttypes(); $post_types = array_map('strtolower', $post_types); $post_type_found = false; foreach ($post_types as $type) { if (strtolower($incoming_post_type) == strtolower($type)) { $post_type_found = true; } } return $post_type_found; }
/** * Get sort options based on post type. * * @since 1.0.0 * @package GeoDirectory * @global object $wpdb WordPress Database object. * @param string $post_type The post type. * @return bool|mixed|void Returns sort options when post type available. Otherwise returns false. */ function geodir_get_custom_sort_options($post_type = '') { global $wpdb; if ($post_type != '') { $all_postypes = geodir_get_posttypes(); if (!in_array($post_type, $all_postypes)) { return false; } $fields = array(); $fields[] = array('post_type' => $post_type, 'data_type' => '', 'field_type' => 'random', 'site_title' => 'Random', 'htmlvar_name' => 'post_title'); $fields[] = array('post_type' => $post_type, 'data_type' => '', 'field_type' => 'datetime', 'site_title' => __('Add date', 'geodirectory'), 'htmlvar_name' => 'post_date'); $fields[] = array('post_type' => $post_type, 'data_type' => '', 'field_type' => 'bigint', 'site_title' => __('Review', 'geodirectory'), 'htmlvar_name' => 'comment_count'); $fields[] = array('post_type' => $post_type, 'data_type' => '', 'field_type' => 'float', 'site_title' => __('Rating', 'geodirectory'), 'htmlvar_name' => 'overall_rating'); $fields[] = array('post_type' => $post_type, 'data_type' => '', 'field_type' => 'text', 'site_title' => __('Title', 'geodirectory'), 'htmlvar_name' => 'post_title'); /** * Hook to add custom sort options. * * @since 1.0.0 * @param array $fields Unmodified sort options array. * @param string $post_type Post type. */ return $fields = apply_filters('geodir_add_custom_sort_options', $fields, $post_type); } return false; }
function gdlist_get_all_reviewed_posts() { $p_ids = gdlist_get_user_reviewed_posts(); $post_types = geodir_get_posttypes(); $all_posts = array(); if ($p_ids) { $query_args = array('post_type' => $post_types, 'posts_per_page' => 100); $query_args['post__in'] = $p_ids; $listings = new WP_Query($query_args); if ($listings) { while ($listings->have_posts()) { $listings->the_post(); $all_posts[get_the_ID()] = get_the_title(); } } wp_reset_postdata(); } return $all_posts; }
/** * Called when post updated. * * @since 1.0.0 * @package GeoDirectory * @param int $post_ID The post ID. * @param object $post_after The post object after update. * @param object $post_before The post object before update. */ function geodir_function_post_updated($post_ID, $post_after, $post_before) { $post_type = get_post_type($post_ID); if ($post_type != '' && in_array($post_type, geodir_get_posttypes())) { // send notification to client when post moves from draft to publish if (!empty($post_after->post_status) && $post_after->post_status == 'publish' && !empty($post_before->post_status) && ($post_before->post_status == 'draft' || $post_before->post_status == 'auto-draft')) { $post_author_id = !empty($post_after->post_author) ? $post_after->post_author : NULL; $post_author_data = get_userdata($post_author_id); $to_name = geodir_get_client_name($post_author_id); $from_email = geodir_get_site_email_id(); $from_name = get_site_emailName(); $to_email = $post_author_data->user_email; if (!is_email($to_email) && !empty($post_author_data->user_email)) { $to_email = $post_author_data->user_email; } $message_type = 'listing_published'; if (get_option('geodir_post_published_email_subject') == '') { update_option('geodir_post_published_email_subject', __('Listing Published Successfully', GEODIRECTORY_TEXTDOMAIN)); } if (get_option('geodir_post_published_email_content') == '') { update_option('geodir_post_published_email_content', __("<p>Dear [#client_name#],</p><p>Your listing [#listing_link#] has been published. This email is just for your information.</p><p>[#listing_link#]</p><br><p>Thank you for your contribution.</p><p>[#site_name#]</p>", GEODIRECTORY_TEXTDOMAIN)); } /** * Called before sending the email when listing gets published. * * @since 1.0.0 * @package GeoDirectory * @param object $post_after The post object after update. * @param object $post_before The post object before update. */ do_action('geodir_before_listing_published_email', $post_after, $post_before); if (is_email($to_email)) { geodir_sendEmail($from_email, $from_name, $to_email, $to_name, '', '', '', $message_type, $post_ID); } /** * Called after sending the email when listing gets published. * * @since 1.0.0 * @package GeoDirectory * @param object $post_after The post object after update. * @param object $post_before The post object before update. */ do_action('geodir_after_listing_published_email', $post_after, $post_before); } } }
<div class="geodir-search"> <?php $default_search_for_text = SEARCH_FOR_TEXT; if (get_option('geodir_search_field_default_text')) { $default_search_for_text = __(get_option('geodir_search_field_default_text'), 'geodirectory'); } $default_near_text = NEAR_TEXT; if (get_option('geodir_near_field_default_text')) { $default_near_text = __(get_option('geodir_near_field_default_text'), 'geodirectory'); } $default_search_button_label = __('Search', 'geodirectory'); if (get_option('geodir_search_button_label')) { $default_search_button_label = __(get_option('geodir_search_button_label'), 'geodirectory'); } $post_types = geodir_get_posttypes('object'); if (!empty($post_types) && count((array) $post_types) > 1) { ?> <select name="stype" class="search_by_post"> <?php foreach ($post_types as $post_type => $info) { global $wpdb; $has_posts = ''; $has_posts = $wpdb->get_row($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_type = %s AND post_status='publish' LIMIT 1", $post_type)); if (!$has_posts) { continue; } ?> <option data-label="<?php echo get_post_type_archive_link($post_type);
/** * Remove location and its data using location ID. * * @since 1.0.0 * @package GeoDirectory_Location_Manager * * @global object $wpdb WordPress Database object. * @global string $plugin_prefix Geodirectory plugin table prefix. * * @param int $id Location ID. * @return bool Returns true when successful deletion. */ function geodir_location_delete_by_id($id) { global $wpdb, $plugin_prefix; if (!current_user_can('manage_options') || !$id > 0) { return false; } $geodir_posttypes = geodir_get_posttypes(); do_action('geodir_location_before_delete', $id); $location_info = $wpdb->get_row($wpdb->prepare("SELECT city_slug, is_default FROM " . POST_LOCATION_TABLE . " WHERE location_id = %d", array($id))); if (!empty($location_info) && !empty($location_info->is_default)) { return false; // Default location } foreach ($geodir_posttypes as $geodir_posttype) { $table = $plugin_prefix . $geodir_posttype . '_detail'; $rows = $wpdb->get_results($wpdb->prepare("SELECT post_id FROM " . $table . " WHERE post_location_id = %d", array($id))); if (!empty($rows)) { foreach ($rows as $row) { wp_delete_post($row->post_id); // Delete post } } } // Remove neighbourhood location $wpdb->query($wpdb->prepare("DELETE FROM " . POST_NEIGHBOURHOOD_TABLE . " WHERE hood_location_id = %d", array($id))); // Remove current location data if (!empty($location_info) && !empty($location_info->city_slug) && isset($_SESSION['gd_city']) && $_SESSION['gd_city'] == $location_info->city_slug) { unset($_SESSION['gd_multi_location'], $_SESSION['gd_city'], $_SESSION['gd_region'], $_SESSION['gd_country']); } // Remove post location data $wpdb->query($wpdb->prepare("DELETE FROM " . POST_LOCATION_TABLE . " WHERE location_id = %d", array($id))); do_action('geodir_location_after_delete', $id); return true; }
/** * Modify rating fields when rating disabled. * * @since 1.0.0 * @package GeoDirectory * @global object $post The current post object. */ function geodir_no_rating_rating_fields() { global $post; $post_types = geodir_get_posttypes(); if (!empty($post) && isset($post->post_type) && in_array($post->post_type, $post_types)) { if (is_plugin_active('geodir_review_rating_manager/geodir_review_rating_manager.php')) { echo '<input type="hidden" value="1" name="geodir_rating[overall]" />'; if (get_option('geodir_reviewrating_enable_images')) { geodir_reviewrating_rating_img_html(); } } else { echo '<input type="hidden" id="geodir_overallrating" name="geodir_overallrating" value="1" />'; } } }
/** * Fixes the address field limit of 30 to 50 in details table. * * @since 1.0.0 * @package GeoDirectory * @global object $wpdb WordPress Database object. */ function gd_fix_address_detail_table_limit() { global $wpdb; $all_postypes = geodir_get_posttypes(); if (!empty($all_postypes)) { foreach ($all_postypes as $key) { // update each GD CTP @$wpdb->query("ALTER TABLE " . $wpdb->prefix . "geodir_" . $key . "_detail MODIFY post_city VARCHAR( 50 ) NULL,MODIFY post_region VARCHAR( 50 ) NULL,MODIFY post_country VARCHAR( 50 ) NULL"); } } }
/** * Disable Disqus plugin on the fly when visiting GeoDirectory post types. * * @since 1.5.0 * @package GeoDirectory * @param string $disqus_active Hook called before DB call for option so this is empty. * @return string `1` if active `0` if disabled. */ function geodir_option_disqus_active($disqus_active) { global $post; $all_postypes = geodir_get_posttypes(); if (isset($post->post_type) && is_array($all_postypes) && in_array($post->post_type, $all_postypes)) { $disqus_active = '0'; } return $disqus_active; }
/** * Back-end listing slider widget settings form. * * @since 1.0.0 * @since 1.5.1 Declare function public. * * @param array $instance Previously saved values from database. */ public function form($instance) { //widgetform in backend $instance = wp_parse_args((array) $instance, array('title' => '', 'post_type' => '', 'category' => '', 'post_number' => '5', 'max_show' => '1', 'slide_width' => '', 'show_title' => '', 'slideshow' => '', 'animationLoop' => '', 'directionNav' => '', 'slideshowSpeed' => 5000, 'animationSpeed' => 600, 'animation' => '', 'list_sort' => 'latest', 'show_featured_only' => '')); $title = strip_tags($instance['title']); $post_type = strip_tags($instance['post_type']); $category = strip_tags($instance['category']); $post_number = strip_tags($instance['post_number']); $max_show = strip_tags($instance['max_show']); $slide_width = strip_tags($instance['slide_width']); $show_title = $instance['show_title']; $slideshow = $instance['slideshow']; $animationLoop = $instance['animationLoop']; $directionNav = $instance['directionNav']; $slideshowSpeed = $instance['slideshowSpeed']; $animationSpeed = $instance['animationSpeed']; $animation = $instance['animation']; $list_sort = $instance['list_sort']; $show_featured_only = isset($instance['show_featured_only']) && $instance['show_featured_only'] ? true : false; $sort_fields = array(); $sort_fields[] = array('field' => 'latest', 'label' => __('Latest', 'geodirectory')); $sort_fields[] = array('field' => 'featured', 'label' => __('Featured', 'geodirectory')); $sort_fields[] = array('field' => 'high_review', 'label' => __('Review', 'geodirectory')); $sort_fields[] = array('field' => 'high_rating', 'label' => __('Rating', 'geodirectory')); $sort_fields[] = array('field' => 'random', 'label' => __('Random', 'geodirectory')); ?> <p> <label for="<?php echo $this->get_field_id('title'); ?> "><?php _e('Title:', 'geodirectory'); ?> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?> " name="<?php echo $this->get_field_name('title'); ?> " type="text" value="<?php echo esc_attr($title); ?> "/> </label> </p> <p> <label for="<?php echo $this->get_field_id('post_type'); ?> "><?php _e('Post Type:', 'geodirectory'); ?> <?php $postypes = geodir_get_posttypes(); ?> <select class="widefat" id="<?php echo $this->get_field_id('post_type'); ?> " name="<?php echo $this->get_field_name('post_type'); ?> " onchange="geodir_change_category_list(this.value)"> <?php foreach ($postypes as $postypes_obj) { ?> <option <?php if ($post_type == $postypes_obj) { echo 'selected="selected"'; } ?> value="<?php echo $postypes_obj; ?> "><?php $extvalue = explode('_', $postypes_obj); echo ucfirst($extvalue[1]); ?> </option> <?php } ?> </select> </label> </p> <p> <label for="<?php echo $this->get_field_id('category'); ?> "><?php _e('Post Category:', 'geodirectory'); ?> <?php $category_taxonomy = geodir_get_taxonomies('gd_place'); $categories = get_terms($category_taxonomy, array('orderby' => 'count', 'order' => 'DESC')); ?> <select class="widefat" id="<?php echo $this->get_field_id('category'); ?> " name="<?php echo $this->get_field_name('category'); ?> "> <option <?php if ($category == '0') { echo 'selected="selected"'; } ?> value="0"><?php _e('All', 'geodirectory'); ?> </option> <?php foreach ($categories as $category_obj) { ?> <option <?php if ($category == $category_obj->term_id) { echo 'selected="selected"'; } ?> value="<?php echo $category_obj->term_id; ?> "><?php echo ucfirst($category_obj->name); ?> </option> <?php } ?> </select> </label> </p> <p> <label for="<?php echo $this->get_field_id('list_sort'); ?> "><?php _e('Sort by:', 'geodirectory'); ?> </label> <select class="widefat" id="<?php echo $this->get_field_id('list_sort'); ?> " name="<?php echo $this->get_field_name('list_sort'); ?> "> <?php foreach ($sort_fields as $sort_field) { ?> <option value="<?php echo $sort_field['field']; ?> " <?php echo $list_sort == $sort_field['field'] ? 'selected="selected"' : ''; ?> ><?php echo $sort_field['label']; ?> </option> <?php } ?> </select> </p> <p> <label for="<?php echo $this->get_field_id('post_number'); ?> "><?php _e('Number of posts(total):', 'geodirectory'); ?> <input class="widefat" id="<?php echo $this->get_field_id('post_number'); ?> " name="<?php echo $this->get_field_name('post_number'); ?> " type="text" value="<?php echo esc_attr($post_number); ?> "/> </label> </p> <p> <label for="<?php echo $this->get_field_id('max_show'); ?> "><?php _e('Number of posts(shown at one time, requires a slide width to be set):', 'geodirectory'); ?> <input class="widefat" id="<?php echo $this->get_field_id('max_show'); ?> " name="<?php echo $this->get_field_name('max_show'); ?> " type="text" value="<?php echo esc_attr($max_show); ?> "/> </label> </p> <p> <label for="<?php echo $this->get_field_id('slide_width'); ?> "><?php _e('Slide width(leave blank unless showing more than one slide at a time, ex: 210):', 'geodirectory'); ?> <input class="widefat" id="<?php echo $this->get_field_id('slide_width'); ?> " name="<?php echo $this->get_field_name('slide_width'); ?> " type="text" value="<?php echo esc_attr($slide_width); ?> "/> </label> </p> <p> <label for="<?php echo $this->get_field_id('animation'); ?> "><?php _e('Animation:', 'geodirectory'); ?> <select class="widefat" id="<?php echo $this->get_field_id('animation'); ?> " name="<?php echo $this->get_field_name('animation'); ?> "> <option <?php if ($animation == 'slide') { echo 'selected="selected"'; } ?> value="slide">Slide </option> <option <?php if ($animation == 'fade') { echo 'selected="selected"'; } ?> value="fade">Fade </option> </select> </label> </p> <p> <label for="<?php echo $this->get_field_id('slideshowSpeed'); ?> "><?php _e('Slide Show Speed: (milliseconds)', 'geodirectory'); ?> <input class="widefat" id="<?php echo $this->get_field_id('slideshowSpeed'); ?> " name="<?php echo $this->get_field_name('slideshowSpeed'); ?> " type="text" value="<?php echo esc_attr($slideshowSpeed); ?> "/> </label> </p> <p> <label for="<?php echo $this->get_field_id('animationSpeed'); ?> "><?php _e('Animation Speed: (milliseconds)', 'geodirectory'); ?> <input class="widefat" id="<?php echo $this->get_field_id('animationSpeed'); ?> " name="<?php echo $this->get_field_name('animationSpeed'); ?> " type="text" value="<?php echo esc_attr($animationSpeed); ?> "/> </label> </p> <p> <label for="<?php echo $this->get_field_id('slideshow'); ?> "><?php _e('SlideShow:', 'geodirectory'); ?> <input type="checkbox" <?php if ($slideshow) { echo 'checked="checked"'; } ?> id="<?php echo $this->get_field_id('slideshow'); ?> " value="1" name="<?php echo $this->get_field_name('slideshow'); ?> "/> </label> </p> <p> <label for="<?php echo $this->get_field_id('animationLoop'); ?> "><?php _e('AnimationLoop:', 'geodirectory'); ?> <input type="checkbox" <?php if ($animationLoop) { echo 'checked="checked"'; } ?> id="<?php echo $this->get_field_id('animationLoop'); ?> " value="1" name="<?php echo $this->get_field_name('animationLoop'); ?> "/> </label> </p> <p> <label for="<?php echo $this->get_field_id('directionNav'); ?> "><?php _e('DirectionNav:', 'geodirectory'); ?> <input type="checkbox" <?php if ($directionNav) { echo 'checked="checked"'; } ?> id="<?php echo $this->get_field_id('directionNav'); ?> " value="1" name="<?php echo $this->get_field_name('directionNav'); ?> "/> </label> </p> <p> <label for="<?php echo $this->get_field_id('show_title'); ?> "><?php _e('Show Title:', 'geodirectory'); ?> <input type="checkbox" <?php if ($show_title) { echo 'checked="checked"'; } ?> id="<?php echo $this->get_field_id('show_title'); ?> " value="1" name="<?php echo $this->get_field_name('show_title'); ?> "/> </label> </p> <p> <label for="<?php echo $this->get_field_id('show_featured_only'); ?> "><?php _e('Show only featured listings:', 'geodirectory'); ?> <input type="checkbox" id="<?php echo $this->get_field_id('show_featured_only'); ?> " name="<?php echo $this->get_field_name('show_featured_only'); ?> " <?php if ($show_featured_only) { echo 'checked="checked"'; } ?> value="1"/> </label> </p> <script type="text/javascript"> function geodir_change_category_list(post_type, selected) { var ajax_url = '<?php echo geodir_get_ajax_url(); ?> ' var myurl = ajax_url + "&geodir_ajax=admin_ajax&ajax_action=get_cat_dl&post_type=" + post_type + "&selected=" + selected; jQuery.ajax({ type: "GET", url: myurl, success: function (data) { jQuery('#<?php echo $this->get_field_id('category'); ?> ').html(data); } }); } <?php if (is_active_widget(false, false, $this->id_base, true)) { ?> var post_type = jQuery('#<?php echo $this->get_field_id('post_type'); ?> ').val(); geodir_change_category_list(post_type, '<?php echo $category; ?> '); <?php } ?> </script> <?php }
$grid_view_class = 'gridview_onethird '; } if ($_SESSION['gd_listing_view'] == '4') { $grid_view_class = 'gridview_onefourth'; } if ($_SESSION['gd_listing_view'] == '5') { $grid_view_class = 'gridview_onefifth'; } } ?> <ul class="geodir_category_list_view clearfix"> <?php if (!empty($widget_listings)) { /** This action is documented in geodirectory-templates/listing-listview.php */ do_action('geodir_before_listing_post_listview'); $all_postypes = geodir_get_posttypes(); $geodir_days_new = (int) get_option('geodir_listing_new_days'); foreach ($widget_listings as $widget_listing) { global $gd_widget_listing_type; $post = $widget_listing; $GLOBALS['post'] = $post; setup_postdata($post); $gd_widget_listing_type = $post->post_type; /** This action is documented in geodirectory-templates/listing-listview.php */ $post_view_class = apply_filters('geodir_post_view_extra_class', '', $all_postypes); /** This action is documented in geodirectory-templates/listing-listview.php */ $post_view_article_class = apply_filters('geodir_post_view_article_extra_class', ''); ?> <li class="clearfix <?php if ($grid_view_class) { echo 'geodir-gridview ' . $grid_view_class;
/** * Add the location variables in session. * * @since 1.0.0 * * @param object $wp The WordPress object. */ function geodir_set_location_var_in_session_in_core($wp) { //$wp->geodir_query_vars = $wp->query_vars ; // this code will determine when a user wants to switch location // Query Vars will have page_id parameter // check if query var has page_id and that page id is location page geodir_set_is_geodir_page($wp); if (!get_option('geodir_set_as_home')) { if (empty($wp->query_vars) || !array_diff(array_keys($wp->query_vars), array('preview', 'page', 'paged', 'cpage'))) { if ('page' == get_option('show_on_front')) { $wp->query_vars['page_id'] = get_option('page_on_front'); } } } if (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_location_page_id()) { $gd_country = ''; $gd_region = ''; $gd_city = ''; if (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') { $gd_country = urldecode($wp->query_vars['gd_country']); } if (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') { $gd_region = urldecode($wp->query_vars['gd_region']); } if (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') { $gd_city = urldecode($wp->query_vars['gd_city']); } if (!($gd_country == '' && $gd_region == '' && $gd_city == '')) { $default_location = geodir_get_default_location(); if (get_option('geodir_add_location_url')) { if (get_option('geodir_show_location_url') != 'all') { if ($gd_region == '') { if (isset($_SESSION['gd_region'])) { $gd_region = $_SESSION['gd_region']; } else { $gd_region = $default_location->region_slug; } } if ($gd_city == '') { if (isset($_SESSION['gd_city'])) { $gd_city = $_SESSION['gd_city']; } else { $gd_city = $default_location->city_slug; } $base_location_link = geodir_get_location_link('base'); wp_redirect($base_location_link . '/' . $gd_country . '/' . $gd_region . '/' . $gd_city); exit; } } } $args = array('what' => 'city', 'city_val' => $gd_city, 'region_val' => $gd_region, 'country_val' => $gd_country, 'country_column_name' => 'country_slug', 'region_column_name' => 'region_slug', 'city_column_name' => 'city_slug', 'location_link_part' => false, 'compare_operator' => ''); $location_array = function_exists('geodir_get_location_array') ? geodir_get_location_array($args) : array(); if (!empty($location_array)) { $_SESSION['gd_multi_location'] = 1; $_SESSION['gd_country'] = $gd_country; $_SESSION['gd_region'] = $gd_region; $_SESSION['gd_city'] = $gd_city; $wp->query_vars['gd_country'] = $gd_country; $wp->query_vars['gd_region'] = $gd_region; $wp->query_vars['gd_city'] = $gd_city; } else { unset($_SESSION['gd_multi_location'], $_SESSION['gd_city'], $_SESSION['gd_region'], $_SESSION['gd_country']); } } else { unset($_SESSION['gd_multi_location'], $_SESSION['gd_city'], $_SESSION['gd_region'], $_SESSION['gd_country']); } } else { if (isset($wp->query_vars['post_type']) && $wp->query_vars['post_type'] != '') { if (!is_admin()) { $requested_post_type = $wp->query_vars['post_type']; // check if this post type is geodirectory post types $post_type_array = geodir_get_posttypes(); if (in_array($requested_post_type, $post_type_array)) { // now u can apply geodirectory related manipulation. } } } else { // check if a geodirectory taxonomy is set $gd_country = ''; $gd_region = ''; $gd_city = ''; $is_geodir_taxonomy = false; $is_geodir_taxonomy_term = false; // the last term is real geodirectory taxonomy term or not $is_geodir_location_found = false; $geodir_taxonomy = ''; $geodir_post_type = ''; $geodir_term = ''; $geodir_set_location_session = true; $geodir_taxonomis = geodir_get_taxonomies('', true); foreach ($geodir_taxonomis as $taxonomy) { if (array_key_exists($taxonomy, $wp->query_vars)) { $is_geodir_taxonomy = true; $geodir_taxonomy = $taxonomy; $geodir_post_type = str_replace('category', '', $taxonomy); $geodir_post_type = str_replace('_tags', '', $geodir_post_type); $geodir_term = $wp->query_vars[$geodir_taxonomy]; break; } } // now get an array of all terms seperated by '/' $geodir_terms = explode('/', $geodir_term); $geodir_last_term = end($geodir_terms); if ($is_geodir_taxonomy) { $wp->query_vars['post_type'] = $geodir_post_type; // now check if last term is a post of geodirectory post types $geodir_post = get_posts(array('name' => $geodir_last_term, 'posts_per_page' => 1, 'post_type' => $geodir_post_type)); if (empty($geodir_post)) { $geodir_post = get_posts(array('name' => $geodir_last_term, 'posts_per_page' => 1, 'post_type' => $geodir_post_type, 'post_status' => 'draft', 'suppress_filters' => false)); } if (!empty($geodir_post)) { if ($geodir_post[0]->post_status != 'publish') { foreach ($wp->query_vars as $key => $vars) { unset($wp->query_vars[$key]); } $wp->query_vars['error'] = '404'; // set it as 404 if post exists but its status is not published yet } else { //$wp->query_vars[$geodir_taxonomy] = str_replace( '/'.$geodir_last_term , '' , $geodir_term); $wp->query_vars[$geodir_post_type] = $geodir_last_term; $wp->query_vars['name'] = $geodir_last_term; } $geodir_term = str_replace('/' . $geodir_last_term, '', $geodir_term, $post_title_replace_count); if (!$post_title_replace_count) { $geodir_term = str_replace($geodir_last_term, '', $geodir_term, $post_title_replace_count); } $geodir_terms = explode('/', $geodir_term); $geodir_last_term = end($geodir_terms); $geodir_set_location_session = false; //return ; } $geodir_location_terms = ''; // if last term is not a post then check if last term is a term of the specific texonomy or not if (geodir_term_exists($geodir_last_term, $geodir_taxonomy)) { $is_geodir_taxonomy_term = true; $geodir_set_location_session = false; } // now check if there is location parts in the url or not if (get_option('geodir_add_location_url')) { $default_location = geodir_get_default_location(); if (get_option('geodir_show_location_url') == 'all') { if (count($geodir_terms) >= 3) { $gd_country = urldecode($geodir_terms[0]); $gd_region = urldecode($geodir_terms[1]); $gd_city = urldecode($geodir_terms[2]); } else { if (count($geodir_terms) >= 2) { $gd_country = urldecode($geodir_terms[0]); $gd_region = urldecode($geodir_terms[1]); } else { if (count($geodir_terms) >= 1) { $gd_country = urldecode($geodir_terms[0]); } } } if (strtolower($default_location->country_slug) == strtolower($gd_country) && strtolower($default_location->region_slug) == strtolower($gd_region) && strtolower($default_location->city_slug) == strtolower($gd_city)) { $is_geodir_location_found = true; } // if location has not been found for country , region and city then search for country and region only if (!$is_geodir_location_found) { $gd_city = ''; if (strtolower($default_location->country_slug) == strtolower($gd_country) && strtolower($default_location->region_slug) == strtolower($gd_region)) { $is_geodir_location_found = true; } } // if location has not been found for country , region then search for country only if (!$is_geodir_location_found) { $gd_city = ''; $gd_region = ''; if (strtolower($default_location->country_slug) == strtolower($gd_country)) { $is_geodir_location_found = true; } } } else { $gd_city = $geodir_terms[0]; if (strtolower($default_location->city_slug) == strtolower($gd_city)) { $is_geodir_location_found = true; $gd_region = $default_location->region_slug; $gd_country = $default_location->country_slug; } } // if locaton still not found then clear location related session variables if ($is_geodir_location_found && $geodir_set_location_session) { $_SESSION['gd_multi_location'] = 1; $_SESSION['gd_country'] = $gd_country; $_SESSION['gd_region'] = $gd_region; $_SESSION['gd_city'] = $gd_city; } if (get_option('geodir_show_location_url') != 'all') { $gd_country = ''; $gd_region = ''; } if ($is_geodir_location_found) { $wp->query_vars['gd_country'] = $gd_country; $wp->query_vars['gd_region'] = $gd_region; $wp->query_vars['gd_city'] = $gd_city; } else { $gd_country = ''; $gd_region = ''; $gd_city = ''; } } $wp->query_vars[$geodir_taxonomy] = $geodir_term; // eliminate location related terms from taxonomy term if ($gd_country != '') { $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_country) . '/', '', $wp->query_vars[$geodir_taxonomy], 1); } if ($gd_region != '') { $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_region) . '/', '', $wp->query_vars[$geodir_taxonomy], 1); } if ($gd_city != '') { $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_city) . '/', '', $wp->query_vars[$geodir_taxonomy], 1); } $wp->query_vars[$geodir_taxonomy] = str_replace('///', '', $wp->query_vars[$geodir_taxonomy]); $wp->query_vars[$geodir_taxonomy] = str_replace('//', '', $wp->query_vars[$geodir_taxonomy]); $wp->query_vars[$geodir_taxonomy] = trim($wp->query_vars[$geodir_taxonomy], '/'); if ($wp->query_vars[$geodir_taxonomy] == '') { unset($wp->query_vars[$geodir_taxonomy]); } else { if (!$is_geodir_taxonomy_term) { foreach ($wp->query_vars as $key => $vars) { unset($wp->query_vars[$key]); } $wp->query_vars['error'] = '404'; } } } } } if (isset($_SESSION['gd_multi_location']) && $_SESSION['gd_multi_location'] == 1) { $wp->query_vars['gd_country'] = $_SESSION['gd_country']; $wp->query_vars['gd_region'] = $_SESSION['gd_region']; $wp->query_vars['gd_city'] = $_SESSION['gd_city']; } // now check if there is location parts in the url or not if (get_option('geodir_add_location_url')) { if (get_option('geodir_show_location_url') != 'all') { if (isset($wp->query_vars['gd_country'])) { $wp->query_vars['gd_country'] = ''; } if (isset($wp->query_vars['gd_region'])) { $wp->query_vars['gd_region'] = ''; } } } else { if (isset($wp->query_vars['gd_country'])) { $wp->query_vars['gd_country'] = ''; } if (isset($wp->query_vars['gd_region'])) { $wp->query_vars['gd_region'] = ''; } if (isset($wp->query_vars['gd_city'])) { $wp->query_vars['gd_city'] = ''; } } }
/** * Gets term icon using term ID. * * If term ID not passed returns all icons. * * @since 1.0.0 * @package GeoDirectory * @global object $wpdb WordPress Database object. * @param int|bool $term_id The term ID. * @param bool $rebuild Force rebuild the icons when set to true. * @return mixed|string|void Term icon(s). */ function geodir_get_term_icon($term_id = false, $rebuild = false) { global $wpdb; if (!$rebuild) { $terms_icons = get_option('gd_term_icons'); } else { $terms_icons = ''; } if (empty($terms_icons)) { $default_icon_url = get_option('geodir_default_marker_icon'); $taxonomy = geodir_get_taxonomies(); $post_types = geodir_get_posttypes(); $tax_arr = array(); foreach ($post_types as $post_type) { $tax_arr[] = "'" . $post_type . "category'"; } $tax_c = implode(',', $tax_arr); $terms = $wpdb->get_results("SELECT * FROM {$wpdb->term_taxonomy} WHERE taxonomy IN ({$tax_c})"); //$terms = get_terms( $taxonomy ); if ($terms) { foreach ($terms as $term) { $post_type = str_replace("category", "", $term->taxonomy); $a_terms[$post_type][] = $term; } } if ($a_terms) { foreach ($a_terms as $pt => $t2) { foreach ($t2 as $term) { $term_icon = get_tax_meta($term->term_id, 'ct_cat_icon', false, $pt); if ($term_icon) { $term_icon_url = $term_icon["src"]; } else { $term_icon_url = $default_icon_url; } $terms_icons[$term->term_id] = $term_icon_url; } } } update_option('gd_term_icons', $terms_icons); } if ($term_id && isset($terms_icons[$term_id])) { return $terms_icons[$term_id]; } elseif ($term_id && !isset($terms_icons[$term_id])) { return get_option('geodir_default_marker_icon'); } if (is_ssl()) { $terms_icons = str_replace("http:", "https:", $terms_icons); } return $terms_icons; }
/** * Handles location form submitted data. * * @since 1.0.0 * @package GeoDirectory * @global object $wpdb WordPress Database object. * @global string $plugin_prefix Geodirectory plugin table prefix. */ function geodir_location_form_submit() { global $wpdb, $plugin_prefix; if (isset($_REQUEST['add_location'])) { $location_info = array('city' => $_REQUEST['city'], 'region' => $_REQUEST['region'], 'country' => $_REQUEST['country'], 'geo_lat' => $_REQUEST['latitude'], 'geo_lng' => $_REQUEST['longitude'], 'is_default' => $_REQUEST['is_default'], 'update_city' => $_REQUEST['update_city']); $old_location = geodir_get_default_location(); $locationid = geodir_add_new_location($location_info); $default_location = geodir_get_location($locationid); //UPDATE AND DELETE LISTING $posttype = geodir_get_posttypes(); if (isset($_REQUEST['listing_action']) && $_REQUEST['listing_action'] == 'delete') { foreach ($posttype as $posttypeobj) { /* do not update latitude and longitude otrherwise all listings will be spotted on one point on map if ($old_location->city_latitude != $_REQUEST['latitude'] || $old_location->city_longitude != $_REQUEST['longitude']) { $del_post_sql = $wpdb->get_results( $wpdb->prepare( "SELECT post_id from ".$plugin_prefix.$posttypeobj."_detail WHERE post_location_id = %d AND (post_city != %s OR post_region != %s)", array($locationid,$_REQUEST['city'],$_REQUEST['region']) ) ); $sql = $wpdb->prepare( "SELECT post_id from ".$plugin_prefix.$posttypeobj."_detail WHERE post_location_id = %d AND (post_city != %s OR post_region != %s)", array($locationid,$_REQUEST['city'],$_REQUEST['region']) ); if (!empty($del_post_sql)) { foreach ($del_post_sql as $del_post_info) { $postid = (int)$del_post_info->post_id; //wp_delete_post($postid); // update post location instead of delete post $sql = $wpdb->prepare( "UPDATE ".$plugin_prefix.$posttypeobj."_detail SET post_latitude=%s, post_longitude=%s WHERE post_location_id=%d AND post_id=%d", array( $_REQUEST['latitude'], $_REQUEST['longitude'], $locationid, $postid ) ); $wpdb->query($sql); } } } */ $post_locations = '[' . $default_location->city_slug . '],[' . $default_location->region_slug . '],[' . $default_location->country_slug . ']'; // set all overall post location $sql = $wpdb->prepare("UPDATE " . $plugin_prefix . $posttypeobj . "_detail SET post_city=%s, post_region=%s, post_country=%s, post_locations=%s\r\n\t\t\t\t\t\tWHERE post_location_id=%d AND ( post_city!=%s OR post_region!=%s OR post_country!=%s OR post_locations!=%s OR post_locations IS NULL)", array($_REQUEST['city'], $_REQUEST['region'], $_REQUEST['country'], $post_locations, $locationid, $_REQUEST['city'], $_REQUEST['region'], $_REQUEST['country'], $post_locations)); $wpdb->query($sql); } } } }
/** * * @global object $wpdb WordPress Database object. * * @param $atts * @return string */ function geodir_sc_popular_in_neighbourhood($atts) { ob_start(); $defaults = array('post_type' => 'gd_place', 'category' => '0', 'list_sort' => 'latest', 'post_number' => 5, 'layout' => 'gridview_onehalf', 'character_count' => 20, 'add_location_filter' => 1); $params = shortcode_atts($defaults, $atts); /** * Being validating $params */ // Check we have a valid post_type if (!gdsc_is_post_type_valid($params['post_type'])) { $params['post_type'] = 'gd_place'; } // Manage the entered categories if (0 != $params['category'] || '' != $params['category']) { $params['category'] = gdsc_manage_category_choice($params['post_type'], $params['category']); } // Validate our sorting choice $params['list_sort'] = gdsc_validate_sort_choice($params['list_sort']); // Post_number needs to be a positive integer $params['post_number'] = absint($params['post_number']); if (0 == $params['post_number']) { $params['post_number'] = 1; } // Validate our layout choice // Outside of the norm, I added some more simple terms to match the existing // So now I just run the switch to set it properly. $params['layout'] = gdsc_validate_layout_choice($params['layout']); // Validate character_count $params['character_count'] = absint($params['character_count']); if (20 > $params['character_count']) { $params['character_count'] = 20; } /** * End validation */ global $wpdb, $post, $geodir_post_type; if ($geodir_post_type == '') { $geodir_post_type = 'gd_place'; } $all_postypes = geodir_get_posttypes(); $location_id = ''; $not_in_array = array(); if (geodir_is_page('detail') || geodir_is_page('preview') || geodir_is_page('add-listing')) { if (isset($post->post_type) && $post->post_type == $params['post_type'] && isset($post->post_location_id)) { $not_in_array[] = $post->ID; $location_id = $post->post_location_id; } } elseif (in_array($geodir_post_type, $all_postypes) && $geodir_post_type == $params['post_type']) { if (isset($_SESSION['gd_city']) && $_SESSION['gd_city'] != '') { $location_id = $wpdb->get_var($wpdb->prepare("SELECT location_id FROM " . POST_LOCATION_TABLE . " WHERE city_slug = %s", array($_SESSION['gd_city']))); } else { $default_location = geodir_get_default_location(); $location_id = $default_location->location_id; } } $gd_neighbourhoods = geodir_get_neighbourhoods($location_id); if ($gd_neighbourhoods) { ?> <div class="geodir_locations geodir_location_listing"> <?php $hood_slug_arr = array(); if (!empty($gd_neighbourhoods)) { foreach ($gd_neighbourhoods as $hoodslug) { $hood_slug_arr[] = $hoodslug->hood_slug; } } $query_args = array('posts_per_page' => $params['post_number'], 'is_geodir_loop' => true, 'post__not_in' => $not_in_array, 'gd_neighbourhood' => $hood_slug_arr, 'gd_location' => $params['add_location_filter'] ? true : false, 'post_type' => $params['post_type'], 'order_by' => $params['list_sort'], 'excerpt_length' => $params['character_count']); if ($params['category'] != 0 || $params['category'] != '') { $category_taxonomy = geodir_get_taxonomies($params['post_type']); $tax_query = array('taxonomy' => $category_taxonomy[0], 'field' => 'id', 'terms' => $params['category']); $query_args['tax_query'] = array($tax_query); } global $gridview_columns; query_posts($query_args); if (strstr($params['layout'], 'gridview')) { $listing_view_exp = explode('_', $params['layout']); $gridview_columns = $params['layout']; $layout = $listing_view_exp[0]; } $template = apply_filters("geodir_template_part-listing-listview", geodir_plugin_path() . '/geodirectory-templates/listing-listview.php'); include $template; wp_reset_query(); ?> </div> <?php } $output = ob_get_contents(); ob_end_clean(); return $output; }
function geodir_payment_after_main_form_fields() { if (!empty($_REQUEST['pid']) && !empty($_REQUEST['package_id'])) { $post_type = get_post_type($_REQUEST['pid']); $prev_package_id = geodir_get_post_meta($_REQUEST['pid'], 'package_id', true); $prev_expire_date = geodir_get_post_meta($_REQUEST['pid'], 'expire_date', true); $_SESSION['geodir_prev_package_id'] = $prev_package_id; $_SESSION['geodir_prev_expire_date'] = $prev_expire_date; if ($post_type != '' && in_array($post_type, geodir_get_posttypes()) && $prev_package_id == $_REQUEST['package_id'] && $prev_expire_date != '' && strtolower($prev_expire_date) != 'never' && strtotime($prev_expire_date) >= strtotime(date('Y-m-d'))) { echo '<input type="hidden" id="geodir_prev_package_id" name="geodir_prev_package_id" value="' . $prev_package_id . '" /><input type="hidden" id="geodir_prev_expire_date" name="geodir_prev_expire_date" value="' . $prev_expire_date . '" />'; } } }
/** * Meta description for search page. * * @since 1.0.0 * @package GeoDirectory */ function geodir_search_meta_desc($html) { if (is_search() && isset($_REQUEST['geodir_search'])) { $all_postypes = geodir_get_posttypes(); $keyword = esc_sql(strip_tags(get_query_var('s'))); $stype = esc_sql(strip_tags(esc_attr($_REQUEST['stype']))); $snear = esc_sql(strip_tags(esc_attr($_REQUEST['snear']))); if ($stype && in_array($stype, $all_postypes)) { $desc = __('Search results for', 'geodirectory'); if (!empty($keyword)) { $desc = $desc . ' ' . $keyword; } if (!empty($stype)) { $posttype_obj = get_post_type_object($stype); $desc = $desc . ' ' . __('in', 'geodirectory') . ' ' . $posttype_obj->labels->name; } if (!empty($snear)) { $desc = $desc . ' ' . __('near', 'geodirectory') . ' ' . $snear; } $html = '<meta name="description" content="' . $desc . '" />'; } } return $html; }
function geodir_payment_coupon_form() { global $wpdb; if (isset($_REQUEST['id']) && $_REQUEST['id'] != '') { $cid = $_REQUEST['id']; $couponsql = $wpdb->prepare("select * from " . COUPON_TABLE . " where cid=%d", array($cid)); $couponinfo = $wpdb->get_row($couponsql); } ?> <div class="gd-content-heading active"> <h3> <?php if (isset($_REQUEST['id']) && $_REQUEST['id'] != '') { _e('Edit Coupon', GEODIRPAYMENT_TEXTDOMAIN); } else { _e('Add Coupon', GEODIRPAYMENT_TEXTDOMAIN); } ?> </h3> <?php $nonce = wp_create_nonce('coupon_add_update'); ?> <input type="hidden" name="coupon_add_update_nonce" value="<?php echo $nonce; ?> " /> <input type="hidden" name="gd_add_coupon" value="addprice"> <input type="hidden" name="gd_id" value="<?php if (isset($_REQUEST['id'])) { echo $_REQUEST['id']; } ?> "> <table class="form-table"> <tbody> <tr valign="top" class="single_select_page"> <th class="titledesc" scope="row"><?php _e('Coupon Code', GEODIRPAYMENT_TEXTDOMAIN); ?> </th> <td class="forminp"><div class="gtd-formfield"> <input type="text" style="min-width:200px;" name="coupon_code" id="coupon_code" value="<?php if (isset($couponinfo->coupon_code)) { echo $couponinfo->coupon_code; } ?> "> </div></td> </tr> <tr valign="top" class="single_select_page"> <th class="titledesc" scope="row"><?php _e('Post type', GEODIRPAYMENT_TEXTDOMAIN); ?> </th> <td class="forminp"><div class="gtd-formfield"> <?php $get_post_types = array(); if (isset($couponinfo->post_types) && $couponinfo->post_types != '') { $get_post_types = explode(',', $couponinfo->post_types); } ?> <select multiple="multiple" style="min-width:200px;" id="post_type" name="post_type[]" > <?php $post_types = geodir_get_posttypes(); if (!empty($post_types)) { foreach ($post_types as $post_type) { ?> <option value="<?php echo $post_type; ?> " <?php if (in_array($post_type, $get_post_types)) { echo 'selected="selected"'; } ?> ><?php echo $post_type; ?> </option> <?php } } ?> </select> </div></td> </tr> <tr valign="top" class="single_select_page"> <th class="titledesc" scope="row"><?php _e('Discount Type', GEODIRPAYMENT_TEXTDOMAIN); ?> </th> <td class="forminp"><div class="gtd-formfield"> <input type="radio" style="min-width:20px;" name="discount_type" <?php if (isset($couponinfo->discount_type) && $couponinfo->discount_type == 'per' || (!isset($couponinfo->discount_type) || $couponinfo->discount_type == '')) { echo 'checked="checked"'; } ?> id="discount_type" value="per"><?php _e('Percentage(%)', GEODIRPAYMENT_TEXTDOMAIN); ?> <input type="radio" style="min-width:20px;" name="discount_type" <?php if (isset($couponinfo->discount_type) && $couponinfo->discount_type == 'amt') { echo 'checked="checked"'; } ?> id="discount_type" value="amt"><?php _e('Amount', GEODIRPAYMENT_TEXTDOMAIN); ?> </div></td> </tr> <tr valign="top" class="single_select_page"> <th class="titledesc" scope="row"><?php _e('Discount Amount ($)', GEODIRPAYMENT_TEXTDOMAIN); ?> </th> <td class="forminp"><div class="gtd-formfield"> <input type="text" style="min-width:200px;" name="discount_amount" id="discount_amount" value="<?php if (isset($couponinfo->discount_amount)) { echo $couponinfo->discount_amount; } ?> "> </div></td> </tr> <tr valign="top" class="single_select_page"> <th class="titledesc" scope="row"><?php _e('Recurring', GEODIRPAYMENT_TEXTDOMAIN); ?> </th> <td class="forminp"><div class="gtd-formfield"> <select style="min-width:200px;" name="gd_recurring" > <option value="0" <?php if (!isset($couponinfo->recurring) || $couponinfo->recurring == '0') { echo 'selected="selected"'; } ?> > <?php _e("All payments", GEODIRPAYMENT_TEXTDOMAIN); ?> </option> <option value="1" <?php if (isset($couponinfo->recurring) && $couponinfo->recurring == '1') { echo 'selected="selected"'; } ?> > <?php _e("First payment only", GEODIRPAYMENT_TEXTDOMAIN); ?> </option> </select><small><?php _e('If applied to a recurring price package, how should it apply.', GEODIRPAYMENT_TEXTDOMAIN); ?> </small> </div></td> </tr> <tr valign="top" class="single_select_page"> <th class="titledesc" scope="row"><?php _e('Status', GEODIRPAYMENT_TEXTDOMAIN); ?> </th> <td class="forminp"><div class="gtd-formfield"> <select style="min-width:200px;" name="gd_status" > <option value="1" <?php if (isset($couponinfo->status) && $couponinfo->status == '1') { echo 'selected="selected"'; } ?> > <?php _e("Active", GEODIRPAYMENT_TEXTDOMAIN); ?> </option> <option value="0" <?php if (!isset($couponinfo->status) || $couponinfo->status == '0') { echo 'selected="selected"'; } ?> > <?php _e("Inactive", GEODIRPAYMENT_TEXTDOMAIN); ?> </option> </select> </div></td> </tr> </tbody> </table> <p class="submit" style="margin-top:10px; padding-left:15px;"> <input type="submit" id="coupon_submit" class="button-primary" name="submit" value="<?php _e('Submit', GEODIRPAYMENT_TEXTDOMAIN); ?> " > <input type="button" class="button-primary" name="gd_cancel" value="<?php _e('Cancel', GEODIRPAYMENT_TEXTDOMAIN); ?> " onClick="window.location.href='<?php echo admin_url(); ?> admin.php?page=geodirectory&tab=paymentmanager_fields&subtab=geodir_coupon_manager'" > </p> </form> </div> <?php }