WordPress.org

Plugin Directory

Changeset 646191


Ignore:
Timestamp:
12/30/12 22:56:56 (16 months ago)
Author:
eskapism
Message:

fixes for showing/hiding states

Location:
cms-tree-page-view/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • cms-tree-page-view/trunk/functions.php

    r645039 r646191  
    11<?php 
     2 
     3 
     4/** 
     5 * Example how to use action cms_tree_page_view_post_can_edit to modify if a user can edit the page/post 
     6 */ 
     7 
     8add_action("cms_tree_page_view_post_can_edit", function($can_edit, $post_id) { 
     9     
     10    if ($post_id === 163) $can_edit = FALSE; 
     11 
     12    return $can_edit; 
     13 
     14}, 10, 2); 
     15 
     16 
     17 
     18add_action("cms_tree_page_view_post_user_can_add_inside", function($can_edit, $post_id) { 
     19     
     20    if ($post_id === 233) $can_edit = FALSE; 
     21 
     22    return $can_edit; 
     23 
     24}, 10, 2); 
     25 
     26add_action("cms_tree_page_view_post_user_can_add_after", function($can_edit, $post_id) { 
     27     
     28    if ($post_id === 142) $can_edit = FALSE; 
     29 
     30    return $can_edit; 
     31 
     32}, 10, 2); 
     33 
    234 
    335/** 
     
    898930                    <span class='cms_tpv_action_add_page'><?php echo $post_type_object->labels->add_new_item ?></span> 
    899931                     
    900                     <a href="#" title='<?php _e("Add new page after", "cms-tree-page-view")?>' class='cms_tpv_action_add_page_after'><?php _e("After", "cms-tree-page-view")?></a> 
     932                    <a class='cms_tpv_action_add_page_after' href="#" title='<?php _e("Add new page after", "cms-tree-page-view")?>' ><?php _e("After", "cms-tree-page-view")?></a> 
    901933                     
    902934                    <?php 
    903935                    // if post type is hierarchical we can add pages inside 
    904936                    if (cms_tpv_is_post_type_hierarchical($post_type_object)) { 
    905                         ?><a href="#" title='<?php _e("Add new page inside", "cms-tree-page-view")?>' class='cms_tpv_action_add_page_inside'><?php _e("Inside", "cms-tree-page-view")?></a><?php 
     937                        ?><a class='cms_tpv_action_add_page_inside' href="#" title='<?php _e("Add new page inside", "cms-tree-page-view")?>' ><?php _e("Inside", "cms-tree-page-view")?></a><?php 
    906938                    } 
    907939                    // if post status = draft then we can not add pages inside because wordpress currently can not keep its parent if we edit the page 
     
    932964                            </div> 
    933965 
    934                             <div> 
     966                            <div class="cms_tpv_add_position"> 
    935967                                <?php _e("Position", "cms-tree-page-view") ?><br> 
    936968                                <label><input type="radio" name="cms_tpv_add_type" value="after"> <?php _e("After", "cms-tree-page-view") ?></label> 
     
    10171049         
    10181050        <?php 
    1019         /* 
    1020         Not so much nagging, since I'm a nice guy. 
    1021         <div class="bonny-plugins-inner-sidebar"> 
    1022             <h3>Support the author</h3> 
    1023             <p> 
    1024                 If you like this plugin you are welcome to support the author by donating: 
    1025             </p> 
    1026             <form action="https://www.paypal.com/cgi-bin/webscr" method="post" style="text-align: center"> 
    1027                 <input type="hidden" name="cmd" value="_s-xclick"> 
    1028                 <input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----MIIHXwYJKoZIhvcNAQcEoIIHUDCCB0wCAQExggEwMIIBLAIBADCBlDCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UEAxQIbGl2ZV9hcGkxHDAaBgkqhkiG9w0BCQEWDXJlQHBheXBhbC5jb20CAQAwDQYJKoZIhvcNAQEBBQAEgYArzkksMbzVWCE3kMsAGZ6xe4p6CQcaIaH3w9JF5RS6Z8PIelZw26PHvfrQUVAUCL3IecfDVU0hjDCDfvmQe16lNZSVvy57uwk20ryOTf5IJ7Ujulw1G0T0Fpc7M9Mb0FRWblgnbETeEREzRZiGZBPfI+cn9rghM1Sb3xcYGWFfujELMAkGBSsOAwIaBQAwgdwGCSqGSIb3DQEHATAUBggqhkiG9w0DBwQIZb6E5mM+R7iAgbgoPH19h/wvJIJR8lPTFEg2qb4bpstEjDo5rgjbdWEBbVp1dtFXdDCf4Nbivm5yvk2Ugf5sDsX1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5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UEAxQIbGl2ZV9hcGkxHDAaBgkqhkiG9w0BCQEWDXJlQHBheXBhbC5jb22CAQAwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOBgQCBXzpWmoBa5e9fo6ujionW1hUhPkOBakTr3YCDjbYfvJEiv/2P+IobhOGJr85+XHhN0v4gUkEDI8r2/rNk1m0GA8HKddvTjyGw/XqXa+LSTlDYkqI8OwR8GEYj4efEtcRpRYBxV8KxAW93YDWzFGvruKnnLbDAF6VR5w/cCMn5hzGCAZowggGWAgEBMIGUMIGOMQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0ExFjAUBgNVBAcTDU1vdW50YWluIFZpZXcxFDASBgNVBAoTC1BheVBhbCBJbmMuMRMwEQYDVQQLFApsaXZlX2NlcnRzMREwDwYDVQQDFAhsaXZlX2FwaTEcMBoGCSqGSIb3DQEJARYNcmVAcGF5cGFsLmNvbQIBADAJBgUrDgMCGgUAoF0wGAYJKoZIhvcNAQkDMQsGCSqGSIb3DQEHATAcBgkqhkiG9w0BCQUxDxcNMTEwMTE2MjIyNzQyWjAjBgkqhkiG9w0BCQQxFgQUiaTKjuxCgwQjZm+TAmb0/tQbdWIwDQYJKoZIhvcNAQEBBQAEgYAn4V+IMVl19uvdDieOk8Wahvy1QYm+UfdMQn8ZuHOAswJ9vYreuqcradc4EL0kWH/o2/wzPWxoT3S2fqgdrVeKm8hnsXOWcpuFYMMu9fdLCe0wak8jpzTb02gm+LfYnK/dxe5FkgmzR2HN0tAdl+xlSUUApUZ1yZsXgWe9kFKZdg==-----END PKCS7-----"> 
    1029                 <input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"> 
    1030                 <img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1"> 
    1031             </form> 
    1032  
    1033             <p style="text-align: center"> 
    1034                 <a href="http://flattr.com/thing/117882/CMS-Tree-Page-View-Plugin-for-WordPress" target="_blank"> 
    1035                 <img src="http://api.flattr.com/button/flattr-badge-large.png" alt="Flattr this" title="Flattr this" border="0" /></a> 
    1036             </p> 
    1037  
    1038             <p> 
    1039                 You can also show your appreciation  
    1040                 by giving the plugin a <a href="http://wordpress.org/extend/plugins/cms-tree-page-view/">good rating over at the plugin directory</a> 
    1041                 or blog or tweet something nice about this plugin. 
    1042             </p> 
    1043  
    1044             <h3>Support</h3> 
    1045             <p>If you have any problems with this plugins please check out the <a href="http://wordpress.org/tags/cms-tree-page-view?forum_id=10">support forum</a>.</p> 
    1046              
    1047             <h3>More CMS related plugins</h3> 
    1048             <p>These are some more plugins that enhance the CMS functionality of WordPress. Please check them out!</p> 
    1049             <ul> 
    1050                 <li><a href="http://wordpress.org/extend/plugins/admin-menu-tree-page-view/">Admin Menu Tree Page View</a></li> 
    1051                 <li><a href="http://wordpress.org/extend/plugins/simple-history/">Simple History</a></li> 
    1052                 <li><a href="http://wordpress.org/extend/plugins/simple-fields/">Simple Fields</a></li> 
    1053                 <li><a href="http://wordpress.org/extend/plugins/simple-front-end-edit-buttons/">Simple Front End Edit Buttons</a></li> 
    1054             </ul> 
    1055              
    1056              
    1057         </div> 
    1058         */ 
    1059         ?> 
    1060  
    1061         <?php 
    1062         // cms_tpv_show_annoying_box(); 
    10631051        cms_tpv_print_common_tree_stuff($post_type); 
    10641052        ?> 
     
    11511139        $screen = convert_to_screen("edit"); 
    11521140        $screen->post_type = null; 
     1141        $post_type_object = get_post_type_object($post_type); 
    11531142 
    11541143        ob_start(); // some plugins, for example magic fields, return javascript and things here. we're not compatible with that, so just swallow any output 
     
    12171206            } 
    12181207            $title = esc_html($title); 
    1219             #$title = html_entity_decode($title, ENT_COMPAT, "UTF-8"); 
    1220             #$title = html_entity_decode($title, ENT_COMPAT); 
    1221  
    1222             // can edit? 
    1223             if ( current_user_can( 'edit_page', $page_id ) ) { 
    1224                 $user_can_edit_page = true; 
    1225                 $user_can_edit_page_css = "cms_tpv_user_can_edit_page_yes"; 
     1208 
     1209            $arr_page_css_styles = array(); 
     1210            $user_can_edit_page = apply_filters("cms_tree_page_view_post_can_edit", current_user_can( $post_type_object->cap->edit_post, $page_id), $page_id); 
     1211            $user_can_add_inside = apply_filters("cms_tree_page_view_post_user_can_add_inside", current_user_can( $post_type_object->cap->edit_post, $page_id), $page_id); 
     1212            $user_can_add_after = apply_filters("cms_tree_page_view_post_user_can_add_after", current_user_can( $post_type_object->cap->edit_post, $page_id), $page_id);     
     1213 
     1214            if ( $user_can_edit_page ) { 
     1215                $arr_page_css_styles[] = "cms_tpv_user_can_edit_page_yes"; 
    12261216            } else { 
    1227                 $user_can_edit_page = false; 
    1228                 $user_can_edit_page_css = "cms_tpv_user_can_edit_page_no"; 
    1229             } 
     1217                $arr_page_css_styles[] = "cms_tpv_user_can_edit_page_no"; 
     1218            } 
     1219 
     1220            if ( $user_can_add_inside ) { 
     1221                $arr_page_css_styles[] = "cms_tpv_user_can_add_page_inside_yes"; 
     1222            } else { 
     1223                $arr_page_css_styles[] = "cms_tpv_user_can_add_page_inside_no"; 
     1224            } 
     1225 
     1226            if ( $user_can_add_after ) { 
     1227                $arr_page_css_styles[] = "cms_tpv_user_can_add_page_after_yes"; 
     1228            } else { 
     1229                $arr_page_css_styles[] = "cms_tpv_user_can_add_page_after_no"; 
     1230            } 
     1231 
     1232            $page_css = join(" ", $arr_page_css_styles); 
    12301233 
    12311234            // fetch columns 
     
    12831286                    "id": "cms-tpv-<?php echo $onePage->ID ?>", 
    12841287                    <?php /* "xtitle": "<?php _e("Click to edit. Drag to move.", 'cms-tree-page-view') ?>", */ ?> 
    1285                     "class": "<?php echo $user_can_edit_page_css ?>" 
     1288                    "class": "<?php echo $page_css ?>" 
    12861289                }, 
    12871290                <?php echo $strState ?> 
     
    13001303                    "columns": <?php echo $str_columns ?>, 
    13011304                    "user_can_edit_page": "<?php echo (int) $user_can_edit_page ?>", 
     1305                    "user_can_add_page_inside": "<?php echo (int) $user_can_add_inside ?>", 
     1306                    "user_can_add_page_after": "<?php echo (int) $user_can_add_after ?>", 
    13021307                    "post_title": "<?php echo $title ?>" 
    13031308                } 
  • cms-tree-page-view/trunk/readme.txt

    r645039 r646191  
    105105== Changelog == 
    106106 
     107= 1.2.x = 
     108- Hide "inside" link if post type is draft, since you can't create new post inside a page with status draft (limitation/bug with Wordpress) 
     109-  
     110 
    107111= 1.2.1 = 
    108112- Fixed wrong count if WPML where activated and future or private posts existed for a language 
  • cms-tree-page-view/trunk/scripts/cms_tree_page_view.js

    r644827 r646191  
    447447            var editlink = $li.data("editlink"); 
    448448            $edit.attr("href", editlink); 
     449            $edit.removeClass("hidden"); 
    449450 
    450451            // ..and some extras 
     
    460461            div_actions_for_post_type.data("post_id", $li.data("post_id")); 
    461462             
     463 
     464            // check permissions, may the current user add page, after or inside 
     465            // If page has status draft then no one is allowed to add page inside 
     466            // div_actions_for_post_type.find(".cms_tpv_action_add_page_inside, .cms_tpv_action_add_page_inside").show(); 
     467            div_actions_for_post_type.find(".cms_tpv_action_add_page_inside, .cms_tpv_action_add_page_inside").removeClass("hidden"); 
     468             
     469            var inside_allowed = true; 
     470            if ("draft" === $li.data("post_status")) { 
     471                inside_allowed = false; 
     472            } 
     473 
     474            if (!inside_allowed) { 
     475                //div_actions_for_post_type.find(".cms_tpv_action_add_page_inside").hide(); 
     476            } 
     477 
     478 
    462479            // position and show action div 
    463480            var $a = $li.find("a"); 
     
    486503            // check if user is allowed to edit page 
    487504            var $cms_tpv_action_add_and_edit_page = div_actions_for_post_type.find(".cms_tpv_action_add_and_edit_page"); 
     505            //$cms_tpv_action_add_and_edit_page.show(); 
     506 
     507            // console.log( $li.data("user_can_edit_page") ); 
     508            // console.log( $li.data("user_can_add_page_inside") ); 
     509            // console.log( $li.data("user_can_add_page_after") ); 
     510            div_actions_for_post_type.addClass("cms_tpv_page_actions_visible"); 
     511 
    488512            if ($li.data("user_can_edit_page") === "0") { 
    489                 // nooope 
    490                 $edit.hide(); 
    491                 $cms_tpv_action_add_and_edit_page.hide(); 
    492             } else { 
    493                 //$edit.show(); 
    494                 $cms_tpv_action_add_and_edit_page.show(); 
    495                 div_actions_for_post_type.addClass("cms_tpv_page_actions_visible"); 
    496             } 
    497              
     513                $edit.addClass("hidden"); 
     514            } 
     515 
     516 
     517            $cms_tpv_add_position = div_actions_for_post_type.find(".cms_tpv_add_position"); 
     518 
     519            $cms_tpv_action_add_page_after = div_actions_for_post_type.find(".cms_tpv_action_add_page_after"); 
     520            $cms_tpv_action_add_page_after.removeClass("hidden"); 
     521            //$cms_tpv_action_add_page_after.show(); 
     522            if ($li.data("user_can_add_page_after") === "0") { 
     523                $cms_tpv_action_add_page_after.addClass("hidden"); 
     524            } 
     525 
     526            $cms_tpv_action_add_page_inside = div_actions_for_post_type.find(".cms_tpv_action_add_page_inside"); 
     527            $cms_tpv_action_add_page_inside.removeClass("hidden"); 
     528            if ($li.data("user_can_add_page_inside") === "0") { 
     529                $cms_tpv_action_add_page_inside.addClass("hidden"); 
     530            } 
    498531 
    499532        } 
  • cms-tree-page-view/trunk/styles/styles.css

    r644827 r646191  
    298298} 
    299299.cms_tpv_wrapper .cms_tpv_page_actions a { 
    300     display: inline; 
    301300    background: transparent; 
    302301    text-decoration: underline; 
     
    305304    padding: 0 .5em 0 0; 
    306305    margin-right: .2em; 
     306} 
     307 
     308.cms_tpv_wrapper .cms_tpv_page_actions .cms_tpv_action_edit_and_view a { 
    307309    border-right: 1px solid #aaa; 
    308310} 
    309 .cms_tpv_wrapper .cms_tpv_page_actions a:last-child { 
    310     border: none; 
    311 } 
    312  
    313 .cms_tpv_wrapper .cms_tpv_page_actions a:hover 
    314  { 
     311 
     312.cms_tpv_wrapper .cms_tpv_page_actions .cms_tpv_action_edit_and_view a:not(.hidden):last-of-type { 
     313    border-right: none; 
     314} 
     315 
     316.cms_tpv_wrapper .cms_tpv_page_actions a:hover { 
    315317    color: #d54e21; 
    316318    background-color: transparent; 
     319} 
     320 
     321/* applied to all (aka "first") */ 
     322.cms_tpv_wrapper .cms_tpv_page_actions .cms_tpv_action_add_and_edit_page a:not(.hidden) { 
     323    /*background: red;*/ 
     324    padding: 0; 
     325    margin: 0; 
     326} 
     327/* tricky way to get non first not hidden */ 
     328.cms_tpv_wrapper .cms_tpv_page_actions .cms_tpv_action_add_and_edit_page a:not(.hidden) ~ a:not(.hidden) { 
     329    /*background: yellow;*/ 
     330    border-left: 1px solid #aaa; 
     331    padding-left: .5em; 
     332    margin-left: .2em; 
    317333} 
    318334 
Note: See TracChangeset for help on using the changeset viewer.