/** * Adds admin html for sorting options available fields. * * @since 1.0.0 * @package GeoDirectory * @global object $wpdb WordPress Database object. */ function geodir_sorting_options_available_fields() { global $wpdb; $listing_type = $_REQUEST['listing_type'] != '' ? $_REQUEST['listing_type'] : 'gd_place'; ?> <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type; ?> "/> <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo $_REQUEST['subtab']; ?> "/> <ul> <?php $sort_options = geodir_get_custom_sort_options($listing_type); foreach ($sort_options as $key => $val) { $val = stripslashes_deep($val); // strip slashes $check_html_variable = $wpdb->get_var($wpdb->prepare("select htmlvar_name from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s and field_type=%s ", array($val['htmlvar_name'], $listing_type, $val['field_type']))); $display = ''; if ($check_html_variable) { $display = ' style="display:none;"'; } ?> <li <?php echo $display; ?> > <a id="gt-<?php echo $val['field_type']; ?> -_-<?php echo $val['htmlvar_name']; ?> " title="<?php echo $val['site_title']; ?> " class="gt-draggable-form-items gt-<?php echo $val['field_type']; ?> geodir-sort-<?php echo $val['htmlvar_name']; ?> " href="javascript:void(0);"><b></b><?php _e($val['site_title'], 'geodirectory'); ?> </a> </li><?php } ?> </ul> <?php }
/** * Custom sort field admin html. * * @since 1.0.0 * @package GeoDirectory * @global object $wpdb WordPress Database object. * @param string $field_type The form field type. * @param object|int $result_str The custom field results object or row id. * @param string $field_ins_upd When set to "submit" displays form. * @param bool $default when set to true field will be for admin use only. */ function geodir_custom_sort_field_adminhtml($field_type, $result_str, $field_ins_upd = '', $default = false) { global $wpdb; $cf = $result_str; if (!is_object($cf)) { $field_info = $wpdb->get_row($wpdb->prepare("select * from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where id= %d", array($cf))); } else { $field_info = $cf; $result_str = $cf->id; } $field_info = stripslashes_deep($field_info); // strip slashes if (!isset($field_info->post_type)) { $post_type = $_REQUEST['listing_type']; } else { $post_type = $field_info->post_type; } $field_types = explode('-_-', $field_type); $field_type = $field_types[0]; $htmlvar_name = isset($field_types[1]) ? $field_types[1] : ''; $site_title = ''; if ($site_title == '') { $site_title = isset($field_info->site_title) ? $field_info->site_title : ''; } if ($site_title == '') { $fields = geodir_get_custom_sort_options($post_type); foreach ($fields as $val) { $val = stripslashes_deep($val); // strip slashes if ($val['field_type'] == $field_type && $val['htmlvar_name'] == $htmlvar_name) { $site_title = isset($val['site_title']) ? $val['site_title'] : ''; } } } if ($htmlvar_name == '') { $htmlvar_name = isset($field_info->htmlvar_name) ? $field_info->htmlvar_name : ''; } $nonce = wp_create_nonce('custom_fields_' . $result_str); ?> <li class="text" id="licontainer_<?php echo $result_str; ?> "> <div class="title title<?php echo $result_str; ?> gt-fieldset" title="<?php _e('Double Click to toggle and drag-drop to sort', 'geodirectory'); ?> " ondblclick="show_hide('field_frm<?php echo $result_str; ?> ')"> <?php $nonce = wp_create_nonce('custom_fields_' . $result_str); ?> <div title="<?php _e('Click to remove field', 'geodirectory'); ?> " onclick="delete_sort_field('<?php echo $result_str; ?> ', '<?php echo $nonce; ?> ', this)" class="handlediv close"></div> <b style="cursor:pointer;" onclick="show_hide('field_frm<?php echo $result_str; ?> ')"><?php echo ucwords(__('Field:', 'geodirectory') . ' (' . $site_title . ')'); ?> </b> </div> <div id="field_frm<?php echo $result_str; ?> " class="field_frm" style="display:<?php if ($field_ins_upd == 'submit') { echo 'block;'; } else { echo 'none;'; } ?> "> <input type="hidden" name="_wpnonce" value="<?php echo $nonce; ?> "/> <input type="hidden" name="listing_type" id="listing_type" value="<?php echo $post_type; ?> "/> <input type="hidden" name="field_type" id="field_type" value="<?php echo $field_type; ?> "/> <input type="hidden" name="field_id" id="field_id" value="<?php echo $result_str; ?> "/> <input type="hidden" name="data_type" id="data_type" value="<?php if (isset($field_info->data_type)) { echo $field_info->data_type; } ?> "/> <input type="hidden" name="htmlvar_name" id="htmlvar_name" value="<?php echo $htmlvar_name; ?> "/> <table class="widefat post fixed" border="0" style="width:100%;"> <?php if ($field_type != 'random') { ?> <input type="hidden" name="site_title" id="site_title" value="<?php echo esc_attr($site_title); ?> "/> <tr> <td>Select Ascending</td> <td> <input type="checkbox" name="asc" id="asc" value="1" <?php if (isset($field_info->sort_asc) && $field_info->sort_asc == '1') { echo 'checked="checked"'; } ?> /> <input type="text" name="asc_title" id="asc_title" placeholder="<?php esc_attr_e('Ascending title', 'geodirectory'); ?> " value="<?php if (isset($field_info->asc_title)) { echo esc_attr($field_info->asc_title); } ?> " style="width:45%;"/> <input type="radio" name="is_default" value="<?php echo $htmlvar_name; ?> _asc" <?php if (isset($field_info->default_order) && $field_info->default_order == $htmlvar_name . '_asc') { echo 'checked="checked"'; } ?> /><span><?php _e('Set as default sort.', 'geodirectory'); ?> </span> <br/> <span><?php _e('Select if you want to show option in sort.', 'geodirectory'); ?> </span> </td> </tr> <tr> <td>Select Descending</td> <td> <input type="checkbox" name="desc" id="desc" value="1" <?php if (isset($field_info->sort_desc) && $field_info->sort_desc == '1') { echo 'checked="checked"'; } ?> /> <input type="text" name="desc_title" id="desc_title" placeholder="<?php esc_attr_e('Descending title', 'geodirectory'); ?> " value="<?php if (isset($field_info->desc_title)) { echo esc_attr($field_info->desc_title); } ?> " style="width:45%;"/> <input type="radio" name="is_default" value="<?php echo $htmlvar_name; ?> _desc" <?php if (isset($field_info->default_order) && $field_info->default_order == $htmlvar_name . '_desc') { echo 'checked="checked"'; } ?> /><span><?php _e('Set as default sort.', 'geodirectory'); ?> </span> <br/> <span><?php _e('Select if you want to show option in sort.', 'geodirectory'); ?> </span> </td> </tr> <?php } else { ?> <tr> <td><strong><?php _e('Frontend title :', 'geodirectory'); ?> </strong></td> <td align="left"> <input type="text" name="site_title" id="site_title" value="<?php echo esc_attr($site_title); ?> " size="50"/> <br/><span><?php _e('Section title which you wish to display in frontend', 'geodirectory'); ?> </span> </td> </tr> <tr> <td><strong><?php _e('Default sort option :', 'geodirectory'); ?> </strong></td> <td align="left"> <input type="checkbox" name="is_default" value="<?php echo $field_type; ?> " <?php if (isset($field_info->is_default) && $field_info->is_default == '1') { echo 'checked="checked"'; } ?> /> <br/> <span><?php _e('If field is checked then the field will be use as default sort.', 'geodirectory'); ?> </span> </td> </tr> <?php } ?> <tr> <td><strong><?php _e('Is active :', 'geodirectory'); ?> </strong></td> <td align="left"> <select name="is_active" id="is_active"> <option value="1" <?php if (isset($field_info->is_active) && $field_info->is_active == '1') { echo 'selected="selected"'; } ?> ><?php _e('Yes', 'geodirectory'); ?> </option> <option value="0" <?php if (isset($field_info->is_active) && $field_info->is_active == '0') { echo 'selected="selected"'; } ?> ><?php _e('No', 'geodirectory'); ?> </option> </select> <br/> <span><?php _e('Select yes or no. If no is selected then the field will not be displayed anywhere.', 'geodirectory'); ?> </span> </td> </tr> <tr> <td><strong><?php _e('Display order :', 'geodirectory'); ?> </strong></td> <td align="left"><input type="text" readonly="readonly" name="sort_order" id="sort_order" value="<?php if (isset($field_info->sort_order)) { echo esc_attr($field_info->sort_order); } ?> " size="50"/> <br/> <span><?php _e('Enter the display order of this field in backend. e.g. 5', 'geodirectory'); ?> </span> </td> </tr> <tr> <td> </td> <td align="left"> <input type="button" class="button" name="save" id="save" value="<?php esc_attr_e('Save', 'geodirectory'); ?> " onclick="save_sort_field('<?php echo $result_str; ?> ')"/> <a href="javascript:void(0)"><input type="button" name="delete" value="<?php esc_attr_e('Delete', 'geodirectory'); ?> " onclick="delete_sort_field('<?php echo $result_str; ?> ', '<?php echo $nonce; ?> ', this)" class="button_n"/></a> </td> </tr> </table> </div> </li> <?php }