Plugin Directory

Changeset 1498241


Ignore:
Timestamp:
09/19/2016 03:56:31 PM (9 years ago)
Author:
bostonu
Message:

Pulling in 0.7.8 changeset from Github

Location:
bu-versions/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • bu-versions/trunk/.travis.yml

    r1146729 r1498241  
    33php:
    44    - 5.3
    5     - 5.4
     5    - 5.6
    66
    77env:
    88    - WP_VERSION=latest WP_MULTISITE=0
    99    - WP_VERSION=latest WP_MULTISITE=1
    10     - WP_VERSION=3.8 WP_MULTISITE=0
    11     - WP_VERSION=3.8 WP_MULTISITE=1
     10    - WP_VERSION=4.1 WP_MULTISITE=0
     11    - WP_VERSION=4.1 WP_MULTISITE=1
    1212
    1313before_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
    1515
    1616script: phpunit
     17
     18sudo: false
  • bu-versions/trunk/bu-versions.php

    r1280658 r1498241  
    66Author URI: http://sites.bu.edu/web/
    77Description: Make and review edits to published content.
    8 Version: 0.7.7
     8Version: 0.7.8
    99Text Domain: bu-versions
    1010Domain Path: /languages
     
    4040 **/
    4141
     42require_once __DIR__ . '/inc/class-bu-version-import.php';
     43
    4244class BU_Version_Workflow {
    4345
     
    4547    public static $controller;
    4648    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';
    4953
    5054    static function init() {
     
    7781        add_filter( 'get_edit_post_link', array( self::$controller, 'override_edit_post_link' ), 10, 3 );
    7882
    79         if (is_admin() ) {
     83        if ( is_admin() ) {
    8084            self::$admin = new BU_Version_Admin( self::$v_factory );
    8185            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' ) );
    8387            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();
    8493        }
    8594
     
    175184        global $current_screen;
    176185        global $post_ID;
    177 
    178186
    179187        if($current_screen->base == 'post') {
     
    343351        );
    344352
     353        $default_supports = array( 'editor', 'title', 'author', 'revisions', 'excerpt' ); // @todo copy support from the post_type
     354
    345355        $default_args = array(
    346356            'labels' => $labels,
     
    353363            'has_archive' => false,
    354364            'query_var' => true,
    355             'supports' => array('editor', 'title', 'author', 'revisions' ), // copy support from the post_type
     365            'supports' => array(),
    356366            'taxonomies' => array(),
    357367            'show_ui' => true,
     
    403413            $args['capability_type'] = $type->capability_type;
    404414
     415            foreach ( $default_supports as $support ) {
     416                if ( post_type_supports( $type->name, $support ) ) {
     417                    $args['supports'][] = $support;
     418                }
     419            }
     420
    405421            foreach(array_keys($alt_supported_features) as $feature) {
    406422                if( post_type_supports($type->name, $feature) ) {
     
    522538
    523539    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        }
    533549    }
    534550
     
    633649    function orig_column($column_name, $post_id) {
    634650        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);
    636652        if(!empty($version_id)) {
    637653            $version = new BU_Version();
     
    675691
    676692    static function get_URL($post) {
    677         $url = 'admin.php?page=bu_create_version';
     693        $url = admin_url( 'admin.php?page=bu_create_version' );
    678694        $url = add_query_arg(array('post_type' => $post->post_type, 'post' => $post->ID), $url);
    679695        return wp_nonce_url($url, 'create_version');
     
    865881            $current_post_type = get_post_type_object( $current_object->post_type );
    866882
    867             if( ! isset( $current_object ) ) return;
     883            if ( ! isset( $current_object ) ) {
     884                return;
     885            }
    868886
    869887            $version = new BU_Version();
     
    871889                $version->get( $current_object->ID );
    872890            } else {
     891
     892                $alt_manager = $this->v_factory->get_alt_manager( $current_object->post_type );
     893                if ( ! $alt_manager ) {
     894                    return;
     895                }
     896
    873897                $version->get_version( $current_object->ID );
    874898            }
    875899
    876900            $original_post_type = get_post_type_object( $version->original->post_type );
     901            $alternate_post_type = null;
    877902
    878903            if( $version->has_version() ) {
    879904                $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            }
    882908
    883909            $wp_admin_bar->remove_menu('edit');
     
    888914
    889915            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 ) ) );
    891917
    892918                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) ) );
    894924                }
    895925
    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) ) );
    902933            }
    903934
     
    920951    public $original = null;
    921952    public $post = null;
    922     const tracking_meta_key = '_bu_version';
    923953
    924954    /**
     
    934964                $this->original = $original;
    935965
    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 );
    937967
    938968                if ( ! empty( $version_id ) ) {
     
    966996            // @see http://core.trac.wordpress.org/ticket/16673
    967997            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 ) );
    969999                if ( $original_id )
    9701000                    $this->original = get_post( $original_id );
     
    9731003
    9741004                // 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 );
    9761006                if ( $version_tracking_id && $version_id == $version_tracking_id )
    9771007                    $this->original = $original;
     
    10131043            $this->post = get_post( $result );
    10141044            $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 );
    10161046
    10171047            do_action( 'bu_version_create', $result, $this->post, $this->original );
     
    10971127
    10981128    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 );
    11001130    }
    11011131
     
    11381168
    11391169}
    1140 
    1141 ?>
  • bu-versions/trunk/css/bu-versions.css

    r1146729 r1498241  
    2121}
    2222
     23/**
     24 * Hide "Add New" link on alternate post type
     25 * https://core.trac.wordpress.org/ticket/31650
     26 */
    2327.bu_alt_postedit a.add-new-h2 {
     28    display: none;
     29}
     30
     31/* since 4.3 */
     32.bu_alt_postedit a.page-title-action {
    2433    display: none;
    2534}
  • bu-versions/trunk/js/bu-versions.js

    r680877 r1498241  
    1010
    1111    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
    1314    $('.bu-version-notice').show();
    1415    overridePublishButton();
  • bu-versions/trunk/readme.txt

    r1271963 r1498241  
    11=== BU Versions ===
    2 Contributors: gcorne, mgburns, awbauer
     2Contributors: gcorne, mgburns, awbauer, inderpreet99
    33Tags: content editing, workflow, version, merge, boston university, bu
    44Requires at least: 3.1
    5 Tested up to: 4.3
    6 Stable tag: 0.7.7
     5Tested up to: 4.6.1
     6Stable tag: 0.7.8
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    3030
    3131For 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)
    3234
    3335== Installation ==
     
    5961
    6062== 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
    6171= 0.7.7 =
    6272
  • bu-versions/trunk/tests/test-bu-versions.php

    r1271963 r1498241  
    137137
    138138}
    139 
    140 ?>
Note: See TracChangeset for help on using the changeset viewer.