diff --git a/addons/grouping/bootstrap.php b/addons/grouping/bootstrap.php new file mode 100644 index 00000000..f8d09952 --- /dev/null +++ b/addons/grouping/bootstrap.php @@ -0,0 +1,17 @@ +=5.6", + "composer/installers": "v1.0.6" + }, + "autoload": { + "psr-4": {"OrganizeSeries\\GroupingAddon\\": "src/"} + } +} diff --git a/addons/grouping/composer.lock b/addons/grouping/composer.lock new file mode 100644 index 00000000..792be788 --- /dev/null +++ b/addons/grouping/composer.lock @@ -0,0 +1,98 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "e9b3436036ef0e93945c8c39e35e0299", + "packages": [ + { + "name": "composer/installers", + "version": "v1.0.6", + "source": { + "type": "git", + "url": "https://github.com/composer/installers.git", + "reference": "b3bd071ea114a57212c75aa6a2eef5cfe0cc798f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/installers/zipball/b3bd071ea114a57212c75aa6a2eef5cfe0cc798f", + "reference": "b3bd071ea114a57212c75aa6a2eef5cfe0cc798f", + "shasum": "" + }, + "replace": { + "shama/baton": "*" + }, + "require-dev": { + "composer/composer": "1.0.*@dev", + "phpunit/phpunit": "3.7.*" + }, + "type": "composer-installer", + "extra": { + "class": "Composer\\Installers\\Installer", + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-0": { + "Composer\\Installers\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Kyle Robinson Young", + "email": "kyle@dontkry.com", + "homepage": "https://github.com/shama", + "role": "Developer" + } + ], + "description": "A multi-framework Composer library installer", + "homepage": "http://composer.github.com/installers/", + "keywords": [ + "TYPO3 CMS", + "TYPO3 Flow", + "TYPO3 Neos", + "agl", + "cakephp", + "codeigniter", + "drupal", + "fuelphp", + "installer", + "joomla", + "kohana", + "laravel", + "li3", + "lithium", + "mako", + "modulework", + "phpbb", + "ppi", + "silverstripe", + "symfony", + "wordpress", + "zend" + ], + "support": { + "issues": "https://github.com/composer/installers/issues", + "source": "https://github.com/composer/installers/tree/master" + }, + "time": "2013-08-20T04:37:09+00:00" + } + ], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "php": ">=5.6" + }, + "platform-dev": [], + "plugin-api-version": "2.0.0" +} diff --git a/addons/grouping/info.json b/addons/grouping/info.json new file mode 100644 index 00000000..0325835f --- /dev/null +++ b/addons/grouping/info.json @@ -0,0 +1 @@ +{"versionFile":"organize-series-grouping.php","slug":"organize-series-grouping","textDomain":"organize-series-grouping","name":"PublishPress Series Grouping","releaseFilesRemove":["src\/tests\/**","src\/acceptance_tests\/**","src\/docs\/**","src\/info.json","src\/readme.txt","src\/wp-assets\/**","src\/.travis.yml","src\/ISSUE_TEMPLATE.md","src\/PULL_REQUEST_TEMPLATE.md","src\/assets\/src\/**"],"wpOrgRelease":"2.2.6"} \ No newline at end of file diff --git a/addons/grouping/js/series-groups.js b/addons/grouping/js/series-groups.js new file mode 100644 index 00000000..eacf2bbf --- /dev/null +++ b/addons/grouping/js/series-groups.js @@ -0,0 +1,47 @@ +jQuery(document).ready(function($) { + $('#the-list').on('click', '.editinline', function() { + var id, type, editRowData, rowData, group_check, group_text; + var r_id = inlineEditTax.getId(this); + type = $('#the-list').attr('data-wp-lists').substr(5); + rowData = $('#inline_group_'+r_id); + id = $('series_group_id', rowData).text(); + $('#hidden_group_id', 'div.inline_edit_group_old').remove(); + $('div.inline_edit_group_old').attr('class', 'inline_edit_group_'); + $('div.inline_edit_group_').attr('class', 'inline_edit_group_'+id); + editRowData = $('.inline_edit_group_'+id); + /*editRow = $('#inline-edit').clone(true);*/ + + if ( type == 'tag' ) { + group_check = $('.group_inline_edit', rowData).text(); + group_text = $('.group_inline_name', rowData).text(); + + if ( group_check === '' ) { + group_check = -1; + } + + $('.group_inline_edit', rowData).each(function() { + if ( term_ids = $(this).text() ) + { + taxname = 'category'; + + $('ul.'+taxname+'-checklist :checkbox', editRowData).val(term_ids.split(',')); + + } + }); + + } + + $('span.catshow').click(function() { + $(this).hide().next().show().parent().next().addClass("cat-hover"); + }); + + $('span.cathide').click(function() { + $(this).hide().prev().show().parent().next().removeClass("cat-hover"); + }); + $(editRowData).attr('class', 'inline_edit_group_old'); + }); + + var series_filter = $('#series_group_filter'); + + $('.col-wrap', '#col-right').prepend(series_filter); +}); \ No newline at end of file diff --git a/addons/grouping/legacy-includes.php b/addons/grouping/legacy-includes.php new file mode 100644 index 00000000..e6fd11fb --- /dev/null +++ b/addons/grouping/legacy-includes.php @@ -0,0 +1,650 @@ +series_load_theme_css(); + } + return $template; +} + +function orgseries_upgrade_check() { + global $orgseries_groups_ver; + //below is where I will indicate any upgrade routines that need to be run + $version_check = get_option('orgseries_grouping_version'); + if ( !$version_check ) { //this may be the first time orgseries is used + if ( $is_imported = get_option('orgseries_grouping_import_completed') ) // we know a version 1.5 and earlier was previously installed (before we saved version numbers) - update needed + upgrade_orgseries_grouping_from_one_five(); + add_option('orgseries_grouping_version', $orgseries_groups_ver); + add_option('orgser_grp_upgrade_'.$orgseries_groups_ver); + return; + } + + orgseries_grouping_upgrade($orgseries_groups_ver, $version_check); + + update_option('orgseries_grouping_version', $orgseries_groups_ver); +} + +/* +* +* This is the function for doing any upgrades necessary +*/ + +function orgseries_grouping_upgrade($this_version, $old_version) { + global $wpdb; + + if ( $old_version == '1.6' ) { + //let's fix up any potential errors in the database from a bad 1.5-1.6 import + //First up is a fix for object_id == 0; + $object_id = 0; + $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->term_relationships WHERE object_id = %d", $object_id) ); + + //next up is reset the term_counts for all series_groups so they are correct. + $args = array( + 'hide_empty' => false, + 'fields' => 'ids' + ); + + $groups = get_series_groups($args); + $groups = array_map('intval', $groups); + $groups = implode(', ',$groups); + $query = "SELECT term_taxonomy_id FROM $wpdb->term_taxonomy WHERE term_id IN ( $groups ) AND taxonomy = 'series_group'"; + $terms = $wpdb->get_results( $query ); + while ( $group = array_shift($terms) ) + $_groups[] = $group->term_taxonomy_id; + $series_groups = $_groups; + update_series_group_count($series_groups, 'series_group'); + exit; + return true; + } + return true; +} + +function upgrade_orgseries_grouping_from_one_five() { + //if ( !taxonomy_exists('series_group') ) + //orgseries_grouping_taxonomy(); + + //let's get all the existing Series Categories in the old category system + $args = array( + 'hide_empty' => false, + 'fields' => 'ids', + 'taxonomy' => 'category' + ); + + + $old_groups = get_old_series_groups($args); //list of category ids that are groups + + $args_b = array( + 'include' => $old_groups, + 'hide_empty' => false + ); + + $_old_groups = get_terms('category', $args_b); //need to do this in order to get the description field. + + $args_c = array( + 'hide_empty' => false, + 'taxonomy' => 'category' + ); + + //let's set up the new groups in the new taxonomy system + if ( empty($_old_groups) ) return; + foreach ( $_old_groups as $new_group ) { + wp_insert_term( + $new_group->name, + 'series_group', + array( + 'description' => $new_group->description, + 'slug' => $new_group->slug + ) + ); + + //let's get the series from the old groups, add to the new taxonomy, and then remove them from the old groups. We'll leave the old groups (categories) in case there are regular posts added to them. + $get_series = get_series_in_group($new_group->term_id, $args_c); + $ser_term_id = (int) $new_group->term_id; + + if ( empty($get_series) ) continue; + foreach ( $get_series as $serial ) { + $id = orgseries_group_id($serial); + + $post_arr = array( + 'ID' => $id, + 'post_status' => 'publish', + ); + wp_update_post($post_arr); + wp_set_object_terms($id, $ser_term_id, 'series_group', true); + } + } + + $group_ids = get_objects_in_term( $old_groups, 'category', array( 'hide_empty' => false)); + + if ( empty($group_ids) ) return; + foreach ($group_ids as $p_id) { + wp_delete_object_term_relationships($p_id,'category'); + } +} + +function orgseries_grouping_posttype() { + global $checkpage, $_GET; + $args = array( + 'description' => 'Used for associating Series with series categoriess', + 'public' => false, + 'public_queryable' => true, + 'taxonomies' => array('category', 'series_group'), + 'rewrite' => array('slug' => 'seriesgroup') + ); + + register_post_type('series_grouping', $args); + + if ( 'edit-tags.php' == $checkpage && ( isset($_GET['taxonomy']) && ppseries_get_series_slug() == $_GET['taxonomy'] ) ) { + require_once(ABSPATH.'wp-admin/includes/meta-boxes.php'); + add_action('quick_edit_custom_box', 'orgseries_group_inline_edit', 9,3); + + } + +} + +function orgseries_grouping_taxonomy() { + $permalink_slug = 'series_group'; + $object_type = array('series_grouping'); + $capabilities = array( + 'manage_terms' => 'manage_series', + 'edit_terms' => 'manage_series', + 'delete_terms' => 'manage_series', + 'assign_terms' => 'manage_series' + ); + $labels = array( + 'name' => _x('Series Categories', 'taxonomy general name', 'organize-series'), + 'singular_name' => _x('Series Category', 'taxonomy singular name', 'organize-series'), + 'search_items' => __('Search Series Categories', 'organize-series'), + 'popular_items' => __('Popular Series Categories', 'organize-series'), + 'all_items' => __('All Series Categories', 'organize-series'), + 'edit_item' => __('Edit Series Category', 'organize-series'), + 'update_item' => __('Update Series Category', 'organize-series'), + 'add_new_item' => __('Add New Series Category', 'organize-series'), + 'new_item_name' => __('New Series Category', 'organize-series'), + 'menu_name' => __('Series Categories', 'organize-series') + ); + $args = array( + 'update_count_callback' => 'update_series_group_count', + 'labels' => $labels, + 'rewrite' => array( 'slug' => $permalink_slug, 'with_front' => true ), + 'show_ui' => true, + 'public' => true, + 'capabilities' => $capabilities, + 'query_var' => 'series_group', + 'hierarchical' => true + ); + register_taxonomy( 'series_group', $object_type, $args ); +} + +function update_series_group_count($terms, $taxonomy) { + global $wpdb; + if ( !is_array($terms) ) $terms = (array) $terms; + $terms = array_map('intval', $terms); + $taxonomy = 'series_group'; + foreach ( (array) $terms as $term) { + $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term) ); + $wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $term ) ); + } + + clean_term_cache($terms, '', false); + return true; +} + + +function orgseries_grouping_import_existing_series() { + //do a check to see if there are existing series and NO existing posts in the 'series_grouping' post_type. If this is the case then we need to do the import. If not, then we break out. + if ( !($is_imported = get_option('orgseries_grouping_import_completed')) ) { + $series = get_terms( ppseries_get_series_slug(), array('hide_empty'=>false, 'fields' => 'ids') ); + + foreach ( $series as $this_series ) { + $post_args = array( + 'post_type' => 'series_grouping', + 'to_ping' => 0, + 'post_title' => 'series_grouping_'.$this_series, + 'post_name' => 'series_grouping_'.$this_series + ); + wp_insert_post($post_args); + } + add_option('orgseries_grouping_import_completed','1'); + + } +} + +function orgseries_groups_admin_menu() { + add_submenu_page( 'edit.php', 'Series Categories', 'Series Categories', 'manage_series', 'edit-tags.php?taxonomy=series_group'); +} + +function orgseries_group_add_queryvars($qvs) { + $qvs[] = 'series_group'; + return $qvs; +} + +function orgseries_group_parsequery() { + global $wp_query; + if ( isset($wp_query->query_vars['series_group']) ) { + $wp_query->is_series_group = true; + } else { + $wp_query->is_series_group = false; + } +} + +function orgseries_group_where($where) { + global $wpdb, $wp_query; + if ( $wp_query->is_series_group && is_admin() ) { + $series_group = $wp_query->query_vars['series_group']; + $series_array = get_series_in_group($series_group); + $series_string = implode(",", $series); + $where .= " AND t.term_id IN ({$series_string})"; + } + return $where; +} + +function orgseries_manage_grouping_filter_setup() { + global $_GET, $wp_version; + if ( !empty($_GET['ser_grp']) && is_admin() && $wp_version >= 3.1 ) { + add_filter('get_terms_args', 'orgseries_grp_term_filter', 10, 2); + } +} + +function orgseries_grp_term_filter($args, $taxonomies) { + global $_GET; + if ( in_array(ppseries_get_series_slug(), $taxonomies) ) { + $group_id = (int) $_GET['ser_grp']; + $series_array = get_series_in_group($group_id); + $args['include'] = $series_array; + } + return $args; +} + +function orgseries_manage_grouping_columns() { + global $wp_version; + //hook into manage-series-groups page + add_filter('manage_edit-series_group_columns', 'series_grouping_columns', 10); + add_filter('manage_series_group_custom_column', 'series_grouping_columns_inside',1,3); + add_filter('manage_edit-series_group_sortable_columns', 'series_group_sortable_columns'); + if ($wp_version >= '3.1') + add_action('after-series-table', 'select_series_group_filter'); +} + +function orgseries_grouping_settings_setup() { + //add_settings_field('series_grouping_delete_settings','Series Categories Addon Settings','series_grouping_delete_output', 'orgseries_options_page','series_uninstall_settings'); + register_setting('orgseries_options', 'org_series_options'); + add_filter('orgseries_options', 'series_grouping_options_validate', 10, 2); +} + +function series_grouping_options_validate($newinput, $input) { + $newinput['kill_grouping_on_delete'] = ( isset($input['kill_grouping_on_delete']) && $input['kill_grouping_on_delete'] == 1 ? 1 : 0 ); + return $newinput; +} + +function series_grouping_delete_output() { + global $orgseries; + $org_opt = $orgseries->settings; + $org_name = 'org_series_options'; + $k_on_delete = is_array($org_opt) && isset($org_opt['kill_grouping_on_delete']) ? $org_opt['kill_grouping_on_delete'] : 0; + ?> +
'.$g_link.'
'; + } + return $column_return; +} + +function manage_series_grouping_columns($columns) { + global $pagenow; + $columns['group'] = __('Series Categories', 'organize-series'); + return $columns; +} + +function manage_series_grouping_columns_inside($content, $column_name, $id) { + $column_return = $content; + if ($column_name == 'group') { + $group_id = orgseries_group_id($id); + + $column_return .= '+ + + 'taxopress-log-search-submit']); ?> +
+ ID, SERIES_PART_KEY, true); + + if(empty(trim($series_part))){ + $series_part_output = esc_html__('(Currently has no Part number)', 'organize-series'); + }else{ + $series_part_output = $series_part; + } + + return $series_part_output; + } + /** * The title column * @@ -294,42 +459,30 @@ protected function get_bulk_actions() */ public function prepare_items() { + /** * First, lets decide how many records per page to show */ - $per_page = $this->get_items_per_page(str_replace('-', '_', $this->screen->id . '_per_page'), 999); - + $per_page = $this->get_items_per_page('pp_series_publisher_per_page', 20); /** * Fetch the data */ - $data = $this->get_table_data(); - - /** - * Pagination. - */ + $results = $this->get_table_data(); + $data = $results['posts']; + $total_items = $results['counts']; $current_page = $this->get_pagenum(); - $total_items = count($data); - - - /** - * The WP_List_Table class does not handle pagination for us, so we need - * to ensure that the data is trimmed to only the current page. We can use - * array_slice() to - */ - $data = array_slice($data, (($current_page - 1) * $per_page), $per_page); /** * Now we can add the data to the items property, where it can be used by the rest of the class. */ $this->items = $data; - /** * We also have to register our pagination options & calculations. */ $this->set_pagination_args([ 'total_items' => $total_items, //calculate the total number of items - 'per_page' => $per_page, //determine how many items to show on a page + 'per_page' => $per_page, //determine how many items to show on a page 'total_pages' => ceil($total_items / $per_page) //calculate the total number of pages ]); } diff --git a/addons/publisher/series_im_admin_main.php b/addons/publisher/series_im_admin_main.php index 84e53dfb..c6ef6290 100644 --- a/addons/publisher/series_im_admin_main.php +++ b/addons/publisher/series_im_admin_main.php @@ -4,87 +4,23 @@- | - | - | - | - | - | - | - | + | + | + | + | + | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
name); ?> | -- | - | - | term_id.'')) ."'>". esc_html__('Update order', 'organize-series').""; - ?> | term_id.'')) ."'>". esc_html__('Publish all', 'organize-series').""; + echo "term_id.'')) ."'>". esc_html__('Series order', 'organize-series').""; ?> | term_id.'')) ."'>". esc_html__('Unpublish all', 'organize-series').""; + echo "term_id.'')) ."'>". esc_html__('Publish or schedule posts', 'organize-series').""; ?> | slug.'')) ."'>". esc_html__('View series in admin','organize-series')."";
diff --git a/addons/publisher/series_issue_manager.php b/addons/publisher/series_issue_manager.php
index 7f1718b3..bb880c57 100644
--- a/addons/publisher/series_issue_manager.php
+++ b/addons/publisher/series_issue_manager.php
@@ -227,7 +227,7 @@ function series_issue_manager_add_series_form()
{
$published = get_option('im_published_series');
$unpublished = get_option('im_unpublished_series'); ?>
-
+ |
||||||
+ | /> + | +||||||||||||
diff --git a/orgSeries-setup.php b/orgSeries-setup.php index ed73dcbd..d2571d72 100644 --- a/orgSeries-setup.php +++ b/orgSeries-setup.php @@ -286,8 +286,14 @@ function register_taxonomy() { 'update_item' => __('Update Series', 'organize-series'), 'add_new_item' => __('Add New Series', 'organize-series'), 'new_item_name' => __('New Series Name', 'organize-series'), - 'menu_name' => __('Manage Series', 'organize-series'), - 'not_found' => __('No series found', 'organize-series') + 'menu_name' => __('Series', 'organize-series'), + 'not_found' => __('No series found', 'organize-series'), + 'back_to_items' => __('← Go to Series', 'organize-series'), + 'view_item' => __('View Series', 'organize-series'), + 'no_terms' => __('No Series', 'organize-series'), + 'items_list' => __('Series List', 'organize-series'), + 'item_link' => __('Series Link', 'organize-series'), + 'item_link_description' => __('A link to a Series', 'organize-series') ); $args = array( 'update_count_callback' => '_os_update_post_term_count', @@ -309,7 +315,7 @@ function add_settings($reset = false) { 'custom_css' => 1, 'automatic_series_part' => 0, 'metabox_show_add_new' => 0, - 'metabox_show_series_part' => 0, + 'metabox_show_series_part' => 1, 'metabox_show_post_title_in_widget' => 0, 'kill_on_delete' => 0, //determines if all series information (including series-icon tables) will be deleted when the plugin is deleted using the delete link on the plugins page. 'auto_tag_toggle' => 1, //sets the auto-tag insertions for the post-list box for posts that are part of series. @@ -321,6 +327,7 @@ function add_settings($reset = false) { 'series_post_list_limit' => '', 'series_post_list_position' => 'default', 'series_metabox_position' => 'default', + 'limit_series_meta_to_single' => 0, 'series_navigation_box_position' => 'default', 'series_toc_title' => __('All Series','organize-series'), //new template options @@ -654,6 +661,10 @@ public function add_series_meta($content) { */ $add_series_content = apply_filters('pp_series_add_series_content', true); + if (isset($this->settings['limit_series_meta_to_single']) && (int)$this->settings['limit_series_meta_to_single'] > 0 && !is_single()) { + return $content; + } + if($add_series_content && $this->settings['auto_tag_seriesmeta_toggle']) { if ($series_meta = wp_seriesmeta_write()) { $position = isset($this->settings['series_metabox_position']) ? $this->settings['series_metabox_position'] : 'default'; @@ -679,6 +690,11 @@ function orgseries_trim_excerpt($content) { function add_series_meta_excerpt($content) { if ( is_single() ) return; + + if (isset($this->settings['limit_series_meta_to_single']) && (int)$this->settings['limit_series_meta_to_single'] > 0 && !is_single()) { + return $content; + } + if($this->settings['auto_tag_seriesmeta_toggle']) { if ($series_meta = wp_seriesmeta_write(true)) { $position = isset($this->settings['series_metabox_position']) ? $this->settings['series_metabox_position'] : 'default'; diff --git a/orgSeries-taxonomy.php b/orgSeries-taxonomy.php index 68e08c7b..7429f51c 100644 --- a/orgSeries-taxonomy.php +++ b/orgSeries-taxonomy.php @@ -495,6 +495,18 @@ function wp_set_post_series( $post, $update, $post_ID = 0, $series_id = array(), $automatic_series_part = isset($settings['automatic_series_part']) ? (int)$settings['automatic_series_part'] : 0; + //set auto series part if part is empty + if($automatic_series_part === 0 + && isset($_REQUEST['action']) + && in_array($_REQUEST['action'], ['editpost']) + && $_REQUEST['post_series'] > 0 + && is_array($_REQUEST['series_part']) + && count($_REQUEST['series_part']) === 1 + && empty($_REQUEST['series_part'][$_REQUEST['post_series']]) + ) { + $automatic_series_part = 1; + } + if ( !is_bool($update) ){ return; //safety check for users on earlier version of WP (so existing series don't get messed up) } diff --git a/orgSeries-utility.php b/orgSeries-utility.php index b38fb94d..8d1afa01 100644 --- a/orgSeries-utility.php +++ b/orgSeries-utility.php @@ -77,7 +77,7 @@ function get_series_order($posts, $postid = 0, $series_id = 0, $skip = TRUE, $on /** NOTE: %postcontent% is NOT replaced with this function...it happens in the content filter function **/ function token_replace($replace, $referral = 'other', $id = 0, $ser_ID = 0) { global $post, $orgseries; - $p_id = ( $id == 0 ) ? $post->ID : $id; + $p_id = ( $id == 0 && !empty($post) ) ? $post->ID : $id; $ser_id = ( $ser_ID == 0 ) ? $id : $ser_ID; $id = ( (int)$id === 0 ) ? $ser_ID : $id; diff --git a/orgSeries-widgets.php b/orgSeries-widgets.php index 60965c83..661010c0 100644 --- a/orgSeries-widgets.php +++ b/orgSeries-widgets.php @@ -70,7 +70,7 @@ function form( $instance ) { $number = (int) $instance['number']; ?>- + @@ -275,23 +275,23 @@ function form( $instance ) {
- -
-
- |