Plugin Directory

Changeset 1322567


Ignore:
Timestamp:
01/06/2016 06:18:00 PM (10 years ago)
Author:
bostonu
Message:

bu-navigation: fix nav widget when in Adaptive mode

Location:
bu-navigation/trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • bu-navigation/trunk/bin/install-wp-tests.sh

    r1048298 r1322567  
    1313
    1414WP_TESTS_DIR=${WP_TESTS_DIR-/tmp/wordpress-tests-lib}
    15 WP_CORE_DIR=/tmp/wordpress/
     15WP_CORE_DIR=${WP_CORE_DIR-/tmp/wordpress/}
     16
     17download() {
     18    if [ `which curl` ]; then
     19        curl -s "$1" > "$2";
     20    elif [ `which wget` ]; then
     21        wget -nv -O "$2" "$1"
     22    fi
     23}
     24
     25if [[ $WP_VERSION =~ [0-9]+\.[0-9]+(\.[0-9]+)? ]]; then
     26    WP_TESTS_TAG="tags/$WP_VERSION"
     27else
     28    # http serves a single offer, whereas https serves multiple. we only want one
     29    download http://api.wordpress.org/core/version-check/1.7/ /tmp/wp-latest.json
     30    grep '[0-9]+\.[0-9]+(\.[0-9]+)?' /tmp/wp-latest.json
     31    LATEST_VERSION=$(grep -o '"version":"[^"]*' /tmp/wp-latest.json | sed 's/"version":"//')
     32    if [[ -z "$LATEST_VERSION" ]]; then
     33        echo "Latest WordPress version could not be found"
     34        exit 1
     35    fi
     36    WP_TESTS_TAG="tags/$LATEST_VERSION"
     37fi
    1638
    1739set -ex
    1840
    1941install_wp() {
     42
     43    if [ -d $WP_CORE_DIR ]; then
     44        return;
     45    fi
     46
    2047    mkdir -p $WP_CORE_DIR
    2148
    22     if [ $WP_VERSION == 'latest' ]; then 
     49    if [ $WP_VERSION == 'latest' ]; then
    2350        local ARCHIVE_NAME='latest'
    2451    else
     
    2653    fi
    2754
    28     wget -nv -O /tmp/wordpress.tar.gz http://wordpress.org/${ARCHIVE_NAME}.tar.gz
     55    download https://wordpress.org/${ARCHIVE_NAME}.tar.gz  /tmp/wordpress.tar.gz
    2956    tar --strip-components=1 -zxmf /tmp/wordpress.tar.gz -C $WP_CORE_DIR
    3057
    31     wget -nv -O $WP_CORE_DIR/wp-content/db.php https://raw.github.com/markoheijnen/wp-mysqli/master/db.php
     58    download https://raw.github.com/markoheijnen/wp-mysqli/master/db.php $WP_CORE_DIR/wp-content/db.php
    3259}
    3360
     
    4067    fi
    4168
    42     # set up testing suite
    43     mkdir -p $WP_TESTS_DIR
     69    # set up testing suite if it doesn't yet exist
     70    if [ ! -d $WP_TESTS_DIR ]; then
     71        # set up testing suite
     72        mkdir -p $WP_TESTS_DIR
     73        svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes/ $WP_TESTS_DIR/includes
     74    fi
     75
    4476    cd $WP_TESTS_DIR
    45     svn co --quiet http://develop.svn.wordpress.org/trunk/tests/phpunit/includes/
    4677
    47     wget -nv -O wp-tests-config.php http://develop.svn.wordpress.org/trunk/wp-tests-config-sample.php
    48     sed $ioption "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR':" wp-tests-config.php
    49     sed $ioption "s/youremptytestdbnamehere/$DB_NAME/" wp-tests-config.php
    50     sed $ioption "s/yourusernamehere/$DB_USER/" wp-tests-config.php
    51     sed $ioption "s/yourpasswordhere/$DB_PASS/" wp-tests-config.php
    52     sed $ioption "s|localhost|${DB_HOST}|" wp-tests-config.php
     78    if [ ! -f wp-tests-config.php ]; then
     79        download https://develop.svn.wordpress.org/${WP_TESTS_TAG}/wp-tests-config-sample.php "$WP_TESTS_DIR"/wp-tests-config.php
     80        sed $ioption "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR':" "$WP_TESTS_DIR"/wp-tests-config.php
     81        sed $ioption "s/youremptytestdbnamehere/$DB_NAME/" "$WP_TESTS_DIR"/wp-tests-config.php
     82        sed $ioption "s/yourusernamehere/$DB_USER/" "$WP_TESTS_DIR"/wp-tests-config.php
     83        sed $ioption "s/yourpasswordhere/$DB_PASS/" "$WP_TESTS_DIR"/wp-tests-config.php
     84        sed $ioption "s|localhost|${DB_HOST}|" "$WP_TESTS_DIR"/wp-tests-config.php
     85    fi
     86
    5387}
    5488
     
    6195
    6296    if ! [ -z $DB_HOSTNAME ] ; then
    63         if [[ "$DB_SOCK_OR_PORT" =~ ^[0-9]+$ ]] ; then
     97        if [ $(echo $DB_SOCK_OR_PORT | grep -e '^[0-9]\{1,\}$') ]; then
    6498            EXTRA=" --host=$DB_HOSTNAME --port=$DB_SOCK_OR_PORT --protocol=tcp"
    6599        elif ! [ -z $DB_SOCK_OR_PORT ] ; then
  • bu-navigation/trunk/bu-navigation-widget.php

    r1225359 r1322567  
    5151            if ( $instance['navigation_style'] == 'adaptive' ) {
    5252                $grandparent_offset = count( $sections ) - 2;
     53
     54                // If the current page is the last item, go up one further
     55                if( end( $sections ) == $post->ID ){
     56                    $grandparent_offset--;
     57                }
     58
    5359                if ( isset( $sections[$grandparent_offset] ) ) {
    5460                    $section_id = $sections[$grandparent_offset];
  • bu-navigation/trunk/bu-navigation.php

    r1225359 r1322567  
    66Author URI: http://sites.bu.edu/web/
    77Description: Provides alternative navigation elements designed for blogs with large page counts
    8 Version: 1.2.7
     8Version: 1.2.8
    99Text Domain: bu-navigation
    1010Domain Path: /languages
     
    3535@author Mike Burns <[email protected]>
    3636@author Tyler Wiest <[email protected]>
     37@author Andrew Bauer <[email protected]>
    3738*/
    3839
  • bu-navigation/trunk/composer.json

    r1048298 r1322567  
    1919            "name": "Tyler Wiest",
    2020            "email": "[email protected]"
     21        },
     22        {
     23            "name": "Andrew Bauer",
     24            "email": "[email protected]"
    2125        }
    2226    ],
  • bu-navigation/trunk/extras/bu-navigation-adaptive-contentnav.php

    r766271 r1322567  
    8787    return $filtered;
    8888}
    89 
    90 ?>
  • bu-navigation/trunk/includes/library.php

    r1048298 r1322567  
    361361        // Append parent post name and keep looping backwards.
    362362        $parent = $ancestors[ $page->post_parent ];
    363         if ( is_object( $parent ) && isset( $parent->post_name ) ) {
     363        if ( is_object( $parent ) && ! empty( $parent->post_name ) ) {
    364364            $uri = $parent->post_name . '/' . $uri;
    365365        }
     
    888888            array_push( $sections, $last_section );
    889889
    890             if ( is_array( $pages_by_parent[$last_section] ) && ( count( $pages_by_parent[$last_section] ) > 0 ) ) {
     890            if ( array_key_exists( $last_section, $pages_by_parent ) &&
     891                 is_array( $pages_by_parent[$last_section] ) &&
     892                 ( count( $pages_by_parent[$last_section] ) > 0 )
     893               ) {
    891894                // The last section has children, so it will be the "top"
    892895                $sections = array_slice($sections, -2);
  • bu-navigation/trunk/languages/bu-navigation.pot

    r1225359 r1322567  
    33msgid ""
    44msgstr ""
    5 "Project-Id-Version: bu-navigation 1.2.7\n"
     5"Project-Id-Version: bu-navigation 1.2.8\n"
    66"Report-Msgid-Bugs-To: http://wordpress.org/support/plugin/bu-navigation\n"
    77"POT-Creation-Date: 2015-08-19 12:32-0400\n"
  • bu-navigation/trunk/package.json

    r1225359 r1322567  
    11{
    22  "name": "bu-navigation",
    3   "version": "1.2.7",
     3  "version": "1.2.8",
    44  "description": "Provides alternative navigation elements designed for blogs with large page counts",
    55  "main": "bu-navigation.php",
  • bu-navigation/trunk/readme.txt

    r1225359 r1322567  
    33Tags: navigation, hierarchical, post type, boston university, bu
    44Requires at least: 3.1
    5 Tested up to: 4.3
    6 Stable tag: 1.2.7
     5Tested up to: 4.4
     6Stable tag: 1.2.8
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    7676
    7777== Changelog ==
     78
     79= 1.2.8 =
     80
     81* Fixes an issue affecting section titles in the navigation widget when using Adaptive Mode
     82* Corrects invalid unit tests
    7883
    7984= 1.2.7 =
  • bu-navigation/trunk/tests/phpunit/test-library.php

    r1146690 r1322567  
    431431        // Non-Page Hierarchical Post Type 'Default Permalinks' do not work for child posts prior to 4.0
    432432        // @see https://core.trac.wordpress.org/ticket/29615
    433         if ( $wp_rewrite->using_permalinks() || version_compare( $GLOBALS['wp_version'], '4.0', '>' ) ) {
     433        if ( $wp_rewrite->using_permalinks() && version_compare( $GLOBALS['wp_version'], '4.4', '>=' ) ) {
    434434            $grandchild = $this->posts['test_grandchild'];
    435435            $grandchild = get_post( $grandchild );
     
    471471        $this->assertEquals( get_post_permalink( $pending_child ), bu_navigation_get_post_link( $pending_child ) );
    472472
    473         // Non-Page Hierarchical Post Type 'Default Permalinks' do not work for child posts prior to 4.0
     473        // #29615: Non-Page Hierarchical Post Type 'Default Permalinks' do not work for child posts prior to 4.0.
     474        // #23458: get_post_permalink() improved in v4.4 to fix incorrect URLs for pages when child of a draft (e.g. http://example.org/test//post-title-5/)
    474475        // @see https://core.trac.wordpress.org/ticket/29615
    475         if ( $wp_rewrite->using_permalinks() || version_compare( $GLOBALS['wp_version'], '4.0', '>' ) ) {
     476        // @see https://core.trac.wordpress.org/ticket/23458
     477        if ( $wp_rewrite->using_permalinks() && version_compare( $GLOBALS['wp_version'], '4.4', '>=' ) ) {
    476478            // Draft parent, public children
    477479            $this->assertEquals( get_post_permalink( $public_draft_child ), bu_navigation_get_post_link( $public_draft_child ) );
  • bu-navigation/trunk/tests/phpunit/test-plugin.php

    r1048298 r1322567  
    88 */
    99class Test_BU_Navigation_Plugin extends BU_Navigation_UnitTestCase {
     10
     11    public function setUp(){
     12        parent::setUp();
     13
     14        $this->plugin->load_widget();
     15    }
    1016
    1117    /**
     
    5056    }
    5157
     58    public function test_widget_adaptive_with_section_title(){
     59        global $wp_widget_factory,
     60               $post;
     61
     62        /*
     63         * IA
     64         * - Page 1
     65         *     - Subpage 1.A
     66         *         - Subpage 1.A.1 (widget loaded here)
     67         *             - Subpage 1.A.1.A (excluded from nav)
     68         *         - Subpage 1.A.2
     69         */
     70       
     71        $page1 = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'Page 1', ) );
     72        $page1_A = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'Subpage 1-A', 'post_parent' => $page1 ) );
     73        $page1_A_1 = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'Subpage 1-A-1 (Has Child)', 'post_parent' => $page1_A ) );
     74        $page1_A_1_A = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'Subpage 1-A-1-A', 'post_parent' => $page1_A_1 ) );
     75        $page1_A_2 = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'Subpage 1-A-2 (No Child)', 'post_parent' => $page1_A ) );
     76
     77        // make sure we've got everyone
     78        $posts = bu_navigation_get_posts();
     79        $this->assertCount( 5, $posts );
     80
     81        // set page1_A_1_A to hidden in nav
     82        update_post_meta( $page1_A_1_A, BU_NAV_META_PAGE_EXCLUDE, 1 );
     83
     84        // make sure we're missing page1_A_1
     85        $posts = bu_navigation_get_posts();
     86        $this->assertCount( 4, $posts );
     87
     88        // load persepctive of page page1_A_1
     89        $post = get_post( $page1_A_1 );
     90        setup_postdata( $post );
     91
     92        $instance = array(
     93            'navigation_title' => 'section',
     94            'navigation_title_text' => '',
     95            'navigation_title_url' => '',
     96            'navigation_style' => 'adaptive',
     97            );
     98
     99        ob_start();
     100        the_widget( 'BU_Widget_Pages', $instance );
     101        $widget = ob_get_contents();
     102        ob_end_clean();
     103        // echo $widget;
     104
     105        $this->assertRegExp('/<h2.+Page 1<\/a>/i', $widget);
     106        $this->assertRegExp('/class="level_1".+Subpage 1-A<\/a>/is', $widget);
     107    }
     108
    52109}
Note: See TracChangeset for help on using the changeset viewer.