Changeset 1498241
- Timestamp:
- 09/19/2016 03:56:31 PM (9 years ago)
- Location:
- bu-versions/trunk
- Files:
-
- 6 edited
-
.travis.yml (modified) (1 diff)
-
bu-versions.php (modified) (21 diffs)
-
css/bu-versions.css (modified) (1 diff)
-
js/bu-versions.js (modified) (1 diff)
-
readme.txt (modified) (3 diffs)
-
tests/test-bu-versions.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
bu-versions/trunk/.travis.yml
r1146729 r1498241 3 3 php: 4 4 - 5.3 5 - 5. 45 - 5.6 6 6 7 7 env: 8 8 - WP_VERSION=latest WP_MULTISITE=0 9 9 - WP_VERSION=latest WP_MULTISITE=1 10 - WP_VERSION= 3.8WP_MULTISITE=011 - WP_VERSION= 3.8WP_MULTISITE=110 - WP_VERSION=4.1 WP_MULTISITE=0 11 - WP_VERSION=4.1 WP_MULTISITE=1 12 12 13 13 before_script: 14 - bash bin/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION 14 - bash bin/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION 15 15 16 16 script: phpunit 17 18 sudo: false -
bu-versions/trunk/bu-versions.php
r1280658 r1498241 6 6 Author URI: http://sites.bu.edu/web/ 7 7 Description: Make and review edits to published content. 8 Version: 0.7. 78 Version: 0.7.8 9 9 Text Domain: bu-versions 10 10 Domain Path: /languages … … 40 40 **/ 41 41 42 require_once __DIR__ . '/inc/class-bu-version-import.php'; 43 42 44 class BU_Version_Workflow { 43 45 … … 45 47 public static $controller; 46 48 public static $admin; 47 48 const version = '0.7.7'; 49 public static $import; 50 51 const version = '0.7.8'; 52 const version_meta = '_bu_version'; 49 53 50 54 static function init() { … … 77 81 add_filter( 'get_edit_post_link', array( self::$controller, 'override_edit_post_link' ), 10, 3 ); 78 82 79 if ( is_admin() ) {83 if ( is_admin() ) { 80 84 self::$admin = new BU_Version_Admin( self::$v_factory ); 81 85 self::$admin->bind_hooks(); 82 add_action( 'load-admin_page_bu_create_version', array( self::$controller, 'load_create_version' ) );86 add_action( 'load-admin_page_bu_create_version', array( self::$controller, 'load_create_version' ) ); 83 87 add_filter( 'redirect_post_location', array( self::$controller, 'published_version_redirect_loc' ), 10, 2 ); 88 } 89 90 if ( class_exists( 'WP_Import' ) || class_exists( 'WXR_Importer' ) ) { 91 self::$import = new BU_Version_Import( self::$v_factory ); 92 self::$import->bind_hooks(); 84 93 } 85 94 … … 175 184 global $current_screen; 176 185 global $post_ID; 177 178 186 179 187 if($current_screen->base == 'post') { … … 343 351 ); 344 352 353 $default_supports = array( 'editor', 'title', 'author', 'revisions', 'excerpt' ); // @todo copy support from the post_type 354 345 355 $default_args = array( 346 356 'labels' => $labels, … … 353 363 'has_archive' => false, 354 364 'query_var' => true, 355 'supports' => array( 'editor', 'title', 'author', 'revisions' ), // copy support from the post_type365 'supports' => array(), 356 366 'taxonomies' => array(), 357 367 'show_ui' => true, … … 403 413 $args['capability_type'] = $type->capability_type; 404 414 415 foreach ( $default_supports as $support ) { 416 if ( post_type_supports( $type->name, $support ) ) { 417 $args['supports'][] = $support; 418 } 419 } 420 405 421 foreach(array_keys($alt_supported_features) as $feature) { 406 422 if( post_type_supports($type->name, $feature) ) { … … 522 538 523 539 function publish($post_id) { 524 $version = new BU_Version();525 $version->get($post_id);526 527 $result = $version->publish( $this->meta_keys );528 if( $result && ! is_wp_error( $result ) ) {529 return $version;530 } else {531 return $result;532 }540 $version = new BU_Version(); 541 $version->get($post_id); 542 543 $result = $version->publish( $this->meta_keys ); 544 if( $result && ! is_wp_error( $result ) ) { 545 return $version; 546 } else { 547 return $result; 548 } 533 549 } 534 550 … … 633 649 function orig_column($column_name, $post_id) { 634 650 if($column_name != 'alternate_versions') return; 635 $version_id = get_post_meta($post_id, '_bu_version', true);651 $version_id = get_post_meta($post_id, BU_Version_Workflow::version_meta, true); 636 652 if(!empty($version_id)) { 637 653 $version = new BU_Version(); … … 675 691 676 692 static function get_URL($post) { 677 $url = 'admin.php?page=bu_create_version';693 $url = admin_url( 'admin.php?page=bu_create_version' ); 678 694 $url = add_query_arg(array('post_type' => $post->post_type, 'post' => $post->ID), $url); 679 695 return wp_nonce_url($url, 'create_version'); … … 865 881 $current_post_type = get_post_type_object( $current_object->post_type ); 866 882 867 if( ! isset( $current_object ) ) return; 883 if ( ! isset( $current_object ) ) { 884 return; 885 } 868 886 869 887 $version = new BU_Version(); … … 871 889 $version->get( $current_object->ID ); 872 890 } else { 891 892 $alt_manager = $this->v_factory->get_alt_manager( $current_object->post_type ); 893 if ( ! $alt_manager ) { 894 return; 895 } 896 873 897 $version->get_version( $current_object->ID ); 874 898 } 875 899 876 900 $original_post_type = get_post_type_object( $version->original->post_type ); 901 $alternate_post_type = null; 877 902 878 903 if( $version->has_version() ) { 879 904 $alternate_post_type = get_post_type_object( $version->post->post_type ); 880 } 881 905 } else if ( $alt_manager ) { 906 $alternate_post_type = get_post_type_object( $alt_manager->post_type ); 907 } 882 908 883 909 $wp_admin_bar->remove_menu('edit'); … … 888 914 889 915 if ( current_user_can( $current_post_type->cap->edit_post, $current_object->ID ) ) { 890 $wp_admin_bar->add_menu( array( 'id' => ' bu-edit', 'title' => _x( 'Edit', 'admin bar menu group label', 'bu-versions'), 'href' => get_edit_post_link( $current_object->ID ) ) );916 $wp_admin_bar->add_menu( array( 'id' => 'edit', 'title' => $current_post_type->labels->edit_item, 'href' => get_edit_post_link( $current_object->ID ) ) ); 891 917 892 918 if ( $version->original->ID != $current_object->ID && current_user_can( $original_post_type->cap->edit_post, $version->original->ID ) ) { 893 $wp_admin_bar->add_menu( array( 'parent' => 'bu-edit', 'id' => 'bu-edit-original', 'title' => __('Edit Original', 'bu-versions'), 'href' => $version->get_original_edit_url() ) ); 919 $wp_admin_bar->add_menu( array( 'parent' => 'edit', 'id' => 'bu-edit-original', 'title' => __('Edit Original', 'bu-versions'), 'href' => $version->get_original_edit_url() ) ); 920 } else if ( $version->has_version() && $version->post->ID != $current_object->ID && current_user_can( $alternate_post_type->cap->edit_post, $version->post->ID ) ) { 921 $wp_admin_bar->add_menu( array( 'parent' => 'edit', 'id' => 'bu-edit-alt', 'title' => $alternate_post_type->labels->edit_item, 'href' => $version->get_edit_url() ) ); 922 } else if ( ! $version->has_version() && current_user_can( $alternate_post_type->cap->create_posts ) ) { 923 $wp_admin_bar->add_menu( array( 'parent' => 'edit', 'id' => 'bu-create-alt', 'title' => __('Create Clone', 'bu-versions'), 'href' => BU_Version_Controller::get_URL($current_object) ) ); 894 924 } 895 925 896 if ( $version->has_version() && $version->post->ID != $current_object->ID && current_user_can( $alternate_post_type->cap->edit_post, $version->post->ID ) ) { 897 $wp_admin_bar->add_menu( array( 'parent' => 'bu-edit', 'id' => 'bu-edit-alt', 'title' => __('Edit Alternate Version', 'bu-versions'), 'href' => $version->get_edit_url() ) ); 898 } 899 900 } elseif ( $version->has_version() && current_user_can( $alternate_post_type->cap->edit_post, $version->post->ID ) ) { 901 $wp_admin_bar->add_menu( array( 'id' => 'bu-edit-alt', 'title' => __('Edit Alternate Version', 'bu-versions'), 'href' => $version->get_edit_url() ) ); 926 } else if ( $version->has_version() && current_user_can( $alternate_post_type->cap->edit_post, $version->post->ID ) ) { 927 928 $wp_admin_bar->add_menu( array( 'id' => 'bu-edit-alt', 'title' => $alternate_post_type->labels->edit_item, 'href' => $version->get_edit_url() ) ); 929 930 } else if ( $alternate_post_type && current_user_can( $alternate_post_type->cap->create_posts ) ) { 931 932 $wp_admin_bar->add_menu( array( 'id' => 'bu-create-alt', 'title' => __('Create Clone', 'bu-versions'), 'href' => BU_Version_Controller::get_URL($current_object) ) ); 902 933 } 903 934 … … 920 951 public $original = null; 921 952 public $post = null; 922 const tracking_meta_key = '_bu_version';923 953 924 954 /** … … 934 964 $this->original = $original; 935 965 936 $version_id = get_post_meta( $this->original->ID, self::tracking_meta_key, true );966 $version_id = get_post_meta( $this->original->ID, BU_Version_Workflow::version_meta, true ); 937 967 938 968 if ( ! empty( $version_id ) ) { … … 966 996 // @see http://core.trac.wordpress.org/ticket/16673 967 997 if ( ! $this->post->post_parent ) { 968 $original_id = $wpdb->get_var( "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key = '_bu_version' AND meta_value = $version_id");998 $original_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key = %s AND meta_value = %s", BU_Version_Workflow::version_meta, $version_id ) ); 969 999 if ( $original_id ) 970 1000 $this->original = get_post( $original_id ); … … 973 1003 974 1004 // For safety check integrity of alt. versions' post_parent field 975 $version_tracking_id = get_post_meta( $original->ID, '_bu_version', true );1005 $version_tracking_id = get_post_meta( $original->ID, BU_Version_Workflow::version_meta, true ); 976 1006 if ( $version_tracking_id && $version_id == $version_tracking_id ) 977 1007 $this->original = $original; … … 1013 1043 $this->post = get_post( $result ); 1014 1044 $this->copy_original_meta( $meta_keys ); 1015 update_post_meta( $this->original->ID, self::tracking_meta_key, $this->post->ID );1045 update_post_meta( $this->original->ID, BU_Version_Workflow::version_meta, $this->post->ID ); 1016 1046 1017 1047 do_action( 'bu_version_create', $result, $this->post, $this->original ); … … 1097 1127 1098 1128 function delete_parent_meta() { 1099 delete_post_meta( $this->original->ID, self::tracking_meta_key);1129 delete_post_meta( $this->original->ID, BU_Version_Workflow::version_meta ); 1100 1130 } 1101 1131 … … 1138 1168 1139 1169 } 1140 1141 ?> -
bu-versions/trunk/css/bu-versions.css
r1146729 r1498241 21 21 } 22 22 23 /** 24 * Hide "Add New" link on alternate post type 25 * https://core.trac.wordpress.org/ticket/31650 26 */ 23 27 .bu_alt_postedit a.add-new-h2 { 28 display: none; 29 } 30 31 /* since 4.3 */ 32 .bu_alt_postedit a.page-title-action { 24 33 display: none; 25 34 } -
bu-versions/trunk/js/bu-versions.js
r680877 r1498241 10 10 11 11 var notice = $('.bu-version-notice').remove(); 12 $('#wpbody-content > .wrap > h2').after(notice); 12 $('#wpbody-content > .wrap > h2').after(notice); // pre-4.3 13 $('#wpbody-content > .wrap > h1').after(notice); // since 4.3 13 14 $('.bu-version-notice').show(); 14 15 overridePublishButton(); -
bu-versions/trunk/readme.txt
r1271963 r1498241 1 1 === BU Versions === 2 Contributors: gcorne, mgburns, awbauer 2 Contributors: gcorne, mgburns, awbauer, inderpreet99 3 3 Tags: content editing, workflow, version, merge, boston university, bu 4 4 Requires at least: 3.1 5 Tested up to: 4. 36 Stable tag: 0.7. 75 Tested up to: 4.6.1 6 Stable tag: 0.7.8 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 30 30 31 31 For developer documentation, feature roadmaps and more visit the [plugin repository on Github](https://github.com/bu-ist/bu-versions/). 32 33 [Build Status](https://travis-ci.org/bu-ist/bu-versions) 32 34 33 35 == Installation == … … 59 61 60 62 == Changelog == 63 64 = 0.7.8 = 65 66 * Fix UI issues since WP 4.3. 67 * Add support for excerpts. Fixes #15. 68 * Add create alternate version link to WP Admin Bar. Fixes #3. 69 * Rewrite BU Version postmeta on WP importer. Fixes #22. 70 61 71 = 0.7.7 = 62 72 -
bu-versions/trunk/tests/test-bu-versions.php
r1271963 r1498241 137 137 138 138 } 139 140 ?>
Note: See TracChangeset
for help on using the changeset viewer.