/** * Rating manager update Rating Styles Tab settings. * * @since 1.0.0 * @package GeoDirectory_Review_Rating_Manager */ function geodir_reviewrating_update_rating_styles() { if (current_user_can('manage_options')) { global $vailed_file_type, $wpdb, $multi_rating_path; if (isset($_REQUEST['ajax_action']) && $_REQUEST['ajax_action'] == 'update_styles' && isset($_REQUEST['geodir_update_rating_styles_nonce'])) { if (!wp_verify_nonce($_REQUEST['geodir_update_rating_styles_nonce'], 'geodir_update_rating_styles')) { wp_redirect(home_url()); exit; } $plugin_dir_path = GEODIR_REVIEWRATING_PLUGINDIR_PATH; $multi_rating_category = $_REQUEST['multi_rating_category']; $style_count = $_REQUEST['style_count']; $style_color = $_REQUEST['style_color']; $star_rating_text = $_REQUEST['star_rating_text']; if (count($star_rating_text) > 0) { //$star_rating_text_value = implode( ',', $star_rating_text ); $star_rating_text_value = geodir_reviewrating_serialize_star_lables($star_rating_text); } $set_query = $wpdb->prepare("SET name = %s,\n\t\t\t\t\t\t\t\t\t\t\tstar_lables = %s,\n\t\t\t\t\t\t\t\t\t\t\tstar_number = %s , \n\t\t\t\t\t\t\t\t\t\t\tstar_color = %s ", array($multi_rating_category, $star_rating_text_value, $style_count, $style_color)); if (isset($_FILES['s_file_off']) && in_array($_FILES['s_file_off']['type'], $vailed_file_type)) { $move_off_file = $plugin_dir_path . '/images/' . $_FILES['s_file_off']['name']; if (!function_exists('wp_handle_upload')) { require_once ABSPATH . 'wp-admin/includes/file.php'; } $uploadedfile = $_FILES['s_file_off']; $upload_overrides = array('test_form' => false); $movefile = wp_handle_upload($uploadedfile, $upload_overrides); $s_file_off_path = $movefile['url']; if ($movefile) { @(list($width, $height) = getimagesize($movefile['file'])); if ($width) { $set_query .= $wpdb->prepare(", s_img_width = %s ", array(addslashes($width))); $width = ''; } if ($height) { $set_query .= $wpdb->prepare(", s_img_height = %s ", array(addslashes($height))); $height = ''; } $set_query .= $wpdb->prepare(", s_img_off = %s ", array(addslashes($s_file_off_path))); } } if (isset($_REQUEST['update_category']) && $_REQUEST['update_category'] != '') { $wpdb->query($wpdb->prepare("UPDATE " . GEODIR_REVIEWRATING_STYLE_TABLE . " {$set_query} WHERE id = %d ", array($_REQUEST['update_category']))); } else { $wpdb->query("INSERT INTO " . GEODIR_REVIEWRATING_STYLE_TABLE . " {$set_query} "); } } if (isset($_REQUEST['ajax_action']) && $_REQUEST['ajax_action'] == 'delete_style' && isset($_REQUEST['_wpnonce'])) { if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'geodir_delete_rating_styles_' . $_REQUEST['cat_id'])) { wp_redirect(home_url()); exit; } $wpdb->query($wpdb->prepare("DELETE FROM " . GEODIR_REVIEWRATING_STYLE_TABLE . " WHERE id = %d", array($_REQUEST['cat_id']))); } } else { wp_redirect(home_url() . '/?geodir_signup=true'); exit; } }
/** * Adds rating manager 'Overall Rating Settings' tab - form fields. * * @since 1.0.0 * @package GeoDirectory_Review_Rating_Manager */ function geodir_reviewrating_overall_settings_form() { $nonce = wp_create_nonce('geodir_overall_rating'); $rating_img_featured = get_option('geodir_reviewrating_overall_off_img_featured'); $rating_img_featured = $rating_img_featured != '' ? $rating_img_featured : get_option('geodir_reviewrating_overall_off_img'); $rating_color_featured = get_option('geodir_reviewrating_overall_color_featured'); $rating_color_featured = $rating_color_featured != '' ? $rating_color_featured : get_option('geodir_reviewrating_overall_color'); ?> <div class="gd-content-heading active"> <h3><?php _e('Overall Rating Settings', GEODIRREVIEWRATING_TEXTDOMAIN); ?> </h3> <input type="hidden" name="geodir_overall_rating_nonce" value="<?php echo $nonce; ?> " /> <div id="form_div"> <table class="form-table" id='tblSample1'> <tr> <th><?php _e('Overall rating image.', GEODIRREVIEWRATING_TEXTDOMAIN); ?> </th> <td> <?php if (get_option('geodir_reviewrating_overall_off_img')) { ?> <img style="width:32px;"src="<?php echo get_option('geodir_reviewrating_overall_off_img'); ?> " alt="<?php esc_attr_e('rating icon', GEODIRREVIEWRATING_TEXTDOMAIN); ?> " /> <?php } ?> </td> <td><input type="file" name="file_off" value="" /> </td> </tr> <tr> <th><?php _e('Overall rating image for featured listing:', GEODIRREVIEWRATING_TEXTDOMAIN); ?> </th> <td><?php if ($rating_img_featured) { ?> <img style="width:32px;" src="<?php echo $rating_img_featured; ?> " alt="<?php esc_attr_e('rating icon', GEODIRREVIEWRATING_TEXTDOMAIN); ?> " /><?php } ?> </td> <td><input type="file" name="file_off_featured" value="" /></td> </tr> <tr> <th scope="row"><?php _e('Overall rating color code', GEODIRREVIEWRATING_TEXTDOMAIN); ?> </th> <td> </td> <td> <input class="" type="color" name="overall_color" id="overall_color" value="<?php if (get_option('geodir_reviewrating_overall_color') != '') { echo get_option('geodir_reviewrating_overall_color'); } else { echo '#ff9900'; } ?> " autocomplete="off" /> </td> </tr> <tr> <th scope="row"><?php _e('Overall rating color code for featured listing:', GEODIRREVIEWRATING_TEXTDOMAIN); ?> </th> <td> </td> <td><input class="" type="color" name="overall_color_featured" id="overall_color_featured" value="<?php echo $rating_color_featured != '' ? $rating_color_featured : '#ff9900'; ?> " autocomplete="off" /></td> </tr> <tr> <th scope="row"><?php _e('Overall rating setting score', GEODIRREVIEWRATING_TEXTDOMAIN); ?> </th> <td> </td> <td> <input class="" type="text" name="overall_count" id="overall_count" value="<?php if (get_option('geodir_reviewrating_overall_count') != '') { echo get_option('geodir_reviewrating_overall_count'); } else { echo '5'; } ?> " onBlur="overall_the_text_box()" autocomplete="off" /> </td> </tr> <tr> <th scope="row"><?php _e('Overall rating score text.', GEODIRREVIEWRATING_TEXTDOMAIN); ?> </th> <td><?php if (get_option('geodir_reviewrating_overall_rating_texts')) { $getoratting = get_option('geodir_reviewrating_overall_rating_texts'); } if (isset($getoratting) && count($getoratting) > 0) { //$impl = implode(',',$getoratting); $impl = geodir_reviewrating_serialize_star_lables($getoratting); } ?> <input type="hidden" id="hidden-text" value="<?php echo isset($impl) ? esc_attr($impl) : ''; ?> " /> <input type="hidden" id="hidden-serialized" value="<?php echo isset($impl) && is_serialized($impl) ? 1 : 0; ?> " /> </td> <td id="overall_texts"> <?php $i = 1; if (isset($getoratting) && count($getoratting) > 0) { foreach ($getoratting as $value) { $value = esc_attr($value); $value = stripslashes_deep($value); echo $i . ' ' . __('Score text', GEODIRREVIEWRATING_TEXTDOMAIN) . ' <input class="overall_rating_text" type="text" name="overall_rating_text[]" value="' . $value . '" style="width:247px;"/><br>'; $i++; } } else { for ($k = 1; $k <= 5; $k++) { echo $k . ' ' . __('Score text', GEODIRREVIEWRATING_TEXTDOMAIN) . ' <input class="overall_rating_text" type="text" name="overall_rating_text[]" value="" style="width:247px;"><br>'; } } ?> </td> </tr> </table> <p class="submit" style="padding-left:10px; margin-bottom:10px;"> <input id="geodir_reviewrating_overall_settings" type="button" class="button-primary" value="<?php _e('Update Settings', GEODIRREVIEWRATING_TEXTDOMAIN); ?> " /> </p> </div> </div> <?php }