Changeset 861421
- Timestamp:
- 02/20/2014 06:01:14 AM (12 years ago)
- Location:
- custom-post-order-category/trunk
- Files:
-
- 2 edited
-
readme.txt (modified) (2 diffs)
-
wp-customcategorypostorder.php (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
custom-post-order-category/trunk/readme.txt
r715464 r861421 44 44 Now post of Uncategorized can be ordered. 45 45 46 = 1.5.4 = 47 Resolved some internal issue 46 48 47 49 … … 57 59 now custom post type and categories both can be ordered. 58 60 61 = 1.5.4 = 62 Resolved some internal issue 63 64 59 65 == Arbitrary section 1 == -
custom-post-order-category/trunk/wp-customcategorypostorder.php
r793487 r861421 8 8 Plugin Name: Custom Category Post Order 9 9 Description: Arrange Post through drag n drop interface of selected category and post type. 10 Author: Faaiq Ahmed, Sr Wordpress Developer,[email protected]10 Author: Faaiq Ahmed, Technical Architect PHP, [email protected] 11 11 Version: 1.5.4 12 12 */ … … 23 23 add_action('wp_ajax_build_order', array($this,'build_order_callback')); 24 24 add_action( 'save_post', array($this,'ccpo_update_post_order' )); 25 add_action('admin_head', array($this,'admin_load_js')); 25 26 26 27 add_action('wp_ajax_user_ordering', array($this,'user_ordering')); … … 32 33 register_activation_hook(__FILE__, array($this,'ccpo_install')); 33 34 register_deactivation_hook(__FILE__, array($this,'ccpo_uninstall')); 35 } 36 37 function admin_load_js() { 38 $url = plugins_url(); 34 39 } 35 40 … … 144 149 145 150 $sql = "select * from ".$wpdb->prefix."ccpo_post_order_rel where category_id = '$category' order by weight"; 146 $order_result = $wpdb->get_results($sql);151 $order_result = $wpdb->get_results($sql); 147 152 148 153 for($k = 0 ;$k < count($order_result); ++$k) { … … 209 214 210 215 if($category != '' ) { 211 print '<th scope="row"> Use Ordering for selected Category/Post Type:</th>216 print '<th scope="row">Enable Ordering:</th> 212 217 <td><input type="checkbox" name="category_ordering" rel="'.$category.'" id="user_ordering_category" value="1" '.$checked.'></td> 213 218 </tr>'; … … 215 220 216 221 print '<tr valign="top"><td colspan="2"> 217 <input type="submit" class="button" value="Load Posts"/>222 <input type="submit" class="button button-primary" value="Load Posts" id="Load_Posts"/> 218 223 <br> 219 <small>Note: Initially some post will not display remove or add link. to resolve this case move any post up or down and press load posts button again.</small>224 <small>Note: Initially some post may display without remove or add link. To resolve this issue please move any post up or down and press load posts button again.</small> 220 225 </td></tr> 221 226 </table>'; 222 223 $html = '<ul id="sortable" style="width:100%;">';227 $html = '<div id="sortablewrapper">'; 228 $html .= '<ul id="sortable" class="sortableul">'; 224 229 225 230 for($i = 0; $i < count( $order_result); ++$i) { … … 237 242 if($checked == "checked") { 238 243 if($total >0 ) { 239 $html .= '<li class="sortable" id="'.$post->ID.'" rel="'.$post->ID.'" >';240 $html .= '<div id="post" class="drag_post">'.$post->post_title.'<div style="float:right;border:0px solid;width:50px;" id="id_'.$post->ID.'">'.$edit.'</div></div>';244 $html .= '<li class="sortable" id="'.$post->ID.'" rel="'.$post->ID.'" post_title="'.$post->post_title.'">'; 245 $html .= '<div id="post" class="drag_post">'.$post->post_title.'<div class="ar_link" id="id_'.$post->ID.'">'.$edit.'</div></div>'; 241 246 } 242 247 }else { 243 $html .= '<li class="sortable" id="'.$post->ID.'" rel="'.$post->ID.'" >';244 $html .= '<div id="post" class="drag_post">'.$post->post_title.'<div style="float:right;border:0px solid;width:50px;"id="id_'.$post->ID.'">'.$edit.'</div></div>';248 $html .= '<li class="sortable" id="'.$post->ID.'" rel="'.$post->ID.'" post_title="'.$post->post_title.'">'; 249 $html .= '<div id="post" class="drag_post">'.$post->post_title.'<div class="ar_link" id="id_'.$post->ID.'">'.$edit.'</div></div>'; 245 250 } 246 251 $html .= '</li>'; … … 251 256 $post = $temp_order_post; 252 257 $total = $this->check_order_table($post->ID,$category); 253 $html .= '<li class="sortable" id="'.$post->ID.'" rel="'.$post->ID.'" >';254 $html .= '<div id="post" class="drag_post">'.$post->post_title.'<div style="float:right;border:0px solid;width:50px;"></div></div>';258 $html .= '<li class="sortable" id="'.$post->ID.'" rel="'.$post->ID.'" post_title="'.$post->post_title.'">'; 259 $html .= '<div id="post" class="drag_post">'.$post->post_title.'<div class="ar_link" ></div></div>'; 255 260 $html .= '</li>'; 256 261 } 257 262 258 263 $html .= '</ul>'; 264 $html .= '</div>'; 259 265 print $html; 260 266 … … 265 271 </div>'; 266 272 print '<style> 273 #sortablewrapper { 274 width:95%; 275 border:1px solid #c1e2b3; 276 padding:20px; 277 border-radius:5px; 278 } 279 .sortableul { 280 width:100% !important; 281 282 } 283 .ar_link { 284 float:right; 285 width:50px; 286 text-decoration:none; 287 color:#a94442; 288 } 289 290 .ar_link a { 291 text-decoration:none; 292 color:#a94442; 293 font-size:12px; 294 } 295 267 296 .drag_post { 268 border:1px solid #cccccc;;297 border:1px dashed #245269; 269 298 background:#F1F1F1; 270 299 padding:5px; 300 padding-right:15px; 301 width:100%; 302 font-size:14px; 303 } 304 .drag_post:hover { 305 cursor:crosshair; 271 306 } 272 307 #sortable { list-style-type: none; margin: 0; padding: 0; width: 60%; } … … 285 320 286 321 }, 322 sort: function (event, ui) { 323 324 325 326 }, 327 stop: function (event, ui) { 328 329 330 }, 287 331 change: function (event, ui) { 288 332 … … 293 337 var category = jQuery("#category").attr("value"); 294 338 jQuery.post(\'admin-ajax.php\', {order:newOrder,category:category,action:\'build_order\'}); 339 295 340 } 296 341 }); … … 363 408 $total = $wpdb->get_var("select count(*) as total from ".$wpdb->prefix."ccpo_post_order_rel where category_id = '$category'"); 364 409 365 if($total == 0) { 410 if($total == 0) { //executes when there is not date for selected category 366 411 foreach($order as $post_id) { 367 412 ++$weight; … … 396 441 if($exists > 0) { 397 442 $sql = "update ".$wpdb->prefix."ccpo_post_order_rel set post_id = '$post_id',incl = '$incl' where id = '$id'"; 398 //$wpdb->query($sql);443 $wpdb->query($sql); 399 444 }else { 400 445 $sql = "insert into ".$wpdb->prefix."ccpo_post_order_rel set category_id = '$category' ,post_id = '$post_id', incl = '0'"; 401 //$wpdb->query($sql);446 $wpdb->query($sql); 402 447 } 403 448 }
Note: See TracChangeset
for help on using the changeset viewer.