From 4849aee47b0c2faf753e3e4fbc40b6d5fb4fc3b0 Mon Sep 17 00:00:00 2001 From: Rachel Carden Date: Tue, 13 Sep 2016 22:13:38 -0700 Subject: [PATCH] Working on more syntax and SASS fixes --- admin-settings.php | 6 +- admin.php | 54 ++--- assets/scss/admin-options.scss | 403 ++++++++++++++++++--------------- cpt-onomies.php | 1 - cpt-onomy.php | 18 +- gulpfile.js | 2 +- languages/cpt-onomies.pot | 34 +-- manager.php | 41 ++-- 8 files changed, 300 insertions(+), 259 deletions(-) diff --git a/admin-settings.php b/admin-settings.php index e4de246..f49aeba 100644 --- a/admin-settings.php +++ b/admin-settings.php @@ -179,13 +179,13 @@ private function get_conflicting_taxonomy_terms_count( $post_type ) { } // First check both the taxonomy and terms tables together - $terms_count = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->term_taxonomy} term_tax INNER JOIN {$wpdb->terms} terms ON terms.term_id = term_tax.term_id WHERE term_tax.taxonomy = '{$post_type}' GROUP BY term_tax.term_id" ); + $terms_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->term_taxonomy} term_tax INNER JOIN {$wpdb->terms} terms ON terms.term_id = term_tax.term_id WHERE term_tax.taxonomy = %s GROUP BY term_tax.term_id", $post_type ) ); if ( $terms_count > 0 ) { return $terms_count; } // Then check just the taxonomy table - $terms_count = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->term_taxonomy} WHERE taxonomy = '{$post_type}'" ); + $terms_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->term_taxonomy} WHERE taxonomy = %s", $post_type ) ); if ( $terms_count > 0 ) { return $terms_count; } @@ -2888,7 +2888,7 @@ public function print_plugin_options_meta_box( $post, $metabox ) { $edit = $_REQUEST[ 'edit' ]; $delete_url = esc_url( add_query_arg( array( 'page' => CPT_ONOMIES_OPTIONS_PAGE, 'delete' => $edit, '_wpnonce' => wp_create_nonce( 'delete-cpt-' . $edit ) ), $this->admin_url ), 'delete-cpt-' . $edit ); ?> -

', '' ); ?>

+

', '' ); ?>

= 3.5 - it allows you to remove "show_admin_column" column via filter * < 3.5 - backwards compatibility for a little while - adds column */ - add_filter( 'manage_pages_columns', array( &$this, 'add_cpt_onomy_admin_column' ), 100, 1 ); - add_filter( 'manage_posts_columns', array( &$this, 'add_cpt_onomy_admin_column' ), 100, 2 ); + add_filter( 'manage_pages_columns', array( $this, 'add_cpt_onomy_admin_column' ), 100, 1 ); + add_filter( 'manage_posts_columns', array( $this, 'add_cpt_onomy_admin_column' ), 100, 2 ); // Define sortable columns - add_action( 'load-edit.php', array( &$this, 'add_cpt_onomy_admin_sortable_columns_filter' ) ); + add_action( 'load-edit.php', array( $this, 'add_cpt_onomy_admin_sortable_columns_filter' ) ); // Edit custom admin columns for version < 3.5 - backwards compatibility for a little while - add_action( 'manage_pages_custom_column', array( &$this, 'edit_cpt_onomy_admin_column' ), 10, 2 ); - add_action( 'manage_posts_custom_column', array( &$this, 'edit_cpt_onomy_admin_column' ), 10, 2 ); + add_action( 'manage_pages_custom_column', array( $this, 'edit_cpt_onomy_admin_column' ), 10, 2 ); + add_action( 'manage_posts_custom_column', array( $this, 'edit_cpt_onomy_admin_column' ), 10, 2 ); } @@ -567,7 +567,7 @@ public function add_cpt_onomy_meta_boxes( $post_type, $post ) { $meta_box_title = isset( $tax->meta_box_title ) && ! empty( $tax->meta_box_title ) ? $tax->meta_box_title : $tax->label; // Add the meta box - add_meta_box( 'custom-post-type-onomies-' . $taxonomy, apply_filters( 'custom_post_type_onomies_meta_box_title', $meta_box_title, $taxonomy, $post_type ), array( &$this, 'print_cpt_onomy_meta_box' ), $post_type, 'side', 'core', array( 'taxonomy' => $taxonomy ) ); + add_meta_box( 'custom-post-type-onomies-' . $taxonomy, apply_filters( 'custom_post_type_onomies_meta_box_title', $meta_box_title, $taxonomy, $post_type ), array( $this, 'print_cpt_onomy_meta_box' ), $post_type, 'side', 'core', array( 'taxonomy' => $taxonomy ) ); } @@ -1241,7 +1241,7 @@ public function add_cpt_onomy_admin_column( $columns, $post_type='page' ) { public function add_cpt_onomy_admin_sortable_columns_filter() { global $current_screen; if ( $current_screen && isset( $current_screen->id ) ) - add_filter( "manage_{$current_screen->id}_sortable_columns", array( &$this, 'add_cpt_onomy_admin_sortable_columns' ) ); + add_filter( "manage_{$current_screen->id}_sortable_columns", array( $this, 'add_cpt_onomy_admin_sortable_columns' ) ); } /** @@ -1393,7 +1393,7 @@ function display_element( $element, &$children_elements, $max_depth, $depth=0, $ } $cb_args = array_merge( array( &$output, $element, $depth ), $args ); - call_user_func_array( array( &$this, 'start_el' ), $cb_args ); + call_user_func_array( array( $this, 'start_el' ), $cb_args ); $id = $element->$id_field; @@ -1407,7 +1407,7 @@ function display_element( $element, &$children_elements, $max_depth, $depth=0, $ // Start the child delimiter $cb_args = array_merge( array( &$output, $depth ), $args ); - call_user_func_array( array( &$this, 'start_lvl' ), $cb_args ); + call_user_func_array( array( $this, 'start_lvl' ), $cb_args ); } @@ -1421,13 +1421,13 @@ function display_element( $element, &$children_elements, $max_depth, $depth=0, $ // End the child delimiter $cb_args = array_merge( array( &$output, $depth ), $args ); - call_user_func_array( array( &$this, 'end_lvl' ), $cb_args ); + call_user_func_array( array( $this, 'end_lvl' ), $cb_args ); } // End this element $cb_args = array_merge( array( &$output, $element, $depth ), $args ); - call_user_func_array( array( &$this, 'end_el' ), $cb_args ); + call_user_func_array( array( $this, 'end_el' ), $cb_args ); } } diff --git a/assets/scss/admin-options.scss b/assets/scss/admin-options.scss index 5ea7021..1be0109 100644 --- a/assets/scss/admin-options.scss +++ b/assets/scss/admin-options.scss @@ -3,8 +3,7 @@ visibility: hidden!important; } -.underline { text-decoration:underline!important; } - +.underline { text-decoration: underline!important; } .not-bold { font-weight: normal; } .gray, .gray a { color: gray; } @@ -13,52 +12,57 @@ #message, #setting-error-settings_updated { margin: 11px 0 6px 0; } -#custom-post-type-onomies .nav-tab-wrapper { - overflow: visible; - margin-bottom: 5px; - line-height: 25px; -} - -#custom-post-type-onomies .nav-tab-wrapper .label { - line-height: 28px; -} - -/* ensures that the border bottom shows up on inactive tabs */ -#custom-post-type-onomies .nav-tab-wrapper .nav-tab { - border-width: 1px; -} - -#custom-post-type-onomies .nav-tab-wrapper .etc { - float: right; - font-size: 12px; - line-height: 30px; -} - -#custom-post-type-onomies .nav-tab-wrapper .etc a { - display: inline-block; - text-decoration: none; - overflow: visible; - position: relative; - padding: 0 0 0 10px; -} - -#custom-post-type-onomies .nav-tab-wrapper .etc a:before { - content: ""; - width: 1px; - height: 10px; - background: #0074a2; - position: absolute; - left: 3px; - top: 50%; - margin-top: -5px; -} - -#custom-post-type-onomies .nav-tab-wrapper .etc a:first-child { - padding-left: 0; -} - -#custom-post-type-onomies .nav-tab-wrapper .etc a:first-child:before { - display: none; +#custom-post-type-onomies { + + .nav-tab-wrapper { + overflow: visible; + margin-bottom: 5px; + line-height: 25px; + + .label { + font-size: 13px; + line-height: 28px; + margin-left: 10px; + } + + // Ensures that the border bottom shows up on inactive tabs + .nav-tab { + border-width: 1px; + } + + .etc { + float: right; + font-size: 12px; + line-height: 30px; + + a { + display: inline-block; + text-decoration: none; + overflow: visible; + position: relative; + padding: 0 0 0 10px; + + &:before { + content: ''; + width: 1px; + height: 10px; + background: #0074a2; + position: absolute; + left: 3px; + top: 50%; + margin-top: -5px; + } + + &:first-child { + padding-left: 0; + + &:before { + display: none; + } + } + } + } + } } #tab-panel-custom_post_type_onomies_help_getting_started h3 { margin-bottom: 5px; } @@ -119,23 +123,17 @@ margin-left: 26px; } -/** - * Edit meta boxes - */ +// Edit meta boxes .custom-post-type-onomies-edit-postbox { padding: 5px 0 1px 0; } -/** - * Button meta boxes - */ +// Button meta boxes .custom-post-type-onomies-button-postbox { margin: 12px 0 0 0; } -/** - * Add new custom post type buttons. - */ +// Add new custom post type buttons .add_new_cpt_onomies_custom_post_type, #custom-post-type-onomies-save-changes, #custom-post-type-onomies-save-changes-bottom, @@ -188,13 +186,13 @@ background-color: #81021f !important; } -/* button in "Manage Custom Post Types" table */ +// Button in "Manage Custom Post Types" table table.manage_custom_post_type_onomies .add_new_cpt_onomies_custom_post_type { float: left; width: auto; } -/* save changes button at bottom of screen */ +// Save changes button at bottom of screen #custom-post-type-onomies-save-changes-bottom { margin-top: -5px; } @@ -211,9 +209,9 @@ table.manage_custom_post_type_onomies .add_new_cpt_onomies_custom_post_type { vertical-align: middle; } - .rating img { margin-right:8px; } + .rating img { margin-right: 8px; } - .inactive { color: #333; margin-top:9px; } + .inactive { color: #333; margin-top: 9px; } .attention { color: #d54e21; } .working { color: #457800; } } @@ -244,10 +242,10 @@ table.manage_custom_post_type_onomies .add_new_cpt_onomies_custom_post_type { } -/** - * Manage meta boxes - */ -.custom-post-type-onomies-manage-postbox p { margin: 10px 0 7px 0; } +// Manage meta boxes +.custom-post-type-onomies-manage-postbox p { + margin: 10px 0 7px 0; +} table.manage_custom_post_type_onomies { width: 100%; @@ -289,7 +287,8 @@ table.manage_custom_post_type_onomies td { color: #000; } -table.manage_custom_post_type_onomies tr th:last-child, table.manage_custom_post_type_onomies tr td:last-child { padding-right: 10px; } +table.manage_custom_post_type_onomies tr th:last-child, +table.manage_custom_post_type_onomies tr td:last-child { padding-right: 10px; } table.manage_custom_post_type_onomies tr:last-child td { border-bottom: 0; } table.manage_custom_post_type_onomies tr:nth-child(even) td { background: #eee; } @@ -373,9 +372,7 @@ table.manage_custom_post_type_onomies tr.add td { border: 0; } -/** - * Editing meta box - */ +// Editing meta box #custom-post-type-onomies-edit-header { display: block; background: #333; @@ -420,47 +417,59 @@ table.manage_custom_post_type_onomies tr.add td { color: #457800; border: 1px solid #c7cfbd; font-weight: bold; -} -#custom-post-type-onomies-edit-message a { color: #457800; } -#custom-post-type-onomies-edit-message.information, -#custom-post-type-onomies-edit-message.inactive { - background-image: url(../images/inactive.png); - background-color: #ddd; - color: #333; - border-color: #bbb; -} + a { + color: #457800; + } + + &.information, + &.inactive { + background-image: url(../images/inactive.png); + background-color: #ddd; + color: #333; + border-color: #bbb; -#custom-post-type-onomies-edit-message.information { background-image: url(../images/information.png); } + a { + color: #333; + } + } -#custom-post-type-onomies-edit-message.information a, -#custom-post-type-onomies-edit-message.inactive a { color: #333; } + &.information { + background-image: url(../images/information.png); + } -#custom-post-type-onomies-edit-message.attention { - background-image: url(../images/attention.png); - background-color: #f2ebe6; - color: #d54e21; - border-color: #e2caba; -} -#custom-post-type-onomies-edit-message.attention a { color: #8a2a0a; } + &.attention { + background-image: url(../images/attention.png); + background-color: #f2ebe6; + color: #d54e21; + border-color: #e2caba; -#custom-post-type-onomies-edit-message p { - margin: 0; - padding: 0 0 12px 0; - line-height: 1.2em; -} -#custom-post-type-onomies-edit-message p:first-child { padding-top: 12px; } + a { + color: #8a2a0a; + } + } -#custom-post-type-onomies-edit-message .action.button { - display: inline-block; - background: #457800; - border: 0; - color: #fff; - margin: 0 5px 0 0; -} + p { + margin: 0; + padding: 0 0 12px 0; + line-height: 1.2em; + + &:first-child { + padding-top: 12px; + } + } -#custom-post-type-onomies-edit-message.attention .action.button { - background: #d54e21; + .action.button { + display: inline-block; + background: #457800; + border: 0; + color: #fff; + margin: 0 5px 0 0; + } + + &.attention .action.button { + background: #d54e21; + } } #custom-post-type-onomies-edit-table { @@ -471,27 +480,31 @@ table.manage_custom_post_type_onomies tr.add td { padding: 10px 10px 0 10px; border: 1px solid #ddd; text-align: left; -} -#custom-post-type-onomies-edit-table table { - width: 100%; - height: auto; - background: none; - margin: 0; - padding: 0; - border: 0; -} + table { + width: 100%; + height: auto; + background: none; + margin: 0; + padding: 0; + border: 0; + } -#custom-post-type-onomies-edit-table td { - width: auto; - height: auto; - background: none; - margin: 0; - padding: 0 0 10px 0; - border: 0; - vertical-align: top; + td { + width: auto; + height: auto; + background: none; + margin: 0; + padding: 0 0 10px 0; + border: 0; + vertical-align: top; + + &.group { + padding-bottom: 0; + } + } } -#custom-post-type-onomies-edit-table td.group { padding-bottom: 0; } + #custom-post-type-onomies-edit-table table.checkbox td, #custom-post-type-onomies-edit-table table.radio td { width: 50%; @@ -505,13 +518,13 @@ table.manage_custom_post_type_onomies tr.add td { line-height: normal; padding-top: 2px; padding-right: 15px; -} -#custom-post-type-onomies-edit-table td.label .programmatically { - display: block; - font-style: italic; - font-weight: normal; - line-height: 120%; + .programmatically { + display: block; + font-style: italic; + font-weight: normal; + line-height: 120%; + } } #custom-post-type-onomies-edit-table table td.label { @@ -528,22 +541,27 @@ table.manage_custom_post_type_onomies tr.add td { padding-top: 4px; padding-bottom: 12px; line-height: 1.3em; -} -#custom-post-type-onomies-edit-table .advanced_message a { font-weight: normal; } -#custom-post-type-onomies-edit-table .advanced_message .show_advanced { - cursor: pointer; - text-decoration: underline; - color: #0074a2; -} -#custom-post-type-onomies-edit-table .advanced_message .close_advanced { - display: block; - background: url(../images/close_advanced.png) 10px center no-repeat #dbecf9; - text-align: left; - padding: 11px 10px 9px 30px; - color: #0074a2; - font-weight: bold; - cursor: pointer; - border: 1px solid #71abc6; + + a { + font-weight: normal; + } + + .show_advanced { + cursor: pointer; + text-decoration: underline; + color: #0074a2; + } + + .close_advanced { + display: block; + background: url(../images/close_advanced.png) 10px center no-repeat #dbecf9; + text-align: left; + padding: 11px 10px 9px 30px; + color: #0074a2; + font-weight: bold; + cursor: pointer; + border: 1px solid #71abc6; + } } #custom-post-type-onomies-edit-table input[type="text"], @@ -552,6 +570,7 @@ table.manage_custom_post_type_onomies tr.add td { width: 100%; margin: 0; } + #custom-post-type-onomies-edit-table input[type="text"] { padding: 3px; } #custom-post-type-onomies-edit-table input[type="checkbox"], @@ -562,42 +581,45 @@ table.manage_custom_post_type_onomies tr.add td { input#custom-post-type-onomies-custom-post-type-name.inactive { color: #666; } -#custom-post-type-onomies-edit-table span.description { +#custom-post-type-onomies-edit-table .description { display: block; - margin: 0; - padding: 2px 0 0 0; -} - -#custom-post-type-onomies-edit-table span.description .message { - display: block; - background: #DBECF9; - border: 1px solid #71abc6; - padding: 10px; - color: #000; - font-style: normal; - margin: 4px 0 5px 0; + margin: 5px 0; + padding: 0; + font-weight: 300; + + .message { + display: block; + background: #DBECF9; + border: 1px solid #71abc6; + padding: 10px; + color: #000; + font-style: normal; + margin: 4px 0 5px 0; + + a { + color: #0074a2; + } + } } -#custom-post-type-onomies-edit-table span.description .message a { color: #0074a2; } - #custom-post-type-onomies-edit-table .dismiss { position: relative; -} -#custom-post-type-onomies-edit-table .dismiss .close { - display: block; - cursor: pointer; - width: 22px; - background: #71abc6; - padding: 4px 0; - position: absolute; - right: -15px; - top: 10px; - font-size: 16px; - line-height: normal; - text-align: center; - color: #000; - text-transform: lowercase; + .close { + display: block; + cursor: pointer; + width: 22px; + background: #71abc6; + padding: 4px 0; + position: absolute; + right: -15px; + top: 10px; + font-size: 16px; + line-height: normal; + text-align: center; + color: #000; + text-transform: lowercase; + } } #custom-post-type-onomies-edit-table .reset_property { @@ -607,7 +629,7 @@ input#custom-post-type-onomies-custom-post-type-name.inactive { color: #666; } color: #0074a2; } -/* errors */ +// Errors #custom-post-type-onomies-edit-table input.error, #custom-post-type-onomies-edit-table select.error { border-color: red; } @@ -617,25 +639,32 @@ input#custom-post-type-onomies-custom-post-type-name.inactive { color: #666; } color: red; } -/** - * Thickboxes - */ +// Thickboxes table#thickbox-network-sites { width: 100%; margin: 15px 0 0 0; border: 0; padding: 0; -} -table#thickbox-network-sites th { - background: #333; - padding: 5px 0 3px 5px; - color: #fff; - font-weight: bold; -} + th { + background: #333; + padding: 5px 0 3px 5px; + color: #fff; + font-weight: bold; + } -table#thickbox-network-sites td { padding: 5px 0 4px 5px; } + td { + padding: 5px 0 4px 5px; -table#thickbox-network-sites tr:nth-child(even) td { background: #eee; } + &.blog_id { + width: 80px; + } + } + + tr:nth-child(even) { -table#thickbox-network-sites td.blog_id { width: 80px; } \ No newline at end of file + td { + background: #eee; + } + } +} \ No newline at end of file diff --git a/cpt-onomies.php b/cpt-onomies.php index 915f606..91e7d66 100644 --- a/cpt-onomies.php +++ b/cpt-onomies.php @@ -1,5 +1,4 @@ __construct(); } @@ -1168,21 +1168,25 @@ public function get_the_term_list( $id = 0, $taxonomy, $before = '', $sep = '', * This function only processes registered CPT-onomies. * If this is a normal taxonomy, then use the WordPress function. */ - if ( ! $cpt_onomies_manager->is_registered_cpt_onomy( $taxonomy ) ) + if ( ! $cpt_onomies_manager->is_registered_cpt_onomy( $taxonomy ) ) { return get_the_term_list( $id, $taxonomy, $before, $sep, $after ); + } $terms = get_the_terms( $id, $taxonomy ); - if ( is_wp_error( $terms ) ) + if ( is_wp_error( $terms ) ) { return $terms; + } - if ( empty( $terms ) ) + if ( empty( $terms ) ) { return false; + } foreach ( $terms as $term ) { $link = $this->get_term_link( $term, $taxonomy ); - if ( is_wp_error( $link ) ) + if ( is_wp_error( $link ) ) { return $link; + } $term_links[] = ''; } diff --git a/gulpfile.js b/gulpfile.js index 9d1c1f8..1048fb2 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -62,7 +62,7 @@ gulp.task('translate', function () { }); // "Sniff" the code for PHP standards -gulp.task('codesniff', function () { +gulp.task('sniff', function () { return gulp.src('**/*.php') // Validate files using PHP Code Sniffer .pipe(phpcs({ diff --git a/languages/cpt-onomies.pot b/languages/cpt-onomies.pot index 5410c16..96fce03 100644 --- a/languages/cpt-onomies.pot +++ b/languages/cpt-onomies.pot @@ -1528,7 +1528,7 @@ msgid "All user roles" msgstr "" #: admin-settings.php:2891 -msgid "Deleting your custom post type %1$2DOES NOT%2$s delete the actual posts. They'll be waiting for you if you decide to register this post type again. Just make sure you use the same name." +msgid "Deleting your custom post type %1$sDOES NOT%2$s delete the actual posts. They'll be waiting for you if you decide to register this post type again. Just make sure you use the same name." msgstr "" #: admin-settings.php:2892 @@ -1651,7 +1651,7 @@ msgstr "" msgid "Empty Term" msgstr "" -#: cpt-onomy.php:149, cpt-onomy.php:536, cpt-onomy.php:573, cpt-onomy.php:1978 +#: cpt-onomy.php:149, cpt-onomy.php:536, cpt-onomy.php:573, cpt-onomy.php:1982 msgid "Invalid Taxonomy" msgstr "" @@ -1667,63 +1667,63 @@ msgstr "" msgid "Use commas instead of %s to separate excluded categories." msgstr "" -#: cpt-onomy.php:1988 +#: cpt-onomy.php:1992 msgid "You are not allowed to assign terms for this taxonomy." msgstr "" -#: cpt-onomy.php:1996 +#: cpt-onomy.php:2000 msgid "This post type object and taxonomy are not allowed to have a relationship." msgstr "" -#: manager.php:1075 +#: manager.php:1084 msgid "Search %s" msgstr "" -#: manager.php:1076 +#: manager.php:1085 msgid "Popular %s" msgstr "" -#: manager.php:1077 +#: manager.php:1086 msgid "All %s" msgstr "" -#: manager.php:1078, manager.php:1079 +#: manager.php:1087, manager.php:1088 msgid "Parent %s" msgstr "" -#: manager.php:1080 +#: manager.php:1089 msgid "Edit %s" msgstr "" -#: manager.php:1081 +#: manager.php:1090 msgid "View %s" msgstr "" -#: manager.php:1082 +#: manager.php:1091 msgid "Update %s" msgstr "" -#: manager.php:1083 +#: manager.php:1092 msgid "Add New %s" msgstr "" -#: manager.php:1084 +#: manager.php:1093 msgid "New %s Name" msgstr "" -#: manager.php:1085 +#: manager.php:1094 msgid "Separate %s with commas" msgstr "" -#: manager.php:1086 +#: manager.php:1095 msgid "Add or remove %s" msgstr "" -#: manager.php:1087 +#: manager.php:1096 msgid "Choose from the most used %s" msgstr "" -#: manager.php:1088 +#: manager.php:1097 msgid "No %s found." msgstr "" diff --git a/manager.php b/manager.php index 06f2c9d..8d7cde0 100644 --- a/manager.php +++ b/manager.php @@ -27,7 +27,7 @@ class CPT_ONOMIES_MANAGER { public $user_settings = array( 'network_custom_post_types' => array(), 'custom_post_types' => array(), - 'other_custom_post_types' => array() + 'other_custom_post_types' => array(), ); /** @@ -60,24 +60,24 @@ public function __construct() { $this->user_settings[ 'other_custom_post_types' ] = ( $other_custom_post_types = get_option( 'custom_post_type_onomies_other_custom_post_types' ) ) ? $other_custom_post_types : array(); // Register custom query vars - add_filter( 'query_vars', array( &$this, 'register_custom_query_vars' ) ); + add_filter( 'query_vars', array( $this, 'register_custom_query_vars' ) ); // Revert the query vars - add_action( 'parse_request', array( &$this, 'revert_query_vars' ), 100 ); + add_action( 'parse_request', array( $this, 'revert_query_vars' ), 100 ); // Manage user capabilities - add_filter( 'user_has_cap', array( &$this, 'user_has_term_capabilities' ), 10, 3 ); + add_filter( 'user_has_cap', array( $this, 'user_has_term_capabilities' ), 10, 3 ); // Tweak the query - add_filter( 'request', array( &$this, 'change_query_vars' ) ); - add_action( 'pre_get_posts', array( &$this, 'add_cpt_onomy_term_queried_object' ), 1 ); - add_filter( 'posts_clauses', array( &$this, 'posts_clauses' ), 100, 2 ); + add_filter( 'request', array( $this, 'change_query_vars' ) ); + add_action( 'pre_get_posts', array( $this, 'add_cpt_onomy_term_queried_object' ), 1 ); + add_filter( 'posts_clauses', array( $this, 'posts_clauses' ), 100, 2 ); // Clean up the query - add_action( 'pre_get_posts', array( &$this, 'clean_get_posts_terms_query' ), 100 ); + add_action( 'pre_get_posts', array( $this, 'clean_get_posts_terms_query' ), 100 ); // Register custom post types and taxonomies - add_action( 'init', array( &$this, 'register_custom_post_types_and_taxonomies' ), 100 ); + add_action( 'init', array( $this, 'register_custom_post_types_and_taxonomies' ), 100 ); } public function CPT_ONOMIES_MANAGER() { $this->__construct(); } @@ -116,6 +116,7 @@ public function register_custom_query_vars( $vars ) { */ public function change_query_vars( $query ) { global $cpt_onomy, $pagenow, $post_type; + if ( isset( $query[ 'cpt_onomy_archive' ] ) && $query[ 'cpt_onomy_archive' ] ) { // Make sure CPT-onomy AND term exists, otherwise, why bother @@ -177,6 +178,7 @@ public function change_query_vars( $query ) { } // For filtering by CPT-onomy on admin edit posts screen else if ( is_admin() && $pagenow == 'edit.php' && isset( $post_type ) ) { + foreach( get_taxonomies( array(), 'objects' ) as $taxonomy => $tax ) { if ( isset( $_REQUEST[ $taxonomy ] ) && ! empty( $_REQUEST[ $taxonomy ] ) && $this->is_registered_cpt_onomy( $taxonomy ) ) { @@ -193,6 +195,7 @@ public function change_query_vars( $query ) { } } + } return $query; } @@ -364,7 +367,7 @@ public function add_cpt_onomy_term_queried_object( $query ) { * @since 1.0.3 * @uses $wpdb, $cpt_onomy * @param array $clauses - the clauses variables already created by WordPress - * @param WP_Query object $query - all of the query info + * @param WP_Query $query - all of the query info * @return array - the clauses info after it has been filtered */ public function posts_clauses( $clauses, $query ) { @@ -380,10 +383,13 @@ public function posts_clauses( $clauses, $query ) { if ( ( $taxonomies = $query->get( 'orderby' ) ) && ( $post_type = $query->get( 'post_type' ) ) ) { - // First, validate the CPT-onomy - could be multiple as array - // Make sure everyone is an array - if ( ! is_array( $taxonomies ) ) + /** + * First, validate the CPT-onomy - could be multiple as array. + * Make sure everyone is an array. + */ + if ( ! is_array( $taxonomies ) ) { $taxonomies = explode( ',', $taxonomies ); + } // Holds valid CPT-onomies $valid_cpt_onomies = array(); @@ -404,8 +410,10 @@ public function posts_clauses( $clauses, $query ) { } else { - // Check against each post type - // Let it through if it passes at least one test + /** + * Check against each post type. + * Let it through if it passes at least one test. + */ foreach( $post_type as $pt ) { // Check against post type @@ -437,10 +445,11 @@ public function posts_clauses( $clauses, $query ) { LEFT OUTER JOIN {$wpdb->posts} cpt_onomy_order_{$tax_index}_posts ON cpt_onomy_order_{$tax_index}_posts.ID = cpt_onomy_order_{$tax_index}_pm.meta_value AND cpt_onomy_order_{$tax_index}_posts.post_type = '{$taxonomy}'"; - // Orderby each CPT-onomy + // Order by each CPT-onomy if ( $new_orderby ) { $new_orderby .= ', '; } + $new_orderby .= "GROUP_CONCAT( cpt_onomy_order_{$tax_index}_posts.post_title ORDER BY cpt_onomy_order_{$tax_index}_posts.post_title ASC )" . ( ( isset( $query->query[ 'order' ] ) && strcasecmp( $query->query[ 'order' ], 'desc' ) == 0 ) ? ' DESC' : ' ASC' ) . ( ! empty( $clauses[ 'orderby' ] ) ? ', ' : ' ' ) . $clauses[ 'orderby' ]; }