Plugin Directory

Changeset 861421


Ignore:
Timestamp:
02/20/2014 06:01:14 AM (12 years ago)
Author:
faaiq
Message:

faaiq, fix some issues

Location:
custom-post-order-category/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • custom-post-order-category/trunk/readme.txt

    r715464 r861421  
    4444Now post of Uncategorized can be ordered.
    4545
     46= 1.5.4 =
     47Resolved some internal issue
    4648
    4749
     
    5759now custom post type and categories both can be ordered.
    5860
     61= 1.5.4 =
     62Resolved some internal issue
     63
     64
    5965== Arbitrary section 1 ==
  • custom-post-order-category/trunk/wp-customcategorypostorder.php

    r793487 r861421  
    88Plugin Name: Custom Category Post Order
    99Description: Arrange Post through drag n drop interface of selected category and post type.
    10 Author: Faaiq Ahmed, Sr Wordpress Developer,[email protected]
     10Author: Faaiq Ahmed, Technical Architect PHP, [email protected]
    1111Version: 1.5.4
    1212*/
     
    2323            add_action('wp_ajax_build_order', array($this,'build_order_callback'));
    2424            add_action( 'save_post', array($this,'ccpo_update_post_order' ));
     25            add_action('admin_head', array($this,'admin_load_js'));
    2526           
    2627            add_action('wp_ajax_user_ordering', array($this,'user_ordering'));
     
    3233            register_activation_hook(__FILE__, array($this,'ccpo_install'));
    3334            register_deactivation_hook(__FILE__, array($this,'ccpo_uninstall'));
     35    }
     36   
     37    function admin_load_js() {
     38        $url = plugins_url();
    3439    }
    3540   
     
    144149       
    145150     $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);
    147152       
    148153        for($k = 0 ;$k < count($order_result); ++$k) {
     
    209214       
    210215        if($category != '' ) {
    211                 print '<th scope="row">Use Ordering for selected Category/Post Type:</th>
     216                print '<th scope="row">Enable Ordering:</th>
    212217                <td><input type="checkbox" name="category_ordering" rel="'.$category.'" id="user_ordering_category" value="1" '.$checked.'></td>
    213218                </tr>';
     
    215220       
    216221        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"/>
    218223        <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>
    220225        </td></tr>
    221226        </table>';
    222        
    223         $html = '<ul id="sortable" style="width:100%;">';
     227        $html = '<div id="sortablewrapper">';
     228        $html .= '<ul id="sortable" class="sortableul">';
    224229
    225230        for($i = 0; $i < count( $order_result); ++$i) {
     
    237242            if($checked == "checked") {
    238243                 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>';
    241246                 }
    242247            }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>';
    245250            }
    246251            $html .= '</li>';
     
    251256            $post = $temp_order_post;
    252257            $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>';
    255260            $html .= '</li>';
    256261        }
    257262       
    258263        $html .= '</ul>';
     264        $html .= '</div>';
    259265        print $html;
    260266       
     
    265271        </div>';
    266272        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           
    267296            .drag_post {
    268                  border:1px solid #cccccc;;
     297                 border:1px dashed #245269;
    269298                 background:#F1F1F1;
    270299                 padding:5px;
     300                 padding-right:15px;
     301                 width:100%;
     302                 font-size:14px;
     303            }
     304            .drag_post:hover {
     305                 cursor:crosshair;
    271306            }
    272307      #sortable { list-style-type: none; margin: 0; padding: 0; width: 60%; }
     
    285320               
    286321            },
     322            sort: function (event, ui) {
     323                         
     324                           
     325               
     326            },
     327                        stop: function (event, ui) {
     328                         
     329               
     330            },                     
    287331            change:  function (event, ui) {
    288332               
     
    293337                         var category = jQuery("#category").attr("value");
    294338                     jQuery.post(\'admin-ajax.php\', {order:newOrder,category:category,action:\'build_order\'});
     339                         
    295340                        }
    296341       });
     
    363408    $total = $wpdb->get_var("select count(*) as total from ".$wpdb->prefix."ccpo_post_order_rel where category_id = '$category'");
    364409   
    365     if($total == 0) {
     410    if($total == 0) { //executes when there is not date for selected category
    366411        foreach($order as $post_id) {
    367412                ++$weight;
     
    396441                if($exists > 0) {
    397442                    $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);
    399444                }else {
    400445                    $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);
    402447                }
    403448        }   
Note: See TracChangeset for help on using the changeset viewer.