/** * Custom taxonomy walker function. * * @since 1.0.0 * @package GeoDirectory * @param string $cat_taxonomy The taxonomy name. * @param int $cat_parent The parent term ID. * @param bool $hide_empty Hide empty taxonomies? Default: false. * @param int $pading CSS padding in pixels. * @return string|void taxonomy HTML. */ function geodir_custom_taxonomy_walker($cat_taxonomy, $cat_parent = 0, $hide_empty = false, $pading = 0) { global $cat_display, $post_cat, $exclude_cats; $search_terms = trim($post_cat, ","); $search_terms = explode(",", $search_terms); $cat_terms = get_terms($cat_taxonomy, array('parent' => $cat_parent, 'hide_empty' => $hide_empty, 'exclude' => $exclude_cats)); $display = ''; $onchange = ''; $term_check = ''; $main_list_class = ''; $out = ''; //If there are terms, start displaying if (count($cat_terms) > 0) { //Displaying as a list $p = $pading * 20; $pading++; if (!geodir_is_page('listing') || is_search() && $_REQUEST['search_taxonomy'] == '') { if ($cat_parent == 0) { $list_class = 'main_list gd-parent-cats-list gd-cats-display-' . $cat_display; $main_list_class = 'class="main_list_selecter"'; } else { //$display = 'display:none'; $list_class = 'sub_list gd-sub-cats-list'; } } if ($cat_display == 'checkbox' || $cat_display == 'radio') { $p = 0; $out = '<div class="' . $list_class . ' gd-cat-row-' . $cat_parent . '" style="margin-left:' . $p . 'px;' . $display . ';">'; } foreach ($cat_terms as $cat_term) { $checked = ''; if (in_array($cat_term->term_id, $search_terms)) { if ($cat_display == 'select' || $cat_display == 'multiselect') { $checked = 'selected="selected"'; } else { $checked = 'checked="checked"'; } } if ($cat_display == 'radio') { $out .= '<span style="display:block" ><input type="radio" field_type="radio" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . ucfirst($cat_term->name) . '</span>'; } elseif ($cat_display == 'select' || $cat_display == 'multiselect') { $out .= '<option ' . $main_list_class . ' style="margin-left:' . $p . 'px;" alt="' . $cat_term->taxonomy . '" title="' . ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' >' . $term_check . ucfirst($cat_term->name) . '</option>'; } else { $out .= '<span style="display:block"><input style="display:inline-block" type="checkbox" field_type="checkbox" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . ucfirst($cat_term->name) . '</span>'; } // Call recurson to print sub cats $out .= geodir_custom_taxonomy_walker($cat_taxonomy, $cat_term->term_id, $hide_empty, $pading); } if ($cat_display == 'checkbox' || $cat_display == 'radio') { $out .= '</div>'; } return $out; } return; }
function geodir_fields_list_by_posttype($post_type = '', $pkg_id = '', $cats = '', $ajax_data = '') { global $wpdb, $cat_display, $post_cat; if ($post_type) { $custom_fields = geodir_post_custom_fields('', 'all', $post_type); $html = '<select style="min-width:200px;" multiple="multiple" name="pay_custom_fields[]">'; if (!empty($custom_fields)) { foreach ($custom_fields as $key => $val) { $id = $val['id']; $label = $val['label']; $is_default = $val['is_default']; $is_admin = $val['is_admin']; $field_type = $val['field_type']; if (!($field_type == 'address' && $is_admin == '1') && !($field_type == 'taxonomy' && $is_admin == '1')) { $selected = ''; if ($pkg_id != '' && $wpdb->get_var($wpdb->prepare("SELECT id FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE FIND_IN_SET(%s, packages) AND id='" . $id . "'", array($pkg_id)))) { $selected = 'selected="selected"'; } $html .= '<option ' . $selected . ' value="' . $id . '">' . $label . '</option>'; } } } $cat_display = 'multiselect'; $post_cat = $cats; $html_cat = '<select style="min-width:200px;" name="gd_cat[]" multiple="multiple" style="height: 100px;" >'; $html_cat .= geodir_custom_taxonomy_walker($post_type . 'category'); $html_cat .= '</select>'; $downgrade = '<select style="min-width:200px;" name="gd_downgrade_pkg" style="height: 100px;" >'; $downgrade .= '<option value="0">' . __("Expire", GEODIRPAYMENT_TEXTDOMAIN) . '</option>'; $priceinfo = geodir_package_list_info($post_type); $pricearr = array(); foreach ($priceinfo as $priceinfoObj) { $selected = ''; if ($priceinfoObj->pid == $cats) { $selected = 'selected="selected"'; } $downgrade .= '<option value="' . $priceinfoObj->pid . '" ' . $selected . '>' . $priceinfoObj->title . ' - ' . $priceinfoObj->post_type . '</option>'; } $downgrade .= '</select>'; if ($ajax_data == '') { $htmls['html_cat'] = isset($html_cat) ? $html_cat : ''; $htmls['posttype'] = isset($html) ? $html : ''; $htmls['downgrade'] = isset($downgrade) ? $downgrade : ''; return $htmls; } else { $htmls['html_cat'] = $html_cat; $htmls['posttype'] = $html; $htmls['downgrade'] = $downgrade; echo json_encode($htmls); //echo $htmls = '{"posttypes":"$html","html_cat":"$html_cat"}'; } } }
/** * Displays custom fields html. * * @since 1.0.0 * @since 1.5.2 Added TERRAIN map type. * @package GeoDirectory * @global object $wpdb WordPress Database object. * @global object $post The current post object. * @global array $geodir_addon_list List of active GeoDirectory extensions. * @param int|string $package_id The package ID. * @param string $default Optional. When set to "default" it will display only default fields. * @param string $post_type Optional. The wordpress post type. */ function geodir_get_custom_fields_html($package_id = '', $default = 'custom', $post_type = 'gd_place') { global $is_default, $mapzoom; $show_editors = array(); $listing_type = $post_type; $custom_fields = geodir_post_custom_fields($package_id, $default, $post_type); foreach ($custom_fields as $key => $val) { $val = stripslashes_deep($val); // strip slashes from labels $name = $val['name']; $site_title = $val['site_title']; $type = $val['type']; $admin_desc = $val['desc']; $option_values = $val['option_values']; $is_required = $val['is_required']; $is_default = $val['is_default']; $is_admin = $val['is_admin']; $required_msg = $val['required_msg']; $extra_fields = unserialize($val['extra_fields']); $value = ''; /* field available to site admin only for edit */ $for_admin_use = isset($val['for_admin_use']) && (int) $val['for_admin_use'] == 1 ? true : false; if ($for_admin_use && !is_super_admin()) { continue; } if (is_admin()) { global $post; if (isset($_REQUEST['post'])) { $_REQUEST['pid'] = $_REQUEST['post']; } } if (isset($_REQUEST['backandedit']) && $_REQUEST['backandedit'] && isset($_SESSION['listing'])) { $post = unserialize($_SESSION['listing']); $value = isset($post[$name]) ? $post[$name] : ''; } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') { $value = geodir_get_post_meta($_REQUEST['pid'], $name, true); } else { if ($value == '') { $value = $val['default']; } } /** * Called before the custom fields info is output for submitting a post. * * Used dynamic hook type geodir_before_custom_form_field_$name. * * @since 1.0.0 * @param string $listing_type The post post type. * @param int $package_id The price package ID for the post. * @param array $val The settings array for the field. {@see geodir_custom_field_save()}. * @see 'geodir_after_custom_form_field_$name' */ do_action('geodir_before_custom_form_field_' . $name, $listing_type, $package_id, $val); if ($type == 'fieldset') { ?> <h5><?php echo $site_title; ?> <?php if ($admin_desc != '') { echo '<small>( ' . $admin_desc . ' )</small>'; } ?> </h5><?php } elseif ($type == 'address') { $prefix = $name . '_'; $site_title != '' ? $address_title = $site_title : ($address_title = ucwords($prefix . ' address')); $extra_fields['zip_lable'] != '' ? $zip_title = $extra_fields['zip_lable'] : ($zip_title = ucwords($prefix . ' zip/post code ')); $extra_fields['map_lable'] != '' ? $map_title = $extra_fields['map_lable'] : ($map_title = ucwords('set address on map')); $extra_fields['mapview_lable'] != '' ? $mapview_title = $extra_fields['mapview_lable'] : ($mapview_title = ucwords($prefix . ' mapview')); $address = ''; $zip = ''; $mapview = ''; $mapzoom = ''; $lat = ''; $lng = ''; if (isset($_REQUEST['backandedit']) && $_REQUEST['backandedit'] && isset($_SESSION['listing'])) { $post = unserialize($_SESSION['listing']); $address = $post[$prefix . 'address']; $zip = isset($post[$prefix . 'zip']) ? $post[$prefix . 'zip'] : ''; $lat = isset($post[$prefix . 'latitude']) ? $post[$prefix . 'latitude'] : ''; $lng = isset($post[$prefix . 'longitude']) ? $post[$prefix . 'longitude'] : ''; $mapview = isset($post[$prefix . 'mapview']) ? $post[$prefix . 'mapview'] : ''; $mapzoom = isset($post[$prefix . 'mapzoom']) ? $post[$prefix . 'mapzoom'] : ''; } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '' && ($post_info = geodir_get_post_info($_REQUEST['pid']))) { $post_info = (array) $post_info; $address = $post_info[$prefix . 'address']; $zip = isset($post_info[$prefix . 'zip']) ? $post_info[$prefix . 'zip'] : ''; $lat = isset($post_info[$prefix . 'latitude']) ? $post_info[$prefix . 'latitude'] : ''; $lng = isset($post_info[$prefix . 'longitude']) ? $post_info[$prefix . 'longitude'] : ''; $mapview = isset($post_info[$prefix . 'mapview']) ? $post_info[$prefix . 'mapview'] : ''; $mapzoom = isset($post_info[$prefix . 'mapzoom']) ? $post_info[$prefix . 'mapzoom'] : ''; } $location = geodir_get_default_location(); if (empty($city)) { $city = isset($location->city) ? $location->city : ''; } if (empty($region)) { $region = isset($location->region) ? $location->region : ''; } if (empty($country)) { $country = isset($location->country) ? $location->country : ''; } $lat_lng_blank = false; if (empty($lat) && empty($lng)) { $lat_lng_blank = true; } if (empty($lat)) { $lat = isset($location->city_latitude) ? $location->city_latitude : ''; } if (empty($lng)) { $lng = isset($location->city_longitude) ? $location->city_longitude : ''; } /** * Filter the default latitude. * * @since 1.0.0 * * @param float $lat Default latitude. * @param bool $is_admin For admin use only?. */ $lat = apply_filters('geodir_default_latitude', $lat, $is_admin); /** * Filter the default longitude. * * @since 1.0.0 * * @param float $lat Default longitude. * @param bool $is_admin For admin use only?. */ $lng = apply_filters('geodir_default_longitude', $lng, $is_admin); ?> <div id="geodir_<?php echo $prefix . 'address'; ?> _row" class="<?php if ($is_required) { echo 'required_field'; } ?> geodir_form_row clearfix"> <label> <?php _e($address_title, 'geodirectory'); ?> <?php if ($is_required) { echo '<span>*</span>'; } ?> </label> <input type="text" field_type="<?php echo $type; ?> " name="<?php echo $prefix . 'address'; ?> " id="<?php echo $prefix . 'address'; ?> " class="geodir_textfield" value="<?php echo esc_attr(stripslashes($address)); ?> "/> <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory'); ?> </span> <?php if ($is_required) { ?> <span class="geodir_message_error"><?php _e($required_msg, 'geodirectory'); ?> </span> <?php } ?> </div> <?php /** * Called after the address input on the add listings. * * This is used by the location manage to add further locations info etc. * * @since 1.0.0 * @param array $val The array of setting for the custom field. {@see geodir_custom_field_save()}. */ do_action('geodir_address_extra_listing_fields', $val); if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) { ?> <div id="geodir_<?php echo $prefix . 'zip'; ?> _row" class="<?php /*if($is_required) echo 'required_field';*/ ?> geodir_form_row clearfix"> <label> <?php _e($zip_title, 'geodirectory'); ?> <?php /*if($is_required) echo '<span>*</span>';*/ ?> </label> <input type="text" field_type="<?php echo $type; ?> " name="<?php echo $prefix . 'zip'; ?> " id="<?php echo $prefix . 'zip'; ?> " class="geodir_textfield autofill" value="<?php echo esc_attr(stripslashes($zip)); ?> "/> <?php /*if($is_required) {?> <span class="geodir_message_error"><?php echo _e($required_msg,'geodirectory');?></span> <?php }*/ ?> </div> <?php } ?> <?php if (isset($extra_fields['show_map']) && $extra_fields['show_map']) { ?> <div id="geodir_<?php echo $prefix . 'map'; ?> _row" class="geodir_form_row clearfix"> <?php /** * Contains add listing page map functions. * * @since 1.0.0 */ include geodir_plugin_path() . "/geodirectory-functions/map-functions/map_on_add_listing_page.php"; if ($lat_lng_blank) { $lat = ''; $lng = ''; } ?> <span class="geodir_message_note"><?php echo GET_MAP_MSG; ?> </span> </div> <?php /* show lat lng */ $style_latlng = isset($extra_fields['show_latlng']) && $extra_fields['show_latlng'] || is_admin() ? '' : 'style="display:none"'; ?> <div id="geodir_<?php echo $prefix . 'latitude'; ?> _row" class="<?php if ($is_required) { echo 'required_field'; } ?> geodir_form_row clearfix" <?php echo $style_latlng; ?> > <label> <?php echo PLACE_ADDRESS_LAT; ?> <?php if ($is_required) { echo '<span>*</span>'; } ?> </label> <input type="text" field_type="<?php echo $type; ?> " name="<?php echo $prefix . 'latitude'; ?> " id="<?php echo $prefix . 'latitude'; ?> " class="geodir_textfield" value="<?php echo esc_attr(stripslashes($lat)); ?> " size="25"/> <span class="geodir_message_note"><?php echo GET_LATITUDE_MSG; ?> </span> <?php if ($is_required) { ?> <span class="geodir_message_error"><?php _e($required_msg, 'geodirectory'); ?> </span> <?php } ?> </div> <div id="geodir_<?php echo $prefix . 'longitude'; ?> _row" class="<?php if ($is_required) { echo 'required_field'; } ?> geodir_form_row clearfix" <?php echo $style_latlng; ?> > <label> <?php echo PLACE_ADDRESS_LNG; ?> <?php if ($is_required) { echo '<span>*</span>'; } ?> </label> <input type="text" field_type="<?php echo $type; ?> " name="<?php echo $prefix . 'longitude'; ?> " id="<?php echo $prefix . 'longitude'; ?> " class="geodir_textfield" value="<?php echo esc_attr(stripslashes($lng)); ?> " size="25"/> <span class="geodir_message_note"><?php echo GET_LOGNGITUDE_MSG; ?> </span> <?php if ($is_required) { ?> <span class="geodir_message_error"><?php _e($required_msg, 'geodirectory'); ?> </span> <?php } ?> </div> <?php } ?> <?php if (isset($extra_fields['show_mapview']) && $extra_fields['show_mapview']) { ?> <div id="geodir_<?php echo $prefix . 'mapview'; ?> _row" class="geodir_form_row clearfix "> <label><?php _e($mapview_title, 'geodirectory'); ?> </label> <span class="geodir_user_define"><input field_type="<?php echo $type; ?> " type="radio" class="gd-checkbox" name="<?php echo $prefix . 'mapview'; ?> " id="<?php echo $prefix . 'mapview'; ?> " <?php if ($mapview == 'ROADMAP' || $mapview == '') { echo 'checked="checked"'; } ?> value="ROADMAP" size="25"/> <?php _e('Default Map', 'geodirectory'); ?> </span> <span class="geodir_user_define"> <input field_type="<?php echo $type; ?> " type="radio" class="gd-checkbox" name="<?php echo $prefix . 'mapview'; ?> " id="map_view1" <?php if ($mapview == 'SATELLITE') { echo 'checked="checked"'; } ?> value="SATELLITE" size="25"/> <?php _e('Satellite Map', 'geodirectory'); ?> </span> <span class="geodir_user_define"><input field_type="<?php echo $type; ?> " type="radio" class="gd-checkbox" name="<?php echo $prefix . 'mapview'; ?> " id="map_view2" <?php if ($mapview == 'HYBRID') { echo 'checked="checked"'; } ?> value="HYBRID" size="25"/> <?php _e('Hybrid Map', 'geodirectory'); ?> </span> <span class="geodir_user_define"><input field_type="<?php echo $type; ?> " type="radio" class="gd-checkbox" name="<?php echo $prefix . 'mapview'; ?> " id="map_view3" <?php if ($mapview == 'TERRAIN') { echo 'checked="checked"'; } ?> value="TERRAIN" size="25"/> <?php _e('Terrain Map', 'geodirectory'); ?> </span> </div> <?php } ?> <?php if (isset($extra_fields['show_mapzoom']) && $extra_fields['show_mapzoom']) { ?> <input type="hidden" value="<?php if (isset($mapzoom)) { echo esc_attr($mapzoom); } ?> " name="<?php echo $prefix . 'mapzoom'; ?> " id="<?php echo $prefix . 'mapzoom'; ?> "/> <?php } ?> <?php } elseif ($type == 'text') { ?> <div id="<?php echo $name; ?> _row" class="<?php if ($is_required) { echo 'required_field'; } ?> geodir_form_row clearfix"> <label> <?php $site_title = __($site_title, 'geodirectory'); echo trim($site_title) ? $site_title : ' '; ?> <?php if ($is_required) { echo '<span>*</span>'; } ?> </label> <input field_type="<?php echo $type; ?> " name="<?php echo $name; ?> " id="<?php echo $name; ?> " value="<?php echo esc_attr(stripslashes($value)); ?> " type="text" class="geodir_textfield"/> <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory'); ?> </span> <?php if ($is_required) { ?> <span class="geodir_message_error"><?php _e($required_msg, 'geodirectory'); ?> </span> <?php } ?> </div> <?php } elseif ($type == 'email') { if ($value == $val['default']) { $value = ''; } ?> <div id="<?php echo $name; ?> _row" class="<?php if ($is_required) { echo 'required_field'; } ?> geodir_form_row clearfix"> <label> <?php $site_title = __($site_title, 'geodirectory'); echo trim($site_title) ? $site_title : ' '; ?> <?php if ($is_required) { echo '<span>*</span>'; } ?> </label> <input field_type="<?php echo $type; ?> " name="<?php echo $name; ?> " id="<?php echo $name; ?> " value="<?php echo esc_attr(stripslashes($value)); ?> " type="text" class="geodir_textfield"/> <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory'); ?> </span> <?php if ($is_required) { ?> <span class="geodir_message_error"><?php _e($required_msg, 'geodirectory'); ?> </span> <?php } ?> </div> <?php } elseif ($type == 'phone') { if ($value == $val['default']) { $value = ''; } ?> <div id="<?php echo $name; ?> _row" class="<?php if ($is_required) { echo 'required_field'; } ?> geodir_form_row clearfix"> <label> <?php $site_title = __($site_title, 'geodirectory'); echo trim($site_title) ? $site_title : ' '; ?> <?php if ($is_required) { echo '<span>*</span>'; } ?> </label> <input field_type="<?php echo $type; ?> " name="<?php echo $name; ?> " id="<?php echo $name; ?> " value="<?php echo esc_attr(stripslashes($value)); ?> " type="text" class="geodir_textfield"/> <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory'); ?> </span> <?php if ($is_required) { ?> <span class="geodir_message_error"><?php _e($required_msg, 'geodirectory'); ?> </span> <?php } ?> </div> <?php } elseif ($type == 'url') { if ($value == $val['default']) { $value = ''; } ?> <div id="<?php echo $name; ?> _row" class="<?php if ($is_required) { echo 'required_field'; } ?> geodir_form_row clearfix"> <label> <?php $site_title = __($site_title, 'geodirectory'); echo trim($site_title) ? $site_title : ' '; ?> <?php if ($is_required) { echo '<span>*</span>'; } ?> </label> <input field_type="<?php echo $type; ?> " name="<?php echo $name; ?> " id="<?php echo $name; ?> " value="<?php echo esc_attr(stripslashes($value)); ?> " type="text" class="geodir_textfield"/> <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory'); ?> </span> <?php if ($is_required) { ?> <span class="geodir_message_error"><?php _e($required_msg, 'geodirectory'); ?> </span> <?php } ?> </div> <?php } elseif ($type == 'radio') { ?> <div id="<?php echo $name; ?> _row" class="<?php if ($is_required) { echo 'required_field'; } ?> geodir_form_row clearfix"> <label> <?php $site_title = __($site_title, 'geodirectory'); echo trim($site_title) ? $site_title : ' '; ?> <?php if ($is_required) { echo '<span>*</span>'; } ?> </label> <?php if ($option_values) { $option_values_arr = explode(',', $option_values); for ($i = 0; $i < count($option_values_arr); $i++) { if (strstr($option_values_arr[$i], "/")) { $radio_attr = explode("/", $option_values_arr[$i]); $radio_lable = ucfirst($radio_attr[0]); $radio_value = $radio_attr[1]; } else { $radio_lable = ucfirst($option_values_arr[$i]); $radio_value = $option_values_arr[$i]; } ?> <input name="<?php echo $name; ?> " id="<?php echo $name; ?> " <?php if ($radio_value == $value) { echo 'checked="checked"'; } ?> value="<?php echo $radio_value; ?> " class="gd-checkbox" field_type="<?php echo $type; ?> " type="radio" /><?php _e($radio_lable); ?> <?php } } ?> <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory'); ?> </span> <?php if ($is_required) { ?> <span class="geodir_message_error"><?php _e($required_msg, 'geodirectory'); ?> </span> <?php } ?> </div> <?php } elseif ($type == 'checkbox') { ?> <div id="<?php echo $name; ?> _row" class="<?php if ($is_required) { echo 'required_field'; } ?> geodir_form_row clearfix"> <label> <?php $site_title = __($site_title, 'geodirectory'); echo trim($site_title) ? $site_title : ' '; ?> <?php if ($is_required) { echo '<span>*</span>'; } ?> </label> <?php if ($value != '1') { $value = '0'; } ?> <input type="hidden" name="<?php echo $name; ?> " id="<?php echo $name; ?> " value="<?php echo esc_attr($value); ?> "/> <input <?php if ($value == '1') { echo 'checked="checked"'; } ?> value="1" class="gd-checkbox" field_type="<?php echo $type; ?> " type="checkbox" onchange="if(this.checked){jQuery('#<?php echo $name; ?> ').val('1');} else{ jQuery('#<?php echo $name; ?> ').val('0');}"/> <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory'); ?> </span> <?php if ($is_required) { ?> <span class="geodir_message_error"><?php _e($required_msg, 'geodirectory'); ?> </span> <?php } ?> </div> <?php } elseif ($type == 'textarea') { ?> <div id="<?php echo $name; ?> _row" class="<?php if ($is_required) { echo 'required_field'; } ?> geodir_form_row clearfix"> <label> <?php $site_title = __($site_title, 'geodirectory'); echo trim($site_title) ? $site_title : ' '; ?> <?php if ($is_required) { echo '<span>*</span>'; } ?> </label><?php if (is_array($extra_fields) && in_array('1', $extra_fields)) { $editor_settings = array('media_buttons' => false, 'textarea_rows' => 10); ?> <div class="editor" field_id="<?php echo $name; ?> " field_type="editor"> <?php wp_editor(stripslashes($value), $name, $editor_settings); ?> </div><?php } else { ?> <textarea field_type="<?php echo $type; ?> " class="geodir_textarea" name="<?php echo $name; ?> " id="<?php echo $name; ?> "><?php echo stripslashes($value); ?> </textarea><?php } ?> <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory'); ?> </span> <?php if ($is_required) { ?> <span class="geodir_message_error"><?php _e($required_msg, 'geodirectory'); ?> </span> <?php } ?> </div> <?php } elseif ($type == 'select') { ?> <div id="<?php echo $name; ?> _row" class="<?php if ($is_required) { echo 'required_field'; } ?> geodir_form_row geodir_custom_fields clearfix"> <label> <?php $site_title = __($site_title, 'geodirectory'); echo trim($site_title) ? $site_title : ' '; ?> <?php if ($is_required) { echo '<span>*</span>'; } ?> </label> <?php $option_values_arr = geodir_string_values_to_options($option_values); $select_options = ''; if (!empty($option_values_arr)) { foreach ($option_values_arr as $option_row) { if (isset($option_row['optgroup']) && ($option_row['optgroup'] == 'start' || $option_row['optgroup'] == 'end')) { $option_label = isset($option_row['label']) ? $option_row['label'] : ''; $select_options .= $option_row['optgroup'] == 'start' ? '<optgroup label="' . esc_attr($option_label) . '">' : '</optgroup>'; } else { $option_label = isset($option_row['label']) ? $option_row['label'] : ''; $option_value = isset($option_row['value']) ? $option_row['value'] : ''; $selected = $option_value == $value ? 'selected="selected"' : ''; $select_options .= '<option value="' . esc_attr($option_value) . '" ' . $selected . '>' . $option_label . '</option>'; } } } ?> <select field_type="<?php echo $type; ?> " name="<?php echo $name; ?> " id="<?php echo $name; ?> " class="geodir_textfield textfield_x chosen_select" data-placeholder="<?php echo __('Choose', 'geodirectory') . ' ' . $site_title . '…'; ?> " option-ajaxchosen="false"><?php echo $select_options; ?> </select> <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory'); ?> </span> <?php if ($is_required) { ?> <span class="geodir_message_error"><?php _e($required_msg, 'geodirectory'); ?> </span> <?php } ?> </div> <?php } else { if ($type == 'multiselect') { $multi_display = 'select'; if (!empty($val['extra_fields'])) { $multi_display = unserialize($val['extra_fields']); } ?> <div id="<?php echo $name; ?> _row" class="<?php if ($is_required) { echo 'required_field'; } ?> geodir_form_row clearfix"> <label> <?php $site_title = __($site_title, 'geodirectory'); echo trim($site_title) ? $site_title : ' '; ?> <?php if ($is_required) { echo '<span>*</span>'; } ?> </label> <input type="hidden" name="gd_field_<?php echo $name; ?> " value="1"/> <?php if ($multi_display == 'select') { ?> <div class="geodir_multiselect_list"> <select field_type="<?php echo $type; ?> " name="<?php echo $name; ?> []" id="<?php echo $name; ?> " multiple="multiple" class="geodir_textfield textfield_x chosen_select" data-placeholder="<?php _e('Select', 'geodirectory'); ?> " option-ajaxchosen="false"> <?php } else { echo '<ul class="gd_multi_choice">'; } $option_values_arr = geodir_string_values_to_options($option_values); $select_options = ''; if (!empty($option_values_arr)) { foreach ($option_values_arr as $option_row) { if (isset($option_row['optgroup']) && ($option_row['optgroup'] == 'start' || $option_row['optgroup'] == 'end')) { $option_label = isset($option_row['label']) ? $option_row['label'] : ''; if ($multi_display == 'select') { $select_options .= $option_row['optgroup'] == 'start' ? '<optgroup label="' . esc_attr($option_label) . '">' : '</optgroup>'; } else { $select_options .= $option_row['optgroup'] == 'start' ? '<li>' . $option_label . '</li>' : ''; } } else { $option_label = isset($option_row['label']) ? $option_row['label'] : ''; $option_value = isset($option_row['value']) ? $option_row['value'] : ''; $selected = $option_value == $value ? 'selected="selected"' : ''; $selected = ''; $checked = ''; if (!is_array($value) && trim($value) != '' || is_array($value) && !empty($value)) { if (!is_array($value)) { $value_array = explode(',', $value); } else { $value_array = $value; } if (is_array($value_array)) { if (in_array($option_value, $value_array)) { $selected = 'selected="selected"'; $checked = 'checked="checked"'; } } } if ($multi_display == 'select') { $select_options .= '<option value="' . esc_attr($option_value) . '" ' . $selected . '>' . $option_label . '</option>'; } else { $select_options .= '<li><input name="' . $name . '[]" ' . $checked . ' value="' . esc_attr($option_value) . '" class="gd-' . $multi_display . '" field_type="' . $multi_display . '" type="' . $multi_display . '" /> ' . $option_label . ' </li>'; } } } } echo $select_options; if ($multi_display == 'select') { ?> </select></div> <?php } else { ?> </ul><?php } ?> <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory'); ?> </span> <?php if ($is_required) { ?> <span class="geodir_message_error"><?php _e($required_msg, 'geodirectory'); ?> </span> <?php } ?> </div> <?php } else { if ($type == 'html') { ?> <div id="<?php echo $name; ?> _row" class="<?php if ($is_required) { echo 'required_field'; } ?> geodir_form_row clearfix"> <label> <?php $site_title = __($site_title, 'geodirectory'); echo trim($site_title) ? $site_title : ' '; ?> <?php if ($is_required) { echo '<span>*</span>'; } ?> </label> <?php $editor_settings = array('media_buttons' => false, 'textarea_rows' => 10); ?> <div class="editor" field_id="<?php echo $name; ?> " field_type="editor"> <?php wp_editor(stripslashes($value), $name, $editor_settings); ?> </div> <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory'); ?> </span> <?php if ($is_required) { ?> <span class="geodir_message_error"><?php _e($required_msg, 'geodirectory'); ?> </span> <?php } ?> </div> <?php } elseif ($type == 'datepicker') { if ($extra_fields['date_format'] == '') { $extra_fields['date_format'] = 'yy-mm-dd'; } $search = array('dd', 'mm', 'yy'); $replace = array('d', 'm', 'Y'); $date_format = str_replace($search, $replace, $extra_fields['date_format']); if ($value && !isset($_REQUEST['backandedit'])) { $time = strtotime($value); $value = date($date_format, $time); } ?> <script type="text/javascript"> jQuery(function () { jQuery("#<?php echo $name; ?> ").datepicker({changeMonth: true, changeYear: true,}); jQuery("#<?php echo $name; ?> ").datepicker("option", "dateFormat", '<?php echo $extra_fields['date_format']; ?> '); <?php if (!empty($value)) { ?> jQuery("#<?php echo $name; ?> ").datepicker("setDate", "<?php echo $value; ?> "); <?php } ?> }); </script> <div id="<?php echo $name; ?> _row" class="<?php if ($is_required) { echo 'required_field'; } ?> geodir_form_row clearfix"> <label> <?php $site_title = __($site_title, 'geodirectory'); echo trim($site_title) ? $site_title : ' '; ?> <?php if ($is_required) { echo '<span>*</span>'; } ?> </label> <input field_type="<?php echo $type; ?> " name="<?php echo $name; ?> " id="<?php echo $name; ?> " value="<?php echo esc_attr($value); ?> " type="text" class="geodir_textfield"/> <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory'); ?> </span> <?php if ($is_required) { ?> <span class="geodir_message_error"><?php _e($required_msg, 'geodirectory'); ?> </span> <?php } ?> </div> <?php } elseif ($type == 'time') { if ($value != '') { $value = date('H:i', strtotime($value)); } ?> <script type="text/javascript"> jQuery(document).ready(function () { jQuery('#<?php echo $name; ?> ').timepicker({ showPeriod: true, showLeadingZero: true, showPeriod: true, }); }); </script> <div id="<?php echo $name; ?> _row" class="<?php if ($is_required) { echo 'required_field'; } ?> geodir_form_row clearfix"> <label> <?php $site_title = __($site_title, 'geodirectory'); echo trim($site_title) ? $site_title : ' '; ?> <?php if ($is_required) { echo '<span>*</span>'; } ?> </label> <input readonly="readonly" field_type="<?php echo $type; ?> " name="<?php echo $name; ?> " id="<?php echo $name; ?> " value="<?php echo esc_attr($value); ?> " type="text" class="geodir_textfield"/> <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory'); ?> </span> <?php if ($is_required) { ?> <span class="geodir_message_error"><?php _e($required_msg, 'geodirectory'); ?> </span> <?php } ?> </div> <?php } elseif ($type == 'taxonomy') { if ($value == $val['default']) { $value = ''; } ?> <div id="<?php echo $name; ?> _row" class="<?php if ($is_required) { echo 'required_field'; } ?> geodir_form_row clearfix"> <label> <?php $site_title = __($site_title, 'geodirectory'); echo trim($site_title) ? $site_title : ' '; ?> <?php if ($is_required) { echo '<span>*</span>'; } ?> </label> <div id="<?php echo $name; ?> " class="geodir_taxonomy_field" style="float:left; width:70%;"> <?php global $wpdb, $post, $cat_display, $post_cat, $package_id, $exclude_cats; $exclude_cats = array(); if ($is_admin == '1') { $post_type = get_post_type(); $package_info = array(); $package_info = (array) geodir_post_package_info($package_info, $post, $post_type); if (!empty($package_info)) { if (isset($package_info['cat']) && $package_info['cat'] != '') { $exclude_cats = explode(',', $package_info['cat']); } } } $cat_display = unserialize($val['extra_fields']); if (isset($_REQUEST['backandedit']) && (is_array($post_cat[$name]) && !empty($post_cat[$name]))) { $post_cat = implode(",", $post_cat[$name]); } else { if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') { $post_cat = geodir_get_post_meta($_REQUEST['pid'], $name, true); } } global $geodir_addon_list; if (!empty($geodir_addon_list) && array_key_exists('geodir_payment_manager', $geodir_addon_list) && $geodir_addon_list['geodir_payment_manager'] == 'yes') { $catadd_limit = $wpdb->get_var($wpdb->prepare("SELECT cat_limit FROM " . GEODIR_PRICE_TABLE . " WHERE pid = %d", array($package_id))); } else { $catadd_limit = 0; } if ($cat_display != '' && $cat_display != 'ajax_chained') { $required_limit_msg = ''; if ($catadd_limit > 0 && $cat_display != 'select' && $cat_display != 'radio') { $required_limit_msg = __('Only select', 'geodirectory') . ' ' . $catadd_limit . __(' categories for this package.', 'geodirectory'); } else { $required_limit_msg = $required_msg; } echo '<input type="hidden" cat_limit="' . $catadd_limit . '" id="cat_limit" value="' . esc_attr($required_limit_msg) . '" name="cat_limit[' . $name . ']" />'; if ($cat_display == 'select' || $cat_display == 'multiselect') { $cat_display == ''; $multiple = ''; if ($cat_display == 'multiselect') { $multiple = 'multiple="multiple"'; } echo '<select id="' . $name . '" ' . $multiple . ' type="' . $name . '" name="post_category[' . $name . '][]" alt="' . $name . '" field_type="' . $cat_display . '" class="geodir_textfield textfield_x chosen_select" data-placeholder="' . __('Select Category', 'geodirectory') . '">'; if ($cat_display == 'select') { echo '<option value="">' . __('Select Category', 'geodirectory') . '</option>'; } } echo geodir_custom_taxonomy_walker($name, $catadd_limit = 0); if ($cat_display == 'select' || $cat_display == 'multiselect') { echo '</select>'; } } else { echo geodir_custom_taxonomy_walker2($name, $catadd_limit); } ?> </div> <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory'); ?> </span> <?php if ($is_required) { ?> <span class="geodir_message_error"><?php _e($required_msg, 'geodirectory'); ?> </span> <?php } ?> </div> <?php } elseif ($type == 'file') { ?> <?php // adjust values here $file_id = $name; // this will be the name of form field. Image url(s) will be submitted in $_POST using this key. So if $id == �img1� then $_POST[�img1�] will have all the image urls if ($value != '') { $file_value = trim($value, ","); // this will be initial value of the above form field. Image urls. } else { $file_value = ''; } if (isset($extra_fields['file_multiple']) && $extra_fields['file_multiple']) { $file_multiple = true; } else { $file_multiple = false; } if (isset($extra_fields['image_limit']) && $extra_fields['image_limit']) { $file_image_limit = $extra_fields['image_limit']; } else { $file_image_limit = 1; } $file_width = geodir_media_image_large_width(); // If you want to automatically resize all uploaded images then provide width here (in pixels) $file_height = geodir_media_image_large_height(); // If you want to automatically resize all uploaded images then provide height here (in pixels) if (!empty($file_value)) { $curImages = explode(',', $file_value); if (!empty($curImages)) { $file_totImg = count($curImages); } } $allowed_file_types = !empty($extra_fields['gd_file_types']) && is_array($extra_fields['gd_file_types']) && !in_array("*", $extra_fields['gd_file_types']) ? implode(",", $extra_fields['gd_file_types']) : ''; $display_file_types = $allowed_file_types != '' ? '.' . implode(", .", $extra_fields['gd_file_types']) : ''; ?> <?php /*?> <h5 class="geodir-form_title"> <?php echo $site_title; ?> <?php if($file_image_limit!=0 && $file_image_limit==1 ){echo '<br /><small>('.__('You can upload').' '.$file_image_limit.' '.__('image with this package').')</small>';} ?> <?php if($file_image_limit!=0 && $file_image_limit>1 ){echo '<br /><small>('.__('You can upload').' '.$file_image_limit.' '.__('images with this package').')</small>';} ?> <?php if($file_image_limit==0){echo '<br /><small>('.__('You can upload unlimited images with this package').')</small>';} ?> </h5> <?php */ ?> <div id="<?php echo $name; ?> _row" class="<?php if ($is_required) { echo 'required_field'; } ?> geodir_form_row clearfix"> <div id="<?php echo $file_id; ?> dropbox" align="center" style=""> <label style="text-align:left; padding-top:10px;"><?php $site_title = __($site_title, 'geodirectory'); echo $site_title; if ($is_required) { echo '<span>*</span>'; } ?> </label> <input class="geodir-custom-file-upload" field_type="file" type="hidden" name="<?php echo $file_id; ?> " id="<?php echo $file_id; ?> " value="<?php echo esc_attr($file_value); ?> "/> <input type="hidden" name="<?php echo $file_id; ?> image_limit" id="<?php echo $file_id; ?> image_limit" value="<?php echo $file_image_limit; ?> "/> <?php if ($allowed_file_types != '') { ?> <input type="hidden" name="<?php echo $file_id; ?> _allowed_types" id="<?php echo $file_id; ?> _allowed_types" value="<?php echo esc_attr($allowed_file_types); ?> " data-exts="<?php echo esc_attr($display_file_types); ?> "/> <?php } ?> <input type="hidden" name="<?php echo $file_id; ?> totImg" id="<?php echo $file_id; ?> totImg" value="<?php if (isset($file_totImg)) { echo esc_attr($file_totImg); } else { echo '0'; } ?> "/> <div style="float:left; width:55%;"> <div class="plupload-upload-uic hide-if-no-js <?php if ($file_multiple) { ?> plupload-upload-uic-multiple<?php } ?> " id="<?php echo $file_id; ?> plupload-upload-ui" style="float:left; width:30%;"> <?php /*?><h4><?php _e('Drop files to upload');?></h4><br/><?php */ ?> <input id="<?php echo $file_id; ?> plupload-browse-button" type="button" value="<?php $file_image_limit > 1 ? esc_attr_e('Select Files', 'geodirectory') : esc_attr_e('Select File', 'geodirectory'); ?> " class="geodir_button" style="margin-top:10px;"/> <span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce($file_id . 'pluploadan'); ?> "></span> <?php if ($file_width && $file_height) { ?> <span class="plupload-resize"></span> <span class="plupload-width" id="plupload-width<?php echo $file_width; ?> "></span> <span class="plupload-height" id="plupload-height<?php echo $file_height; ?> "></span> <?php } ?> <div class="filelist"></div> </div> <div class="plupload-thumbs <?php if ($file_multiple) { ?> plupload-thumbs-multiple<?php } ?> " id="<?php echo $file_id; ?> plupload-thumbs" style=" clear:inherit; margin-top:0; margin-left:15px; padding-top:10px; float:left; width:50%;"> </div> <?php /*?><span id="upload-msg" ><?php _e('Please drag & drop the images to rearrange the order');?></span><?php */ ?> <span id="<?php echo $file_id; ?> upload-error" style="display:none"></span> </div> </div> <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory'); ?> <?php echo $display_file_types != '' ? __('Allowed file types:', 'geodirectory') . ' ' . $display_file_types : ''; ?> </span> <?php if ($is_required) { ?> <span class="geodir_message_error"><?php _e($required_msg, 'geodirectory'); ?> </span> <?php } ?> </div> <?php } } } /** * Called after the custom fields info is output for submitting a post. * * Used dynamic hook type geodir_after_custom_form_field_$name. * * @since 1.0.0 * @param string $listing_type The post post type. * @param int $package_id The price package ID for the post. * @param array $val The settings array for the field. {@see geodir_custom_field_save()}. * @see 'geodir_before_custom_form_field_$name' */ do_action('geodir_after_custom_form_field_' . $name, $listing_type, $package_id, $val); } }
/** * Admin fields * * Loops though the geodirectory options array and outputs each field. * * @since 1.0.0 * @package GeoDirectory * @global object $geodirectory GeoDirectory plugin object. * @param array $options The options array. */ function geodir_admin_fields($options) { global $geodirectory; $first_title = true; $tab_id = ''; $i = 0; foreach ($options as $value) { if (!isset($value['name'])) { $value['name'] = ''; } if (!isset($value['class'])) { $value['class'] = ''; } if (!isset($value['css'])) { $value['css'] = ''; } if (!isset($value['std'])) { $value['std'] = ''; } $desc = ''; switch ($value['type']) { case 'dummy_installer': $post_type = isset($value['post_type']) ? $value['post_type'] : 'gd_place'; geodir_autoinstall_admin_header($post_type); break; case 'csv_installer': geodir_insert_csv_post_data(); break; case 'title': if ($i == 0) { echo '<dl id="geodir_oiption_tabs" class="gd-tab-head"></dl>'; echo '<div class="inner_content_tab_main">'; } $i++; if (isset($value['id']) && $value['id']) { $tab_id = $value['id']; } if (isset($value['desc']) && $value['desc']) { $desc = '<span style=" text-transform:none;">:- ' . $value['desc'] . '</span>'; } if (isset($value['name']) && $value['name']) { if ($first_title === true) { $first_title = false; } else { echo '</div>'; } echo '<dd id="' . trim($tab_id) . '" class="geodir_option_tabs" ><a href="javascript:void(0);">' . $value['name'] . '</a></dd>'; echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >'; } /** * Called after a GeoDirectory settings title is output in the GD settings page. * * The action is called dynamically geodir_settings_$value['id']. * * @since 1.0.0 */ do_action('geodir_settings_' . sanitize_title($value['id'])); break; case 'no_tabs': echo '<div class="inner_content_tab_main">'; echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >'; break; case 'sectionstart': if (isset($value['desc']) && $value['desc']) { $desc = '<span style=" text-transform:none;"> - ' . $value['desc'] . '</span>'; } if (isset($value['name']) && $value['name']) { echo '<h3>' . $value['name'] . $desc . '</h3>'; } /** * Called after a GeoDirectory settings sectionstart is output in the GD settings page. * * The action is called dynamically geodir_settings_$value['id']_start. * * @since 1.0.0 */ if (isset($value['id']) && $value['id']) { do_action('geodir_settings_' . sanitize_title($value['id']) . '_start'); } echo '<table class="form-table">' . "\n\n"; break; case 'sectionend': /** * Called before a GeoDirectory settings sectionend is output in the GD settings page. * * The action is called dynamically geodir_settings_$value['id']_end. * * @since 1.0.0 */ if (isset($value['id']) && $value['id']) { do_action('geodir_settings_' . sanitize_title($value['id']) . '_end'); } echo '</table>'; /** * Called after a GeoDirectory settings sectionend is output in the GD settings page. * * The action is called dynamically geodir_settings_$value['id']_end. * * @since 1.0.0 */ if (isset($value['id']) && $value['id']) { do_action('geodir_settings_' . sanitize_title($value['id']) . '_after'); } break; case 'text': ?> <tr valign="top"> <th scope="row" class="titledesc"><?php echo $value['name']; ?> </th> <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?> " id="<?php echo esc_attr($value['id']); ?> " type="<?php echo esc_attr($value['type']); ?> " style=" <?php echo esc_attr($value['css']); ?> " value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) { echo esc_attr(stripslashes(get_option($value['id']))); } else { echo esc_attr($value['std']); } ?> "/> <span class="description"><?php echo $value['desc']; ?> </span></td> </tr><?php break; case 'password': ?> <tr valign="top"> <th scope="row" class="titledesc"><?php echo $value['name']; ?> </th> <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?> " id="<?php echo esc_attr($value['id']); ?> " type="<?php echo esc_attr($value['type']); ?> " style="<?php echo esc_attr($value['css']); ?> " value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) { echo esc_attr(stripslashes(get_option($value['id']))); } else { echo esc_attr($value['std']); } ?> "/> <span class="description"><?php echo $value['desc']; ?> </span></td> </tr><?php break; case 'html_content': ?> <tr valign="top"> <th scope="row" class="titledesc"><?php echo $value['name']; ?> </th> <td class="forminp"><span class="description"><?php echo $value['desc']; ?> </span></td> </tr><?php break; case 'color': ?> <tr valign="top"> <th scope="row" class="titledesc"><?php echo $value['name']; ?> </th> <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?> " id="<?php echo esc_attr($value['id']); ?> " type="text" style="<?php echo esc_attr($value['css']); ?> " value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) { echo esc_attr(stripslashes(get_option($value['id']))); } else { echo esc_attr($value['std']); } ?> " class="colorpick"/> <span class="description"><?php echo $value['desc']; ?> </span> <div id="colorPickerDiv_<?php echo esc_attr($value['id']); ?> " class="colorpickdiv" style="z-index: 100;background:#eee;border:1px solid #ccc;position:absolute;display:none;"></div> </td> </tr><?php break; case 'image_width': ?> <tr valign="top"> <th scope="row" class="titledesc"><?php echo $value['name']; ?> </th> <td class="forminp"> <?php _e('Width', GEODIRECTORY_TEXTDOMAIN); ?> <input name="<?php echo esc_attr($value['id']); ?> _width" id="<?php echo esc_attr($value['id']); ?> _width" type="text" size="3" value="<?php if ($size = get_option($value['id'] . '_width')) { echo stripslashes($size); } else { echo $value['std']; } ?> "/> <?php _e('Height', GEODIRECTORY_TEXTDOMAIN); ?> <input name="<?php echo esc_attr($value['id']); ?> _height" id="<?php echo esc_attr($value['id']); ?> _height" type="text" size="3" value="<?php if ($size = get_option($value['id'] . '_height')) { echo stripslashes($size); } else { echo $value['std']; } ?> "/> <label><?php _e('Hard Crop', GEODIRECTORY_TEXTDOMAIN); ?> <input name="<?php echo esc_attr($value['id']); ?> _crop" id="<?php echo esc_attr($value['id']); ?> _crop" type="checkbox" <?php if (get_option($value['id'] . '_crop') != '') { checked(get_option($value['id'] . '_crop'), 1); } else { checked(1); } ?> /></label> <span class="description"><?php echo $value['desc']; ?> </span></td> </tr><?php break; case 'select': ?> <tr valign="top"> <th scope="row" class="titledesc"><?php echo $value['name']; ?> </th> <td class="forminp"><select name="<?php echo esc_attr($value['id']); ?> " id="<?php echo esc_attr($value['id']); ?> " style="<?php echo esc_attr($value['css']); ?> " class="<?php if (isset($value['class'])) { echo $value['class']; } ?> " option-ajaxchosen="false"> <?php foreach ($value['options'] as $key => $val) { $geodir_select_value = ''; if (get_option($value['id']) != '') { if (get_option($value['id']) != '' && get_option($value['id']) == $key) { $geodir_select_value = ' selected="selected" '; } } else { if ($value['std'] == $key) { $geodir_select_value = ' selected="selected" '; } } ?> <option value="<?php echo esc_attr($key); ?> " <?php echo $geodir_select_value; ?> ><?php echo ucfirst($val); ?> </option> <?php } ?> </select> <span class="description"><?php echo $value['desc']; ?> </span> </td> </tr><?php break; case 'multiselect': ?> <tr valign="top"> <th scope="row" class="titledesc"><?php echo $value['name']; ?> </th> <td class="forminp"><select multiple="multiple" name="<?php echo esc_attr($value['id']); ?> []" id="<?php echo esc_attr($value['id']); ?> " style="<?php echo esc_attr($value['css']); ?> " class="<?php if (isset($value['class'])) { echo $value['class']; } ?> " data-placeholder="<?php if (isset($value['placeholder_text'])) { echo $value['placeholder_text']; } ?> " option-ajaxchosen="false"> <?php foreach ($value['options'] as $key => $val) { if (strpos($key, 'optgroup_start-') === 0) { ?> <optgroup label="<?php echo ucfirst($val); ?> "><?php } else { if (strpos($key, 'optgroup_end-') === 0) { ?> </optgroup><?php } else { ?> <option value="<?php echo esc_attr($key); ?> " <?php if (is_array(get_option($value['id']))) { if (in_array($key, get_option($value['id']))) { ?> selected="selected" <?php } } ?> ><?php echo ucfirst($val); ?> </option> <?php } } } ?> </select> <span class="description"><?php echo $value['desc']; ?> </span> </td> </tr><?php break; case 'file': ?> <tr valign="top"> <th scope="row" class="titledesc"><?php echo $value['name']; ?> </th> <td class="forminp"> <input type="file" name="<?php echo esc_attr($value['id']); ?> " id="<?php echo esc_attr($value['id']); ?> " style="<?php echo esc_attr($value['css']); ?> " class="<?php if (isset($value['class'])) { echo $value['class']; } ?> "/> <?php if (get_option($value['id'])) { ?> <input type="hidden" name="<?php echo esc_attr($value['id']); ?> _remove" id="<?php echo esc_attr($value['id']); ?> _remove" value="0"> <span class="description"> <?php $uploads = wp_upload_dir(); ?> <a href="<?php echo get_option($value['id']); ?> " target="_blank"><?php echo get_option($value['id']); ?> </a> <i title="<?php _e('remove file (set to empty)', GEODIRECTORY_TEXTDOMAIN); ?> " onclick="jQuery('#<?php echo esc_attr($value['id']); ?> _remove').val('1'); jQuery( this ).parent().text('<?php _e('save to remove file', GEODIRECTORY_TEXTDOMAIN); ?> ');" class="fa fa-times gd-remove-file"></i></span> <?php } ?> </td> </tr><?php break; case 'map_default_settings': ?> <tr valign="top"> <th class="titledesc" width="40%"><?php _e('Default map language', GEODIRECTORY_TEXTDOMAIN); ?> </th> <td width="60%"> <select name="geodir_default_map_language" style="width:60%"> <?php $arr_map_langages = array('ar' => __('ARABIC', GEODIRECTORY_TEXTDOMAIN), 'eu' => __('BASQUE', GEODIRECTORY_TEXTDOMAIN), 'bg' => __('BULGARIAN', GEODIRECTORY_TEXTDOMAIN), 'bn' => __('BENGALI', GEODIRECTORY_TEXTDOMAIN), 'ca' => __('CATALAN', GEODIRECTORY_TEXTDOMAIN), 'cs' => __('CZECH', GEODIRECTORY_TEXTDOMAIN), 'da' => __('DANISH', GEODIRECTORY_TEXTDOMAIN), 'de' => __('GERMAN', GEODIRECTORY_TEXTDOMAIN), 'el' => __('GREEK', GEODIRECTORY_TEXTDOMAIN), 'en' => __('ENGLISH', GEODIRECTORY_TEXTDOMAIN), 'en-AU' => __('ENGLISH (AUSTRALIAN)', GEODIRECTORY_TEXTDOMAIN), 'en-GB' => __('ENGLISH (GREAT BRITAIN)', GEODIRECTORY_TEXTDOMAIN), 'es' => __('SPANISH', GEODIRECTORY_TEXTDOMAIN), 'eu' => __('BASQUE', GEODIRECTORY_TEXTDOMAIN), 'fa' => __('FARSI', GEODIRECTORY_TEXTDOMAIN), 'fi' => __('FINNISH', GEODIRECTORY_TEXTDOMAIN), 'fil' => __('FILIPINO', GEODIRECTORY_TEXTDOMAIN), 'fr' => __('FRENCH', GEODIRECTORY_TEXTDOMAIN), 'gl' => __('GALICIAN', GEODIRECTORY_TEXTDOMAIN), 'gu' => __('GUJARATI', GEODIRECTORY_TEXTDOMAIN), 'hi' => __('HINDI', GEODIRECTORY_TEXTDOMAIN), 'hr' => __('CROATIAN', GEODIRECTORY_TEXTDOMAIN), 'hu' => __('HUNGARIAN', GEODIRECTORY_TEXTDOMAIN), 'id' => __('INDONESIAN', GEODIRECTORY_TEXTDOMAIN), 'it' => __('ITALIAN', GEODIRECTORY_TEXTDOMAIN), 'iw' => __('HEBREW', GEODIRECTORY_TEXTDOMAIN), 'ja' => __('JAPANESE', GEODIRECTORY_TEXTDOMAIN), 'kn' => __('KANNADA', GEODIRECTORY_TEXTDOMAIN), 'ko' => __('KOREAN', GEODIRECTORY_TEXTDOMAIN), 'lt' => __('LITHUANIAN', GEODIRECTORY_TEXTDOMAIN), 'lv' => __('LATVIAN', GEODIRECTORY_TEXTDOMAIN), 'ml' => __('MALAYALAM', GEODIRECTORY_TEXTDOMAIN), 'mr' => __('MARATHI', GEODIRECTORY_TEXTDOMAIN), 'nl' => __('DUTCH', GEODIRECTORY_TEXTDOMAIN), 'no' => __('NORWEGIAN', GEODIRECTORY_TEXTDOMAIN), 'pl' => __('POLISH', GEODIRECTORY_TEXTDOMAIN), 'pt' => __('PORTUGUESE', GEODIRECTORY_TEXTDOMAIN), 'pt-BR' => __('PORTUGUESE (BRAZIL)', GEODIRECTORY_TEXTDOMAIN), 'pt-PT' => __('PORTUGUESE (PORTUGAL)', GEODIRECTORY_TEXTDOMAIN), 'ro' => __('ROMANIAN', GEODIRECTORY_TEXTDOMAIN), 'ru' => __('RUSSIAN', GEODIRECTORY_TEXTDOMAIN), 'ru' => __('RUSSIAN', GEODIRECTORY_TEXTDOMAIN), 'sk' => __('SLOVAK', GEODIRECTORY_TEXTDOMAIN), 'sl' => __('SLOVENIAN', GEODIRECTORY_TEXTDOMAIN), 'sr' => __('SERBIAN', GEODIRECTORY_TEXTDOMAIN), 'sv' => __(' SWEDISH', GEODIRECTORY_TEXTDOMAIN), 'tl' => __('TAGALOG', GEODIRECTORY_TEXTDOMAIN), 'ta' => __('TAMIL', GEODIRECTORY_TEXTDOMAIN), 'te' => __('TELUGU', GEODIRECTORY_TEXTDOMAIN), 'th' => __('THAI', GEODIRECTORY_TEXTDOMAIN), 'tr' => __('TURKISH', GEODIRECTORY_TEXTDOMAIN), 'uk' => __('UKRAINIAN', GEODIRECTORY_TEXTDOMAIN), 'vi' => __('VIETNAMESE', GEODIRECTORY_TEXTDOMAIN), 'zh-CN' => __('CHINESE (SIMPLIFIED)', GEODIRECTORY_TEXTDOMAIN), 'zh-TW' => __('CHINESE (TRADITIONAL)', GEODIRECTORY_TEXTDOMAIN)); $geodir_default_map_language = get_option('geodir_default_map_language'); if (empty($geodir_default_map_language)) { $geodir_default_map_language = 'en'; } foreach ($arr_map_langages as $language_key => $language_txt) { if (!empty($geodir_default_map_language) && $language_key == $geodir_default_map_language) { $geodir_default_language_selected = "selected='selected'"; } else { $geodir_default_language_selected = ''; } ?> <option value="<?php echo $language_key; ?> " <?php echo $geodir_default_language_selected; ?> ><?php echo $language_txt; ?> </option> <?php } ?> </select> </td> </tr> <tr valign="top"> <th class="titledesc" width="40%"><?php _e('Default post type search on map', GEODIRECTORY_TEXTDOMAIN); ?> </th> <td width="60%"> <select name="geodir_default_map_search_pt" style="width:60%"> <?php $post_types = geodir_get_posttypes('array'); $geodir_default_map_search_pt = get_option('geodir_default_map_search_pt'); if (empty($geodir_default_map_search_pt)) { $geodir_default_map_search_pt = 'gd_place'; } if (is_array($post_types)) { foreach ($post_types as $key => $post_types_obj) { if (!empty($geodir_default_map_search_pt) && $key == $geodir_default_map_search_pt) { $geodir_search_pt_selected = "selected='selected'"; } else { $geodir_search_pt_selected = ''; } ?> <option value="<?php echo $key; ?> " <?php echo $geodir_search_pt_selected; ?> ><?php echo $post_types_obj['labels']['singular_name']; ?> </option> <?php } } ?> </select> </td> </tr> <?php break; case 'map': ?> <tr valign="top"> <td class="forminp"> <?php global $post_cat, $cat_display; $post_types = geodir_get_posttypes('object'); $cat_display = 'checkbox'; $gd_post_types = get_option('geodir_exclude_post_type_on_map'); $gd_cats = get_option('geodir_exclude_cat_on_map'); $gd_cats_upgrade = (int) get_option('geodir_exclude_cat_on_map_upgrade'); $count = 1; ?> <table width="70%" class="widefat"> <thead> <tr> <th><b><?php echo DESIGN_POST_TYPE_SNO; ?> </b></th> <th><b><?php echo DESIGN_POST_TYPE; ?> </b></th> <th><b><?php echo DESIGN_POST_TYPE_CAT; ?> </b></th> </tr> <?php $gd_categs = $gd_cats; foreach ($post_types as $key => $post_types_obj) { $checked = is_array($gd_post_types) && in_array($key, $gd_post_types) ? 'checked="checked"' : ''; $gd_taxonomy = geodir_get_taxonomies($key); if ($gd_cats_upgrade) { $gd_cat_taxonomy = isset($gd_taxonomy[0]) ? $gd_taxonomy[0] : ''; $gd_cats = isset($gd_categs[$gd_cat_taxonomy]) ? $gd_categs[$gd_cat_taxonomy] : array(); $gd_cats = !empty($gd_cats) && is_array($gd_cats) ? array_unique($gd_cats) : array(); } $post_cat = implode(',', $gd_cats); $gd_taxonomy_list = geodir_custom_taxonomy_walker($gd_taxonomy); ?> <tr> <td valign="top" width="5%"><?php echo $count; ?> </td> <td valign="top" width="25%" id="td_post_types"><input type="checkbox" name="home_map_post_types[]" id="<?php echo esc_attr($value['id']); ?> " value="<?php echo $key; ?> " class="map_post_type" <?php echo $checked; ?> /> <?php echo $post_types_obj->labels->singular_name; ?> </td> <td width="40%"> <div class="home_map_category" style="overflow:auto;width:200px;height:100px;" id="<?php echo $key; ?> "><?php echo $gd_taxonomy_list; ?> </div> </td> </tr> <?php $count++; } ?> </thead> </table> <p><?php _e('Note: Tick respective post type or categories which you want to hide from home page map widget.', GEODIRECTORY_TEXTDOMAIN); ?> </p> </td> </tr> <?php break; case 'checkbox': if (!isset($value['checkboxgroup']) || isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'start') { ?> <tr valign="top"> <th scope="row" class="titledesc"><?php echo $value['name']; ?> </th> <td class="forminp"> <?php } ?> <fieldset> <legend class="screen-reader-text"><span><?php echo $value['name']; ?> </span></legend> <label for="<?php echo $value['id']; ?> "> <input name="<?php echo esc_attr($value['id']); ?> " id="<?php echo esc_attr($value['id']); ?> " type="checkbox" value="1" <?php checked(get_option($value['id']), true); ?> /> <?php echo $value['desc']; ?> </label><br> </fieldset> <?php if (!isset($value['checkboxgroup']) || isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'end') { ?> </td> </tr> <?php } break; case 'radio': if (!isset($value['radiogroup']) || isset($value['radiogroup']) && $value['radiogroup'] == 'start') { ?> <tr valign="top"> <th scope="row" class="titledesc"><?php echo $value['name']; ?> </th> <td class="forminp"> <?php } ?> <fieldset> <legend class="screen-reader-text"><span><?php echo $value['name']; ?> </span></legend> <label for="<?php echo $value['id']; ?> "> <input name="<?php echo esc_attr($value['id']); ?> " id="<?php echo esc_attr($value['id'] . $value['value']); ?> " type="radio" value="<?php echo $value['value']; ?> " <?php if (get_option($value['id']) == $value['value']) { echo 'checked="checked"'; } ?> /> <?php echo $value['desc']; ?> </label><br> </fieldset> <?php if (!isset($value['radiogroup']) || isset($value['radiogroup']) && $value['radiogroup'] == 'end') { ?> </td> </tr> <?php } break; case 'textarea': ?> <tr valign="top"> <th scope="row" class="titledesc"><?php echo $value['name']; ?> </th> <td class="forminp"> <textarea <?php if (isset($value['args'])) { echo $value['args'] . ' '; } ?> name="<?php echo esc_attr($value['id']); ?> " id="<?php echo esc_attr($value['id']); ?> " style="<?php echo esc_attr($value['css']); ?> "><?php if (get_option($value['id'])) { echo esc_textarea(stripslashes(get_option($value['id']))); } else { echo esc_textarea($value['std']); } ?> </textarea><span class="description"><?php echo $value['desc']; ?> </span> </td> </tr><?php break; case 'editor': ?> <tr valign="top"> <th scope="row" class="titledesc"><?php echo $value['name']; ?> </th> <td class="forminp"><?php $content = ''; if (get_option($value['id'])) { $content = stripslashes(get_option($value['id'])); } else { $content = $value['std']; } $editor_settings = array('media_buttons' => false, 'textarea_rows' => 10); wp_editor($content, esc_attr($value['id']), $editor_settings); ?> <span class="description"><?php echo $value['desc']; ?> </span> </td> </tr><?php break; case 'single_select_page': $page_setting = (int) get_option($value['id']); $args = array('name' => $value['id'], 'id' => $value['id'], 'sort_column' => 'menu_order', 'sort_order' => 'ASC', 'show_option_none' => ' ', 'class' => $value['class'], 'echo' => false, 'selected' => $page_setting); if (isset($value['args'])) { $args = wp_parse_args($value['args'], $args); } ?> <tr valign="top" class="single_select_page"> <th scope="row" class="titledesc"><?php echo $value['name']; ?> </th> <td class="forminp"> <?php echo str_replace(' id=', " data-placeholder='" . __('Select a page...', 'geodirectory') . "' style='" . $value['css'] . "' class='" . $value['class'] . "' id=", wp_dropdown_pages($args)); ?> <span class="description"><?php echo $value['desc']; ?> </span> </td> </tr><?php break; case 'single_select_country': $countries = $geodirectory->countries->countries; $country_setting = (string) get_option($value['id']); if (strstr($country_setting, ':')) { $country = current(explode(':', $country_setting)); $state = end(explode(':', $country_setting)); } else { $country = $country_setting; $state = '*'; } ?> <tr valign="top"> <th scope="rpw" class="titledesc"><?php echo $value['name']; ?> </th> <td class="forminp"><select name="<?php echo esc_attr($value['id']); ?> " style="<?php echo esc_attr($value['css']); ?> " data-placeholder="<?php _e('Choose a country…', GEODIRECTORY_TEXTDOMAIN); ?> " title="Country" class="chosen_select"> <?php echo $geodirectory->countries->country_dropdown_options($country, $state); ?> </select> <span class="description"><?php echo $value['desc']; ?> </span> </td> </tr><?php break; case 'multi_select_countries': $countries = $geodirectory->countries->countries; asort($countries); $selections = (array) get_option($value['id']); ?> <tr valign="top"> <th scope="row" class="titledesc"><?php echo $value['name']; ?> </th> <td class="forminp"> <select multiple="multiple" name="<?php echo esc_attr($value['id']); ?> []" style="width:450px;" data-placeholder="<?php _e('Choose countries…', GEODIRECTORY_TEXTDOMAIN); ?> " title="Country" class="chosen_select"> <?php if ($countries) { foreach ($countries as $key => $val) { echo '<option value="' . $key . '" ' . selected(in_array($key, $selections), true, false) . '>' . $val . '</option>'; } } ?> </select> </td> </tr> <?php break; case 'google_analytics': $selections = (array) get_option($value['id']); if (get_option('geodir_ga_client_id') && get_option('geodir_ga_client_secret')) { ?> <tr valign="top"> <th scope="row" class="titledesc"><?php echo $value['name']; ?> </th> <td class="forminp"> <?php $oAuthURL = "https://accounts.google.com/o/oauth2/auth?"; $scope = "scope=https://www.googleapis.com/auth/analytics.readonly"; $state = "&state=123"; //any string $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback"; $response_type = "&response_type=code"; $client_id = "&client_id=" . get_option('geodir_ga_client_id'); $access_type = "&access_type=offline"; $approval_prompt = "&approval_prompt=force"; $auth_url = $oAuthURL . $scope . $state . $redirect_uri . $response_type . $client_id . $access_type . $approval_prompt; ?> <script> function gd_ga_popup() { var win = window.open("<?php echo $auth_url; ?> ", "Google Analytics", ""); var pollTimer = window.setInterval(function () { if (win.closed !== false) { // !== is required for compatibility with Opera window.clearInterval(pollTimer); jQuery(".general_settings .submit .button-primary").trigger('click'); } }, 200); } </script> <?php if (get_option('gd_ga_refresh_token')) { ?> <span class="button-primary" onclick="gd_ga_popup();"><?php _e('Re-authorize', GEODIRECTORY_TEXTDOMAIN); ?> </span> <span style="color: green; font-weight: bold;"><?php _e('Authorized', GEODIRECTORY_TEXTDOMAIN); ?> </span> <?php } else { ?> <span class="button-primary" onclick="gd_ga_popup();"><?php _e('Authorize', GEODIRECTORY_TEXTDOMAIN); ?> </span> <?php } ?> </td> </tr> <?php } break; case 'field_seperator': ?> <tr valign="top"> <td colspan="2" class="forminp geodir_line_seperator"></td> </tr> <?php break; } } if ($first_title === false) { echo "</div>"; } ?> <script type="text/javascript"> jQuery(document).ready(function () { jQuery('.geodir_option_tabs').each(function (ele) { jQuery('#geodir_oiption_tabs').append(jQuery(this)); }); jQuery('.geodir_option_tabs').removeClass('gd-tab-active'); jQuery('.geodir_option_tabs:first').addClass('gd-tab-active'); jQuery('.gd-content-heading').hide(); jQuery('.gd-content-heading:first').show(); jQuery('.geodir_option_tabs').bind('click', function () { var tab_id = jQuery(this).attr('id'); if (tab_id == 'dummy_data_settings') { jQuery('p .button-primary').hide(); } else if (tab_id == 'csv_upload_settings') { jQuery('p .button-primary').hide(); } else { jQuery('.button-primary').show(); } if (jQuery('#sub_' + tab_id + ' div').hasClass('geodir_auto_install')) jQuery('p .button-primary').hide(); jQuery('.geodir_option_tabs').removeClass('gd-tab-active'); jQuery(this).addClass('gd-tab-active'); jQuery('.gd-content-heading').hide(); jQuery('#sub_' + tab_id).show(); jQuery('.active_tab').val(tab_id); jQuery("select.chosen_select").trigger("chosen:updated"); //refresh closen }); <?php if (isset($_REQUEST['active_tab']) && $_REQUEST['active_tab'] != '') { ?> jQuery('.geodir_option_tabs').removeClass('gd-tab-active'); jQuery('#<?php echo $_REQUEST['active_tab']; ?> ').addClass('gd-tab-active'); jQuery('.gd-content-heading').hide(); jQuery('#sub_<?php echo $_REQUEST['active_tab']; ?> ').show(); <?php } ?> }); </script> <?php }
/** * Review Rating ajax submit function. * * @since 1.0.0 * @package GeoDirectory_Review_Rating_Manager */ function geodir_reviewrating_ajax_actions() { global $wpdb; $url = admin_url('admin.php'); if (isset($_REQUEST['subtab']) && $_REQUEST['subtab'] == 'geodir_multirating_options') { geodir_update_options(geodir_reviewrating_default_options()); $msg = __('Your settings have been saved.', GEODIRREVIEWRATING_TEXTDOMAIN); $msg = urlencode($msg); $url = add_query_arg(array('page' => 'geodirectory', 'tab' => 'multirating_fields', 'subtab' => 'geodir_multirating_options', 'gdrr_success' => $msg), esc_url($url)); wp_redirect($url); exit; } if ($_REQUEST['ajax_action'] == 'update_overall_setting') { geodir_reviewrating_update_overall_settings(); $msg = __('Your settings have been saved.', GEODIRREVIEWRATING_TEXTDOMAIN); $msg = urlencode($msg); $url = add_query_arg(array('page' => 'geodirectory&tab=multirating_fields&subtab=geodir_rating_settings&gdrr_success=' . $msg), esc_url($url)); wp_redirect($url); exit; } if ($_REQUEST['ajax_action'] == 'update_review_setting') { geodir_reviewrating_update_review_setting(); $msg = __('Your settings have been saved.', GEODIRREVIEWRATING_TEXTDOMAIN); $msg = urlencode($msg); $url = add_query_arg(array('page' => 'geodirectory&tab=multirating_fields&subtab=geodir_manage_review&gdrr_success=' . $msg), esc_url($url)); wp_redirect($url); exit; } if ($_REQUEST['ajax_action'] == 'update_styles' || $_REQUEST['ajax_action'] == 'delete_style') { geodir_reviewrating_update_rating_styles(); $msg = __('Your settings have been saved.', GEODIRREVIEWRATING_TEXTDOMAIN); if ($_REQUEST['ajax_action'] == 'delete_style') { $msg = __('Rating Style Delete successfully.', GEODIRREVIEWRATING_TEXTDOMAIN); } $msg = urlencode($msg); $url = add_query_arg(array('page' => 'geodirectory&tab=multirating_fields&subtab=geodir_rating_style&gdrr_success=' . $msg), esc_url($url)); wp_redirect($url); exit; } if ($_REQUEST['ajax_action'] == 'update_rating_category' || $_REQUEST['ajax_action'] == 'delete_rating_category') { geodir_reviewrating_add_update_ratings(); $msg = __('Your settings have been saved.', GEODIRREVIEWRATING_TEXTDOMAIN); if ($_REQUEST['ajax_action'] == 'delete_rating_category') { $msg = __('Rating Delete successfully.', GEODIRREVIEWRATING_TEXTDOMAIN); } $msg = urlencode($msg); $url = add_query_arg(array('page' => 'geodirectory&tab=multirating_fields&subtab=geodir_create_rating&gdrr_success=' . $msg), esc_url($url)); wp_redirect($url); exit; } if ($_REQUEST['ajax_action'] == 'ajax_tax_cat') { if (isset($_REQUEST['post_type'])) { global $cat_display; $cat_display = 'select'; echo geodir_custom_taxonomy_walker($_REQUEST['post_type'] . 'category'); } exit; } if ($_REQUEST['ajax_action'] == 'review_update_frontend') { geodir_reviewrating_save_like_unlike($_REQUEST['ajaxcommentid']); } if ($_REQUEST['ajax_action'] == 'comment_actions' || $_REQUEST['ajax_action'] == 'show_tab_head') { geodir_reviewrating_comment_action($_REQUEST); } if (isset($_REQUEST['ajax_action']) && $_REQUEST['ajax_action'] == 'remove_images_by_url') { geodir_reviewrating_delete_comment_images_by_url(); } }
/** * Adds rating manager 'create ratings' tab settings - form fields. * * @since 1.0.0 * @package GeoDirectory_Review_Rating_Manager * * @global object $wpdb WordPress Database object. */ function geodir_reviewrating_create_rating_form() { global $cat_display, $post_cat, $table_prefix, $wpdb; $ajax_url = geodir_reviewrating_ajax_url(); if (isset($_REQUEST['rating_cat_id']) && $_REQUEST['rating_cat_id'] != '') { $sqlquery = $wpdb->prepare("select * from " . GEODIR_REVIEWRATING_CATEGORY_TABLE . " where id = %d", array($_REQUEST['rating_cat_id'])); $qry_result = $wpdb->get_row($sqlquery); } $nonce = wp_create_nonce('geodir_create_rating_nonce'); ?> <div class="gd-content-heading active"> <h3><?php _e('Create Ratings', GEODIRREVIEWRATING_TEXTDOMAIN); ?> </h3> <div id="form_div"> <?php if (isset($_REQUEST['rating_cat_id']) && $_REQUEST['rating_cat_id'] != '') { ?> <input type="hidden" value="<?php echo $_REQUEST['rating_cat_id']; ?> " name="rating_cat_id" /> <?php } ?> <input type="hidden" name="geodir_create_rating_nonce_field" value="<?php echo $nonce; ?> " /> <table class="form-table" id='tblSample'> <tr> <th scope="row"><?php _e('Select multirating style', GEODIRREVIEWRATING_TEXTDOMAIN); ?> </th> <td><?php $qry_result_category_id = isset($qry_result->category_id) ? $qry_result->category_id : ''; echo geodir_reviewrating_style_dl($qry_result_category_id); ?> </td> </tr> <tr> <th scope="row"><?php _e('Rating title', GEODIRREVIEWRATING_TEXTDOMAIN); ?> </th> <td><input class="regular-text" type="text" name="rating_title" id="rating_title" value="<?php if (isset($qry_result->title)) { echo $qry_result->title; } ?> " /></td> </tr> <tr> <th scope="row"><?php _e('Showing method', GEODIRREVIEWRATING_TEXTDOMAIN); ?> </th> <td> <?php $checked = ''; $checked_false = ''; if (isset($qry_result) && $qry_result->check_text_rating_cond == '0') { $checked_false = "checked"; } else { $checked = "checked"; } ?> <input type="radio" name="show_star" id="select_star" value="1" <?php echo $checked; ?> /> <?php _e('Show star', GEODIRREVIEWRATING_TEXTDOMAIN); ?> <input type="radio" name="show_star" id="select_text" value="0" <?php echo $checked_false; ?> /> <?php _e('Show dropdown', GEODIRREVIEWRATING_TEXTDOMAIN); ?> </td> </tr> <tr> <th scope="row"><?php _e('Select post type', GEODIRREVIEWRATING_TEXTDOMAIN); ?> </th> <td> <?php $post_arr = array(); if (isset($qry_result->post_type) && $qry_result->post_type != '') { $post_arr = explode(',', $qry_result->post_type); } $geodir_post_types = get_option('geodir_post_types'); $geodir_posttypes = geodir_get_posttypes(); $i = 1; foreach ($geodir_posttypes as $p_type) { $geodir_posttype_info = $geodir_post_types[$p_type]; $listing_slug = $geodir_posttype_info['labels']['singular_name']; ?> <div style="float:left; border:1px solid #CCCCCC; margin:0 5px;" > <input type="checkbox" name="post_type<?php echo $i; ?> " id="_<?php echo $i; ?> " value="<?php echo $p_type; ?> " class="rating_checkboxs" <?php if (count($post_arr) > 0) { if (in_array($p_type, $post_arr)) { echo 'checked="checked"'; } } ?> /><b> <?php echo ucwords($listing_slug); ?> </b> <?php $cat_display = 'select'; $post_cat = isset($qry_result->category) ? $qry_result->category : ''; ?> <br/> <select id="categories_type_<?php echo $i; ?> " name="categories_type_<?php echo $i; ?> []" multiple="multiple" style="display:<?php if (!in_array($p_type, $post_arr)) { echo 'none'; } ?> ;"> <?php echo geodir_custom_taxonomy_walker($p_type . 'category'); ?> </select> </div> <?php $i++; } ?> <input type="hidden" value="<?php echo $i -= 1; ?> " name="number_of_post" /> </td> </tr> </table> <p class="submit"><input type="button" id="create_rating_submit" class="button-primary" value="<?php _e('Save Changes', GEODIRREVIEWRATING_TEXTDOMAIN); ?> " /></p> </div> <table class="widefat" style="width:100%;"> <thead> <tr> <th width="50"><strong><?php _e('S No.', GEODIRREVIEWRATING_TEXTDOMAIN); ?> </strong></th> <th width="100"><strong><?php _e('Rating Style', GEODIRREVIEWRATING_TEXTDOMAIN); ?> </strong></th> <th width="100"><strong><?php _e('Rating Title', GEODIRREVIEWRATING_TEXTDOMAIN); ?> </strong></th> <th width="100"><strong><?php _e('Rating Image', GEODIRREVIEWRATING_TEXTDOMAIN); ?> </strong></th> <th width="125"><strong><?php _e('Post Types', GEODIRREVIEWRATING_TEXTDOMAIN); ?> </strong></th> <th width="125"><strong><?php _e('Categories', GEODIRREVIEWRATING_TEXTDOMAIN); ?> </strong></th> <th width="50"><strong><?php _e('Action', GEODIRREVIEWRATING_TEXTDOMAIN); ?> </strong></th> </tr> </thead> <tbody> <?php $geodir_reviews = geodir_reviewrating_rating_categories(); $check_multi_category_name = ''; if (!empty($geodir_reviews)) { $counter = 1; foreach ($geodir_reviews as $wnw_review) { $nonce = wp_create_nonce('geodir_delete_rating_' . $wnw_review->id); if ($counter % 2 == 0) { $bgcolor = '#FFF'; } else { $bgcolor = '#FCFCFC'; } $rating_style = geodir_reviewrating_get_style_by_id($wnw_review->category_id); echo '<tr style="background-color:' . $bgcolor . ';height:40px;">'; echo '<td>' . $counter . '</td>'; echo '<td>' . __($rating_style->name, GEODIRECTORY_TEXTDOMAIN) . '</td>'; echo '<td>' . __($wnw_review->title, GEODIRECTORY_TEXTDOMAIN) . '</td>'; echo '<td><img style="width:16px;" src="' . $rating_style->s_img_off . '" alt="' . esc_attr(__('rating icon', GEODIRREVIEWRATING_TEXTDOMAIN)) . '" />'; /*<img style="width:16px;" src="'.$rating_style->s_img_on.'"/> <img style="width:16px;" src="'.$rating_style->s_img_half.'"/>*/ echo '</td>'; echo '<td>'; if ($wnw_review->post_type != '') { $post_types = explode(',', $wnw_review->post_type); if (!empty($post_types)) { $j = 0; $comma = ''; $get_post_types = ''; foreach ($post_types as $ptype) { $post_typeinfo = get_post_type_object($ptype); if ($j != 0) { $comma = ', '; } $get_post_types .= $comma . ucwords($post_typeinfo->labels->singular_name); $j++; } } echo $get_post_types; } echo '</td>'; echo '<td>'; if (isset($wnw_review->multi_category_name)) { $check_multi_category_name .= ',' . $wnw_review->multi_category_name . ','; } $category = trim($wnw_review->category, ","); $terms = explode(",", $category); $rating_term = ''; foreach ($terms as $termid) { $rating_term .= $wpdb->get_var($wpdb->prepare("select name from " . $table_prefix . "terms where term_id = %d", array($termid))) . ','; } echo trim($rating_term, ','); echo '</td>'; $url = admin_url('admin.php'); $edit_action = add_query_arg(array('page' => 'geodirectory&tab=multirating_fields&subtab=geodir_create_rating', 'rating_cat_id' => $wnw_review->id), esc_url($url)); $delete_action = add_query_arg(array('ajax_action' => 'delete_rating_category', 'rating_cat_id' => $wnw_review->id, '_wpnonce' => $nonce), esc_url($ajax_url)); echo '<td><a href="' . $edit_action . '"> <img src="' . GEODIR_REVIEWRATING_PLUGINDIR_URL . '/images/edit.png" alt="' . __('Edit Rating', GEODIRREVIEWRATING_TEXTDOMAIN) . '" title="' . __('Edit Rating', GEODIRREVIEWRATING_TEXTDOMAIN) . '"/></a> <a href="' . $delete_action . '" onclick="return delete_rating();"> <img src="' . GEODIR_REVIEWRATING_PLUGINDIR_URL . '/images/delete.png" alt="' . __('Delete Rating', GEODIRREVIEWRATING_TEXTDOMAIN) . '" title="' . __('Delete Rating', GEODIRREVIEWRATING_TEXTDOMAIN) . '"/></a></td>'; echo '</tr>'; $counter++; } } else { echo '<tr><td colspan="7" align="center">' . __('No Record Found.', GEODIRREVIEWRATING_TEXTDOMAIN) . '</td></tr>'; } ?> </tbody> </table> </div><?php }