Plugin Directory

Changeset 685387


Ignore:
Timestamp:
03/21/2013 09:54:39 PM (13 years ago)
Author:
Jesper800
Message:

Manage terms

Location:
bulkpress/branches/wip/manageterms
Files:
2 edited
12 copied

Legend:

Unmodified
Added
Removed
  • bulkpress/branches/wip/manageterms/bulkpress.php

    r681794 r685387  
    2222
    2323if (is_admin()) {
    24     require_once JWBP_LIBRARY_PATH . '/admin-functions.php';
     24    require_once JWBP_LIBRARY_PATH . '/admin.php';
    2525    require_once JWBP_LIBRARY_PATH . '/adminmenu.php';
    2626}
  • bulkpress/branches/wip/manageterms/lib/adminmenu.php

    r681694 r685387  
    11<?php
    2 require_once JWBP_LIBRARY_PATH . '/adminmenupage/bulkpress.php';
    3 require_once JWBP_LIBRARY_PATH . '/adminmenupage/taxonomies.php';
    4 require_once JWBP_LIBRARY_PATH . '/adminmenupage/posts.php';
     2class JWBP_AdminMenu
     3{
     4
     5    /**
     6     * Initialize
     7     * Mainly used for registering action and filter hooks
     8     */
     9    public function init()
     10    {
     11        // Pages
     12        require_once JWBP_LIBRARY_PATH . '/classes/AdminMenuPage/class.BulkPress.php';
     13        require_once JWBP_LIBRARY_PATH . '/classes/AdminMenuPage/class.Terms.php';
     14       
     15        // Tabs
     16        require_once JWBP_LIBRARY_PATH . '/classes/AdminMenuPageTab/class.AddTerms.php';
     17        require_once JWBP_LIBRARY_PATH . '/classes/AdminMenuPageTab/class.ReorganizeTerms.php';
     18       
     19        // Actions
     20        add_action('plugins_loaded', array('JWBP_AdminMenu', 'menu'));
     21    }
     22   
     23    /**
     24     * Add menu pages and tabs
     25     */
     26    public function menu()
     27    {
     28        $page = new JWBP_AdminMenuPage_BulkPress();
     29       
     30        $page = new JWBP_AdminMenuPage_Terms();
     31        $page->add_tab(new JWBP_AdminMenuPageTab_AddTerms());
     32        $page->add_tab(new JWBP_AdminMenuPageTab_ReorganizeTerms());
     33    }
     34
     35}
     36
     37JWBP_AdminMenu::init();
    538?>
  • bulkpress/branches/wip/manageterms/lib/ajax.php

    r681794 r685387  
    11<?php
    2 /**
    3  * Handle AJAX request for getting details for a taxonomy
    4  */
    5 function jwbp_ajax_get_taxonomy()
     2class JWBP_Ajax
    63{
    7     $result = array();
     4
     5    /**
     6     * Initialize
     7     * Mainly used for registering action and filter hooks
     8     */
     9    public static function init()
     10    {
     11        // Actions
     12        add_action('wp_ajax_jwbp_ajax_get_posttype', array('JWBP_Ajax', 'get_posttype'));
     13        add_action('wp_ajax_nopriv_jwbp_ajax_get_posttype', array('JWBP_Ajax', 'get_posttype'));
     14        add_action('wp_ajax_jwbp_ajax_get_taxonomy', array('JWBP_Ajax', 'get_taxonomy'));
     15        add_action('wp_ajax_nopriv_jwbp_ajax_get_taxonomy', array('JWBP_Ajax', 'get_taxonomy'));
     16    }
    817   
    9     if (isset($_POST['taxonomy']) && $_POST['taxonomy']) {
    10         $taxonomy = get_taxonomy($_POST['taxonomy']);
     18    /**
     19     * Handle AJAX request for getting details for a taxonomy
     20     */
     21    public static function get_taxonomy()
     22    {
     23        $result = array();
    1124       
    12         if (is_object($taxonomy) && $taxonomy->name) {
    13             // Add terms to result
    14             $terms_raw = get_terms($taxonomy->name, array(
    15                 'hide_empty' => false
    16             ));
     25        if (isset($_POST['taxonomy']) && $_POST['taxonomy']) {
     26            $taxonomy = get_taxonomy($_POST['taxonomy']);
    1727           
    18             $result['terms'] = array();
    19            
    20             foreach ($terms_raw as $index => $term) {
    21                 $result['terms'][] = (object) array(
    22                     'id' => $term->id,
    23                     'name' => $term->name,
    24                     'slug' => $term->slug
     28            if (is_object($taxonomy) && $taxonomy->name) {
     29                // Add terms to result
     30                $terms_raw = get_terms($taxonomy->name, array(
     31                    'hide_empty' => false
     32                ));
     33               
     34                $result['terms'] = array();
     35               
     36                foreach ($terms_raw as $index => $term) {
     37                    $result['terms'][] = (object) array(
     38                        'id' => $term->id,
     39                        'name' => $term->name,
     40                        'slug' => $term->slug
     41                    );
     42                }
     43               
     44                if ($taxonomy->hierarchical) {
     45                    $result['terms_select_html'] = wp_dropdown_categories(array(
     46                        'show_option_none' => __('No parent', 'bulkpress'),
     47                        'orderby' => 'name',
     48                        'order' => 'ASC',
     49                        'hide_empty' => false,
     50                        'taxonomy' => $taxonomy->name,
     51                        'name' => 'jwbp-addterms-topparent',
     52                        'id' => 'jwbp-addterms-topparent',
     53                        'echo' => false,
     54                        'hierarchical' => $taxonomy->hierarchical
     55                    ));
     56                }
     57                else {
     58                    $result['terms_select_html'] = '<div id="jwbp-addterms-topparent"></div>';
     59                }
     60               
     61                // Add basic taxonomy details to the result
     62                $result['taxonomy'] = (object) array(
     63                    'name' => $taxonomy->name,
     64                    'hierarchical' => $taxonomy->hierarchical
    2565                );
    2666            }
     67            else {
     68                $result = array('error' => 'unknown_taxonomy');
     69            }
     70        }
     71        else {
     72            $result = array('error' => 'missing_parameters');
     73        }
     74       
     75        echo json_encode($result);
     76       
     77        exit;
     78    }
     79   
     80    /**
     81     * Handle AJAX request for getting details for a post type
     82     */
     83    public static function get_posttype()
     84    {
     85        $result = array();
     86       
     87        if (isset($_POST['posttype']) && $_POST['posttype']) {
     88            $posttype = get_post_type_object($_POST['posttype']);
    2789           
    28             if ($taxonomy->hierarchical) {
    29                 $result['terms_select_html'] = wp_dropdown_categories(array(
    30                     'show_option_none' => __('No parent', 'bulkpress'),
    31                     'orderby' => 'name',
    32                     'order' => 'ASC',
    33                     'hide_empty' => false,
    34                     'taxonomy' => $taxonomy->name,
    35                     'name' => 'jwbp-addterms-topparent',
    36                     'id' => 'jwbp-addterms-topparent',
    37                     'echo' => false,
    38                     'hierarchical' => $taxonomy->hierarchical
    39                 ));
     90            $result['posts_select_html'] = '';
     91           
     92            if (is_object($posttype) && $posttype->name) {
     93                if ($posttype->hierarchical) {
     94                    $result['posts_select_html'] = wp_dropdown_pages(array(
     95                        'show_option_none' => __('No parent', 'bulkpress'),
     96                        'post_type' => $posttype->name,
     97                        'name' => 'jwbp-addposts-topparent',
     98                        'id' => 'jwbp-addposts-topparent',
     99                        'selected' => $_POST['jwbp-addposts-topparent'],
     100                        'echo' => false,
     101                        'post_status' => array('publish', 'draft')
     102                    ));
     103                }
     104                else {
     105                    $result['posts_select_html'] = '<div id="jwbp-addposts-topparent"></div>';
     106                }
     107               
     108                // Add basic post type details to the result
     109                $result['posttype'] = (object) array(
     110                    'name' => $posttype->name,
     111                    'hierarchical' => $posttype->hierarchical
     112                );
    40113            }
    41114            else {
    42                 $result['terms_select_html'] = '<div id="jwbp-addterms-topparent"></div>';
     115                $result = array('error' => 'unknown_posttype');
    43116            }
    44            
    45             // Add basic taxonomy details to the result
    46             $result['taxonomy'] = (object) array(
    47                 'name' => $taxonomy->name,
    48                 'hierarchical' => $taxonomy->hierarchical
    49             );
    50117        }
    51118        else {
    52             $result = array('error' => 'unknown_taxonomy');
     119            $result = array('error' => 'missing_parameters');
    53120        }
     121       
     122        echo json_encode($result);
     123       
     124        exit;
    54125    }
    55     else {
    56         $result = array('error' => 'missing_parameters');
    57     }
    58    
    59     echo json_encode($result);
    60    
    61     exit;
     126
    62127}
    63128
    64 // Actions
    65 add_action('wp_ajax_jwbp_ajax_get_taxonomy', 'jwbp_ajax_get_taxonomy');
    66 add_action('wp_ajax_nopriv_jwbp_ajax_get_taxonomy', 'jwbp_ajax_get_taxonomy');
    67 
    68 /**
    69  * Handle AJAX request for getting details for a post type
    70  */
    71 function jwbp_ajax_get_posttype()
    72 {
    73     $result = array();
    74    
    75     if (isset($_POST['posttype']) && $_POST['posttype']) {
    76         $posttype = get_post_type_object($_POST['posttype']);
    77        
    78         $result['posts_select_html'] = '';
    79        
    80         if (is_object($posttype) && $posttype->name) {
    81             if ($posttype->hierarchical) {
    82                 $result['posts_select_html'] = wp_dropdown_pages(array(
    83                     'show_option_none' => __('No parent', 'bulkpress'),
    84                     'post_type' => $posttype->name,
    85                     'name' => 'jwbp-addposts-topparent',
    86                     'id' => 'jwbp-addposts-topparent',
    87                     'selected' => $_POST['jwbp-addposts-topparent'],
    88                     'echo' => false,
    89                     'post_status' => array('publish', 'draft')
    90                 ));
    91             }
    92             else {
    93                 $result['posts_select_html'] = '<div id="jwbp-addposts-topparent"></div>';
    94             }
    95            
    96             // Add basic post type details to the result
    97             $result['posttype'] = (object) array(
    98                 'name' => $posttype->name,
    99                 'hierarchical' => $posttype->hierarchical
    100             );
    101         }
    102         else {
    103             $result = array('error' => 'unknown_posttype');
    104         }
    105     }
    106     else {
    107         $result = array('error' => 'missing_parameters');
    108     }
    109    
    110     echo json_encode($result);
    111    
    112     exit;
    113 }
    114 
    115 // Actions
    116 add_action('wp_ajax_jwbp_ajax_get_posttype', 'jwbp_ajax_get_posttype');
    117 add_action('wp_ajax_nopriv_jwbp_ajax_get_posttype', 'jwbp_ajax_get_posttype');
     129JWBP_Ajax::init();
    118130?>
  • bulkpress/branches/wip/manageterms/public/css/admin.css

    r681694 r685387  
    22/* CSS Document */
    33
     4/* General */
     5.jwbp-clear { clear: both; }
     6
     7/* Terms table */
     8.jwbp-termshierarchy li > .jwbp-container { background: #F9F9F9; }
     9.jwbp-termshierarchy > li > .jwbp-container { background: #EAF2FA; }
     10.jwbp-termshierarchy > li > ul > li > .jwbp-container { background: #F9F9F9; }
     11.jwbp-termshierarchy > li > ul > li > ul > li > .jwbp-container { background: #F3F3F3; }
     12.jwbp-termshierarchy > li > ul > li > ul > li > ul > li > .jwbp-container { background: #EDEDED; }
     13.jwbp-termshierarchy > li > ul > li > ul > li > ul > li > ul > li > .jwbp-container { background: #E7E7E7; }
     14.jwbp-termshierarchy > li > ul > li > ul > li > ul > li > ul > li > ul > li > .jwbp-container { background: #E1E1E1; }
     15.jwbp-termshierarchy > li > ul > li > ul > li > ul > li > ul > li > ul > li > ul > li > .jwbp-container { background: #DADADA; }
     16.jwbp-termshierarchy > li > ul > li > ul > li > ul > li > ul > li > ul > li > ul > li > ul > li .jwbp-container { background: #D4D4D4; }
     17.jwbp-termshierarchy > li > ul > li > ul > li > ul > li > ul > li > ul > li > ul > li > ul > li > ul > li .jwbp-container { background: #CECECE; }
     18.jwbp-termshierarchy > li > ul > li > ul > li > ul > li > ul > li > ul > li > ul > li > ul > li > ul > li > ul > li .jwbp-container { background: #C8C8C8; }
     19.jwbp-termshierarchy > li > ul > li > ul > li > ul > li > ul > li > ul > li > ul > li > ul > li > ul > li > ul > li > ul > li .jwbp-container { background: #C2C2C2; }
     20
     21.jwbp-termshierarchy { margin: 0; }
     22    .jwbp-termshierarchy ul { margin-left: 16px; }
     23    .jwbp-termshierarchy .jwbp-placeholder { outline: 1px dashed #95a8bc; }
     24    .jwbp-termshierarchy .jwbp-container { position: relative; }
     25        .jwbp-termshierarchy .jwbp-container .jwbp-drag { position: absolute; display: block; width: 30px; height: 100%; top: -1px; left: -1px; border: 1px solid #DFDFDF; border-radius: 2px 0 0 2px; border-right-color: 1px solid #999999; cursor: move; background-color: #eff4f9; }
     26
     27.jwbp-expand { position: absolute; display: block; top: 0; right: 0; width: 80px; height: 100%; z-index: 10; }
     28    .jwbp-expand span { display: block; float: right; width: 12px; height: 11px; margin: 11px 8px 11px 0; background: url('../images/expand.png') no-repeat 0 0 transparent; }
     29    .jwbp-expand:hover span { background-position: -12px 0; }
     30    .mjs-nestedSortable-expanded > .jwbp-container .jwbp-expand span { background-position: -24px 0; }
     31    .mjs-nestedSortable-expanded > .jwbp-container .jwbp-expand:hover span { background-position: -36px 0; }
     32
     33
     34.jwbp-termshierarchy li.mjs-nestedSortable-branch > .jwbp-container { box-shadow: 1px 2px 3px #BFDFFF; }
     35
     36
     37#jwbp-notice-unsavedchanges { display: none; }
     38
     39
     40
     41.jwbp-submit-top { margin: 0 0 12px 0; padding: 0; }
     42.jwbp-submit-bottom { margin: 12px 0 0 0; padding: 0; }
     43
     44
     45
     46.jwbp-termshierarchy li { margin: 4px 0 0 0; padding: 0; list-style-type: none; }
     47    .jwbp-termshierarchy li .jwbp-container { display: block; width: 100%; border: 1px solid #DFDFDF; border-radius: 2px; }
     48        .jwbp-termshierarchy li .jwbp-content { position: relative; margin: 0 0 0 31px; }
     49        .jwbp-display-comfortable li .jwbp-content { padding: 8px 30px 6px 7px; }
     50            .jwbp-display-comfortable li .jwbp-item-overlay { height: 22px; padding-top: 8px; }
     51        .jwbp-display-cozy li .jwbp-content { padding: 5px 30px 3px 5px; }
     52            .jwbp-display-cozy li .jwbp-item-overlay { height: 19px; padding-top: 5px; }
     53        .jwbp-display-compact li .jwbp-content { padding: 2px 30px 0px 3px; }
     54            .jwbp-display-compact li .jwbp-item-overlay { height: 16px; padding-top: 2px; }
     55        .jwbp-termshierarchy li .jwbp-item-overlay { display: none; position: absolute; top: 0px; left: 0px; width: 100%; padding-left: 5px; background: url('../images/helper/opacity/FFFFFF-80.png') repeat 0 0 transparent; text-align: left; }
     56            .jwbp-termshierarchy li .jwbp-item-overlay a { text-decoration: none; }
     57            .jwbp-termshierarchy li .jwbp-item-overlay span.trash a { color: #bc0b0b; }
     58            .jwbp-termshierarchy li .jwbp-item-overlay span.trash a:hover { color: #FF0000; }
     59        .jwbp-termshierarchy li .jwbp-container:hover .jwbp-item-overlay { display: block; }
     60        .jwbp-termshierarchy li .jwbp-container:hover .jwbp-content { text-align: right; }
     61    .jwbp-termshierarchy li.ui-sortable-helper > .jwbp-content { font-weight: bold; }
     62.jwbp-termshierarchy li.mjs-nestedSortable-collapsed > ul { display: none; }
     63
     64.jwbp-termshierarchy li > .jwbp-container .jwbp-content-deleted { border-color: #f2f2f2; color: #b7b7b7; background-color: #FAFCFE; }
     65    .jwbp-termshierarchy li > .jwbp-container .jwbp-content-deleted .jwbp-drag { border-color: #f2f2f2; background-color: #FBFDFE; }
     66    .jwbp-termshierarchy li > .jwbp-container .jwbp-content-deleted .jwbp-title em { font-style: italic; color: #FF8262; }
     67
     68.jwbp-termshierarchy li.jwbp-editing .jwbp-container:hover .jwbp-content { text-align: left; }
     69
     70.jwbp-termshierarchy li.jwbp-normal > .jwbp-container .jwbp-content-normal { display: block; }
     71.jwbp-termshierarchy li.jwbp-normal > .jwbp-container .jwbp-content-deleted { display: none; }
     72.jwbp-termshierarchy li.jwbp-normal > .jwbp-container .jwbp-content-edit { display: none; }
     73
     74.jwbp-termshierarchy li.jwbp-deleted > .jwbp-container .jwbp-content-normal { display: none; }
     75.jwbp-termshierarchy li.jwbp-deleted > .jwbp-container .jwbp-content-deleted { display: block; }
     76.jwbp-termshierarchy li.jwbp-deleted > .jwbp-container .jwbp-content-edit { display: none; }
     77
     78.jwbp-termshierarchy li.jwbp-editing > .jwbp-container .jwbp-content-normal { display: none; }
     79.jwbp-termshierarchy li.jwbp-editing > .jwbp-container .jwbp-content-deleted { display: none; }
     80.jwbp-termshierarchy li.jwbp-editing > .jwbp-container .jwbp-content-edit { display: block; }
     81
     82.jwbp-listdisplay { margin: 0; padding: 0; }
     83    .jwbp-listdisplay li { display: block; float: right; margin: 0 4px 0 0; padding: 0; list-style-type: none; }
     84        .jwbp-listdisplay li a { display: block; width: 32px; height: 32px; text-indent: -9999px; background-repeat: no-repeat; background-color: transparent; }
     85        .jwbp-listdisplay li a#jwbp-listdisplaytype-comfortable { background-image: url('../images/listdisplay-comfortable.png'); }
     86        .jwbp-listdisplay li a#jwbp-listdisplaytype-cozy { background-image: url('../images/listdisplay-cozy.png'); }
     87        .jwbp-listdisplay li a#jwbp-listdisplaytype-compact { background-image: url('../images/listdisplay-compact.png'); }
     88        .jwbp-listdisplay li a:hover,
     89        .jwbp-listdisplay li.current a { background-position: -32px 0; }
     90    .jwbp-listdisplay li:first-child { margin-right: 0; }
     91
     92/* Nestable sort jquery */
     93.mjs-nestedSortable-error { background: #fbe3e4; border-color: transparent; }
     94
    495/* Taxonomies */
    596.jwbp-addterms-terms td > div { margin-bottom: 10px; }
    6         .jwbp-addterms-terms td > div > div { clear: both; }
    7         .jwbp-addterms-terms td > div .description { width: 100%; }
    8             .jwbp-addterms-terms td > div .description h3 { clear: both; text-align: center; }
     97    .jwbp-addterms-terms td > div > div { clear: both; }
     98    .jwbp-addterms-terms td > div .description { width: 100%; }
     99        .jwbp-addterms-terms td > div .description h3 { clear: both; text-align: center; }
    9100    #jwbp-addterms-terms-titles-container { display: block; float: left; width: 50%; }
    10101        #jwbp-addterms-terms-titles { width: 95%; height: 250px; }
     
    15106/* Posts */
    16107.jwbp-addposts-posts td > div { margin-bottom: 10px; }
    17         .jwbp-addposts-posts td > div > div { clear: both; }
    18         .jwbp-addposts-posts td > div .description { width: 100%; }
    19             .jwbp-addposts-posts td > div .description h3 { clear: both; text-align: center; }
     108    .jwbp-addposts-posts td > div > div { clear: both; }
     109    .jwbp-addposts-posts td > div .description { width: 100%; }
     110        .jwbp-addposts-posts td > div .description h3 { clear: both; text-align: center; }
    20111    #jwbp-addposts-posts-titles-container { display: block; float: left; width: 50%; }
    21112        #jwbp-addposts-posts-titles { width: 95%; height: 250px; }
Note: See TracChangeset for help on using the changeset viewer.