Make WordPress Core

Ticket #37013: 37013.6.diff

File 37013.6.diff, 379.2 KB (added by mihai2u, 8 years ago)
  • .travis.yml

    diff --git a/.travis.yml b/.travis.yml
    index 8196d39..e6c8ec7 100644
    a b cache: 
    44  apt: true
    55  directories:
    66    - node_modules
     7    - vendor
     8    - $HOME/.composer/cache
    79env:
    810  global:
    911    - WP_TRAVISCI=travis:phpunit
    1012matrix:
    1113  include:
    12   - php: 7.0
     14  - php: 7.1
    1315    env: WP_TRAVISCI=travis:js
    14   - php: 5.2
    15   - php: 5.3
    16   - php: 5.4
    17   - php: 5.5
     16  - php: 7.1
     17  - php: 7.0
    1818  - php: 5.6
    1919  - php: 5.6
    2020    env: WP_TRAVIS_OBJECT_CACHE=true
    2121    services: memcached
    22   - php: hhvm
    23     sudo: required
    24     dist: trusty
    25     group: edge
    26     addons:
    27       apt:
    28         packages:
    29         - mysql-server-5.6
    30         - mysql-client-core-5.6
    31         - mysql-client-5.6
    32   - php: 7.0
    33   - php: 7.1
     22  - php: 5.5
     23  - php: 5.4
     24  - php: 5.3
     25  - php: 5.2
    3426  - php: nightly
    3527  allow_failures:
    36   - php: hhvm
    3728  - php: nightly
    3829before_install:
    3930- |
    before_install: 
    4334      sed -i "s/youremptytestdbnamehere/wordpress_tests/" wp-tests-config.php
    4435      sed -i "s/yourusernamehere/root/" wp-tests-config.php
    4536      sed -i "s/yourpasswordhere//" wp-tests-config.php
    46       svn checkout https://plugins.svn.wordpress.org/wordpress-importer/trunk tests/phpunit/data/plugins/wordpress-importer
     37      svn checkout https://plugins.svn.wordpress.org/wordpress-importer/tags/0.6.3/ tests/phpunit/data/plugins/wordpress-importer
    4738  fi
    4839- |
    4940  if [[ "$WP_TRAVIS_OBJECT_CACHE" == "true" ]]; then
    50     curl https://raw.githubusercontent.com/tollmanz/wordpress-pecl-memcached-object-cache/584392b56dc4adbe52bd2c7b86f875e23a3e5f75/object-cache.php > src/wp-content/object-cache.php
     41    cp tests/phpunit/includes/object-cache.php src/wp-content/object-cache.php
    5142    echo "extension = memcached.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
    5243  fi
    5344before_script:
    5445- |
    55   # Remove Xdebug for a huge performance increase, but not from nightly or hhvm:
     46  # Remove Xdebug for a huge performance increase, but not from nightly:
    5647  stable='^[0-9\.]+$'
    5748  if [[ "$TRAVIS_PHP_VERSION" =~ $stable ]]; then
    5849    phpenv config-rm xdebug.ini
    before_script: 
    6758  # Install the specified version of PHPUnit depending on the PHP version:
    6859  if [[ "$WP_TRAVISCI" == "travis:phpunit" ]]; then
    6960    case "$TRAVIS_PHP_VERSION" in
    70       7.1|7.0|hhvm|nightly)
    71         echo "Using PHPUnit 5.7"
    72         composer global require "phpunit/phpunit=5.7.*"
     61      7.1|7.0|nightly)
     62        echo "Using PHPUnit 6.1"
     63        composer global require "phpunit/phpunit=6.1.*"
    7364        ;;
    7465      5.6|5.5|5.4|5.3)
    7566        echo "Using PHPUnit 4.8"
    before_script: 
    9485- mysql --version
    9586- phpenv versions
    9687- php --version
    97 - |
    98   # Debug PHP extensions, but not on HHVM because the command hangs indefinitely:
    99   if [[ "$TRAVIS_PHP_VERSION" != 'hhvm' ]]; then
    100     php -m
    101   fi
     88- php -m
    10289- npm --version
    10390- node --version
    10491- which phpunit
    before_script: 
    10794- grunt --version
    10895- git --version
    10996- svn --version
     97- locale -a
    11098script: grunt $WP_TRAVISCI
    11199notifications:
    112100  slack:
  • Gruntfile.js

    diff --git a/Gruntfile.js b/Gruntfile.js
    index 80e2968..14e558f 100644
    a b module.exports = function(grunt) { 
    426426                phpunit: {
    427427                        'default': {
    428428                                cmd: 'phpunit',
    429                                 args: ['-c', 'phpunit.xml.dist']
     429                                args: ['--verbose', '-c', 'phpunit.xml.dist']
    430430                        },
    431431                        ajax: {
    432432                                cmd: 'phpunit',
    433                                 args: ['-c', 'phpunit.xml.dist', '--group', 'ajax']
     433                                args: ['--verbose', '-c', 'phpunit.xml.dist', '--group', 'ajax']
    434434                        },
    435435                        multisite: {
    436436                                cmd: 'phpunit',
    437                                 args: ['-c', 'tests/phpunit/multisite.xml']
     437                                args: ['--verbose', '-c', 'tests/phpunit/multisite.xml']
    438438                        },
    439439                        'external-http': {
    440440                                cmd: 'phpunit',
    441                                 args: ['-c', 'phpunit.xml.dist', '--group', 'external-http']
     441                                args: ['--verbose', '-c', 'phpunit.xml.dist', '--group', 'external-http']
    442442                        },
    443443                        'restapi-jsclient': {
    444444                                cmd: 'phpunit',
    445                                 args: ['-c', 'phpunit.xml.dist', '--group', 'restapi-jsclient']
     445                                args: ['--verbose', '-c', 'phpunit.xml.dist', '--group', 'restapi-jsclient']
    446446                        }
    447447                },
    448448                uglify: {
  • phpunit.xml.dist

    diff --git a/phpunit.xml.dist b/phpunit.xml.dist
    index 415ec76..0bb6491 100644
    a b  
    22        bootstrap="tests/phpunit/includes/bootstrap.php"
    33        backupGlobals="false"
    44        colors="true"
     5        beStrictAboutTestsThatDoNotTestAnything="true"
    56        >
    67    <testsuites>
    78        <!-- Default test suite to run all tests -->
     
    2324        <exclude>
    2425            <group>ajax</group>
    2526            <group>ms-files</group>
     27            <group>ms-required</group>
    2628            <group>external-http</group>
    2729        </exclude>
    2830    </groups>
  • src/wp-admin/css/color-picker.css

    diff --git a/src/wp-admin/css/color-picker.css b/src/wp-admin/css/color-picker.css
    index baa1d94..30dec29 100644
    a b  
    133133        box-shadow:
    134134                0 0 0 1px #5b9dd9,
    135135                0 0 2px 1px rgba(30, 140, 190, .8);
    136 }
    137  No newline at end of file
     136}
     137
     138@media screen and ( max-width: 782px ) {
     139        .wp-picker-container input[type="text"].wp-color-picker {
     140                margin-right: 6px;
     141                padding: 3px 5px;
     142        }
     143}
  • src/wp-admin/css/common.css

    diff --git a/src/wp-admin/css/common.css b/src/wp-admin/css/common.css
    index d06bebe..9074743 100644
    a b hr { 
    865865        border-bottom: 1px solid #fafafa;
    866866}
    867867
    868 .widget-control-remove,
    869 .widget-control-remove:focus,
    870868.row-actions span.delete a,
    871869.row-actions span.trash a,
    872870.row-actions span.spam a,
    span.required, 
    893891#media-items a.delete:hover,
    894892#media-items a.delete-permanently:hover,
    895893#nav-menu-footer .menu-delete:hover {
    896         color: #f00;
     894        color: #dc3232;
    897895        border: none;
    898896}
    899897
    900 .widget-control-remove:hover {
    901         color: #f00;
    902 }
    903 
    904898/*------------------------------------------------------------------------------
    905899  3.0 - Actions
    906900------------------------------------------------------------------------------*/
    img { 
    30863080/* Metabox collapse arrow indicators */
    30873081.js .sidebar-name .sidebar-name-arrow:before,
    30883082.js .meta-box-sortables .postbox .toggle-indicator:before,
    3089 .bulk-action-notice .toggle-indicator:before {
    3090         content: "\f142";
     3083.bulk-action-notice .toggle-indicator:before,
     3084.js .accordion-section .handlediv .sidebar-name-arrow:before {
    30913085        display: inline-block;
    30923086        font: normal 20px/1 dashicons;
    30933087        speak: none;
    img { 
    30963090        text-decoration: none !important;
    30973091}
    30983092
     3093/* Open state */
     3094.js .sidebar-name .sidebar-name-arrow:before,
     3095.js .meta-box-sortables .postbox .toggle-indicator:before,
     3096.bulk-action-notice .toggle-indicator:before,
     3097.js .accordion-section.open .handlediv .sidebar-name-arrow:before {
     3098        content: "\f142";
     3099}
     3100
     3101/* Closed state */
    30993102.js .widgets-holder-wrap.closed .sidebar-name-arrow:before,
    31003103.js .meta-box-sortables .postbox.closed .handlediv .toggle-indicator:before,
    3101 .bulk-action-notice .bulk-action-errors-collapsed .toggle-indicator:before {
     3104.bulk-action-notice .bulk-action-errors-collapsed .toggle-indicator:before,
     3105.js .accordion-section .handlediv .sidebar-name-arrow:before {
    31023106        content: "\f140";
    31033107}
    31043108
    3105 .js .sidebar-name .sidebar-name-arrow:before {
    3106         padding: 10px;
    3107         left: 0;
    3108 }
    3109 
    31103109.js #widgets-left .sidebar-name .sidebar-name-arrow {
    31113110        display: none;
    31123111}
    img { 
    31493148                0 0 2px 1px rgba(30, 140, 190, .8);
    31503149}
    31513150
     3151.js .metabox-holder .accordion-section .accordion-section-title:after {
     3152        content: none;
     3153}
     3154
     3155.js .metabox-holder .accordion-section .handlediv {
     3156        float: right;
     3157        position: relative;
     3158        top: 11px;
     3159        margin-right: 11px;
     3160        z-index: 2;
     3161}
     3162
     3163.js .metabox-holder .accordion-section .handlediv .sidebar-name-arrow:before {
     3164        width: 20px;
     3165        border-radius: 50%;
     3166        text-indent: -1px; /* account for the dashicon alignment */
     3167}
     3168
     3169.js .metabox-holder .accordion-section .handlediv:focus {
     3170        outline: none;
     3171        border: none;
     3172        box-shadow: none;
     3173}
     3174
     3175.js .metabox-holder .accordion-section .handlediv:focus .sidebar-name-arrow:before {
     3176        box-shadow:
     3177                0 0 0 1px #5b9dd9,
     3178                0 0 2px 1px rgba(30, 140, 190, .8);
     3179}
     3180
    31523181/* @todo: appears to be Press This only and overridden */
    31533182#photo-add-url-div input[type="text"] {
    31543183        width: 300px;
    img { 
    32443273
    32453274/* @todo: can we use a common class for these? */
    32463275.nav-menus-php .item-edit:before,
    3247 .widget-top a.widget-action:after,
     3276.widget-top .widget-action .toggle-indicator:before,
    32483277.control-section .accordion-section-title:after,
    3249 .accordion-section-title:after {
     3278.accordion-section-title:after,
     3279.accordion-section-arrow:after {
    32503280        right: 0;
    32513281        content: "\f140";
    3252         border: none;
    3253         background: none;
    32543282        font: normal 20px/1 dashicons;
    32553283        speak: none;
    32563284        display: block;
    3257         padding: 0;
    3258         text-indent: 0;
    3259         text-align: center;
    3260         position: relative;
    32613285        -webkit-font-smoothing: antialiased;
    32623286        -moz-osx-font-smoothing: grayscale;
    32633287        text-decoration: none !important;
    32643288}
    32653289
     3290.widget-top .widget-action .toggle-indicator:before {
     3291        padding: 1px 2px 1px 0px;
     3292        -webkit-border-radius: 50%;
     3293        border-radius: 50%;
     3294}
     3295
    32663296.handlediv,
    32673297.postbox .handlediv.button-link,
    32683298.item-edit,
    img { 
    32883318        color: #23282d;
    32893319}
    32903320
    3291 .widget-top a.widget-action:after {
    3292         padding: 1px 2px 1px 0px;
    3293         margin-top: 10px;
    3294         margin-right: 10px;
    3295         -webkit-border-radius: 50%;
    3296         border-radius: 50%;
    3297 }
    3298 
    3299 .widget-top a.widget-action:focus:after {
     3321.widget-top .widget-action:focus .toggle-indicator:before {
    33003322        -webkit-box-shadow:
    33013323                0 0 0 1px #5b9dd9,
    33023324                0 0 2px 1px rgba(30,140,190,.8);
    img { 
    33153337.control-section.open .accordion-section-title:after,
    33163338#customize-info.open .accordion-section-title:after,
    33173339.nav-menus-php .menu-item-edit-active .item-edit:before,
    3318 .widget.open .widget-top a.widget-action:after {
     3340.widget.open .widget-top .widget-action .toggle-indicator:before,
     3341.open .accordion-section-arrow:after {
    33193342        content: "\f142";
    33203343}
    33213344
    img { 
    35943617        /* @todo: evaluate - most of these were likely replaced by dashicons */
    35953618        .curtime #timestamp,
    35963619        #screen-meta-links a.show-settings,
    3597         .widget-top a.widget-action,
    3598         .widget-top a.widget-action:hover,
     3620        .widget-top .widget-action,
     3621        .widget-top .widget-action:hover,
    35993622        .sidebar-name-arrow,
    36003623        .sidebar-name:hover .sidebar-name-arrow,
    36013624        .meta-box-sortables .postbox:hover .handlediv,
  • src/wp-admin/css/customize-controls.css

    diff --git a/src/wp-admin/css/customize-controls.css b/src/wp-admin/css/customize-controls.css
    index fbcfe64..d033b89 100644
    a b p.customize-section-description { 
    617617
    618618.customize-control select {
    619619        width: 100%;
    620         max-width: 300px;
    621620        height: 28px;
    622621        line-height: 28px;
    623622}
    p.customize-section-description { 
    744743
    745744.customize-control-dropdown-pages .new-content-item {
    746745        width: 100%;
    747         max-width: 300px;
    748746        padding: 5px 0 5px 1px;
    749747        position: relative;
    750748}
    p.customize-section-description { 
    11891187.customize-section-description-container + #customize-control-custom_css:last-child {
    11901188        margin-left: -12px;
    11911189        width: 299px;
     1190        width: -webkit-calc( 100% + 24px );
     1191        width: calc( 100% + 24px );
    11921192        margin-bottom: -12px;
    11931193}
    11941194
    11951195@media screen and ( max-width: 640px ) {
    11961196        .customize-section-description-container + #customize-control-custom_css:last-child {
    1197                 margin-left: 0;
    11981197                margin-right: 0;
    1199                 width: 100%;
    12001198        }
    12011199        .customize-section-description-container + #customize-control-custom_css:last-child textarea {
    12021200                height: -webkit-calc( 100vh - 140px );
    12031201                height: calc( 100vh - 140px );
    1204                 width: 100%;
    1205                 border: solid 1px #ddd;
    12061202        }
    12071203}
    12081204
  • src/wp-admin/css/customize-nav-menus.css

    diff --git a/src/wp-admin/css/customize-nav-menus.css b/src/wp-admin/css/customize-nav-menus.css
    index c42fa54..f2186fb 100644
    a b  
    153153        text-align: center;
    154154}
    155155
    156 .wp-customizer .menu-item.menu-item-edit-active .item-edit .toggle-indicator:after {
     156.wp-customizer .menu-item.menu-item-edit-active .item-edit .toggle-indicator:before {
    157157        content: "\f142";
    158158}
    159159
     
    271271        display: inline-block;
    272272        font-size: 20px;
    273273        line-height: 1;
    274         text-indent: -1px; /* account for the dashicon alignment */
    275274}
    276275
    277276.rtl .wp-customizer .toggle-indicator {
    278277        text-indent: 1px; /* account for the dashicon alignment */
    279278}
    280279
    281 .wp-customizer .toggle-indicator:after {
     280.wp-customizer .menu-item .item-edit .toggle-indicator:before,
     281#available-menu-items .accordion-section-title .toggle-indicator:before {
    282282        content: "\f140";
     283        display: block;
     284        padding: 1px 2px 1px 0px;
    283285        speak: none;
    284         vertical-align: top;
    285286        -webkit-border-radius: 50%;
    286287        border-radius: 50%;
    287288        color: #72777c;
     
    494495        content: none !important;
    495496}
    496497
    497 #available-menu-items .accordion-section-title:hover .toggle-indicator:after,
    498 #available-menu-items .button-link:hover .toggle-indicator:after,
    499 #available-menu-items .button-link:focus .toggle-indicator:after {
     498#available-menu-items .accordion-section-title:hover .toggle-indicator:before,
     499#available-menu-items .button-link:hover .toggle-indicator:before,
     500#available-menu-items .button-link:focus .toggle-indicator:before {
    500501        color: #23282d;
    501502}
    502503
    503 #available-menu-items .open .accordion-section-title .toggle-indicator:after {
     504#available-menu-items .open .accordion-section-title .toggle-indicator:before {
    504505        content: "\f142";
    505506        color: #23282d;
    506507}
    li.assigned-to-menu-location .add-new-menu-item { 
    837838.wp-customizer .menu-item .submitbox .submitdelete:focus,
    838839.customize-screen-options-toggle:focus:before,
    839840#customize-controls .customize-info .customize-help-toggle:focus:before,
    840 .wp-customizer button:focus .toggle-indicator:after,
     841.wp-customizer button:focus .toggle-indicator:before,
    841842.menu-delete:focus,
    842843.menu-item-bar .item-delete:focus:before,
    843844#available-menu-items .item-add:focus:before {
  • src/wp-admin/css/customize-widgets.css

    diff --git a/src/wp-admin/css/customize-widgets.css b/src/wp-admin/css/customize-widgets.css
    index 687c9f8..428c455 100644
    a b  
    8989        line-height: 16px;
    9090}
    9191
    92 .customize-control-widget_form.expanded a.widget-action:after {
     92.customize-control-widget_form.expanded .widget-action .toggle-indicator:before {
    9393        content: "\f142";
    9494}
    9595
    96 .customize-control-widget_form.wide-widget-control a.widget-action:after {
     96.customize-control-widget_form.wide-widget-control .widget-action .toggle-indicator:before {
    9797        content: "\f139";
    9898}
    9999
    100 .customize-control-widget_form.wide-widget-control.expanded a.widget-action:after {
     100.customize-control-widget_form.wide-widget-control.expanded .widget-action .toggle-indicator:before {
    101101        content: "\f141";
    102102}
    103103
    body.adding-widget #customize-preview { 
    438438        .last-widget {
    439439                margin-bottom: 15px;
    440440        }
     441        /* This rule reduces the widgets titles height. */
    441442        .widget-title h3 {
    442443                padding: 13px 15px;
    443444        }
     445        .widget-top .widget-action {
     446                padding-bottom: 8px;
     447        }
    444448        .widget-reorder-nav span {
    445449                height: 39px;
    446450        }
  • src/wp-admin/css/dashboard.css

    diff --git a/src/wp-admin/css/dashboard.css b/src/wp-admin/css/dashboard.css
    index d467f0c..98fb993 100644
    a b  
    308308        padding: 0;
    309309}
    310310
    311 #dashboard_primary .widget-loading,
    312 #dashboard_primary .dashboard-widget-control-form {
     311#dashboard_primary .widget-loading {
    313312        padding: 12px 12px 0;
     313        margin-bottom: 1em !important; /* Needs to override `.postbox .inside > p:last-child` in common.css */
    314314}
    315315
    316 body #dashboard-widgets .postbox form .submit {
     316/* Notice when JS is off. */
     317#dashboard_primary .inside .notice {
    317318        margin: 0;
    318319}
    319320
    320 .dashboard-widget-control-form {
    321         overflow: hidden;
     321body #dashboard-widgets .postbox form .submit {
     322        margin: 0;
    322323}
    323324
     325/* Used only for configurable widgets. */
    324326.dashboard-widget-control-form p {
    325327        margin-top: 0;
    326328}
  • src/wp-admin/css/themes.css

    diff --git a/src/wp-admin/css/themes.css b/src/wp-admin/css/themes.css
    index a18a89a..86fc133 100644
    a b body.full-overlay-active { 
    13321332        -moz-box-sizing: border-box;
    13331333        box-sizing: border-box;
    13341334        position: fixed;
    1335         width: 300px;
     1335        min-width: 300px;
     1336        max-width: 600px;
     1337        width: 18%;
    13361338        height: 100%;
    13371339        top: 0;
    13381340        bottom: 0;
    body.full-overlay-active { 
    13611363        margin-left: -300px;
    13621364}
    13631365
     1366@media screen and (min-width: 1667px) {
     1367        .wp-full-overlay.expanded {
     1368                margin-left: 18%;
     1369        }
     1370
     1371        .wp-full-overlay.collapsed .wp-full-overlay-sidebar {
     1372                margin-left: -18%;
     1373        }
     1374}
     1375
     1376@media screen and (min-width: 3333px) {
     1377        .wp-full-overlay.expanded {
     1378                margin-left: 600px;
     1379        }
     1380
     1381        .wp-full-overlay.collapsed .wp-full-overlay-sidebar {
     1382                margin-left: -600px;
     1383        }
     1384}
     1385
    13641386.wp-full-overlay-sidebar:after {
    13651387        content: "";
    13661388        display: block;
    body.full-overlay-active { 
    15201542        box-shadow: none !important;
    15211543        -webkit-border-radius: 0 !important;
    15221544        border-radius: 0 !important;
    1523         z-index: -1; /* Below device buttons */
    15241545}
    15251546
    15261547.wp-core-ui .wp-full-overlay .collapse-sidebar:hover,
    body.full-overlay-active { 
    16161637        position: fixed;
    16171638        bottom: 0;
    16181639        left: 0;
    1619         width: 299px;
     1640        min-width: 299px;
     1641        max-width: 599px;
     1642        width: 18%;
    16201643        height: 45px;
    16211644        border-top: 1px solid #ddd;
    16221645        background: #eee;
    16231646}
    16241647
    1625 .wp-full-overlay-footer .devices {
     1648.wp-full-overlay-footer .devices-wrapper {
    16261649        float: right;
     1650}
     1651
     1652.wp-full-overlay-footer .devices {
     1653        position: relative;
    16271654        background: #eee;
    16281655        -webkit-box-shadow: -20px 0 10px -5px #eee;
    16291656        box-shadow: -20px 0 10px -5px #eee;
  • src/wp-admin/css/widgets.css

    diff --git a/src/wp-admin/css/widgets.css b/src/wp-admin/css/widgets.css
    index f0be076..bc794e5 100644
    a b  
    1414        background: #f7f7f7;
    1515}
    1616
    17 .widget-top a.widget-action,
    18 .widget-top a.widget-action:hover {
    19         -webkit-box-shadow: none;
    20         box-shadow: none;
     17.widget-top .widget-action {
     18        border: 0;
     19        margin: 0;
     20        padding: 10px;
     21        background: none;
     22        cursor: pointer;
    2123        outline: none;
    22         text-decoration: none;
    2324}
    2425
    2526.widget-title h3,
     
    5051}
    5152
    5253.deleting .widget-title,
    53 .deleting .widget-top a.widget-action:after {
     54.deleting .widget-top .widget-action .toggle-indicator:before {
    5455        color: #a0a5aa;
    5556}
    5657
     
    9192        box-sizing: border-box;
    9293}
    9394
    94 .sidebar-name-arrow {
    95         position: absolute;
    96         top: 0;
    97         right: 0;
    98         bottom: 0;
     95.js .sidebar-name .handlediv {
     96        float: right;
     97    width: 32px;
     98    height: 32px;
     99    padding: 0;
     100}
     101
     102.js .sidebar-name .handlediv:focus {
     103        box-shadow: none;
     104        outline: none;
     105}
     106
     107.js #widgets-left .sidebar-name .handlediv:focus .sidebar-name-arrow {
     108        display: block;
     109}
     110
     111.js .sidebar-name .handlediv:focus .sidebar-name-arrow:before {
     112        box-shadow:
     113                0 0 0 1px #5b9dd9,
     114                0 0 2px 1px rgba(30, 140, 190, .8);
     115}
     116
     117.js .sidebar-name .sidebar-name-arrow:before {
     118        margin-top: 14px;
     119        width: 20px;
     120        border-radius: 50%;
     121        text-indent: -1px; /* account for the dashicon alignment */
     122}
     123
     124.js .widget-liquid-left .sidebar-name .sidebar-name-arrow:before {
     125        margin-top: 7px;
    99126}
    100127
    101128.js .sidebar-name {
    div#widgets-left .sidebar-name h3 { 
    156183        margin: 0 10px 0 0;
    157184}
    158185
    159 #widgets-left .sidebar-name .sidebar-name-arrow:before {
    160         padding: 9px;
    161 }
    162 
    163186#widgets-left .widgets-holder-wrap,
    164187div#widgets-left .widget-holder {
    165188        background: transparent;
    div#widgets-right .sidebar-name h3 { 
    249272        padding: 15px 7px;
    250273}
    251274
    252 div#widgets-right .sidebar-name .sidebar-name-arrow:before {
    253         top: 2px;
    254 }
    255 
    256275div#widgets-right .widget-top {
    257276        padding: 0;
    258277}
  • src/wp-admin/customize.php

    diff --git a/src/wp-admin/customize.php b/src/wp-admin/customize.php
    index f1e66ff..b6c1e63 100644
    a b  
    171171                </div>
    172172
    173173                <div id="customize-footer-actions" class="wp-full-overlay-footer">
    174                         <?php $previewable_devices = $wp_customize->get_previewable_devices(); ?>
    175                         <?php if ( ! empty( $previewable_devices ) ) : ?>
    176                         <div class="devices">
    177                                 <?php foreach ( (array) $previewable_devices as $device => $settings ) : ?>
    178                                         <?php
    179                                         if ( empty( $settings['label'] ) ) {
    180                                                 continue;
    181                                         }
    182                                         $active = ! empty( $settings['default'] );
    183                                         $class = 'preview-' . $device;
    184                                         if ( $active ) {
    185                                                 $class .= ' active';
    186                                         }
    187                                         ?>
    188                                         <button type="button" class="<?php echo esc_attr( $class ); ?>" aria-pressed="<?php echo esc_attr( $active ) ?>" data-device="<?php echo esc_attr( $device ); ?>">
    189                                                 <span class="screen-reader-text"><?php echo esc_html( $settings['label'] ); ?></span>
    190                                         </button>
    191                                 <?php endforeach; ?>
    192                         </div>
    193                         <?php endif; ?>
    194174                        <button type="button" class="collapse-sidebar button" aria-expanded="true" aria-label="<?php echo esc_attr( _x( 'Hide Controls', 'label for hide controls button without length constraints' ) ); ?>">
    195175                                <span class="collapse-sidebar-arrow"></span>
    196176                                <span class="collapse-sidebar-label"><?php _ex( 'Hide Controls', 'short (~12 characters) label for hide controls button' ); ?></span>
    197177                        </button>
     178                        <?php $previewable_devices = $wp_customize->get_previewable_devices(); ?>
     179                        <?php if ( ! empty( $previewable_devices ) ) : ?>
     180                        <div class="devices-wrapper">
     181                                <div class="devices">
     182                                        <?php foreach ( (array) $previewable_devices as $device => $settings ) : ?>
     183                                                <?php
     184                                                if ( empty( $settings['label'] ) ) {
     185                                                        continue;
     186                                                }
     187                                                $active = ! empty( $settings['default'] );
     188                                                $class = 'preview-' . $device;
     189                                                if ( $active ) {
     190                                                        $class .= ' active';
     191                                                }
     192                                                ?>
     193                                                <button type="button" class="<?php echo esc_attr( $class ); ?>" aria-pressed="<?php echo esc_attr( $active ) ?>" data-device="<?php echo esc_attr( $device ); ?>">
     194                                                        <span class="screen-reader-text"><?php echo esc_html( $settings['label'] ); ?></span>
     195                                                </button>
     196                                        <?php endforeach; ?>
     197                                </div>
     198                        </div>
     199                        <?php endif; ?>
    198200                </div>
    199201        </form>
    200202        <div id="customize-preview" class="wp-full-overlay-main"></div>
  • src/wp-admin/includes/ajax-actions.php

    diff --git a/src/wp-admin/includes/ajax-actions.php b/src/wp-admin/includes/ajax-actions.php
    index 90a9dd1..3342cad 100644
    a b function wp_ajax_wp_link_ajax() { 
    14971497
    14981498        $args['pagenum'] = ! empty( $_POST['page'] ) ? absint( $_POST['page'] ) : 1;
    14991499
    1500         require(ABSPATH . WPINC . '/class-wp-editor.php');
     1500        if ( ! class_exists( '_WP_Editors', false ) ) {
     1501                require( ABSPATH . WPINC . '/class-wp-editor.php' );
     1502        }
     1503
    15011504        $results = _WP_Editors::wp_link_query( $args );
    15021505
    15031506        if ( ! isset( $results ) )
  • src/wp-admin/includes/dashboard.php

    diff --git a/src/wp-admin/includes/dashboard.php b/src/wp-admin/includes/dashboard.php
    index b763d43..be0b201 100644
    a b function wp_add_dashboard_widget( $widget_id, $widget_name, $callback, $control_ 
    191191 * @param array $meta_box
    192192 */
    193193function _wp_dashboard_control_callback( $dashboard, $meta_box ) {
    194         echo '<form method="post" class="dashboard-widget-control-form">';
     194        echo '<form method="post" class="dashboard-widget-control-form wp-clearfix">';
    195195        wp_dashboard_trigger_widget_control( $meta_box['id'] );
    196196        wp_nonce_field( 'edit-dashboard-widget_' . $meta_box['id'], 'dashboard-widget-nonce' );
    197197        echo '<input type="hidden" name="widget_id" value="' . esc_attr($meta_box['id']) . '" />';
    function wp_dashboard_rss_output( $widget_id ) { 
    968968 * @return bool False on failure. True on success.
    969969 */
    970970function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = array() ) {
    971         $loading = '<p class="widget-loading hide-if-no-js">' . __( 'Loading&#8230;' ) . '</p><p class="hide-if-js">' . __( 'This widget requires JavaScript.' ) . '</p>';
     971        $loading = '<p class="widget-loading hide-if-no-js">' . __( 'Loading&#8230;' ) . '</p><div class="hide-if-js notice notice-error inline"><p>' . __( 'This widget requires JavaScript.' ) . '</p></div>';
    972972        $doing_ajax = wp_doing_ajax();
    973973
    974974        if ( empty($check_urls) ) {
  • src/wp-admin/includes/meta-boxes.php

    diff --git a/src/wp-admin/includes/meta-boxes.php b/src/wp-admin/includes/meta-boxes.php
    index 23ca247..ba43c7d 100644
    a b function post_submit_meta_box( $post, $args = array() ) { 
    5050<?php
    5151$preview_link = esc_url( get_preview_post_link( $post ) );
    5252if ( 'publish' == $post->post_status ) {
    53         $preview_button = __( 'Preview Changes' );
     53        $preview_button_text = __( 'Preview Changes' );
    5454} else {
    55         $preview_button = __( 'Preview' );
     55        $preview_button_text = __( 'Preview' );
    5656}
     57
     58$preview_button = sprintf( '%1$s<span class="screen-reader-text"> %2$s</span>',
     59        $preview_button_text,
     60        /* translators: accessibility text */
     61        __( '(link opens in a new window)' )
     62);
    5763?>
    5864<a class="preview button" href="<?php echo $preview_link; ?>" target="wp-preview-<?php echo (int) $post->ID; ?>" id="post-preview"><?php echo $preview_button; ?></a>
    5965<input type="hidden" name="wp-preview" id="wp-preview" value="" />
  • src/wp-admin/includes/ms.php

    diff --git a/src/wp-admin/includes/ms.php b/src/wp-admin/includes/ms.php
    index 6a4ca9d..939d0d0 100644
    a b function mu_dropdown_languages( $lang_files = array(), $current = '' ) { 
    785785function site_admin_notice() {
    786786        global $wp_db_version, $pagenow;
    787787
    788         if ( ! is_super_admin() ) {
     788        if ( ! current_user_can( 'upgrade_network' ) ) {
    789789                return false;
    790790        }
    791791
  • src/wp-admin/includes/options.php

    diff --git a/src/wp-admin/includes/options.php b/src/wp-admin/includes/options.php
    index 95d9964..14c175d 100644
    a b function options_general_add_js() { 
    5353                        if ( "date_format_custom_radio" != $(this).attr("id") )
    5454                                $( "input[name='date_format_custom']" ).val( $( this ).val() ).siblings( '.example' ).text( $( this ).parent( 'label' ).children( '.format-i18n' ).text() );
    5555                });
    56                 $("input[name='date_format_custom']").focus(function(){
     56                $( 'input[name="date_format_custom"]' ).on( 'click input', function() {
    5757                        $( '#date_format_custom_radio' ).prop( 'checked', true );
    5858                });
    5959
    function options_general_add_js() { 
    6161                        if ( "time_format_custom_radio" != $(this).attr("id") )
    6262                                $( "input[name='time_format_custom']" ).val( $( this ).val() ).siblings( '.example' ).text( $( this ).parent( 'label' ).children( '.format-i18n' ).text() );
    6363                });
    64                 $("input[name='time_format_custom']").focus(function(){
     64                $( 'input[name="time_format_custom"]' ).on( 'click input', function() {
    6565                        $( '#time_format_custom_radio' ).prop( 'checked', true );
    6666                });
    6767                $("input[name='date_format_custom'], input[name='time_format_custom']").change( function() {
  • src/wp-admin/includes/post.php

    diff --git a/src/wp-admin/includes/post.php b/src/wp-admin/includes/post.php
    index 1054f2b..8055a7b 100644
    a b function _wp_post_thumbnail_html( $thumbnail_id = null, $post = null ) { 
    14481448 *
    14491449 * @since 2.5.0
    14501450 *
    1451  * @param int $post_id ID of the post to check for editing
    1452  * @return integer False: not locked or locked by current user. Int: user ID of user with lock.
     1451 * @param int $post_id ID of the post to check for editing.
     1452 * @return int|false ID of the user with lock. False if the post does not exist, post is not locked,
     1453 *                   the user with lock does not exist, or the post is locked by current user.
    14531454 */
    14541455function wp_check_post_lock( $post_id ) {
    1455         if ( !$post = get_post( $post_id ) )
     1456        if ( ! $post = get_post( $post_id ) ) {
    14561457                return false;
     1458        }
    14571459
    1458         if ( !$lock = get_post_meta( $post->ID, '_edit_lock', true ) )
     1460        if ( ! $lock = get_post_meta( $post->ID, '_edit_lock', true ) ) {
    14591461                return false;
     1462        }
    14601463
    14611464        $lock = explode( ':', $lock );
    14621465        $time = $lock[0];
    14631466        $user = isset( $lock[1] ) ? $lock[1] : get_post_meta( $post->ID, '_edit_last', true );
    14641467
     1468        if ( ! get_userdata( $user ) ) {
     1469                return false;
     1470        }
     1471
    14651472        /** This filter is documented in wp-admin/includes/ajax-actions.php */
    14661473        $time_window = apply_filters( 'wp_check_post_lock_window', 150 );
    14671474
    1468         if ( $time && $time > time() - $time_window && $user != get_current_user_id() )
     1475        if ( $time && $time > time() - $time_window && $user != get_current_user_id() ) {
    14691476                return $user;
     1477        }
     1478
    14701479        return false;
    14711480}
    14721481
    function wp_check_post_lock( $post_id ) { 
    14751484 *
    14761485 * @since 2.5.0
    14771486 *
    1478  * @param int $post_id ID of the post to being edited
    1479  * @return bool|array Returns false if the post doesn't exist of there is no current user, or
    1480  *      an array of the lock time and the user ID.
     1487 * @param int $post_id ID of the post being edited.
     1488 * @return array|false Array of the lock time and user ID. False if the post does not exist, or
     1489 *                     there is no current user.
    14811490 */
    14821491function wp_set_post_lock( $post_id ) {
    1483         if ( !$post = get_post( $post_id ) )
     1492        if ( ! $post = get_post( $post_id ) ) {
    14841493                return false;
    1485         if ( 0 == ($user_id = get_current_user_id()) )
     1494        }
     1495
     1496        if ( 0 == ( $user_id = get_current_user_id() ) ) {
    14861497                return false;
     1498        }
    14871499
    14881500        $now = time();
    14891501        $lock = "$now:$user_id";
    14901502
    14911503        update_post_meta( $post->ID, '_edit_lock', $lock );
     1504
    14921505        return array( $now, $user_id );
    14931506}
    14941507
  • src/wp-admin/includes/schema.php

    diff --git a/src/wp-admin/includes/schema.php b/src/wp-admin/includes/schema.php
    index 70b4686..64ec6b7 100644
    a b function populate_network( $network_id = 1, $domain = '', $email = '', $site_nam 
    951951
    952952        if ( !is_multisite() ) {
    953953                $site_admins = array( $site_user->user_login );
    954                 $users = get_users( array( 'fields' => array( 'ID', 'user_login' ) ) );
     954                $users = get_users( array(
     955                        'fields' => array( 'user_login' ),
     956                        'role'   => 'administrator',
     957                ) );
    955958                if ( $users ) {
    956959                        foreach ( $users as $user ) {
    957                                 if ( is_super_admin( $user->ID ) && !in_array( $user->user_login, $site_admins ) )
    958                                         $site_admins[] = $user->user_login;
     960                                $site_admins[] = $user->user_login;
    959961                        }
     962
     963                        $site_admins = array_unique( $site_admins );
    960964                }
    961965        } else {
    962966                $site_admins = get_site_option( 'site_admins' );
  • src/wp-admin/includes/template.php

    diff --git a/src/wp-admin/includes/template.php b/src/wp-admin/includes/template.php
    index a4672fd..f568e39 100644
    a b function do_accordion_sections( $screen, $context, $object ) { 
    11611161                                        }
    11621162                                        ?>
    11631163                                        <li class="control-section accordion-section <?php echo $hidden_class; ?> <?php echo $open_class; ?> <?php echo esc_attr( $box['id'] ); ?>" id="<?php echo esc_attr( $box['id'] ); ?>">
    1164                                                 <h3 class="accordion-section-title hndle" tabindex="0">
     1164                                                <button type="button" class="handlediv button-link" aria-expanded="true">
     1165                                                        <span class="screen-reader-text"><?php echo sprintf( __( 'Toggle panel: %s' ), esc_html( $box['title'] ) ); ?></span>
     1166                                                        <span class="sidebar-name-arrow" aria-hidden="true"></span>
     1167                                                </button>
     1168                                                <h3 class="accordion-section-title hndle">
    11651169                                                        <?php echo esc_html( $box['title'] ); ?>
    1166                                                         <span class="screen-reader-text"><?php _e( 'Press return or enter to open this section' ); ?></span>
    11671170                                                </h3>
    11681171                                                <div class="accordion-section-content <?php postbox_classes( $box['id'], $page ); ?>">
    11691172                                                        <div class="inside">
  • src/wp-admin/includes/widgets.php

    diff --git a/src/wp-admin/includes/widgets.php b/src/wp-admin/includes/widgets.php
    index fe2a957..408165c 100644
    a b function wp_list_widget_controls( $sidebar, $sidebar_name = '' ) { 
    8080        if ( $sidebar_name ) {
    8181                ?>
    8282                <div class="sidebar-name">
    83                         <div class="sidebar-name-arrow"><br /></div>
     83                        <button type="button" class="handlediv button-link" aria-expanded="true">
     84                                <span class="screen-reader-text"><?php echo sprintf( __( 'Toggle panel: %s' ), $sidebar_name ); ?></span>
     85                                <span class="sidebar-name-arrow" aria-hidden="true"></span>
     86                        </button>
    8487                        <h2><?php echo esc_html( $sidebar_name ); ?> <span class="spinner"></span></h2>
    8588                </div>
    8689                <?php
    function wp_widget_control( $sidebar_args ) { 
    219222        echo $sidebar_args['before_widget']; ?>
    220223        <div class="widget-top">
    221224        <div class="widget-title-action">
    222                 <a class="widget-action hide-if-no-js" href="#available-widgets"></a>
     225                <button type="button" class="widget-action hide-if-no-js" aria-expanded="false">
     226                        <span class="screen-reader-text"><?php printf( __( 'Edit widget: %s' ), $widget_title ); ?></span>
     227                        <span class="toggle-indicator" aria-hidden="true"></span>
     228                </button>
    223229                <a class="widget-control-edit hide-if-js" href="<?php echo esc_url( add_query_arg( $query_arg ) ); ?>">
    224230                        <span class="edit"><?php _ex( 'Edit', 'widget' ); ?></span>
    225231                        <span class="add"><?php _ex( 'Add', 'widget' ); ?></span>
    function wp_widget_control( $sidebar_args ) { 
    250256
    251257        <div class="widget-control-actions">
    252258                <div class="alignleft">
    253                 <a class="widget-control-remove" href="#remove"><?php _e('Delete'); ?></a> |
    254                 <a class="widget-control-close" href="#close"><?php _e('Close'); ?></a>
     259                        <button type="button" class="button-link button-link-delete widget-control-remove"><?php _e( 'Delete' ); ?></button> |
     260                        <button type="button" class="button-link widget-control-close"><?php _e( 'Close' ); ?></button>
    255261                </div>
    256262                <div class="alignright<?php if ( 'noform' === $has_form ) echo ' widget-control-noform'; ?>">
    257263                        <?php submit_button( __( 'Save' ), 'primary widget-control-save right', 'savewidget', false, array( 'id' => 'widget-' . esc_attr( $id_format ) . '-savewidget' ) ); ?>
  • src/wp-admin/js/accordion.js

    diff --git a/src/wp-admin/js/accordion.js b/src/wp-admin/js/accordion.js
    index af62815..6eb919a 100644
    a b  
    3333        $( document ).ready( function () {
    3434
    3535                // Expand/Collapse accordion sections on click.
    36                 $( '.accordion-container' ).on( 'click keydown', '.accordion-section-title', function( e ) {
     36                $( '.accordion-container' ).on( 'click keydown', '.accordion-section-title, .handlediv', function( e ) {
    3737                        if ( e.type === 'keydown' && 13 !== e.which ) { // "return" key
    3838                                return;
    3939                        }
  • src/wp-admin/js/customize-controls.js

    diff --git a/src/wp-admin/js/customize-controls.js b/src/wp-admin/js/customize-controls.js
    index e038dcc..d340a1b 100644
    a b  
    47624762                         */
    47634763                        populateChangesetUuidParam = function( isIncluded ) {
    47644764                                var urlParser, queryParams;
     4765
     4766                                // Abort on IE9 which doesn't support history management.
     4767                                if ( ! history.replaceState ) {
     4768                                        return;
     4769                                }
     4770
    47654771                                urlParser = document.createElement( 'a' );
    47664772                                urlParser.href = location.href;
    47674773                                queryParams = api.utils.parseQueryString( urlParser.search.substr( 1 ) );
     
    47804786                                history.replaceState( {}, document.title, urlParser.href );
    47814787                        };
    47824788
    4783                         if ( history.replaceState ) {
    4784                                 changesetStatus.bind( function( newStatus ) {
    4785                                         populateChangesetUuidParam( '' !== newStatus && 'publish' !== newStatus );
    4786                                 } );
    4787                         }
     4789                        changesetStatus.bind( function( newStatus ) {
     4790                                populateChangesetUuidParam( '' !== newStatus && 'publish' !== newStatus );
     4791                        } );
    47884792
    47894793                        // Expose states to the API.
    47904794                        api.state = state;
  • src/wp-admin/js/customize-widgets.js

    diff --git a/src/wp-admin/js/customize-widgets.js b/src/wp-admin/js/customize-widgets.js
    index b482e8d..df4c8d7 100644
    a b  
    952952                        var self = this, $removeBtn, replaceDeleteWithRemove;
    953953
    954954                        // Configure remove button
    955                         $removeBtn = this.container.find( 'a.widget-control-remove' );
     955                        $removeBtn = this.container.find( '.widget-control-remove' );
    956956                        $removeBtn.on( 'click', function( e ) {
    957957                                e.preventDefault();
    958958
     
    988988                        } );
    989989
    990990                        replaceDeleteWithRemove = function() {
    991                                 $removeBtn.text( l10n.removeBtnLabel ); // wp_widget_control() outputs the link as "Delete"
     991                                $removeBtn.text( l10n.removeBtnLabel ); // wp_widget_control() outputs the button as "Delete"
    992992                                $removeBtn.attr( 'title', l10n.removeBtnTooltip );
    993993                        };
    994994
     
    13671367                 * @param {Object} args  merged on top of this.defaultActiveArguments
    13681368                 */
    13691369                onChangeExpanded: function ( expanded, args ) {
    1370                         var self = this, $widget, $inside, complete, prevComplete, expandControl;
     1370                        var self = this, $widget, $inside, complete, prevComplete, expandControl, $toggleBtn;
    13711371
    13721372                        self.embedWidgetControl(); // Make sure the outer form is embedded so that the expanded state can be set in the UI.
    13731373                        if ( expanded ) {
     
    13861386
    13871387                        $widget = this.container.find( 'div.widget:first' );
    13881388                        $inside = $widget.find( '.widget-inside:first' );
     1389                        $toggleBtn = this.container.find( '.widget-top button.widget-action' );
    13891390
    13901391                        expandControl = function() {
    13911392
     
    13991400                                complete = function() {
    14001401                                        self.container.removeClass( 'expanding' );
    14011402                                        self.container.addClass( 'expanded' );
     1403                                        $toggleBtn.attr( 'aria-expanded', 'true' );
    14021404                                        self.container.trigger( 'expanded' );
    14031405                                };
    14041406                                if ( args.completeCallback ) {
     
    14281430                                        expandControl();
    14291431                                }
    14301432                        } else {
    1431 
    14321433                                complete = function() {
    14331434                                        self.container.removeClass( 'collapsing' );
    14341435                                        self.container.removeClass( 'expanded' );
     1436                                        $toggleBtn.attr( 'aria-expanded', 'false' );
    14351437                                        self.container.trigger( 'collapsed' );
    14361438                                };
    14371439                                if ( args.completeCallback ) {
  • src/wp-admin/js/editor.js

    diff --git a/src/wp-admin/js/editor.js b/src/wp-admin/js/editor.js
    index a63a51c..917721a 100644
    a b  
     1window.wp = window.wp || {};
     2
     3( function( $, wp ) {
     4        wp.editor = wp.editor || {};
    15
    2 ( function( $ ) {
    36        /**
    47         * @summary Utility functions for the editor.
    58         *
     
    484487                        } );
    485488                }
    486489
    487                 window.wp = window.wp || {};
    488                 window.wp.editor = window.wp.editor || {};
    489                 window.wp.editor.autop = wpautop;
    490                 window.wp.editor.removep = pre_wpautop;
     490                wp.editor.autop = wpautop;
     491                wp.editor.removep = pre_wpautop;
    491492
    492493                exports = {
    493494                        go: switchEditor,
     
    505506         * Expose the switch editors to be used globally.
    506507         */
    507508        window.switchEditors = new SwitchEditors();
    508 }( window.jQuery ));
     509
     510        /**
     511         * Initialize TinyMCE and/or Quicktags. For use with wp_enqueue_editor() (PHP).
     512         *
     513         * Intended for use with an existing textarea that will become the Text editor tab.
     514         * The editor width will be the width of the textarea container, height will be adjustable.
     515         *
     516         * Settings for both TinyMCE and Quicktags can be passed on initialization, and are "filtered"
     517         * with custom jQuery events on the document element, wp-before-tinymce-init and wp-before-quicktags-init.
     518         *
     519         * @since 4.8
     520         *
     521         * @param {string} id The HTML id of the textarea that is used for the editor.
     522         *                    Has to be jQuery compliant. No brackets, special chars, etc.
     523         * @param {object} settings Example:
     524         * settings = {
     525         *    // See https://www.tinymce.com/docs/configure/integration-and-setup/.
     526         *    // Alternatively set to `true` to use the defaults.
     527         *    tinymce: {
     528         *        setup: function( editor ) {
     529         *            console.log( 'Editor initialized', editor );
     530         *        }
     531         *    }
     532         *
     533         *    // Alternatively set to `true` to use the defaults.
     534         *        quicktags: {
     535         *        buttons: 'strong,em,link'
     536         *    }
     537         * }
     538         */
     539        wp.editor.initialize = function( id, settings ) {
     540                var init;
     541                var defaults;
     542
     543                if ( ! $ || ! id || ! wp.editor.getDefaultSettings ) {
     544                        return;
     545                }
     546
     547                defaults = wp.editor.getDefaultSettings();
     548
     549                // Initialize TinyMCE by default
     550                if ( ! settings ) {
     551                        settings = {
     552                                tinymce: true
     553                        };
     554                }
     555
     556                // Add wrap and the Visual|Text tabs.
     557                if ( settings.tinymce && settings.quicktags ) {
     558                        var $textarea = $( '#' + id );
     559                        var $wrap = $( '<div>' ).attr( {
     560                                        'class': 'wp-core-ui wp-editor-wrap tmce-active',
     561                                        id: 'wp-' + id + '-wrap'
     562                                } );
     563                        var $editorContainer = $( '<div class="wp-editor-container">' );
     564                        var $button = $( '<button>' ).attr( {
     565                                        type: 'button',
     566                                        'data-wp-editor-id': id
     567                                } );
     568
     569                        $wrap.append(
     570                                $( '<div class="wp-editor-tools">' )
     571                                        .append( $( '<div class="wp-editor-tabs">' )
     572                                                .append( $button.clone().attr({
     573                                                        id: id + '-tmce',
     574                                                        'class': 'wp-switch-editor switch-tmce'
     575                                                }).text( window.tinymce.translate( 'Visual' ) ) )
     576                                                .append( $button.attr({
     577                                                        id: id + '-html',
     578                                                        'class': 'wp-switch-editor switch-html'
     579                                                }).text( window.tinymce.translate( 'Text' ) ) )
     580                                        ).append( $editorContainer )
     581                        );
     582
     583                        $textarea.after( $wrap );
     584                        $editorContainer.append( $textarea );
     585                }
     586
     587                if ( window.tinymce && settings.tinymce ) {
     588                        if ( typeof settings.tinymce !== 'object' ) {
     589                                settings.tinymce = {};
     590                        }
     591
     592                        init = $.extend( {}, defaults.tinymce, settings.tinymce );
     593                        init.selector = '#' + id;
     594
     595                        $( document ).trigger( 'wp-before-tinymce-init', init );
     596                        window.tinymce.init( init );
     597
     598                        if ( ! window.wpActiveEditor ) {
     599                                window.wpActiveEditor = id;
     600                        }
     601                }
     602
     603                if ( window.quicktags && settings.quicktags ) {
     604                        if ( typeof settings.quicktags !== 'object' ) {
     605                                settings.quicktags = {};
     606                        }
     607
     608                        init = $.extend( {}, defaults.quicktags, settings.quicktags );
     609                        init.id = id;
     610
     611                        $( document ).trigger( 'wp-before-quicktags-init', init );
     612                        window.quicktags( init );
     613
     614                        if ( ! window.wpActiveEditor ) {
     615                                window.wpActiveEditor = init.id;
     616                        }
     617                }
     618        };
     619
     620        /**
     621         * Get the editor content.
     622         *
     623         * Intended for use with editors that were initialized with wp.editor.initialize().
     624         *
     625         * @since 4.8
     626         *
     627         * @param {string} id The HTML id of the editor textarea.
     628         * @return The editor content.
     629         */
     630        wp.editor.getContent = function( id ) {
     631                var editor;
     632
     633                if ( ! $ || ! id ) {
     634                        return;
     635                }
     636
     637                if ( window.tinymce ) {
     638                        editor = window.tinymce.get( id );
     639
     640                        if ( editor && ! editor.isHidden() ) {
     641                                editor.save();
     642                        }
     643                }
     644
     645                return $( '#' + id ).val();
     646        };
     647
     648}( window.jQuery, window.wp ));
  • src/wp-admin/js/widgets.js

    diff --git a/src/wp-admin/js/widgets.js b/src/wp-admin/js/widgets.js
    index aa439ea..77cf8f9 100644
    a b wpWidgets = { 
    4141                $(document.body).bind('click.widgets-toggle', function(e) {
    4242                        var target = $(e.target),
    4343                                css = { 'z-index': 100 },
    44                                 widget, inside, targetWidth, widgetWidth, margin;
     44                                widget, inside, targetWidth, widgetWidth, margin,
     45                                toggleBtn = target.closest( '.widget' ).find( '.widget-top button.widget-action' );
    4546
    4647                        if ( target.parents('.widget-top').length && ! target.parents('#available-widgets').length ) {
    4748                                widget = target.closest('div.widget');
    wpWidgets = { 
    6061                                                css[ margin ] = widgetWidth - ( targetWidth + 30 ) + 'px';
    6162                                                widget.css( css );
    6263                                        }
    63                                         widget.addClass( 'open' );
    64                                         inside.slideDown('fast');
     64                                        /*
     65                                         * Don't change the order of attributes changes and animation:
     66                                         * it's important for screen readers, see ticket #31476.
     67                                         */
     68                                        toggleBtn.attr( 'aria-expanded', 'true' );
     69                                        inside.slideDown( 'fast', function() {
     70                                                widget.addClass( 'open' );
     71                                        });
    6572                                } else {
    66                                         inside.slideUp('fast', function() {
     73                                        /*
     74                                         * Don't change the order of attributes changes and animation:
     75                                         * it's important for screen readers, see ticket #31476.
     76                                         */
     77                                        toggleBtn.attr( 'aria-expanded', 'false' );
     78                                        inside.slideUp( 'fast', function() {
    6779                                                widget.attr( 'style', '' );
    6880                                                widget.removeClass( 'open' );
    6981                                        });
    wpWidgets = { 
    7890                        } else if ( target.hasClass('widget-control-close') ) {
    7991                                widget = target.closest('div.widget');
    8092                                widget.removeClass( 'open' );
     93                                toggleBtn.attr( 'aria-expanded', 'false' );
    8194                                wpWidgets.close( widget );
    8295                                e.preventDefault();
    8396                        } else if ( target.attr( 'id' ) === 'inactive-widgets-control-remove' ) {
    wpWidgets = { 
    92105                        wpWidgets.appendTitle( this );
    93106
    94107                        if ( $this.find( 'p.widget-error' ).length ) {
    95                                 $this.find( 'a.widget-action' ).trigger('click');
     108                                $this.find( '.widget-action' ).trigger( 'click' ).attr( 'aria-expanded', 'true' );
    96109                        }
    97110                });
    98111
    wpWidgets = { 
    182195
    183196                                if ( inside.css('display') === 'block' ) {
    184197                                        ui.item.removeClass('open');
     198                                        ui.item.find( '.widget-top button.widget-action' ).attr( 'aria-expanded', 'false' );
    185199                                        inside.hide();
    186200                                        $(this).sortable('refreshPositions');
    187201                                }
    wpWidgets = { 
    254268                                }
    255269
    256270                                if ( addNew ) {
    257                                         $widget.find( 'a.widget-action' ).trigger('click');
     271                                        $widget.find( '.widget-action' ).trigger( 'click' );
    258272                                } else {
    259273                                        wpWidgets.saveOrder( $sidebar.attr('id') );
    260274                                }
    wpWidgets = { 
    492506
    493507        close : function(widget) {
    494508                widget.children('.widget-inside').slideUp('fast', function() {
    495                         widget.attr( 'style', '' );
     509                        widget.attr( 'style', '' )
     510                                .find( '.widget-top button.widget-action' )
     511                                        .attr( 'aria-expanded', 'false' )
     512                                        .focus();
    496513                });
    497514        },
    498515
  • src/wp-admin/network/menu.php

    diff --git a/src/wp-admin/network/menu.php b/src/wp-admin/network/menu.php
    index 41281e7..e4cc786 100644
    a b  
    1919        $submenu['index.php'][10] = array( __( 'Updates' ), 'update_core', 'update-core.php' );
    2020}
    2121
    22 $submenu['index.php'][15] = array( __( 'Upgrade Network' ), 'manage_network', 'upgrade.php' );
     22$submenu['index.php'][15] = array( __( 'Upgrade Network' ), 'upgrade_network', 'upgrade.php' );
    2323
    2424$menu[4] = array( '', 'read', 'separator1', '', 'wp-menu-separator' );
    2525
  • src/wp-admin/network/site-new.php

    diff --git a/src/wp-admin/network/site-new.php b/src/wp-admin/network/site-new.php
    index 0be051e..f36dffb 100644
    a b  
    1313/** WordPress Translation Install API */
    1414require_once( ABSPATH . 'wp-admin/includes/translation-install.php' );
    1515
    16 if ( ! current_user_can( 'manage_sites' ) )
     16if ( ! current_user_can( 'create_sites' ) ) {
    1717        wp_die( __( 'Sorry, you are not allowed to add sites to this network.' ) );
     18}
    1819
    1920get_current_screen()->add_help_tab( array(
    2021        'id'      => 'overview',
  • src/wp-admin/network/upgrade.php

    diff --git a/src/wp-admin/network/upgrade.php b/src/wp-admin/network/upgrade.php
    index 5c2d3f9..46c6a94 100644
    a b  
    3232
    3333require_once( ABSPATH . 'wp-admin/admin-header.php' );
    3434
    35 if ( ! current_user_can( 'manage_network' ) )
     35if ( ! current_user_can( 'upgrade_network' ) ) {
    3636        wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 );
     37}
    3738
    3839echo '<div class="wrap">';
    3940echo '<h1>' . __( 'Upgrade Network' ) . '</h1>';
  • src/wp-admin/options-reading.php

    diff --git a/src/wp-admin/options-reading.php b/src/wp-admin/options-reading.php
    index 69c425f..baa9f75 100644
    a b  
    2222        'title'   => __('Overview'),
    2323        'content' => '<p>' . __('This screen contains the settings that affect the display of your content.') . '</p>' .
    2424                '<p>' . sprintf(__('You can choose what&#8217;s displayed on the front page of your site. It can be posts in reverse chronological order (classic blog), or a fixed/static page. To set a static home page, you first need to create two <a href="%s">Pages</a>. One will become the front page, and the other will be where your posts are displayed.'), 'post-new.php?post_type=page') . '</p>' .
    25                 '<p>' . __('You can also control the display of your content in RSS feeds, including the maximum numbers of posts to display and whether to show full text or a summary.') . '</p>' .
     25                '<p>' . __('You can also control the display of your content in RSS feeds, including the maximum number of posts to display and whether to show full text or a summary.') . '</p>' .
    2626                '<p>' . __('You must click the Save Changes button at the bottom of the screen for new settings to take effect.') . '</p>',
    2727) );
    2828
  • src/wp-admin/widgets.php

    diff --git a/src/wp-admin/widgets.php b/src/wp-admin/widgets.php
    index db4459b..ade84bb 100644
    a b  
    387387<div id="widgets-left">
    388388        <div id="available-widgets" class="widgets-holder-wrap">
    389389                <div class="sidebar-name">
    390                         <div class="sidebar-name-arrow"><br /></div>
     390                        <button type="button" class="handlediv button-link" aria-expanded="true">
     391                                <span class="screen-reader-text">Toggle panel: <?php _e( 'Available Widgets' ); ?></span>
     392                                <span class="sidebar-name-arrow" aria-hidden="true"></span>
     393                        </button>
    391394                        <h2><?php _e( 'Available Widgets' ); ?> <span id="removing-widget"><?php _ex( 'Deactivate', 'removing-widget' ); ?> <span></span></span></h2>
    392395                </div>
    393396                <div class="widget-holder">
  • src/wp-content/themes/twentyseventeen/README.txt

    diff --git a/src/wp-content/themes/twentyseventeen/README.txt b/src/wp-content/themes/twentyseventeen/README.txt
    index 5f1cfb7..9360fc7 100644
    a b  
    22Contributors: the WordPress team
    33Requires at least: WordPress 4.7
    44Tested up to: WordPress 4.7
    5 Version: 1.1
     5Version: 1.2
    66License: GPLv2 or later
    77License URI: http://www.gnu.org/licenses/gpl-2.0.html
    88Tags: one-column, two-columns, right-sidebar, flexible-header, accessibility-ready, custom-colors, custom-header, custom-menu, custom-logo, editor-style, featured-images, footer-widgets, post-formats, rtl-language-support, sticky-post, theme-options, threaded-comments, translation-ready
    Source: https://unsplash.com/@englr?photo=bIhpiQA009k 
    6060
    6161== Changelog ==
    6262
     63= 1.2 =
     64* Released: April 18, 2017
     65
     66https://codex.wordpress.org/Twenty_Seventeen_Theme_Changelog#Version_1.2
     67
    6368= 1.1 =
    6469* Released: January 6, 2017
    6570
    66 - Fix incorrect $content_width value in theme
    67 - Ensure functions in customize-controls.js don't count on Customizer sections always being present
    68 - Deprecate page_home nav menu item starter content in favor of link_home
    69 - Introduce a theme-specific filter twentyseventeen_starter_content for customizing the starter content array
     71https://codex.wordpress.org/Twenty_Seventeen_Theme_Changelog#Version_1.1
    7072
    7173= 1.0 =
    7274* Released: December 6, 2016
  • src/wp-content/themes/twentyseventeen/footer.php

    diff --git a/src/wp-content/themes/twentyseventeen/footer.php b/src/wp-content/themes/twentyseventeen/footer.php
    index c21cfb7..504f573 100644
    a b  
    99 * @package WordPress
    1010 * @subpackage Twenty_Seventeen
    1111 * @since 1.0
    12  * @version 1.0
     12 * @version 1.2
    1313 */
    1414
    1515?>
  • src/wp-content/themes/twentyseventeen/style.css

    diff --git a/src/wp-content/themes/twentyseventeen/style.css b/src/wp-content/themes/twentyseventeen/style.css
    index da3791d..37ec33f 100644
    a b Theme URI: https://wordpress.org/themes/twentyseventeen/ 
    44Author: the WordPress team
    55Author URI: https://wordpress.org/
    66Description: Twenty Seventeen brings your site to life with header video and immersive featured images. With a focus on business sites, it features multiple sections on the front page as well as widgets, navigation and social menus, a logo, and more. Personalize its asymmetrical grid with a custom color scheme and showcase your multimedia content with post formats. Our default theme for 2017 works great in many languages, for any abilities, and on any device.
    7 Version: 1.1
     7Version: 1.2
    88License: GNU General Public License v2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
    1010Text Domain: twentyseventeen
    h1 { 
    451451        font-weight: 300;
    452452}
    453453
    454 h2 {
     454h2,
     455.home.blog .entry-title {
    455456        color: #666;
    456457        font-size: 20px;
    457458        font-size: 1.25rem;
    object { 
    31533154        }
    31543155
    31553156        h2,
     3157        .home.blog .entry-title,
    31563158        .page .panel-content .recent-posts .entry-title {
    31573159                font-size: 26px;
    31583160                font-size: 1.625rem;
  • src/wp-content/themes/twentyseventeen/template-parts/navigation/navigation-top.php

    diff --git a/src/wp-content/themes/twentyseventeen/template-parts/navigation/navigation-top.php b/src/wp-content/themes/twentyseventeen/template-parts/navigation/navigation-top.php
    index be7e426..2c2115e 100644
    a b  
    55 * @package WordPress
    66 * @subpackage Twenty_Seventeen
    77 * @since 1.0
    8  * @version 1.0
     8 * @version 1.2
    99 */
    1010
    1111?>
  • src/wp-content/themes/twentyseventeen/template-parts/post/content-audio.php

    diff --git a/src/wp-content/themes/twentyseventeen/template-parts/post/content-audio.php b/src/wp-content/themes/twentyseventeen/template-parts/post/content-audio.php
    index cf17889..63cf2e5 100644
    a b  
    77 * @package WordPress
    88 * @subpackage Twenty_Seventeen
    99 * @since 1.0
    10  * @version 1.0
     10 * @version 1.2
    1111 */
    1212
    1313?>
     
    3333
    3434                        if ( is_single() ) {
    3535                                the_title( '<h1 class="entry-title">', '</h1>' );
     36                        } elseif ( is_front_page() && is_home() ) {
     37                                the_title( '<h3 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h3>' );
    3638                        } else {
    3739                                the_title( '<h2 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' );
    3840                        }
  • src/wp-content/themes/twentyseventeen/template-parts/post/content-excerpt.php

    diff --git a/src/wp-content/themes/twentyseventeen/template-parts/post/content-excerpt.php b/src/wp-content/themes/twentyseventeen/template-parts/post/content-excerpt.php
    index 4ddc28c..a552fba 100644
    a b  
    99 * @package WordPress
    1010 * @subpackage Twenty_Seventeen
    1111 * @since 1.0
    12  * @version 1.0
     12 * @version 1.2
    1313 */
    1414
    1515?>
     
    3030                        </div><!-- .entry-meta -->
    3131                <?php endif; ?>
    3232
    33                 <?php the_title( sprintf( '<h2 class="entry-title"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h2>' ); ?>
     33                <?php if ( is_front_page() && ! is_home() ) {
     34
     35                        // The excerpt is being displayed within a front page section, so it's a lower hierarchy than h2.
     36                        the_title( sprintf( '<h3 class="entry-title"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h3>' );
     37                } else {
     38                        the_title( sprintf( '<h2 class="entry-title"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h2>' );
     39                } ?>
    3440        </header><!-- .entry-header -->
    3541
    3642        <div class="entry-summary">
  • src/wp-content/themes/twentyseventeen/template-parts/post/content-gallery.php

    diff --git a/src/wp-content/themes/twentyseventeen/template-parts/post/content-gallery.php b/src/wp-content/themes/twentyseventeen/template-parts/post/content-gallery.php
    index e46e7c5..f5934e1 100644
    a b  
    77 * @package WordPress
    88 * @subpackage Twenty_Seventeen
    99 * @since 1.0
    10  * @version 1.0
     10 * @version 1.2
    1111 */
    1212
    1313?>
     
    3333
    3434                if ( is_single() ) {
    3535                        the_title( '<h1 class="entry-title">', '</h1>' );
     36                } elseif ( is_front_page() && is_home() ) {
     37                        the_title( '<h3 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h3>' );
    3638                } else {
    3739                        the_title( '<h2 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' );
    3840                }
  • src/wp-content/themes/twentyseventeen/template-parts/post/content-image.php

    diff --git a/src/wp-content/themes/twentyseventeen/template-parts/post/content-image.php b/src/wp-content/themes/twentyseventeen/template-parts/post/content-image.php
    index 8568d92..91c6545 100644
    a b  
    77 * @package WordPress
    88 * @subpackage Twenty_Seventeen
    99 * @since 1.0
    10  * @version 1.0
     10 * @version 1.2
    1111 */
    1212
    1313?>
     
    3333
    3434                        if ( is_single() ) {
    3535                                the_title( '<h1 class="entry-title">', '</h1>' );
     36                        } elseif ( is_front_page() && is_home() ) {
     37                                the_title( '<h3 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h3>' );
    3638                        } else {
    3739                                the_title( '<h2 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' );
    3840                        }
  • src/wp-content/themes/twentyseventeen/template-parts/post/content-video.php

    diff --git a/src/wp-content/themes/twentyseventeen/template-parts/post/content-video.php b/src/wp-content/themes/twentyseventeen/template-parts/post/content-video.php
    index 1c3ef49..dad681f 100644
    a b  
    77 * @package WordPress
    88 * @subpackage Twenty_Seventeen
    99 * @since 1.0
    10  * @version 1.0
     10 * @version 1.2
    1111 */
    1212
    1313?>
     
    3333
    3434                        if ( is_single() ) {
    3535                                the_title( '<h1 class="entry-title">', '</h1>' );
     36                        } elseif ( is_front_page() && is_home() ) {
     37                                the_title( '<h3 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h3>' );
    3638                        } else {
    3739                                the_title( '<h2 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' );
    3840                        }
  • src/wp-content/themes/twentyseventeen/template-parts/post/content.php

    diff --git a/src/wp-content/themes/twentyseventeen/template-parts/post/content.php b/src/wp-content/themes/twentyseventeen/template-parts/post/content.php
    index a87f646..90c3a4d 100644
    a b  
    77 * @package WordPress
    88 * @subpackage Twenty_Seventeen
    99 * @since 1.0
    10  * @version 1.0
     10 * @version 1.2
    1111 */
    1212
    1313?>
     
    3333
    3434                if ( is_single() ) {
    3535                        the_title( '<h1 class="entry-title">', '</h1>' );
     36                } elseif ( is_front_page() && is_home() ) {
     37                        the_title( '<h3 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h3>' );
    3638                } else {
    3739                        the_title( '<h2 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' );
    3840                }
  • src/wp-includes/capabilities.php

    diff --git a/src/wp-includes/capabilities.php b/src/wp-includes/capabilities.php
    index 0e766b1..abd87257 100644
    a b function map_meta_cap( $cap, $user_id ) { 
    478478        case 'manage_network_plugins':
    479479        case 'manage_network_themes':
    480480        case 'manage_network_options':
     481        case 'upgrade_network':
    481482                $caps[] = $cap;
    482483                break;
    483484        case 'setup_network':
  • src/wp-includes/class-walker-nav-menu.php

    diff --git a/src/wp-includes/class-walker-nav-menu.php b/src/wp-includes/class-walker-nav-menu.php
    index 4c1a1f2..c97188b 100644
    a b public function start_lvl( &$output, $depth = 0, $args = array() ) { 
    5858                        $n = "\n";
    5959                }
    6060                $indent = str_repeat( $t, $depth );
    61                 $output .= "{$n}{$indent}<ul class=\"sub-menu\">{$n}";
     61
     62                /**
     63                 * Filters the CSS class(es) applied to a menu list element.
     64                 *
     65                 * @since 4.8.0
     66                 *
     67                 * @param array    $classes The CSS classes that are applied to the menu `<ul>` element.
     68                 * @param stdClass $args    An object of `wp_nav_menu()` arguments.
     69                 * @param int      $depth   Depth of menu item. Used for padding.
     70                 */
     71
     72                $classes = array( 'sub-menu' );
     73                $classes = apply_filters( 'nav_menu_submenu_css_class', $classes, $args, $depth );
     74                $class_names = join( ' ', $classes );
     75
     76                $output .= "{$n}{$indent}<ul class='" . esc_attr( $class_names ) . "'>{$n}";
    6277        }
    6378
    6479        /**
  • src/wp-includes/class-walker-page.php

    diff --git a/src/wp-includes/class-walker-page.php b/src/wp-includes/class-walker-page.php
    index 30831bb..8bec66f 100644
    a b public function start_el( &$output, $page, $depth = 0, $args = array(), $current 
    160160                $args['link_before'] = empty( $args['link_before'] ) ? '' : $args['link_before'];
    161161                $args['link_after'] = empty( $args['link_after'] ) ? '' : $args['link_after'];
    162162
     163                $atts = array();
     164                $atts['href'] = get_permalink( $page->ID );
     165
     166                /**
     167                 * Filters the HTML attributes applied to a page menu item's anchor element.
     168                 *
     169                 * @since 4.8.0
     170                 *
     171                 * @param array $atts {
     172                 *     The HTML attributes applied to the menu item's `<a>` element, empty strings are ignored.
     173                 *
     174                 *     @type string $href The href attribute.
     175                 * }
     176                 * @param WP_Post $page         Page data object.
     177                 * @param int     $depth        Depth of page, used for padding.
     178                 * @param array   $args         An array of arguments.
     179                 * @param int     $current_page ID of the current page.
     180                 */
     181                $atts = apply_filters( 'page_menu_link_attributes', $atts, $page, $depth, $args, $current_page );
     182
     183                $attributes = '';
     184                foreach ( $atts as $attr => $value ) {
     185                        if ( ! empty( $value ) ) {
     186                                $value = esc_attr( $value );
     187                                $attributes .= ' ' . $attr . '="' . $value . '"';
     188                        }
     189                }
     190
    163191                $output .= $indent . sprintf(
    164                         '<li class="%s"><a href="%s">%s%s%s</a>',
     192                        '<li class="%s"><a%s>%s%s%s</a>',
    165193                        $css_classes,
    166                         get_permalink( $page->ID ),
     194                        $attributes,
    167195                        $args['link_before'],
    168196                        /** This filter is documented in wp-includes/post-template.php */
    169197                        apply_filters( 'the_title', $page->post_title, $page->ID ),
  • src/wp-includes/class-wp-editor.php

    diff --git a/src/wp-includes/class-wp-editor.php b/src/wp-includes/class-wp-editor.php
    index 83777cf..21353c6 100644
    a b  
    2727        private static $drag_drop_upload = false;
    2828        private static $old_dfw_compat = false;
    2929        private static $translation;
     30        private static $tinymce_scripts_printed = false;
     31        private static $link_dialog_printed = false;
    3032
    3133        private function __construct() {}
    3234
    public static function editor_settings($editor_id, $set) { 
    350352                if ( self::$this_tinymce ) {
    351353
    352354                        if ( empty( self::$first_init ) ) {
    353                                 self::$baseurl = includes_url( 'js/tinymce' );
    354 
    355                                 $mce_locale = get_user_locale();
    356                                 self::$mce_locale = $mce_locale = empty( $mce_locale ) ? 'en' : strtolower( substr( $mce_locale, 0, 2 ) ); // ISO 639-1
    357 
    358                                 /** This filter is documented in wp-admin/includes/media.php */
    359                                 $no_captions = (bool) apply_filters( 'disable_captions', '' );
     355                                $baseurl = self::get_baseurl();
     356                                $mce_locale = self::get_mce_locale();
    360357                                $ext_plugins = '';
    361                                 $shortcut_labels = array();
    362 
    363                                 foreach ( self::get_translation() as $name => $value ) {
    364                                         if ( is_array( $value ) ) {
    365                                                 $shortcut_labels[$name] = $value[1];
    366                                         }
    367                                 }
    368358
    369359                                if ( $set['teeny'] ) {
    370360
    public static function editor_settings($editor_id, $set) { 
    376366                                         * @param array  $plugins   An array of teenyMCE plugins.
    377367                                         * @param string $editor_id Unique editor identifier, e.g. 'content'.
    378368                                         */
    379                                         self::$plugins = $plugins = apply_filters( 'teeny_mce_plugins', array( 'colorpicker', 'lists', 'fullscreen', 'image', 'wordpress', 'wpeditimage', 'wplink' ), $editor_id );
     369                                        $plugins = apply_filters( 'teeny_mce_plugins', array( 'colorpicker', 'lists', 'fullscreen', 'image', 'wordpress', 'wpeditimage', 'wplink' ), $editor_id );
    380370                                } else {
    381371
    382372                                        /**
    public static function editor_settings($editor_id, $set) { 
    521511                                self::$plugins = $plugins;
    522512                                self::$ext_plugins = $ext_plugins;
    523513
    524                                 self::$first_init = array(
    525                                         'theme' => 'modern',
    526                                         'skin' => 'lightgray',
    527                                         'language' => self::$mce_locale,
    528                                         'formats' => '{' .
    529                                                 'alignleft: [' .
    530                                                         '{selector: "p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li", styles: {textAlign:"left"}},' .
    531                                                         '{selector: "img,table,dl.wp-caption", classes: "alignleft"}' .
    532                                                 '],' .
    533                                                 'aligncenter: [' .
    534                                                         '{selector: "p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li", styles: {textAlign:"center"}},' .
    535                                                         '{selector: "img,table,dl.wp-caption", classes: "aligncenter"}' .
    536                                                 '],' .
    537                                                 'alignright: [' .
    538                                                         '{selector: "p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li", styles: {textAlign:"right"}},' .
    539                                                         '{selector: "img,table,dl.wp-caption", classes: "alignright"}' .
    540                                                 '],' .
    541                                                 'strikethrough: {inline: "del"}' .
    542                                         '}',
    543                                         'relative_urls' => false,
    544                                         'remove_script_host' => false,
    545                                         'convert_urls' => false,
    546                                         'browser_spellcheck' => true,
    547                                         'fix_list_elements' => true,
    548                                         'entities' => '38,amp,60,lt,62,gt',
    549                                         'entity_encoding' => 'raw',
    550                                         'keep_styles' => false,
    551                                         'cache_suffix' => 'wp-mce-' . $tinymce_version,
    552 
    553                                         // Limit the preview styles in the menu/toolbar
    554                                         'preview_styles' => 'font-family font-size font-weight font-style text-decoration text-transform',
    555 
    556                                         'end_container_on_empty_block' => true,
    557                                         'wpeditimage_disable_captions' => $no_captions,
    558                                         'wpeditimage_html5_captions' => current_theme_supports( 'html5', 'caption' ),
    559                                         'plugins' => implode( ',', $plugins ),
    560                                         'wp_lang_attr' => get_bloginfo( 'language' ),
    561                                         'wp_shortcut_labels' => wp_json_encode( $shortcut_labels ),
    562                                 );
     514                                $settings = self::default_settings();
     515                                $settings['plugins'] = implode( ',', $plugins );
    563516
    564517                                if ( ! empty( $mce_external_plugins ) ) {
    565                                         self::$first_init['external_plugins'] = wp_json_encode( $mce_external_plugins );
     518                                        $settings['external_plugins'] = wp_json_encode( $mce_external_plugins );
    566519                                }
    567520
    568                                 $suffix = SCRIPT_DEBUG ? '' : '.min';
    569                                 $version = 'ver=' . get_bloginfo( 'version' );
    570                                 $dashicons = includes_url( "css/dashicons$suffix.css?$version" );
    571 
    572                                 // WordPress default stylesheet and dashicons
    573                                 $mce_css = array(
    574                                         $dashicons,
    575                                         self::$baseurl . '/skins/wordpress/wp-content.css?' . $version
    576                                 );
     521                                /** This filter is documented in wp-admin/includes/media.php */
     522                                if ( apply_filters( 'disable_captions', '' ) ) {
     523                                        $settings['wpeditimage_disable_captions'] = true;
     524                                }
    577525
     526                                $mce_css = $settings['content_css'];
    578527                                $editor_styles = get_editor_stylesheets();
     528
    579529                                if ( ! empty( $editor_styles ) ) {
    580                                         foreach ( $editor_styles as $style ) {
    581                                                 $mce_css[] = $style;
    582                                         }
     530                                        $mce_css .= ',' . implode( ',', $editor_styles );
    583531                                }
    584532
    585533                                /**
    public static function editor_settings($editor_id, $set) { 
    589537                                 *
    590538                                 * @param string $stylesheets Comma-delimited list of stylesheets.
    591539                                 */
    592                                 $mce_css = trim( apply_filters( 'mce_css', implode( ',', $mce_css ) ), ' ,' );
     540                                $mce_css = trim( apply_filters( 'mce_css', $mce_css ), ' ,' );
    593541
    594                                 if ( ! empty($mce_css) )
    595                                         self::$first_init['content_css'] = $mce_css;
     542                                if ( ! empty( $mce_css ) ) {
     543                                        $settings['content_css'] = $mce_css;
     544                                } else {
     545                                        unset( $settings['content_css'] );
     546                                }
     547
     548                                self::$first_init = $settings;
    596549                        }
    597550
    598551                        if ( $set['teeny'] ) {
    public static function editor_settings($editor_id, $set) { 
    690643
    691644                        $body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_user_locale() ) ) );
    692645
    693                         if ( !empty($set['tinymce']['body_class']) ) {
     646                        if ( ! empty( $set['tinymce']['body_class'] ) ) {
    694647                                $body_class .= ' ' . $set['tinymce']['body_class'];
    695                                 unset($set['tinymce']['body_class']);
     648                                unset( $set['tinymce']['body_class'] );
    696649                        }
    697650
    698651                        $mceInit = array (
    699652                                'selector' => "#$editor_id",
    700                                 'resize' => 'vertical',
    701                                 'menubar' => false,
    702653                                'wpautop' => (bool) $set['wpautop'],
    703654                                'indent' => ! $set['wpautop'],
    704                                 'toolbar1' => implode($mce_buttons, ','),
    705                                 'toolbar2' => implode($mce_buttons_2, ','),
    706                                 'toolbar3' => implode($mce_buttons_3, ','),
    707                                 'toolbar4' => implode($mce_buttons_4, ','),
     655                                'toolbar1' => implode( ',', $mce_buttons ),
     656                                'toolbar2' => implode( ',', $mce_buttons_2 ),
     657                                'toolbar3' => implode( ',', $mce_buttons_3 ),
     658                                'toolbar4' => implode( ',', $mce_buttons_4 ),
    708659                                'tabfocus_elements' => $set['tabfocus_elements'],
    709660                                'body_class' => $body_class
    710661                        );
    public static function editor_settings($editor_id, $set) { 
    762713         * @param array $init
    763714         * @return string
    764715         */
    765         private static function _parse_init($init) {
     716        private static function _parse_init( $init ) {
    766717                $options = '';
    767718
    768                 foreach ( $init as $k => $v ) {
    769                         if ( is_bool($v) ) {
    770                                 $val = $v ? 'true' : 'false';
    771                                 $options .= $k . ':' . $val . ',';
     719                foreach ( $init as $key => $value ) {
     720                        if ( is_bool( $value ) ) {
     721                                $val = $value ? 'true' : 'false';
     722                                $options .= $key . ':' . $val . ',';
    772723                                continue;
    773                         } elseif ( !empty($v) && is_string($v) && ( ('{' == $v{0} && '}' == $v{strlen($v) - 1}) || ('[' == $v{0} && ']' == $v{strlen($v) - 1}) || preg_match('/^\(?function ?\(/', $v) ) ) {
    774                                 $options .= $k . ':' . $v . ',';
     724                        } elseif ( ! empty( $value ) && is_string( $value ) && (
     725                                ( '{' == $value{0} && '}' == $value{strlen( $value ) - 1} ) ||
     726                                ( '[' == $value{0} && ']' == $value{strlen( $value ) - 1} ) ||
     727                                preg_match( '/^\(?function ?\(/', $value ) ) ) {
     728
     729                                $options .= $key . ':' . $value . ',';
    775730                                continue;
    776731                        }
    777                         $options .= $k . ':"' . $v . '",';
     732                        $options .= $key . ':"' . $value . '",';
    778733                }
    779734
    780735                return '{' . trim( $options, ' ,' ) . '}';
    private static function _parse_init($init) { 
    784739         *
    785740         * @static
    786741         */
    787         public static function enqueue_scripts() {
    788                 if ( self::$has_tinymce )
    789                         wp_enqueue_script('editor');
     742        public static function enqueue_scripts( $default_scripts = false ) {
     743                if ( $default_scripts || self::$has_tinymce ) {
     744                        wp_enqueue_script( 'editor' );
     745                }
    790746
    791                 if ( self::$has_quicktags ) {
     747                if ( $default_scripts || self::$has_quicktags ) {
    792748                        wp_enqueue_script( 'quicktags' );
    793749                        wp_enqueue_style( 'buttons' );
    794750                }
    795751
    796                 if ( in_array('wplink', self::$plugins, true) || in_array('link', self::$qt_buttons, true) ) {
    797                         wp_enqueue_script('wplink');
     752                if ( $default_scripts || in_array( 'wplink', self::$plugins, true ) || in_array( 'link', self::$qt_buttons, true ) ) {
     753                        wp_enqueue_script( 'wplink' );
    798754                        wp_enqueue_script( 'jquery-ui-autocomplete' );
    799755                }
    800756
    801757                if ( self::$old_dfw_compat ) {
    802                         wp_enqueue_script('wp-fullscreen-stub');
     758                        wp_enqueue_script( 'wp-fullscreen-stub' );
    803759                }
    804760
    805761                if ( self::$has_medialib ) {
    806762                        add_thickbox();
    807763                        wp_enqueue_script( 'media-upload' );
    808764                        wp_enqueue_script( 'wp-embed' );
     765                } elseif ( $default_scripts ) {
     766                        wp_enqueue_script( 'media-upload' );
    809767                }
    810768
    811769                /**
    public static function enqueue_scripts() { 
    817775                 *                       and Quicktags are being loaded.
    818776                 */
    819777                do_action( 'wp_enqueue_editor', array(
    820                         'tinymce'   => self::$has_tinymce,
    821                         'quicktags' => self::$has_quicktags,
     778                        'tinymce'   => ( $default_scripts || self::$has_tinymce ),
     779                        'quicktags' => ( $default_scripts || self::$has_quicktags ),
     780                ) );
     781        }
     782
     783        /**
     784         * Enqueue all editor scripts.
     785         * For use when the editor is going to be initialized after page load.
     786         *
     787         * @since 4.8.0
     788         */
     789        public static function enqueue_default_editor() {
     790                // We are past the point where scripts can be enqueued properly.
     791                if ( did_action( 'wp_enqueue_editor' ) ) {
     792                        return;
     793                }
     794
     795                self::enqueue_scripts( true );
     796
     797                // Also add wp-includes/css/editor.css
     798                wp_enqueue_style( 'editor-buttons' );
     799
     800                if ( is_admin() ) {
     801                        add_action( 'admin_print_footer_scripts', array( __CLASS__, 'print_default_editor_scripts' ), 45 );
     802                } else {
     803                        add_action( 'wp_print_footer_scripts', array( __CLASS__, 'print_default_editor_scripts' ), 45 );
     804                }
     805        }
     806
     807        /**
     808         * Print (output) all editor scripts and default settings.
     809         * For use when the editor is going to be initialized after page load.
     810         *
     811         * @since 4.8.0
     812         *
     813         */
     814        public static function print_default_editor_scripts() {
     815                $settings = self::default_settings();
     816
     817                $settings['toolbar1'] = 'bold,italic,bullist,numlist,link';
     818                $settings['wpautop'] = false;
     819                $settings['indent'] = true;
     820                $settings['elementpath'] = false;
     821
     822                // In production all plugins are loaded (they are in wp-editor.js.gz)
     823                // but only these will be initialized by default.
     824                $settings['plugins'] = implode( ',', array(
     825                        'charmap',
     826                        'colorpicker',
     827                        'hr',
     828                        'lists',
     829        //              'media',
     830                        'paste',
     831                        'tabfocus',
     832                        'textcolor',
     833                        'fullscreen',
     834                        'wordpress',
     835                        'wpautoresize',
     836                        'wpeditimage',
     837                        'wpemoji',
     838                        'wpgallery',
     839                        'wplink',
     840        //              'wpdialogs',
     841                        'wptextpattern',
     842        //              'wpview',
    822843                ) );
     844
     845                $settings = self::_parse_init( $settings );
     846
     847                $suffix = SCRIPT_DEBUG ? '' : '.min';
     848                $baseurl = self::get_baseurl();
     849
     850                ?>
     851                <script type="text/javascript">
     852                window.wp = window.wp || {};
     853                window.wp.editor = window.wp.editor || {};
     854                window.wp.editor.getDefaultSettings = function() {
     855                        return {
     856                                tinymce: <?php echo $settings; ?>,
     857                                quicktags: {
     858                                        buttons: 'strong,em,link,ul,ol,li,code'
     859                                }
     860                        };
     861                };
     862
     863                var tinyMCEPreInit = {
     864                        baseURL: "<?php echo $baseurl; ?>",
     865                        suffix: "<?php echo $suffix; ?>",
     866                        mceInit: {},
     867                        qtInit: {},
     868                        load_ext: function(url,lang){var sl=tinymce.ScriptLoader;sl.markDone(url+'/langs/'+lang+'.js');sl.markDone(url+'/langs/'+lang+'_dlg.js');}
     869                };
     870                </script>
     871                <?php
     872
     873                self::print_tinymce_scripts();
     874
     875                /**
     876                 * Fires when the editor scripts are loaded for later initialization,
     877                 * after all scripts and settings are printed.
     878                 *
     879                 * @since 4.8.0
     880                 */
     881                do_action( 'print_default_editor_scripts' );
     882
     883                self::wp_link_dialog();
     884        }
     885
     886        public static function get_mce_locale() {
     887                if ( empty( self::$mce_locale ) ) {
     888                        $mce_locale = get_user_locale();
     889                        self::$mce_locale = empty( $mce_locale ) ? 'en' : strtolower( substr( $mce_locale, 0, 2 ) ); // ISO 639-1
     890                }
     891
     892                return self::$mce_locale;
     893        }
     894
     895        public static function get_baseurl() {
     896                if ( empty( self::$baseurl ) ) {
     897                        self::$baseurl = includes_url( 'js/tinymce' );
     898                }
     899
     900                return self::$baseurl;
     901        }
     902
     903        /**
     904         * Returns the default TinyMCE settings.
     905         * Doesn't include plugins, buttons, editor selector.
     906         *
     907         * @return array
     908         */
     909        private static function default_settings() {
     910                global $tinymce_version;
     911
     912                $shortcut_labels = array();
     913
     914                foreach ( self::get_translation() as $name => $value ) {
     915                        if ( is_array( $value ) ) {
     916                                $shortcut_labels[$name] = $value[1];
     917                        }
     918                }
     919
     920                $settings = array(
     921                        'theme' => 'modern',
     922                        'skin' => 'lightgray',
     923                        'language' => self::get_mce_locale(),
     924                        'formats' => '{' .
     925                                'alignleft: [' .
     926                                        '{selector: "p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li", styles: {textAlign:"left"}},' .
     927                                        '{selector: "img,table,dl.wp-caption", classes: "alignleft"}' .
     928                                '],' .
     929                                'aligncenter: [' .
     930                                        '{selector: "p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li", styles: {textAlign:"center"}},' .
     931                                        '{selector: "img,table,dl.wp-caption", classes: "aligncenter"}' .
     932                                '],' .
     933                                'alignright: [' .
     934                                        '{selector: "p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li", styles: {textAlign:"right"}},' .
     935                                        '{selector: "img,table,dl.wp-caption", classes: "alignright"}' .
     936                                '],' .
     937                                'strikethrough: {inline: "del"}' .
     938                        '}',
     939                        'relative_urls' => false,
     940                        'remove_script_host' => false,
     941                        'convert_urls' => false,
     942                        'browser_spellcheck' => true,
     943                        'fix_list_elements' => true,
     944                        'entities' => '38,amp,60,lt,62,gt',
     945                        'entity_encoding' => 'raw',
     946                        'keep_styles' => false,
     947                        'cache_suffix' => 'wp-mce-' . $tinymce_version,
     948                        'resize' => 'vertical',
     949                        'menubar' => false,
     950
     951                        // Limit the preview styles in the menu/toolbar
     952                        'preview_styles' => 'font-family font-size font-weight font-style text-decoration text-transform',
     953
     954                        'end_container_on_empty_block' => true,
     955                        'wpeditimage_html5_captions' => true,
     956                        'wp_lang_attr' => get_bloginfo( 'language' ),
     957                        'wp_shortcut_labels' => wp_json_encode( $shortcut_labels ),
     958                );
     959
     960                $suffix = SCRIPT_DEBUG ? '' : '.min';
     961                $version = 'ver=' . get_bloginfo( 'version' );
     962
     963                // Default stylesheets
     964                $settings['content_css'] = includes_url( "css/dashicons$suffix.css?$version" ) . ',' .
     965                        includes_url( "js/tinymce/skins/wordpress/wp-content.css?$version" );
     966
     967                return $settings;
    823968        }
    824969
    825970        private static function get_translation() {
    private static function get_translation() { 
    10281173
    10291174                        /* translators: word count */
    10301175                        'Words: {0}' => sprintf( __( 'Words: %s' ), '{0}' ),
    1031                         'Paste is now in plain text mode. Contents will now be pasted as plain text until you toggle this option off.' => __( 'Paste is now in plain text mode. Contents will now be pasted as plain text until you toggle this option off.' ) . "\n\n" . __( 'If you&#8217;re looking to paste rich content from Microsoft Word, try turning this option off. The editor will clean up text pasted from Word automatically.' ),
    1032                         'Rich Text Area. Press ALT-F9 for menu. Press ALT-F10 for toolbar. Press ALT-0 for help' => __( 'Rich Text Area. Press Alt-Shift-H for help.' ),
     1176                        'Paste is now in plain text mode. Contents will now be pasted as plain text until you toggle this option off.' =>
     1177                                __( 'Paste is now in plain text mode. Contents will now be pasted as plain text until you toggle this option off.' ) . "\n\n" .
     1178                                __( 'If you&#8217;re looking to paste rich content from Microsoft Word, try turning this option off. The editor will clean up text pasted from Word automatically.' ),
     1179                        'Rich Text Area. Press ALT-F9 for menu. Press ALT-F10 for toolbar. Press ALT-0 for help' =>
     1180                                __( 'Rich Text Area. Press Alt-Shift-H for help.' ),
    10331181                        'Rich Text Area. Press Control-Option-H for help.' => __( 'Rich Text Area. Press Control-Option-H for help.' ),
    1034                         'You have unsaved changes are you sure you want to navigate away?' => __( 'The changes you made will be lost if you navigate away from this page.' ),
    1035                         'Your browser doesn\'t support direct access to the clipboard. Please use the Ctrl+X/C/V keyboard shortcuts instead.' => __( 'Your browser does not support direct access to the clipboard. Please use keyboard shortcuts or your browser&#8217;s edit menu instead.' ),
     1182                        'You have unsaved changes are you sure you want to navigate away?' =>
     1183                                __( 'The changes you made will be lost if you navigate away from this page.' ),
     1184                        'Your browser doesn\'t support direct access to the clipboard. Please use the Ctrl+X/C/V keyboard shortcuts instead.' =>
     1185                                __( 'Your browser does not support direct access to the clipboard. Please use keyboard shortcuts or your browser&#8217;s edit menu instead.' ),
    10361186
    10371187                        // TinyMCE menus
    10381188                        'Insert' => _x( 'Insert', 'TinyMCE menu' ),
    private static function get_translation() { 
    10551205                        'Paste URL or type to search' => __( 'Paste URL or type to search' ), // Placeholder for the inline link dialog
    10561206                        'Apply'  => __( 'Apply' ), // Tooltip for the 'apply' button in the inline link dialog
    10571207                        'Link options'  => __( 'Link options' ), // Tooltip for the 'link options' button in the inline link dialog
     1208                        'Visual' => __( 'Visual' ), // Editor switch tab label
     1209                        'Text' => __( 'Text' ), // Editor switch tab label
    10581210
    10591211                        // Shortcuts help modal
    10601212                        'Keyboard Shortcuts' => array( __( 'Keyboard Shortcuts' ), 'accessH' ),
    private static function get_translation() { 
    10981250        }
    10991251
    11001252        /**
    1101          * Translates the default TinyMCE strings and returns them as JSON encoded object ready to be loaded with tinymce.addI18n().
    1102          * Can be used directly (_WP_Editors::wp_mce_translation()) by passing the same locale as set in the TinyMCE init object.
     1253         * Translates the default TinyMCE strings and returns them as JSON encoded object ready to be loaded with tinymce.addI18n(),
     1254         * or as JS snippet that should run after tinymce.js is loaded.
    11031255         *
    11041256         * @static
    11051257         * @param string $mce_locale The locale used for the editor.
    private static function get_translation() { 
    11081260         */
    11091261        public static function wp_mce_translation( $mce_locale = '', $json_only = false ) {
    11101262                if ( ! $mce_locale ) {
    1111                         $mce_locale = self::$mce_locale;
     1263                        $mce_locale = self::get_mce_locale();
    11121264                }
    11131265
    11141266                $mce_translation = self::get_translation();
    1115                
     1267
    11161268                foreach ( $mce_translation as $name => $value ) {
    11171269                        if ( is_array( $value ) ) {
    11181270                                $mce_translation[$name] = $value[0];
    public static function wp_mce_translation( $mce_locale = '', $json_only = false 
    11501302                        return wp_json_encode( $mce_translation );
    11511303                }
    11521304
    1153                 $baseurl = self::$baseurl ? self::$baseurl : includes_url( 'js/tinymce' );
     1305                $baseurl = self::get_baseurl();
    11541306
    11551307                return "tinymce.addI18n( '$mce_locale', " . wp_json_encode( $mce_translation ) . ");\n" .
    11561308                        "tinymce.ScriptLoader.markDone( '$baseurl/langs/$mce_locale.js' );\n";
    11571309        }
    11581310
    11591311        /**
     1312         * Print (output) the main TinyMCE scripts.
     1313         *
     1314         * @since 4.8
    11601315         *
    11611316         * @static
    11621317         * @global string $tinymce_version
    11631318         * @global bool   $concatenate_scripts
    11641319         * @global bool   $compress_scripts
    11651320         */
    1166         public static function editor_js() {
     1321        public static function print_tinymce_scripts() {
    11671322                global $tinymce_version, $concatenate_scripts, $compress_scripts;
    11681323
    1169                 /**
    1170                  * Filters "tiny_mce_version" is deprecated
    1171                  *
    1172                  * The tiny_mce_version filter is not needed since external plugins are loaded directly by TinyMCE.
    1173                  * These plugins can be refreshed by appending query string to the URL passed to "mce_external_plugins" filter.
    1174                  * If the plugin has a popup dialog, a query string can be added to the button action that opens it (in the plugin's code).
    1175                  */
    1176                 $version = 'ver=' . $tinymce_version;
    1177                 $tmce_on = !empty(self::$mce_settings);
     1324                if ( self::$tinymce_scripts_printed ) {
     1325                        return;
     1326                }
     1327
     1328                self::$tinymce_scripts_printed = true;
    11781329
    1179                 if ( ! isset($concatenate_scripts) )
     1330                if ( ! isset( $concatenate_scripts ) ) {
    11801331                        script_concat_settings();
     1332                }
     1333
     1334                $suffix = SCRIPT_DEBUG ? '' : '.min';
     1335                $version = 'ver=' . $tinymce_version;
     1336                $baseurl = self::get_baseurl();
    11811337
    11821338                $compressed = $compress_scripts && $concatenate_scripts && isset($_SERVER['HTTP_ACCEPT_ENCODING'])
    11831339                        && false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip');
    11841340
     1341                // Load tinymce.js when running from /src, else load wp-tinymce.js.gz (production) or tinymce.min.js (SCRIPT_DEBUG)
     1342                $mce_suffix = false !== strpos( get_bloginfo( 'version' ), '-src' ) ? '' : '.min';
     1343
     1344                if ( $compressed ) {
     1345                        echo "<script type='text/javascript' src='{$baseurl}/wp-tinymce.php?c=1&amp;$version'></script>\n";
     1346                } else {
     1347                        echo "<script type='text/javascript' src='{$baseurl}/tinymce{$mce_suffix}.js?$version'></script>\n";
     1348                        echo "<script type='text/javascript' src='{$baseurl}/plugins/compat3x/plugin{$suffix}.js?$version'></script>\n";
     1349                }
     1350
     1351                echo "<script type='text/javascript'>\n" . self::wp_mce_translation() . "</script>\n";
     1352        }
     1353
     1354        /**
     1355         * Print (output) the TinyMCE configuration and initialization scripts.
     1356         *
     1357         * @static
     1358         */
     1359        public static function editor_js() {
     1360                global $tinymce_version;
     1361
     1362                $tmce_on = ! empty( self::$mce_settings );
    11851363                $mceInit = $qtInit = '';
     1364
    11861365                if ( $tmce_on ) {
    11871366                        foreach ( self::$mce_settings as $editor_id => $init ) {
    11881367                                $options = self::_parse_init( $init );
    11891368                                $mceInit .= "'$editor_id':{$options},";
    11901369                        }
    1191                         $mceInit = '{' . trim($mceInit, ',') . '}';
     1370                        $mceInit = '{' . trim( $mceInit, ',' ) . '}';
    11921371                } else {
    11931372                        $mceInit = '{}';
    11941373                }
    11951374
    1196                 if ( !empty(self::$qt_settings) ) {
     1375                if ( ! empty( self::$qt_settings ) ) {
    11971376                        foreach ( self::$qt_settings as $editor_id => $init ) {
    11981377                                $options = self::_parse_init( $init );
    11991378                                $qtInit .= "'$editor_id':{$options},";
    12001379                        }
    1201                         $qtInit = '{' . trim($qtInit, ',') . '}';
     1380                        $qtInit = '{' . trim( $qtInit, ',' ) . '}';
    12021381                } else {
    12031382                        $qtInit = '{}';
    12041383                }
    public static function editor_js() { 
    12101389                );
    12111390
    12121391                $suffix = SCRIPT_DEBUG ? '' : '.min';
     1392                $baseurl = self::get_baseurl();
     1393                $version = 'ver=' . $tinymce_version;
    12131394
    12141395                /**
    12151396                 * Fires immediately before the TinyMCE settings are printed.
    public static function editor_js() { 
    12231404
    12241405                <script type="text/javascript">
    12251406                tinyMCEPreInit = {
    1226                         baseURL: "<?php echo self::$baseurl; ?>",
     1407                        baseURL: "<?php echo $baseurl; ?>",
    12271408                        suffix: "<?php echo $suffix; ?>",
    12281409                        <?php
    12291410
    public static function editor_js() { 
    12401421                </script>
    12411422                <?php
    12421423
    1243                 $baseurl = self::$baseurl;
    1244                 // Load tinymce.js when running from /src, else load wp-tinymce.js.gz (production) or tinymce.min.js (SCRIPT_DEBUG)
    1245                 $mce_suffix = false !== strpos( get_bloginfo( 'version' ), '-src' ) ? '' : '.min';
    1246 
    12471424                if ( $tmce_on ) {
    1248                         if ( $compressed ) {
    1249                                 echo "<script type='text/javascript' src='{$baseurl}/wp-tinymce.php?c=1&amp;$version'></script>\n";
    1250                         } else {
    1251                                 echo "<script type='text/javascript' src='{$baseurl}/tinymce{$mce_suffix}.js?$version'></script>\n";
    1252                                 echo "<script type='text/javascript' src='{$baseurl}/plugins/compat3x/plugin{$suffix}.js?$version'></script>\n";
    1253                         }
    1254 
    1255                         echo "<script type='text/javascript'>\n" . self::wp_mce_translation() . "</script>\n";
     1425                        self::print_tinymce_scripts();
    12561426
    12571427                        if ( self::$ext_plugins ) {
    12581428                                // Load the old-format English strings to prevent unsightly labels in old style popups
    public static function wp_link_query( $args = array() ) { 
    14341604         * @static
    14351605         */
    14361606        public static function wp_link_dialog() {
     1607                // Run once
     1608                if ( self::$link_dialog_printed ) {
     1609                        return;
     1610                }
     1611
     1612                self::$link_dialog_printed = true;
     1613
    14371614                // display: none is required here, see #WP27605
    14381615                ?>
    14391616                <div id="wp-link-backdrop" style="display: none"></div>
  • src/wp-includes/class-wp-site.php

    diff --git a/src/wp-includes/class-wp-site.php b/src/wp-includes/class-wp-site.php
    index c16f498..4bca299 100644
    a b public function __get( $key ) { 
    240240                        case 'siteurl':
    241241                        case 'post_count':
    242242                        case 'home':
     243                        default: // Custom properties added by 'site_details' filter.
    243244                                if ( ! did_action( 'ms_loaded' ) ) {
    244245                                        return null;
    245246                                }
     247
    246248                                $details = $this->get_details();
    247                                 return $details->$key;
     249                                if ( isset( $details->$key ) ) {
     250                                        return $details->$key;
     251                                }
    248252                }
    249253
    250254                return null;
    public function __isset( $key ) { 
    275279                                        return false;
    276280                                }
    277281                                return true;
     282                        default: // Custom properties added by 'site_details' filter.
     283                                if ( ! did_action( 'ms_loaded' ) ) {
     284                                        return false;
     285                                }
     286
     287                                $details = $this->get_details();
     288                                if ( isset( $details->$key ) ) {
     289                                        return true;
     290                                }
    278291                }
    279292
    280293                return false;
  • src/wp-includes/css/admin-bar.css

    diff --git a/src/wp-includes/css/admin-bar.css b/src/wp-includes/css/admin-bar.css
    index fff096d..523b5f7 100644
    a b html:lang(he-il) .rtl #wpadminbar * { 
    624624        -moz-osx-font-smoothing: grayscale;
    625625}
    626626
     627/* The admin bar search field needs to reset many styles that might be inherited from the active Theme CSS. See ticket #40313. */
    627628#wpadminbar > #wp-toolbar > #wp-admin-bar-top-secondary > #wp-admin-bar-search #adminbarsearch input.adminbar-input {
     629        display: inline-block;
     630        float: none;
    628631        position: relative;
    629632        z-index: 30;
    630633        font-size: 13px;
    631634        font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    632635        line-height: 24px;
     636        text-indent: 0;
    633637        height: 24px;
    634638        width: 24px;
    635639        max-width: none;
  • src/wp-includes/css/buttons.css

    diff --git a/src/wp-includes/css/buttons.css b/src/wp-includes/css/buttons.css
    index 1a614cb..80ecd07 100644
    a b TABLE OF CONTENTS: 
    242242
    243243.wp-core-ui .button-link-delete:hover,
    244244.wp-core-ui .button-link-delete:focus {
    245         color: #f00;
     245        color: #dc3232;
    246246}
    247247
    248248.ie8 .wp-core-ui .button-link:focus {
    TABLE OF CONTENTS: 
    411411                vertical-align: inherit;
    412412        }
    413413
     414        .media-modal-content .media-toolbar-primary .media-button {
     415                margin-top: 10px;
     416                margin-left: 5px;
     417        }
     418
    414419        /* Reset responsive styles on Log in button on iframed login form */
    415420
    416421        .interim-login .button.button-large {
  • src/wp-includes/css/editor.css

    diff --git a/src/wp-includes/css/editor.css b/src/wp-includes/css/editor.css
    index e04317e..ca23b91 100644
    a b div.mce-path { 
    608608}
    609609
    610610/* Menubar */
    611 .mce-menubar {
     611div.mce-menubar {
    612612        border-color: #e5e5e5;
    613613        background: #fff;
    614614        border-width: 0px 0px 1px;
    615615}
    616616
    617 .mce-menubar .mce-menubtn {
    618         margin: 2px;
    619 }
    620 
    621617.mce-menubar .mce-menubtn:hover,
    622618.mce-menubar .mce-menubtn.mce-active,
    623619.mce-menubar .mce-menubtn:focus {
    i.mce-i-wp_code:before { 
    10911087
    10921088.wp-editor-container {
    10931089        clear: both;
     1090        border: 1px solid #e5e5e5;
    10941091}
    10951092
    10961093.wp-editor-area {
  • src/wp-includes/css/media-views.css

    diff --git a/src/wp-includes/css/media-views.css b/src/wp-includes/css/media-views.css
    index 698ea2d..0c0bd6d 100644
    a b  
    242242        width: calc(48% - 12px);
    243243}
    244244
    245 .media-modal-content .attachments-browser .media-toolbar-secondary {
    246         width: 66%;
    247 }
    248 
    249 .media-modal-content .media-toolbar-primary.search-form {
    250         width: 33%;
    251 }
    252 
    253245.media-modal-content .media-toolbar-primary .media-button {
    254246        float: right;
    255247}
     
    279271        overflow: hidden;
    280272}
    281273
     274.media-frame-toolbar .media-toolbar {
     275        top: initial;
     276        bottom: -45px;
     277        height: auto;
     278        overflow: initial;
     279        border-top: 1px solid #ddd;
     280}
     281
     282@media screen and (max-width: 782px) {
     283        .media-frame-toolbar .media-toolbar {
     284                bottom: -48px;
     285        }
     286}
     287
    282288.media-toolbar-primary {
    283289        float: right;
    284290        height: 100%;
     
    686692        overflow: auto;
    687693        background: #fff;
    688694        border-top: 1px solid #ddd;
    689         border-bottom: 1px solid #ddd;
    690695}
    691696
    692697.media-frame-toolbar {
     
    696701        bottom: 0;
    697702        height: 60px;
    698703        z-index: 100;
     704        bottom: 60px;
     705        height: auto;
    699706}
    700707
    701708.media-frame.hide-menu .media-frame-title,
  • src/wp-includes/customize/class-wp-customize-color-control.php

    diff --git a/src/wp-includes/customize/class-wp-customize-color-control.php b/src/wp-includes/customize/class-wp-customize-color-control.php
    index 7f6a9b5..775a63d 100644
    a b public function render_content() {} 
    9292         */
    9393        public function content_template() {
    9494                ?>
    95                 <# var defaultValue = '',
     95                <# var defaultValue = '#RRGGBB', defaultValueAttr = '',
    9696                        isHueSlider = data.mode === 'hue';
    9797
    9898                if ( data.defaultValue && ! isHueSlider ) {
    public function content_template() { 
    101101                        } else {
    102102                                defaultValue = data.defaultValue;
    103103                        }
    104                         defaultValue = ' data-default-color=' + defaultValue; // Quotes added automatically.
     104                        defaultValueAttr = ' data-default-color=' + defaultValue; // Quotes added automatically.
    105105                } #>
    106106                <label>
    107107                        <# if ( data.label ) { #>
    public function content_template() { 
    114114                                <# if ( isHueSlider ) { #>
    115115                                        <input class="color-picker-hue" type="text" data-type="hue" />
    116116                                <# } else { #>
    117                                         <input class="color-picker-hex" type="text" maxlength="7" placeholder="<?php esc_attr_e( 'Hex Value' ); ?>" {{ defaultValue }} />
     117                                        <input class="color-picker-hex" type="text" maxlength="7" placeholder="{{ defaultValue }}" {{ defaultValueAttr }} />
    118118                                <# } #>
    119119                        </div>
    120120                </label>
  • src/wp-includes/general-template.php

    diff --git a/src/wp-includes/general-template.php b/src/wp-includes/general-template.php
    index 04df698..2930c54 100644
    a b function wp_editor( $content, $editor_id, $settings = array() ) { 
    30573057}
    30583058
    30593059/**
     3060 * Outputs the editor scripts, stylesheets, and default settings.
     3061 *
     3062 * The editor can be initialized when needed after page load.
     3063 * See wp.editor.initialize() in wp-admin/js/editor.js for initialization options.
     3064 *
     3065 * @uses _WP_Editors
     3066 * @since 4.8.0
     3067 */
     3068function wp_enqueue_editor() {
     3069        if ( ! class_exists( '_WP_Editors', false ) ) {
     3070                require( ABSPATH . WPINC . '/class-wp-editor.php' );
     3071        }
     3072
     3073        _WP_Editors::enqueue_default_editor();
     3074}
     3075
     3076/**
    30603077 * Retrieves the contents of the search WordPress query variable.
    30613078 *
    30623079 * The search query string is passed through esc_attr() to ensure that it is safe
  • src/wp-includes/js/mce-view.js

    diff --git a/src/wp-includes/js/mce-view.js b/src/wp-includes/js/mce-view.js
    index 21b2c87..397af63 100644
    a b  
    729729                                        $( node ).data( 'rendered', false );
    730730                                        editor.dom.setAttrib( node, 'data-wpview-text', encodeURIComponent( text ) );
    731731                                        wp.mce.views.createInstance( type, text, match.options, force ).render();
     732
     733                                        editor.selection.select( node );
     734                                        editor.nodeChanged();
    732735                                        editor.focus();
    733736
    734737                                        return true;
  • src/wp-includes/js/swfupload/handlers.js

    diff --git a/src/wp-includes/js/swfupload/handlers.js b/src/wp-includes/js/swfupload/handlers.js
    index e27bd37..8251f05 100644
    a b function cancelUpload() { 
    356356
    357357// remember the last used image size, alignment and url
    358358jQuery(document).ready(function($){
    359         $('input[type="radio"]', '#media-items').live('click', function(){
     359        $( 'input[type="radio"]', '#media-items' ).on( 'click', function(){
    360360                var tr = $(this).closest('tr');
    361361
    362362                if ( $(tr).hasClass('align') )
    jQuery(document).ready(function($){ 
    365365                        setUserSetting('imgsize', $(this).val());
    366366        });
    367367
    368         $('button.button', '#media-items').live('click', function(){
     368        $( 'button.button', '#media-items' ).on( 'click', function(){
    369369                var c = this.className || '';
    370370                c = c.match(/url([^ '"]+)/);
    371371                if ( c && c[1] ) {
  • src/wp-includes/js/tinymce/plugins/wordpress/plugin.js

    diff --git a/src/wp-includes/js/tinymce/plugins/wordpress/plugin.js b/src/wp-includes/js/tinymce/plugins/wordpress/plugin.js
    index 20cdcd4..08e3cf7 100644
    a b tinymce.PluginManager.add( 'wordpress', function( editor ) { 
    992992
    993993                function hide( event ) {
    994994                        if ( activeToolbar ) {
    995                                 if ( activeToolbar.tempHide || event.type === 'hide' ) {
     995                                if ( activeToolbar.tempHide || event.type === 'hide' || event.type === 'blur' ) {
    996996                                        activeToolbar.hide();
    997997                                        activeToolbar = false;
    998998                                } else if ( (
  • src/wp-includes/js/wp-a11y.js

    diff --git a/src/wp-includes/js/wp-a11y.js b/src/wp-includes/js/wp-a11y.js
    index 2507cbc..7ccdd75 100644
    a b window.wp = window.wp || {}; 
    44        'use strict';
    55
    66        var $containerPolite,
    7                 $containerAssertive;
     7                $containerAssertive,
     8                previousMessage = '';
    89
    910        /**
    1011         * Update the ARIA live notification area text node.
    window.wp = window.wp || {}; 
    2324                // Ensure only text is sent to screen readers.
    2425                message = $( '<p>' ).html( message ).text();
    2526
     27                /*
     28                 * Safari 10+VoiceOver don't announce repeated, identical strings. We use
     29                 * a `no-break space` to force them to think identical strings are different.
     30                 * See ticket #36853.
     31                 */
     32                if ( previousMessage === message ) {
     33                        message = message + '\u00A0';
     34                }
     35
     36                previousMessage = message;
     37
    2638                if ( $containerAssertive && 'assertive' === ariaLive ) {
    2739                        $containerAssertive.text( message );
    2840                } else if ( $containerPolite ) {
  • src/wp-includes/media.php

    diff --git a/src/wp-includes/media.php b/src/wp-includes/media.php
    index 195d0f9..6253bd5 100644
    a b function wp_enqueue_media( $args = array() ) { 
    33243324        /**
    33253325         * Allows showing or hiding the "Create Audio Playlist" button in the media library.
    33263326         *
    3327          * By default (if this filter returns `null`), a query will be run to
    3328          * determine whether the media library contains any audio items.  This
    3329          * query is expensive for large media libraries, so it may be desirable for
    3330          * sites to override this behavior.
     3327         * By default, the "Create Audio Playlist" button will always be shown in
     3328         * the media library.  If this filter returns `null`, a query will be run
     3329         * to determine whether the media library contains any audio items.  This
     3330         * was the default behavior prior to version 4.8.0, but this query is
     3331         * expensive for large media libraries.
    33313332         *
    33323333         * @since 4.7.4
     3334         * @since 4.8.0 The filter's default value is `true` rather than `null`.
    33333335         *
    33343336         * @link https://core.trac.wordpress.org/ticket/31071
    33353337         *
    3336          * @return bool|null Whether to show the button, or `null` for default behavior.
     3338         * @param bool|null Whether to show the button, or `null` to decide based
     3339         *                  on whether any audio files exist in the media library.
    33373340         */
    3338         $has_audio = apply_filters( 'media_has_audio', null );
    3339         if ( is_null( $has_audio ) ) {
    3340                 $has_audio = $wpdb->get_var( "
     3341        $show_audio_playlist = apply_filters( 'media_library_show_audio_playlist', true );
     3342        if ( null === $show_audio_playlist ) {
     3343                $show_audio_playlist = $wpdb->get_var( "
    33413344                        SELECT ID
    33423345                        FROM $wpdb->posts
    33433346                        WHERE post_type = 'attachment'
    function wp_enqueue_media( $args = array() ) { 
    33493352        /**
    33503353         * Allows showing or hiding the "Create Video Playlist" button in the media library.
    33513354         *
    3352          * By default (if this filter returns `null`), a query will be run to
    3353          * determine whether the media library contains any video items.  This
    3354          * query is expensive for large media libraries, so it may be desirable for
    3355          * sites to override this behavior.
     3355         * By default, the "Create Video Playlist" button will always be shown in
     3356         * the media library.  If this filter returns `null`, a query will be run
     3357         * to determine whether the media library contains any video items.  This
     3358         * was the default behavior prior to version 4.8.0, but this query is
     3359         * expensive for large media libraries.
    33563360         *
    33573361         * @since 4.7.4
     3362         * @since 4.8.0 The filter's default value is `true` rather than `null`.
    33583363         *
    33593364         * @link https://core.trac.wordpress.org/ticket/31071
    33603365         *
    3361          * @return bool|null Whether to show the button, or `null` for default behavior.
     3366         * @param bool|null Whether to show the button, or `null` to decide based
     3367         *                  on whether any video files exist in the media library.
    33623368         */
    3363         $has_video = apply_filters( 'media_has_video', null );
    3364         if ( is_null( $has_video ) ) {
    3365                 $has_video = $wpdb->get_var( "
     3369        $show_video_playlist = apply_filters( 'media_library_show_video_playlist', true );
     3370        if ( null === $show_video_playlist ) {
     3371                $show_video_playlist = $wpdb->get_var( "
    33663372                        SELECT ID
    33673373                        FROM $wpdb->posts
    33683374                        WHERE post_type = 'attachment'
    function wp_enqueue_media( $args = array() ) { 
    33833389         *
    33843390         * @link https://core.trac.wordpress.org/ticket/31071
    33853391         *
    3386          * @return array|null An array of objects with `month` and `year`
    3387          *                    properties, or `null` (or any other non-array value)
    3388          *                    for default behavior.
     3392         * @param array|null An array of objects with `month` and `year`
     3393         *                   properties, or `null` (or any other non-array value)
     3394         *                   for default behavior.
    33893395         */
    3390         $months = apply_filters( 'media_months', null );
     3396        $months = apply_filters( 'media_library_months_with_files', null );
    33913397        if ( ! is_array( $months ) ) {
    33923398                $months = $wpdb->get_results( $wpdb->prepare( "
    33933399                        SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month
    function wp_enqueue_media( $args = array() ) { 
    34143420                ),
    34153421                'defaultProps' => $props,
    34163422                'attachmentCounts' => array(
    3417                         'audio' => ( $has_audio ) ? 1 : 0,
    3418                         'video' => ( $has_video ) ? 1 : 0
     3423                        'audio' => ( $show_audio_playlist ) ? 1 : 0,
     3424                        'video' => ( $show_video_playlist ) ? 1 : 0,
    34193425                ),
    34203426                'embedExts'    => $exts,
    34213427                'embedMimes'   => $ext_mimes,
    34223428                'contentWidth' => $content_width,
    34233429                'months'       => $months,
    3424                 'mediaTrash'   => MEDIA_TRASH ? 1 : 0
     3430                'mediaTrash'   => MEDIA_TRASH ? 1 : 0,
    34253431        );
    34263432
    34273433        $post = null;
  • src/wp-includes/ms-functions.php

    diff --git a/src/wp-includes/ms-functions.php b/src/wp-includes/ms-functions.php
    index 9df86cf..d209435 100644
    a b function wp_schedule_update_network_counts() { 
    22742274 * Update the network-wide counts for the current network.
    22752275 *
    22762276 * @since 3.1.0
     2277 * @since 4.8.0 The $network_id parameter has been added.
     2278 *
     2279 * @param int|null $network_id ID of the network. Default is the current network.
    22772280 */
    2278 function wp_update_network_counts() {
    2279         wp_update_network_user_counts();
    2280         wp_update_network_site_counts();
     2281function wp_update_network_counts( $network_id = null ) {
     2282        wp_update_network_user_counts( $network_id );
     2283        wp_update_network_site_counts( $network_id );
    22812284}
    22822285
    22832286/**
    function wp_maybe_update_network_user_counts() { 
    23292332 * Update the network-wide site count.
    23302333 *
    23312334 * @since 3.7.0
     2335 * @since 4.8.0 The $network_id parameter has been added.
    23322336 *
    2333  * @global wpdb $wpdb WordPress database abstraction object.
     2337 * @param int|null $network_id ID of the network. Default is the current network.
    23342338 */
    2335 function wp_update_network_site_counts() {
    2336         global $wpdb;
     2339function wp_update_network_site_counts( $network_id = null ) {
     2340        $network_id = (int) $network_id;
     2341        if ( ! $network_id ) {
     2342                $network_id = get_current_network_id();
     2343        }
    23372344
    23382345        $count = get_sites( array(
    2339                 'network_id' => $wpdb->siteid,
     2346                'network_id' => $network_id,
    23402347                'spam'       => 0,
    23412348                'deleted'    => 0,
    23422349                'archived'   => 0,
    23432350                'count'      => true,
    23442351        ) );
    23452352
    2346         update_site_option( 'blog_count', $count );
     2353        update_network_option( $network_id, 'blog_count', $count );
    23472354}
    23482355
    23492356/**
    23502357 * Update the network-wide user count.
    23512358 *
    23522359 * @since 3.7.0
     2360 * @since 4.8.0 The $network_id parameter has been added.
    23532361 *
    23542362 * @global wpdb $wpdb WordPress database abstraction object.
     2363 *
     2364 * @param int|null $network_id ID of the network. Default is the current network.
    23552365 */
    2356 function wp_update_network_user_counts() {
     2366function wp_update_network_user_counts( $network_id = null ) {
    23572367        global $wpdb;
    23582368
    23592369        $count = $wpdb->get_var( "SELECT COUNT(ID) as c FROM $wpdb->users WHERE spam = '0' AND deleted = '0'" );
    2360         update_site_option( 'user_count', $count );
     2370        update_network_option( $network_id, 'user_count', $count );
    23612371}
    23622372
    23632373/**
  • src/wp-includes/option.php

    diff --git a/src/wp-includes/option.php b/src/wp-includes/option.php
    index d58ae69..8bc8edc 100644
    a b function get_site_transient( $transient ) { 
    16411641 * @see set_transient()
    16421642 *
    16431643 * @param string $transient  Transient name. Expected to not be SQL-escaped. Must be
    1644  *                           40 characters or fewer in length.
     1644 *                           167 characters or fewer in length.
    16451645 * @param mixed  $value      Transient value. Expected to not be SQL-escaped.
    16461646 * @param int    $expiration Optional. Time until expiration in seconds. Default 0 (no expiration).
    16471647 * @return bool False if value was not set and true if value was set.
  • src/wp-includes/post.php

    diff --git a/src/wp-includes/post.php b/src/wp-includes/post.php
    index a33236c..0d62400 100644
    a b function register_post_status( $post_status, $args = array() ) { 
    815815                $args->label = $post_status;
    816816
    817817        if ( false === $args->label_count )
    818                 $args->label_count = array( $args->label, $args->label );
     818                $args->label_count = _n_noop( $args->label, $args->label );
    819819
    820820        $wp_post_statuses[$post_status] = $args;
    821821
    function wp_untrash_post_comments( $post = null ) { 
    28002800 *
    28012801 * @param int   $post_id Optional. The Post ID. Does not default to the ID of the
    28022802 *                       global $post. Default 0.
    2803  * @param array $args    Optional. Category arguments. See wp_get_object_terms(). Default empty.
    2804  * @return array List of categories. If the `$fields` argument passed via `$args` is 'all' or
    2805  *               'all_with_object_id', an array of WP_Term objects will be returned. If `$fields`
    2806  *               is 'ids', an array of category ids. If `$fields` is 'names', an array of category names.
     2803 * @param array $args    Optional. Category query parameters. Default empty array.
     2804 *                       See WP_Term_Query::__construct() for supported arguments.
     2805 * @return array|WP_Error List of categories. If the `$fields` argument passed via `$args` is 'all' or
     2806 *                        'all_with_object_id', an array of WP_Term objects will be returned. If `$fields`
     2807 *                        is 'ids', an array of category ids. If `$fields` is 'names', an array of category names.
     2808 *                        WP_Error object if 'category' taxonomy doesn't exist.
    28072809 */
    28082810function wp_get_post_categories( $post_id = 0, $args = array() ) {
    28092811        $post_id = (int) $post_id;
    function wp_get_post_categories( $post_id = 0, $args = array() ) { 
    28262828 *
    28272829 * @param int   $post_id Optional. The Post ID. Does not default to the ID of the
    28282830 *                       global $post. Default 0.
    2829  * @param array $args Optional. Overwrite the defaults
    2830  * @return array List of post tags.
     2831 * @param array $args    Optional. Tag query parameters. Default empty array.
     2832 *                       See WP_Term_Query::__construct() for supported arguments.
     2833 * @return array|WP_Error Array of WP_Term objects on success or empty array if no tags were found.
     2834 *                        WP_Error object if 'post_tag' taxonomy doesn't exist.
    28312835 */
    28322836function wp_get_post_tags( $post_id = 0, $args = array() ) {
    28332837        return wp_get_post_terms( $post_id, 'post_tag', $args);
    function wp_get_post_tags( $post_id = 0, $args = array() ) { 
    28452849 * @param int    $post_id  Optional. The Post ID. Does not default to the ID of the
    28462850 *                         global $post. Default 0.
    28472851 * @param string $taxonomy Optional. The taxonomy for which to retrieve terms. Default 'post_tag'.
    2848  * @param array  $args     Optional. wp_get_object_terms() arguments. Default empty array.
    2849  * @return array|WP_Error  List of post terms or empty array if no terms were found. WP_Error object
    2850  *                         if `$taxonomy` doesn't exist.
     2852 * @param array  $args     Optional. Term query parameters. Default empty array.
     2853 *                         See WP_Term_Query::__construct() for supported arguments.
     2854 * @return array|WP_Error  Array of WP_Term objects on success or empty array if no terms were found.
     2855 *                         WP_Error object if `$taxonomy` doesn't exist.
    28512856 */
    28522857function wp_get_post_terms( $post_id = 0, $taxonomy = 'post_tag', $args = array() ) {
    28532858        $post_id = (int) $post_id;
  • src/wp-includes/taxonomy.php

    diff --git a/src/wp-includes/taxonomy.php b/src/wp-includes/taxonomy.php
    index 94f3668..f1c1bce 100644
    a b function wp_get_object_terms($object_ids, $taxonomies, $args = array()) { 
    18411841
    18421842        $args = wp_parse_args( $args );
    18431843
     1844        /*
     1845         * When one or more queried taxonomies is registered with an 'args' array,
     1846         * those params override the `$args` passed to this function.
     1847         */
     1848        $terms = array();
     1849        if ( count( $taxonomies ) > 1 ) {
     1850                foreach ( $taxonomies as $index => $taxonomy ) {
     1851                        $t = get_taxonomy( $taxonomy );
     1852                        if ( isset( $t->args ) && is_array( $t->args ) && $args != array_merge( $args, $t->args ) ) {
     1853                                unset( $taxonomies[ $index ] );
     1854                                $terms = array_merge( $terms, wp_get_object_terms( $object_ids, $taxonomy, array_merge( $args, $t->args ) ) );
     1855                        }
     1856                }
     1857        } else {
     1858                $t = get_taxonomy( $taxonomies[0] );
     1859                if ( isset( $t->args ) && is_array( $t->args ) ) {
     1860                        $args = array_merge( $args, $t->args );
     1861                }
     1862        }
     1863
    18441864        $args['taxonomy'] = $taxonomies;
    18451865        $args['object_ids'] = $object_ids;
    18461866
    1847         $terms = get_terms( $args );
     1867        $terms = array_merge( $terms, get_terms( $args ) );
    18481868
    18491869        /**
    18501870         * Filters the terms for a given object or objects.
  • src/wp-includes/user.php

    diff --git a/src/wp-includes/user.php b/src/wp-includes/user.php
    index dcd1026..2bb4e05 100644
    a b function count_users($strategy = 'time') { 
    857857                $select_count = implode(', ', $select_count);
    858858
    859859                // Add the meta_value index to the selection list, then run the query.
    860                 $row = $wpdb->get_row( "SELECT $select_count, COUNT(*) FROM $wpdb->usermeta WHERE meta_key = '{$blog_prefix}capabilities'", ARRAY_N );
     860                $row = $wpdb->get_row( "
     861                        SELECT {$select_count}, COUNT(*)
     862                        FROM {$wpdb->usermeta}
     863                        INNER JOIN {$wpdb->users} ON user_id = ID
     864                        WHERE meta_key = '{$blog_prefix}capabilities'
     865                ", ARRAY_N );
    861866
    862867                // Run the previous loop again to associate results with role names.
    863868                $col = 0;
    function count_users($strategy = 'time') { 
    881886                        'none' => 0,
    882887                );
    883888
    884                 $users_of_blog = $wpdb->get_col( "SELECT meta_value FROM $wpdb->usermeta WHERE meta_key = '{$blog_prefix}capabilities'" );
     889                $users_of_blog = $wpdb->get_col( "
     890                        SELECT meta_value
     891                        FROM {$wpdb->usermeta}
     892                        INNER JOIN {$wpdb->users} ON user_id = ID
     893                        WHERE meta_key = '{$blog_prefix}capabilities'
     894                " );
    885895
    886896                foreach ( $users_of_blog as $caps_meta ) {
    887897                        $b_roles = maybe_unserialize($caps_meta);
  • tests/phpunit/includes/bootstrap.php

    diff --git a/tests/phpunit/includes/bootstrap.php b/tests/phpunit/includes/bootstrap.php
    index b462e70..1450736 100644
    a b  
    33 * Installs WordPress for running the tests and loads WordPress and the test libraries
    44 */
    55
     6/**
     7 * Compatibility with PHPUnit 6+
     8 */
     9if ( class_exists( 'PHPUnit\Runner\Version' ) ) {
     10        require_once dirname( __FILE__ ) . '/phpunit6-compat.php';
     11}
    612
    713$config_file_path = dirname( dirname( __FILE__ ) );
    814if ( ! file_exists( $config_file_path . '/wp-tests-config.php' ) ) {
  • new file tests/phpunit/includes/object-cache.php

    diff --git a/tests/phpunit/includes/object-cache.php b/tests/phpunit/includes/object-cache.php
    new file mode 100644
    index 0000000..51f3e91
    - +  
     1<?php
     2/**
     3 * Adds a value to cache.
     4 *
     5 * If the specified key already exists, the value is not stored and the function
     6 * returns false.
     7 *
     8 * @link http://www.php.net/manual/en/memcached.add.php
     9 *
     10 * @param string    $key        The key under which to store the value.
     11 * @param mixed     $value      The value to store.
     12 * @param string    $group      The group value appended to the $key.
     13 * @param int       $expiration The expiration time, defaults to 0.
     14 * @return bool                 Returns TRUE on success or FALSE on failure.
     15 */
     16function wp_cache_add( $key, $value, $group = '', $expiration = 0 ) {
     17        global $wp_object_cache;
     18        return $wp_object_cache->add( $key, $value, $group, $expiration );
     19}
     20
     21/**
     22 * Adds a value to cache on a specific server.
     23 *
     24 * Using a server_key value, the object can be stored on a specified server as opposed
     25 * to a random server in the stack. Note that this method will add the key/value to the
     26 * _cache object as part of the runtime cache. It will add it to an array for the
     27 * specified server_key.
     28 *
     29 * @link http://www.php.net/manual/en/memcached.addbykey.php
     30 *
     31 * @param string    $server_key     The key identifying the server to store the value on.
     32 * @param string    $key            The key under which to store the value.
     33 * @param mixed     $value          The value to store.
     34 * @param string    $group          The group value appended to the $key.
     35 * @param int       $expiration     The expiration time, defaults to 0.
     36 * @return bool                     Returns TRUE on success or FALSE on failure.
     37 */
     38function wp_cache_add_by_key( $server_key, $key, $value, $group = '', $expiration = 0 ) {
     39        global $wp_object_cache;
     40        return $wp_object_cache->addByKey( $server_key, $key, $value, $group, $expiration );
     41}
     42
     43/**
     44 * Add a single server to the list of Memcached servers.
     45 *
     46 * @link http://www.php.net/manual/en/memcached.addserver.php
     47 *
     48 * @param string        $host   The hostname of the memcache server.
     49 * @param int           $port   The port on which memcache is running.
     50 * @param int           $weight The weight of the server relative to the total weight of all the servers in the pool.
     51 * @return bool                 Returns TRUE on success or FALSE on failure.
     52 */
     53function wp_cache_add_server( $host, $port, $weight = 0 ) {
     54        global $wp_object_cache;
     55        return $wp_object_cache->addServer( $host, $port, $weight );
     56}
     57
     58/**
     59 * Adds an array of servers to the pool.
     60 *
     61 * Each individual server in the array must include a domain and port, with an optional
     62 * weight value: $servers = array( array( '127.0.0.1', 11211, 0 ) );
     63 *
     64 * @link http://www.php.net/manual/en/memcached.addservers.php
     65 *
     66 * @param array     $servers    Array of server to register.
     67 * @return bool                 True on success; false on failure.
     68 */
     69function wp_cache_add_servers( $servers ) {
     70        global $wp_object_cache;
     71        return $wp_object_cache->addServers( $servers );
     72}
     73
     74/**
     75 * Append data to an existing item.
     76 *
     77 * This method should throw an error if it is used with compressed data. This
     78 * is an expected behavior. Memcached casts the value to be appended to the initial value to the
     79 * type of the initial value. Be careful as this leads to unexpected behavior at times. Due to
     80 * how memcached treats types, the behavior has been mimicked in the internal cache to produce
     81 * similar results and improve consistency. It is recommend that appends only occur with data of
     82 * the same type.
     83 *
     84 * @link http://www.php.net/manual/en/memcached.append.php
     85 *
     86 * @param string    $key    The key under which to store the value.
     87 * @param mixed     $value  Must be string as appending mixed values is not well-defined
     88 * @param string    $group  The group value appended to the $key.
     89 * @return bool             Returns TRUE on success or FALSE on failure.
     90 */
     91function wp_cache_append( $key, $value, $group = '' ) {
     92        global $wp_object_cache;
     93        return $wp_object_cache->append( $key, $value, $group );
     94}
     95
     96/**
     97 * Append data to an existing item by server key.
     98 *
     99 * This method should throw an error if it is used with compressed data. This
     100 * is an expected behavior. Memcached casts the value to be appended to the initial value to the
     101 * type of the initial value. Be careful as this leads to unexpected behavior at times. Due to
     102 * how memcached treats types, the behavior has been mimicked in the internal cache to produce
     103 * similar results and improve consistency. It is recommend that appends only occur with data of
     104 * the same type.
     105 *
     106 * @link http://www.php.net/manual/en/memcached.appendbykey.php
     107 *
     108 * @param string    $server_key     The key identifying the server to store the value on.
     109 * @param string    $key            The key under which to store the value.
     110 * @param mixed     $value          Must be string as appending mixed values is not well-defined
     111 * @param string    $group          The group value appended to the $key.
     112 * @return bool                     Returns TRUE on success or FALSE on failure.
     113 */
     114function wp_cache_append_by_key( $server_key, $key, $value, $group = '' ) {
     115        global $wp_object_cache;
     116        return $wp_object_cache->appendByKey( $server_key, $key, $value, $group );
     117}
     118
     119/**
     120 * Performs a "check and set" to store data.
     121 *
     122 * The set will be successful only if the no other request has updated the value since it was fetched by
     123 * this request.
     124 *
     125 * @link http://www.php.net/manual/en/memcached.cas.php
     126 *
     127 * @param float     $cas_token  Unique value associated with the existing item. Generated by memcached.
     128 * @param string    $key        The key under which to store the value.
     129 * @param mixed     $value      The value to store.
     130 * @param string    $group      The group value appended to the $key.
     131 * @param int       $expiration The expiration time, defaults to 0.
     132 * @return bool                 Returns TRUE on success or FALSE on failure.
     133 */
     134function wp_cache_cas( $cas_token, $key, $value, $group = '', $expiration = 0 ) {
     135        global $wp_object_cache;
     136        return $wp_object_cache->cas( $cas_token, $key, $value, $group, $expiration );
     137}
     138
     139/**
     140 * Performs a "check and set" to store data with a server key.
     141 *
     142 * The set will be successful only if the no other request has updated the value since it was fetched by
     143 * this request.
     144 *
     145 * @link http://www.php.net/manual/en/memcached.casbykey.php
     146 *
     147 * @param string    $server_key The key identifying the server to store the value on.
     148 * @param float     $cas_token  Unique value associated with the existing item. Generated by memcached.
     149 * @param string    $key        The key under which to store the value.
     150 * @param mixed     $value      The value to store.
     151 * @param string    $group      The group value appended to the $key.
     152 * @param int       $expiration The expiration time, defaults to 0.
     153 * @return bool                 Returns TRUE on success or FALSE on failure.
     154 */
     155function wp_cache_cas_by_key( $cas_token, $server_key, $key, $value, $group = '', $expiration = 0 ) {
     156        global $wp_object_cache;
     157        return $wp_object_cache->casByKey( $cas_token, $server_key, $key, $value, $group, $expiration );
     158}
     159
     160/**
     161 * Closes the cache.
     162 *
     163 * This function has ceased to do anything since WordPress 2.5. The
     164 * functionality was removed along with the rest of the persistent cache. This
     165 * does not mean that plugins can't implement this function when they need to
     166 * make sure that the cache is cleaned up after WordPress no longer needs it.
     167 *
     168 * @since 2.0.0
     169 *
     170 * @return  bool    Always returns True
     171 */
     172function wp_cache_close() {
     173        return true;
     174}
     175
     176/**
     177 * Decrement a numeric item's value.
     178 *
     179 * @link http://www.php.net/manual/en/memcached.decrement.php
     180 *
     181 * @param string    $key    The key under which to store the value.
     182 * @param int       $offset The amount by which to decrement the item's value.
     183 * @param string    $group  The group value appended to the $key.
     184 * @return int|bool         Returns item's new value on success or FALSE on failure.
     185 */
     186function wp_cache_decrement( $key, $offset = 1, $group = '' ) {
     187        global $wp_object_cache;
     188        return $wp_object_cache->decrement( $key, $offset, $group );
     189}
     190
     191/**
     192 * Decrement a numeric item's value.
     193 *
     194 * Same as wp_cache_decrement. Original WordPress caching backends use wp_cache_decr. I
     195 * want both spellings to work.
     196 *
     197 * @link http://www.php.net/manual/en/memcached.decrement.php
     198 *
     199 * @param string    $key    The key under which to store the value.
     200 * @param int       $offset The amount by which to decrement the item's value.
     201 * @param string    $group  The group value appended to the $key.
     202 * @return int|bool         Returns item's new value on success or FALSE on failure.
     203 */
     204function wp_cache_decr( $key, $offset = 1, $group = '' ) {
     205        return wp_cache_decrement( $key, $offset, $group );
     206}
     207
     208/**
     209 * Remove the item from the cache.
     210 *
     211 * Remove an item from memcached with identified by $key after $time seconds. The
     212 * $time parameter allows an object to be queued for deletion without immediately
     213 * deleting. Between the time that it is queued and the time it's deleted, add,
     214 * replace, and get will fail, but set will succeed.
     215 *
     216 * @link http://www.php.net/manual/en/memcached.delete.php
     217 *
     218 * @param string    $key    The key under which to store the value.
     219 * @param string    $group  The group value appended to the $key.
     220 * @param int       $time   The amount of time the server will wait to delete the item in seconds.
     221 * @return bool             Returns TRUE on success or FALSE on failure.
     222 */
     223function wp_cache_delete( $key, $group = '', $time = 0 ) {
     224        global $wp_object_cache;
     225        return $wp_object_cache->delete( $key, $group, $time );
     226}
     227
     228/**
     229 * Remove the item from the cache by server key.
     230 *
     231 * Remove an item from memcached with identified by $key after $time seconds. The
     232 * $time parameter allows an object to be queued for deletion without immediately
     233 * deleting. Between the time that it is queued and the time it's deleted, add,
     234 * replace, and get will fail, but set will succeed.
     235 *
     236 * @link http://www.php.net/manual/en/memcached.deletebykey.php
     237 *
     238 * @param string        $server_key The key identifying the server to store the value on.
     239 * @param string        $key        The key under which to store the value.
     240 * @param string        $group      The group value appended to the $key.
     241 * @param int           $time       The amount of time the server will wait to delete the item in seconds.
     242 * @return bool                     Returns TRUE on success or FALSE on failure.
     243 */
     244function wp_cache_delete_by_key( $server_key, $key, $group = '', $time = 0 ) {
     245        global $wp_object_cache;
     246        return $wp_object_cache->deleteByKey( $server_key, $key, $group, $time );
     247}
     248
     249/**
     250 * Fetch the next result.
     251 *
     252 * @link http://www.php.net/manual/en/memcached.fetch.php
     253 *
     254 * @return  array|bool   Returns the next result or FALSE otherwise.
     255 */
     256function wp_cache_fetch() {
     257        global $wp_object_cache;
     258        return $wp_object_cache->fetch();
     259}
     260
     261/**
     262 * Fetch all remaining results from the last request.
     263 *
     264 * @link http://www.php.net/manual/en/memcached.fetchall.php
     265 *
     266 * @return  array|bool  Returns the results or FALSE on failure.
     267 */
     268function wp_cache_fetch_all() {
     269        global $wp_object_cache;
     270        return $wp_object_cache->fetchAll();
     271}
     272
     273/**
     274 * Invalidate all items in the cache.
     275 *
     276 * @link http://www.php.net/manual/en/memcached.flush.php
     277 *
     278 * @param int       $delay  Number of seconds to wait before invalidating the items.
     279 * @return bool             Returns TRUE on success or FALSE on failure.
     280 */
     281function wp_cache_flush( $delay = 0 ) {
     282        global $wp_object_cache;
     283        return $wp_object_cache->flush( $delay );
     284}
     285
     286/**
     287 * Retrieve object from cache.
     288 *
     289 * Gets an object from cache based on $key and $group. In order to fully support the $cache_cb and $cas_token
     290 * parameters, the runtime cache is ignored by this function if either of those values are set. If either of
     291 * those values are set, the request is made directly to the memcached server for proper handling of the
     292 * callback and/or token.
     293 *
     294 * Note that the $deprecated and $found args are only here for compatibility with the native wp_cache_get function.
     295 *
     296 * @link http://www.php.net/manual/en/memcached.get.php
     297 *
     298 * @param string        $key        The key under which to store the value.
     299 * @param string        $group      The group value appended to the $key.
     300 * @param bool          $force      Whether or not to force a cache invalidation.
     301 * @param null|bool     $found      Variable passed by reference to determine if the value was found or not.
     302 * @param null|string   $cache_cb   Read-through caching callback.
     303 * @param null|float    $cas_token  The variable to store the CAS token in.
     304 * @return bool|mixed               Cached object value.
     305 */
     306function wp_cache_get( $key, $group = '', $force = false, &$found = null, $cache_cb = null, &$cas_token = null ) {
     307        global $wp_object_cache;
     308
     309        if ( func_num_args() > 4 )
     310                return $wp_object_cache->get( $key, $group, $force, $found, '', false, $cache_cb, $cas_token );
     311        else
     312                return $wp_object_cache->get( $key, $group, $force, $found );
     313}
     314
     315/**
     316 * Retrieve object from cache from specified server.
     317 *
     318 * Gets an object from cache based on $key, $group and $server_key. In order to fully support the $cache_cb and $cas_token
     319 * parameters, the runtime cache is ignored by this function if either of those values are set. If either of
     320 * those values are set, the request is made directly to the memcached server for proper handling of the
     321 * callback and/or token.
     322 *
     323 * @link http://www.php.net/manual/en/memcached.getbykey.php
     324 *
     325 * @param string        $server_key The key identifying the server to store the value on.
     326 * @param string        $key        The key under which to store the value.
     327 * @param string        $group      The group value appended to the $key.
     328 * @param bool          $force      Whether or not to force a cache invalidation.
     329 * @param null|bool     $found      Variable passed by reference to determine if the value was found or not.
     330 * @param null|string   $cache_cb   Read-through caching callback.
     331 * @param null|float    $cas_token  The variable to store the CAS token in.
     332 * @return bool|mixed               Cached object value.
     333 */
     334function wp_cache_get_by_key( $server_key, $key, $group = '', $force = false, &$found = null, $cache_cb = NULL, &$cas_token = NULL ) {
     335        global $wp_object_cache;
     336
     337        if ( func_num_args() > 5 )
     338                return $wp_object_cache->getByKey( $server_key, $key, $group, $force, $found, $cache_cb, $cas_token );
     339        else
     340                return $wp_object_cache->getByKey( $server_key, $key, $group, $force, $found );
     341}
     342
     343/**
     344 * Request multiple keys without blocking.
     345 *
     346 * @link http://www.php.net/manual/en/memcached.getdelayed.php
     347 *
     348 * @param string|array  $keys       Array or string of key(s) to request.
     349 * @param string|array  $groups     Array or string of group(s) for the key(s). See buildKeys for more on how these are handled.
     350 * @param bool          $with_cas   Whether to request CAS token values also.
     351 * @param null          $value_cb   The result callback or NULL.
     352 * @return bool                     Returns TRUE on success or FALSE on failure.
     353 */
     354function wp_cache_get_delayed( $keys, $groups = '', $with_cas = false, $value_cb = NULL ) {
     355        global $wp_object_cache;
     356        return $wp_object_cache->getDelayed( $keys, $groups, $with_cas, $value_cb );
     357}
     358
     359/**
     360 * Request multiple keys without blocking from a specified server.
     361 *
     362 * @link http://www.php.net/manual/en/memcached.getdelayed.php
     363 *
     364 * @param string        $server_key The key identifying the server to store the value on.
     365 * @param string|array  $keys       Array or string of key(s) to request.
     366 * @param string|array  $groups     Array or string of group(s) for the key(s). See buildKeys for more on how these are handled.
     367 * @param bool          $with_cas   Whether to request CAS token values also.
     368 * @param null          $value_cb   The result callback or NULL.
     369 * @return bool                     Returns TRUE on success or FALSE on failure.
     370 */
     371function wp_cache_get_delayed_by_key( $server_key, $keys, $groups = '', $with_cas = false, $value_cb = NULL ) {
     372        global $wp_object_cache;
     373        return $wp_object_cache->getDelayedByKey( $server_key, $keys, $groups, $with_cas, $value_cb );
     374}
     375
     376/**
     377 * Gets multiple values from memcached in one request.
     378 *
     379 * See the buildKeys method definition to understand the $keys/$groups parameters.
     380 *
     381 * @link http://www.php.net/manual/en/memcached.getmulti.php
     382 *
     383 * @param array         $keys       Array of keys to retrieve.
     384 * @param string|array  $groups     If string, used for all keys. If arrays, corresponds with the $keys array.
     385 * @param null|array    $cas_tokens The variable to store the CAS tokens for the found items.
     386 * @param int           $flags      The flags for the get operation.
     387 * @return bool|array               Returns the array of found items or FALSE on failure.
     388 */
     389function wp_cache_get_multi( $keys, $groups = '', &$cas_tokens = NULL, $flags = NULL ) {
     390        global $wp_object_cache;
     391
     392        if ( func_num_args() > 2 )
     393                return $wp_object_cache->getMulti( $keys, $groups, '', $cas_tokens, $flags );
     394        else
     395                return $wp_object_cache->getMulti( $keys, $groups );
     396}
     397
     398/**
     399 * Gets multiple values from memcached in one request by specified server key.
     400 *
     401 * See the buildKeys method definition to understand the $keys/$groups parameters.
     402 *
     403 * @link http://www.php.net/manual/en/memcached.getmultibykey.php
     404 *
     405 * @param string        $server_key The key identifying the server to store the value on.
     406 * @param array         $keys       Array of keys to retrieve.
     407 * @param string|array  $groups     If string, used for all keys. If arrays, corresponds with the $keys array.
     408 * @param null|array    $cas_tokens The variable to store the CAS tokens for the found items.
     409 * @param int           $flags      The flags for the get operation.
     410 * @return bool|array               Returns the array of found items or FALSE on failure.
     411 */
     412function wp_cache_get_multi_by_key( $server_key, $keys, $groups = '', &$cas_tokens = NULL, $flags = NULL ) {
     413        global $wp_object_cache;
     414
     415        if ( func_num_args() > 3 )
     416                return $wp_object_cache->getMultiByKey( $server_key, $keys, $groups, $cas_tokens, $flags );
     417        else
     418                return $wp_object_cache->getMultiByKey( $server_key, $keys, $groups );
     419}
     420
     421/**
     422 * Retrieve a Memcached option value.
     423 *
     424 * @link http://www.php.net/manual/en/memcached.getoption.php
     425 *
     426 * @param int   $option One of the Memcached::OPT_* constants.
     427 * @return mixed        Returns the value of the requested option, or FALSE on error.
     428 */
     429function wp_cache_get_option( $option ) {
     430        global $wp_object_cache;
     431        return $wp_object_cache->getOption( $option );
     432}
     433
     434/**
     435 * Return the result code of the last option.
     436 *
     437 * @link http://www.php.net/manual/en/memcached.getresultcode.php
     438 *
     439 * @return int  Result code of the last Memcached operation.
     440 */
     441function wp_cache_get_result_code() {
     442        global $wp_object_cache;
     443        return $wp_object_cache->getResultCode();
     444}
     445
     446/**
     447 * Return the message describing the result of the last operation.
     448 *
     449 * @link http://www.php.net/manual/en/memcached.getresultmessage.php
     450 *
     451 * @return string   Message describing the result of the last Memcached operation.
     452 */
     453function wp_cache_get_result_message() {
     454        global $wp_object_cache;
     455        return $wp_object_cache->getResultMessage();
     456}
     457
     458/**
     459 * Get server information by key.
     460 *
     461 * @link http://www.php.net/manual/en/memcached.getserverbykey.php
     462 *
     463 * @param string    $server_key The key identifying the server to store the value on.
     464 * @return array                Array with host, post, and weight on success, FALSE on failure.
     465 */
     466function wp_cache_get_server_by_key( $server_key ) {
     467        global $wp_object_cache;
     468        return $wp_object_cache->getServerByKey( $server_key );
     469}
     470
     471/**
     472 * Get the list of servers in the pool.
     473 *
     474 * @link http://www.php.net/manual/en/memcached.getserverlist.php
     475 *
     476 * @return array    The list of all servers in the server pool.
     477 */
     478function wp_cache_get_server_list() {
     479        global $wp_object_cache;
     480        return $wp_object_cache->getServerList();
     481}
     482
     483/**
     484 * Get server pool statistics.
     485 *
     486 * @link http://www.php.net/manual/en/memcached.getstats.php
     487 *
     488 * @return array    Array of server statistics, one entry per server.
     489 */
     490function wp_cache_get_stats() {
     491        global $wp_object_cache;
     492        return $wp_object_cache->getStats();
     493}
     494
     495/**
     496 * Get server pool memcached version information.
     497 *
     498 * @link http://www.php.net/manual/en/memcached.getversion.php
     499 *
     500 * @return array    Array of server versions, one entry per server.
     501 */
     502function wp_cache_get_version() {
     503        global $wp_object_cache;
     504        return $wp_object_cache->getVersion();
     505}
     506
     507/**
     508 * Increment a numeric item's value.
     509 *
     510 * @link http://www.php.net/manual/en/memcached.increment.php
     511 *
     512 * @param string    $key    The key under which to store the value.
     513 * @param int       $offset The amount by which to increment the item's value.
     514 * @param string    $group  The group value appended to the $key.
     515 * @return int|bool         Returns item's new value on success or FALSE on failure.
     516 */
     517function wp_cache_increment( $key, $offset = 1, $group = '' ) {
     518        global $wp_object_cache;
     519        return $wp_object_cache->increment( $key, $offset, $group );
     520}
     521
     522/**
     523 * Increment a numeric item's value.
     524 *
     525 * This is the same as wp_cache_increment, but kept for back compatibility. The original
     526 * WordPress caching backends use wp_cache_incr. I want both to work.
     527 *
     528 * @link http://www.php.net/manual/en/memcached.increment.php
     529 *
     530 * @param string    $key    The key under which to store the value.
     531 * @param int       $offset The amount by which to increment the item's value.
     532 * @param string    $group  The group value appended to the $key.
     533 * @return int|bool         Returns item's new value on success or FALSE on failure.
     534 */
     535function wp_cache_incr( $key, $offset = 1, $group = '' ) {
     536        return wp_cache_increment( $key, $offset, $group );
     537}
     538
     539/**
     540 * Prepend data to an existing item.
     541 *
     542 * This method should throw an error if it is used with compressed data. This is an expected behavior.
     543 * Memcached casts the value to be prepended to the initial value to the type of the initial value. Be
     544 * careful as this leads to unexpected behavior at times. For instance, prepending (float) 45.23 to
     545 * (int) 23 will result in 45, because the value is first combined (45.2323) then cast to "integer"
     546 * (the original value), which will be (int) 45. Due to how memcached treats types, the behavior has been
     547 * mimicked in the internal cache to produce similar results and improve consistency. It is recommend
     548 * that prepends only occur with data of the same type.
     549 *
     550 * @link http://www.php.net/manual/en/memcached.prepend.php
     551 *
     552 * @param string    $key    The key under which to store the value.
     553 * @param string    $value  Must be string as prepending mixed values is not well-defined.
     554 * @param string    $group  The group value prepended to the $key.
     555 * @return bool             Returns TRUE on success or FALSE on failure.
     556 */
     557function wp_cache_prepend( $key, $value, $group = '' ) {
     558        global $wp_object_cache;
     559        return $wp_object_cache->prepend( $key, $value, $group );
     560}
     561
     562/**
     563 * Append data to an existing item by server key.
     564 *
     565 * This method should throw an error if it is used with compressed data. This is an expected behavior.
     566 * Memcached casts the value to be prepended to the initial value to the type of the initial value. Be
     567 * careful as this leads to unexpected behavior at times. For instance, prepending (float) 45.23 to
     568 * (int) 23 will result in 45, because the value is first combined (45.2323) then cast to "integer"
     569 * (the original value), which will be (int) 45. Due to how memcached treats types, the behavior has been
     570 * mimicked in the internal cache to produce similar results and improve consistency. It is recommend
     571 * that prepends only occur with data of the same type.
     572 *
     573 * @link http://www.php.net/manual/en/memcached.prependbykey.php
     574 *
     575 * @param string    $server_key     The key identifying the server to store the value on.
     576 * @param string    $key            The key under which to store the value.
     577 * @param string    $value          Must be string as prepending mixed values is not well-defined.
     578 * @param string    $group          The group value prepended to the $key.
     579 * @return bool                     Returns TRUE on success or FALSE on failure.
     580 */
     581function wp_cache_prepend_by_key( $server_key, $key, $value, $group = '' ) {
     582        global $wp_object_cache;
     583        return $wp_object_cache->prependByKey( $server_key, $key, $value, $group );
     584}
     585
     586/**
     587 * Replaces a value in cache.
     588 *
     589 * This method is similar to "add"; however, is does not successfully set a value if
     590 * the object's key is not already set in cache.
     591 *
     592 * @link http://www.php.net/manual/en/memcached.replace.php
     593 *
     594 * @param string    $key        The key under which to store the value.
     595 * @param mixed     $value      The value to store.
     596 * @param string    $group      The group value appended to the $key.
     597 * @param int       $expiration The expiration time, defaults to 0.
     598 * @return bool                 Returns TRUE on success or FALSE on failure.
     599 */
     600function wp_cache_replace( $key, $value, $group = '', $expiration = 0 ) {
     601        global $wp_object_cache;
     602        return $wp_object_cache->replace( $key, $value, $group, $expiration );
     603}
     604
     605/**
     606 * Replaces a value in cache on a specific server.
     607 *
     608 * This method is similar to "addByKey"; however, is does not successfully set a value if
     609 * the object's key is not already set in cache.
     610 *
     611 * @link http://www.php.net/manual/en/memcached.addbykey.php
     612 *
     613 * @param string    $server_key     The key identifying the server to store the value on.
     614 * @param string    $key            The key under which to store the value.
     615 * @param mixed     $value          The value to store.
     616 * @param string    $group          The group value appended to the $key.
     617 * @param int       $expiration     The expiration time, defaults to 0.
     618 * @return bool                     Returns TRUE on success or FALSE on failure.
     619 */
     620function wp_cache_replace_by_key( $server_key, $key, $value, $group = '', $expiration = 0 ) {
     621        global $wp_object_cache;
     622        return $wp_object_cache->replaceByKey( $server_key, $key, $value, $group, $expiration );
     623}
     624
     625/**
     626 * Sets a value in cache.
     627 *
     628 * The value is set whether or not this key already exists in memcached.
     629 *
     630 * @link http://www.php.net/manual/en/memcached.set.php
     631 *
     632 * @param string    $key        The key under which to store the value.
     633 * @param mixed     $value      The value to store.
     634 * @param string    $group      The group value appended to the $key.
     635 * @param int       $expiration The expiration time, defaults to 0.
     636 * @return bool                 Returns TRUE on success or FALSE on failure.
     637 */
     638function wp_cache_set( $key, $value, $group = '', $expiration = 0 ) {
     639        global $wp_object_cache;
     640        return $wp_object_cache->set( $key, $value, $group, $expiration );
     641}
     642
     643/**
     644 * Sets a value in cache.
     645 *
     646 * The value is set whether or not this key already exists in memcached.
     647 *
     648 * @link http://www.php.net/manual/en/memcached.set.php
     649 *
     650 * @param string    $server_key     The key identifying the server to store the value on.
     651 * @param string    $key            The key under which to store the value.
     652 * @param mixed     $value          The value to store.
     653 * @param string    $group          The group value appended to the $key.
     654 * @param int       $expiration     The expiration time, defaults to 0.
     655 * @return bool                     Returns TRUE on success or FALSE on failure.
     656 */
     657function wp_cache_set_by_key( $server_key, $key, $value, $group = '', $expiration = 0 ) {
     658        global $wp_object_cache;
     659        return $wp_object_cache->setByKey( $server_key, $key, $value, $group, $expiration );
     660}
     661
     662/**
     663 * Set multiple values to cache at once.
     664 *
     665 * By sending an array of $items to this function, all values are saved at once to
     666 * memcached, reducing the need for multiple requests to memcached. The $items array
     667 * keys and values are what are stored to memcached. The keys in the $items array
     668 * are merged with the $groups array/string value via buildKeys to determine the
     669 * final key for the object.
     670 *
     671 * @param array         $items      An array of key/value pairs to store on the server.
     672 * @param string|array  $groups     Group(s) to merge with key(s) in $items.
     673 * @param int           $expiration The expiration time, defaults to 0.
     674 * @return bool                     Returns TRUE on success or FALSE on failure.
     675 */
     676function wp_cache_set_multi( $items, $groups = '', $expiration = 0 ) {
     677        global $wp_object_cache;
     678        return $wp_object_cache->setMulti( $items, $groups, $expiration );
     679}
     680
     681/**
     682 * Set multiple values to cache at once on specified server.
     683 *
     684 * By sending an array of $items to this function, all values are saved at once to
     685 * memcached, reducing the need for multiple requests to memcached. The $items array
     686 * keys and values are what are stored to memcached. The keys in the $items array
     687 * are merged with the $groups array/string value via buildKeys to determine the
     688 * final key for the object.
     689 *
     690 * @param string        $server_key The key identifying the server to store the value on.
     691 * @param array         $items      An array of key/value pairs to store on the server.
     692 * @param string|array  $groups     Group(s) to merge with key(s) in $items.
     693 * @param int           $expiration The expiration time, defaults to 0.
     694 * @return bool                     Returns TRUE on success or FALSE on failure.
     695 */
     696function wp_cache_set_multi_by_key( $server_key, $items, $groups = 'default', $expiration = 0 ) {
     697        global $wp_object_cache;
     698        return $wp_object_cache->setMultiByKey( $server_key, $items, $groups, $expiration );
     699}
     700
     701/**
     702 * Set a Memcached option.
     703 *
     704 * @link http://www.php.net/manual/en/memcached.setoption.php
     705 *
     706 * @param int       $option Option name.
     707 * @param mixed     $value  Option value.
     708 * @return bool             Returns TRUE on success or FALSE on failure.
     709 */
     710function wp_cache_set_option( $option, $value ) {
     711        global $wp_object_cache;
     712        return $wp_object_cache->setOption( $option, $value );
     713}
     714
     715/**
     716 * Switch blog prefix, which changes the cache that is accessed.
     717 *
     718 * @param  int     $blog_id    Blog to switch to.
     719 * @return void
     720 */
     721function wp_cache_switch_to_blog( $blog_id ) {
     722        global $wp_object_cache;
     723        return $wp_object_cache->switch_to_blog( $blog_id );
     724}
     725
     726
     727/**
     728 * Sets up Object Cache Global and assigns it.
     729 *
     730 * @global  WP_Object_Cache     $wp_object_cache    WordPress Object Cache
     731 * @return  void
     732 */
     733function wp_cache_init() {
     734        global $wp_object_cache;
     735        $wp_object_cache = new WP_Object_Cache();
     736}
     737
     738/**
     739 * Adds a group or set of groups to the list of non-persistent groups.
     740 *
     741 * @param   string|array    $groups     A group or an array of groups to add.
     742 * @return  void
     743 */
     744function wp_cache_add_global_groups( $groups ) {
     745        global $wp_object_cache;
     746        $wp_object_cache->add_global_groups( $groups );
     747}
     748
     749/**
     750 * Adds a group or set of groups to the list of non-Memcached groups.
     751 *
     752 * @param   string|array    $groups     A group or an array of groups to add.
     753 * @return  void
     754 */
     755function wp_cache_add_non_persistent_groups( $groups ) {
     756        global $wp_object_cache;
     757        $wp_object_cache->add_non_persistent_groups( $groups );
     758}
     759
     760class WP_Object_Cache {
     761
     762        /**
     763         * Holds the Memcached object.
     764         *
     765         * @var Memcached
     766         */
     767        public $m;
     768
     769        /**
     770         * Hold the Memcached server details.
     771         *
     772         * @var array
     773         */
     774        public $servers;
     775
     776        /**
     777         * Holds the non-Memcached objects.
     778         *
     779         * @var array
     780         */
     781        public $cache = array();
     782
     783        /**
     784         * List of global groups.
     785         *
     786         * @var array
     787         */
     788        public $global_groups = array( 'users', 'userlogins', 'usermeta', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss' );
     789
     790        /**
     791         * List of groups not saved to Memcached.
     792         *
     793         * @var array
     794         */
     795        public $no_mc_groups = array( 'comment', 'counts' );
     796
     797        /**
     798         * Prefix used for global groups.
     799         *
     800         * @var string
     801         */
     802        public $global_prefix = '';
     803
     804        /**
     805         * Prefix used for non-global groups.
     806         *
     807         * @var string
     808         */
     809        public $blog_prefix = '';
     810
     811        /**
     812         * Instantiate the Memcached class.
     813         *
     814         * Instantiates the Memcached class and returns adds the servers specified
     815         * in the $memcached_servers global array.
     816         *
     817         * @link    http://www.php.net/manual/en/memcached.construct.php
     818         *
     819         * @param   null    $persistent_id      To create an instance that persists between requests, use persistent_id to specify a unique ID for the instance.
     820         */
     821        public function __construct( $persistent_id = NULL ) {
     822                global $memcached_servers, $blog_id, $table_prefix;
     823
     824                if ( is_null( $persistent_id ) || ! is_string( $persistent_id ) )
     825                        $this->m = new Memcached();
     826                else
     827                        $this->m = new Memcached( $persistent_id );
     828
     829                if ( isset( $memcached_servers ) )
     830                        $this->servers = $memcached_servers;
     831                else
     832                        $this->servers = array( array( '127.0.0.1', 11211 ) );
     833
     834                $this->addServers( $this->servers );
     835
     836                /**
     837                 * This approach is borrowed from Sivel and Boren. Use the salt for easy cache invalidation and for
     838                 * multi single WP installs on the same server.
     839                 */
     840                if ( ! defined( 'WP_CACHE_KEY_SALT' ) )
     841                        define( 'WP_CACHE_KEY_SALT', '' );
     842
     843                // Assign global and blog prefixes for use with keys
     844                if ( function_exists( 'is_multisite' ) ) {
     845                        $this->global_prefix = ( is_multisite() || defined( 'CUSTOM_USER_TABLE' ) && defined( 'CUSTOM_USER_META_TABLE' ) ) ? '' : $table_prefix;
     846                        $this->blog_prefix = ( is_multisite() ? $blog_id : $table_prefix ) . ':';
     847                }
     848
     849                // Setup cacheable values for handling expiration times
     850                $this->thirty_days = 60 * 60 * 24 * 30;
     851                $this->now         = time();
     852        }
     853
     854        /**
     855         * Adds a value to cache.
     856         *
     857         * If the specified key already exists, the value is not stored and the function
     858         * returns false.
     859         *
     860         * @link    http://www.php.net/manual/en/memcached.add.php
     861         *
     862         * @param   string      $key            The key under which to store the value.
     863         * @param   mixed       $value          The value to store.
     864         * @param   string      $group          The group value appended to the $key.
     865         * @param   int         $expiration     The expiration time, defaults to 0.
     866         * @param   string      $server_key     The key identifying the server to store the value on.
     867         * @param   bool        $byKey          True to store in internal cache by key; false to not store by key
     868         * @return  bool                        Returns TRUE on success or FALSE on failure.
     869         */
     870        public function add( $key, $value, $group = 'default', $expiration = 0, $server_key = '', $byKey = false ) {
     871                /*
     872                 * Ensuring that wp_suspend_cache_addition is defined before calling, because sometimes an advanced-cache.php
     873                 * file will load object-cache.php before wp-includes/functions.php is loaded. In those cases, if wp_cache_add
     874                 * is called in advanced-cache.php before any more of WordPress is loaded, we get a fatal error because
     875                 * wp_suspend_cache_addition will not be defined until wp-includes/functions.php is loaded.
     876                 */
     877                if ( function_exists( 'wp_suspend_cache_addition' ) && wp_suspend_cache_addition() ) {
     878                        return false;
     879                }
     880
     881                $derived_key = $this->buildKey( $key, $group );
     882                $expiration  = $this->sanitize_expiration( $expiration );
     883
     884                // If group is a non-Memcached group, save to runtime cache, not Memcached
     885                if ( in_array( $group, $this->no_mc_groups ) ) {
     886
     887                        // Add does not set the value if the key exists; mimic that here
     888                        if ( isset( $this->cache[$derived_key] ) )
     889                                return false;
     890
     891                        $this->add_to_internal_cache( $derived_key, $value );
     892
     893                        return true;
     894                }
     895
     896                // Save to Memcached
     897                if ( $byKey )
     898                        $result = $this->m->addByKey( $server_key, $derived_key, $value, $expiration );
     899                else
     900                        $result = $this->m->add( $derived_key, $value, $expiration );
     901
     902                // Store in runtime cache if add was successful
     903                if ( Memcached::RES_SUCCESS === $this->getResultCode() )
     904                        $this->add_to_internal_cache( $derived_key, $value );
     905
     906                return $result;
     907        }
     908
     909        /**
     910         * Adds a value to cache on a specific server.
     911         *
     912         * Using a server_key value, the object can be stored on a specified server as opposed
     913         * to a random server in the stack. Note that this method will add the key/value to the
     914         * _cache object as part of the runtime cache. It will add it to an array for the
     915         * specified server_key.
     916         *
     917         * @link    http://www.php.net/manual/en/memcached.addbykey.php
     918         *
     919         * @param   string      $server_key     The key identifying the server to store the value on.
     920         * @param   string      $key            The key under which to store the value.
     921         * @param   mixed       $value          The value to store.
     922         * @param   string      $group          The group value appended to the $key.
     923         * @param   int         $expiration     The expiration time, defaults to 0.
     924         * @return  bool                        Returns TRUE on success or FALSE on failure.
     925         */
     926        public function addByKey( $server_key, $key, $value, $group = 'default', $expiration = 0 ) {
     927                return $this->add( $key, $value, $group, $expiration, $server_key, true );
     928        }
     929
     930        /**
     931         * Add a single server to the list of Memcached servers.
     932         *
     933         * @link http://www.php.net/manual/en/memcached.addserver.php
     934         *
     935         * @param   string      $host           The hostname of the memcache server.
     936         * @param   int         $port           The port on which memcache is running.
     937         * @param   int         $weight         The weight of the server relative to the total weight of all the servers in the pool.
     938         * @return  bool                        Returns TRUE on success or FALSE on failure.
     939         */
     940        public function addServer( $host, $port, $weight = 0 ) {
     941                $host = is_string( $host ) ? $host : '127.0.0.1';
     942                $port = is_numeric( $port ) && $port > 0 ? $port : 11211;
     943                $weight = is_numeric( $weight ) && $weight > 0 ? $weight : 1;
     944
     945                return $this->m->addServer( $host, $port, $weight );
     946        }
     947
     948        /**
     949         * Adds an array of servers to the pool.
     950         *
     951         * Each individual server in the array must include a domain and port, with an optional
     952         * weight value: $servers = array( array( '127.0.0.1', 11211, 0 ) );
     953         *
     954         * @link    http://www.php.net/manual/en/memcached.addservers.php
     955         *
     956         * @param   array       $servers        Array of server to register.
     957         * @return  bool                        True on success; false on failure.
     958         */
     959        public function addServers( $servers ) {
     960                if ( ! is_object( $this->m ) )
     961                        return false;
     962
     963                return $this->m->addServers( $servers );
     964        }
     965
     966        /**
     967         * Append data to an existing item.
     968         *
     969         * This method should throw an error if it is used with compressed data. This
     970         * is an expected behavior. Memcached casts the value to be appended to the initial value to the
     971         * type of the initial value. Be careful as this leads to unexpected behavior at times. Due to
     972         * how memcached treats types, the behavior has been mimicked in the internal cache to produce
     973         * similar results and improve consistency. It is recommend that appends only occur with data of
     974         * the same type.
     975         *
     976         * @link    http://www.php.net/manual/en/memcached.append.php
     977         *
     978         * @param   string      $key            The key under which to store the value.
     979         * @param   mixed       $value          Must be string as appending mixed values is not well-defined.
     980         * @param   string      $group          The group value appended to the $key.
     981         * @param   string      $server_key     The key identifying the server to store the value on.
     982         * @param   bool        $byKey          True to store in internal cache by key; false to not store by key
     983         * @return  bool                        Returns TRUE on success or FALSE on failure.
     984         */
     985        public function append( $key, $value, $group = 'default', $server_key = '', $byKey = false ) {
     986                if ( ! is_string( $value ) && ! is_int( $value ) && ! is_float( $value ) )
     987                        return false;
     988
     989                $derived_key = $this->buildKey( $key, $group );
     990
     991                // If group is a non-Memcached group, append to runtime cache value, not Memcached
     992                if ( in_array( $group, $this->no_mc_groups ) ) {
     993                        if ( ! isset( $this->cache[$derived_key] ) )
     994                                return false;
     995
     996                        $combined = $this->combine_values( $this->cache[$derived_key], $value, 'app' );
     997                        $this->add_to_internal_cache( $derived_key, $combined );
     998                        return true;
     999                }
     1000
     1001                // Append to Memcached value
     1002                if ( $byKey )
     1003                        $result = $this->m->appendByKey( $server_key, $derived_key, $value );
     1004                else
     1005                        $result = $this->m->append( $derived_key, $value );
     1006
     1007                // Store in runtime cache if add was successful
     1008                if ( Memcached::RES_SUCCESS === $this->getResultCode() ) {
     1009                        $combined = $this->combine_values( $this->cache[$derived_key], $value, 'app' );
     1010                        $this->add_to_internal_cache( $derived_key, $combined );
     1011                }
     1012
     1013                return $result;
     1014        }
     1015
     1016        /**
     1017         * Append data to an existing item by server key.
     1018         *
     1019         * This method should throw an error if it is used with compressed data. This
     1020         * is an expected behavior. Memcached casts the value to be appended to the initial value to the
     1021         * type of the initial value. Be careful as this leads to unexpected behavior at times. Due to
     1022         * how memcached treats types, the behavior has been mimicked in the internal cache to produce
     1023         * similar results and improve consistency. It is recommend that appends only occur with data of
     1024         * the same type.
     1025         *
     1026         * @link    http://www.php.net/manual/en/memcached.appendbykey.php
     1027         *
     1028         * @param   string      $server_key     The key identifying the server to store the value on.
     1029         * @param   string      $key            The key under which to store the value.
     1030         * @param   mixed       $value          Must be string as appending mixed values is not well-defined
     1031         * @param   string      $group          The group value appended to the $key.
     1032         * @return  bool                        Returns TRUE on success or FALSE on failure.
     1033         */
     1034        public function appendByKey( $server_key, $key, $value, $group = 'default' ) {
     1035                return $this->append( $key, $value, $group, $server_key, true );
     1036        }
     1037
     1038        /**
     1039         * Performs a "check and set" to store data.
     1040         *
     1041         * The set will be successful only if the no other request has updated the value since it was fetched since
     1042         * this request.
     1043         *
     1044         * @link    http://www.php.net/manual/en/memcached.cas.php
     1045         *
     1046         * @param   float       $cas_token      Unique value associated with the existing item. Generated by memcached.
     1047         * @param   string      $key            The key under which to store the value.
     1048         * @param   mixed       $value          The value to store.
     1049         * @param   string      $group          The group value appended to the $key.
     1050         * @param   int         $expiration     The expiration time, defaults to 0.
     1051         * @param   string      $server_key     The key identifying the server to store the value on.
     1052         * @param   bool        $byKey          True to store in internal cache by key; false to not store by key
     1053         * @return  bool                        Returns TRUE on success or FALSE on failure.
     1054         */
     1055        public function cas( $cas_token, $key, $value, $group = 'default', $expiration = 0, $server_key = '', $byKey = false ) {
     1056                $derived_key = $this->buildKey( $key, $group );
     1057                $expiration  = $this->sanitize_expiration( $expiration );
     1058
     1059                /**
     1060                 * If group is a non-Memcached group, save to runtime cache, not Memcached. Note
     1061                 * that since check and set cannot be emulated in the run time cache, this value
     1062                 * operation is treated as a normal "add" for no_mc_groups.
     1063                 */
     1064                if ( in_array( $group, $this->no_mc_groups ) ) {
     1065                        $this->add_to_internal_cache( $derived_key, $value );
     1066                        return true;
     1067                }
     1068
     1069                // Save to Memcached
     1070                if ( $byKey )
     1071                        $result = $this->m->casByKey( $cas_token, $server_key, $derived_key, $value, $expiration );
     1072                else
     1073                        $result = $this->m->cas( $cas_token, $derived_key, $value, $expiration );
     1074
     1075                // Store in runtime cache if cas was successful
     1076                if ( Memcached::RES_SUCCESS === $this->getResultCode() )
     1077                        $this->add_to_internal_cache( $derived_key, $value );
     1078
     1079                return $result;
     1080        }
     1081
     1082        /**
     1083         * Performs a "check and set" to store data with a server key.
     1084         *
     1085         * The set will be successful only if the no other request has updated the value since it was fetched by
     1086         * this request.
     1087         *
     1088         * @link    http://www.php.net/manual/en/memcached.casbykey.php
     1089         *
     1090         * @param   string      $server_key     The key identifying the server to store the value on.
     1091         * @param   float       $cas_token      Unique value associated with the existing item. Generated by memcached.
     1092         * @param   string      $key            The key under which to store the value.
     1093         * @param   mixed       $value          The value to store.
     1094         * @param   string      $group          The group value appended to the $key.
     1095         * @param   int         $expiration     The expiration time, defaults to 0.
     1096         * @return  bool                        Returns TRUE on success or FALSE on failure.
     1097         */
     1098        public function casByKey( $cas_token, $server_key, $key, $value, $group = 'default', $expiration = 0 ) {
     1099                return $this->cas( $cas_token, $key, $value, $group, $expiration, $server_key, true );
     1100        }
     1101
     1102        /**
     1103         * Decrement a numeric item's value.
     1104         *
     1105         * @link http://www.php.net/manual/en/memcached.decrement.php
     1106         *
     1107         * @param string    $key    The key under which to store the value.
     1108         * @param int       $offset The amount by which to decrement the item's value.
     1109         * @param string    $group  The group value appended to the $key.
     1110         * @return int|bool         Returns item's new value on success or FALSE on failure.
     1111         */
     1112        public function decrement( $key, $offset = 1, $group = 'default' ) {
     1113                $derived_key = $this->buildKey( $key, $group );
     1114
     1115                // Decrement values in no_mc_groups
     1116                if ( in_array( $group, $this->no_mc_groups ) ) {
     1117
     1118                        // Only decrement if the key already exists and value is 0 or greater (mimics memcached behavior)
     1119                        if ( isset( $this->cache[$derived_key] ) && $this->cache[$derived_key] >= 0 ) {
     1120
     1121                                // If numeric, subtract; otherwise, consider it 0 and do nothing
     1122                                if ( is_numeric( $this->cache[$derived_key] ) )
     1123                                        $this->cache[$derived_key] -= (int) $offset;
     1124                                else
     1125                                        $this->cache[$derived_key] = 0;
     1126
     1127                                // Returned value cannot be less than 0
     1128                                if ( $this->cache[$derived_key] < 0 )
     1129                                        $this->cache[$derived_key] = 0;
     1130
     1131                                return $this->cache[$derived_key];
     1132                        } else {
     1133                                return false;
     1134                        }
     1135                }
     1136
     1137                $result = $this->m->decrement( $derived_key, $offset );
     1138
     1139                if ( Memcached::RES_SUCCESS === $this->getResultCode() )
     1140                        $this->add_to_internal_cache( $derived_key, $result );
     1141
     1142                return $result;
     1143        }
     1144
     1145        /**
     1146         * Decrement a numeric item's value.
     1147         *
     1148         * Alias for $this->decrement. Other caching backends use this abbreviated form of the function. It *may* cause
     1149         * breakage somewhere, so it is nice to have. This function will also allow the core unit tests to pass.
     1150         *
     1151         * @param string    $key    The key under which to store the value.
     1152         * @param int       $offset The amount by which to decrement the item's value.
     1153         * @param string    $group  The group value appended to the $key.
     1154         * @return int|bool         Returns item's new value on success or FALSE on failure.
     1155         */
     1156        public function decr( $key, $offset = 1, $group = 'default' ) {
     1157                return $this->decrement( $key, $offset, $group );
     1158        }
     1159
     1160        /**
     1161         * Remove the item from the cache.
     1162         *
     1163         * Remove an item from memcached with identified by $key after $time seconds. The
     1164         * $time parameter allows an object to be queued for deletion without immediately
     1165         * deleting. Between the time that it is queued and the time it's deleted, add,
     1166         * replace, and get will fail, but set will succeed.
     1167         *
     1168         * @link http://www.php.net/manual/en/memcached.delete.php
     1169         *
     1170         * @param   string      $key        The key under which to store the value.
     1171         * @param   string      $group      The group value appended to the $key.
     1172         * @param   int         $time       The amount of time the server will wait to delete the item in seconds.
     1173         * @param   string      $server_key The key identifying the server to store the value on.
     1174         * @param   bool        $byKey      True to store in internal cache by key; false to not store by key
     1175         * @return  bool                    Returns TRUE on success or FALSE on failure.
     1176         */
     1177        public function delete( $key, $group = 'default', $time = 0, $server_key = '', $byKey = false ) {
     1178                $derived_key = $this->buildKey( $key, $group );
     1179
     1180                // Remove from no_mc_groups array
     1181                if ( in_array( $group, $this->no_mc_groups ) ) {
     1182                        if ( isset( $this->cache[$derived_key] ) )
     1183                                unset( $this->cache[$derived_key] );
     1184
     1185                        return true;
     1186                }
     1187
     1188                if ( $byKey )
     1189                        $result = $this->m->deleteByKey( $server_key, $derived_key, $time );
     1190                else
     1191                        $result = $this->m->delete( $derived_key, $time );
     1192
     1193                if ( Memcached::RES_SUCCESS === $this->getResultCode() )
     1194                        unset( $this->cache[$derived_key] );
     1195
     1196                return $result;
     1197        }
     1198
     1199        /**
     1200         * Remove the item from the cache by server key.
     1201         *
     1202         * Remove an item from memcached with identified by $key after $time seconds. The
     1203         * $time parameter allows an object to be queued for deletion without immediately
     1204         * deleting. Between the time that it is queued and the time it's deleted, add,
     1205         * replace, and get will fail, but set will succeed.
     1206         *
     1207         * @link http://www.php.net/manual/en/memcached.deletebykey.php
     1208         *
     1209         * @param   string      $server_key The key identifying the server to store the value on.
     1210         * @param   string      $key        The key under which to store the value.
     1211         * @param   string      $group      The group value appended to the $key.
     1212         * @param   int         $time       The amount of time the server will wait to delete the item in seconds.
     1213         * @return  bool                    Returns TRUE on success or FALSE on failure.
     1214         */
     1215        public function deleteByKey( $server_key, $key, $group = 'default', $time = 0 ) {
     1216                return $this->delete( $key, $group, $time, $server_key, true );
     1217        }
     1218
     1219        /**
     1220         * Fetch the next result.
     1221         *
     1222         * @link http://www.php.net/manual/en/memcached.fetch.php
     1223         *
     1224         * @return array|bool   Returns the next result or FALSE on failure.
     1225         */
     1226        public function fetch() {
     1227                return $this->m->fetch();
     1228        }
     1229
     1230        /**
     1231         * Fetch all remaining results from the last request.
     1232         *
     1233         * @link http://www.php.net/manual/en/memcached.fetchall.php
     1234         *
     1235         * @return  array|bool          Returns the results or FALSE on failure.
     1236         */
     1237        public function fetchAll() {
     1238                return $this->m->fetchAll();
     1239        }
     1240
     1241        /**
     1242         * Invalidate all items in the cache.
     1243         *
     1244         * @link http://www.php.net/manual/en/memcached.flush.php
     1245         *
     1246         * @param   int     $delay      Number of seconds to wait before invalidating the items.
     1247         * @return  bool                Returns TRUE on success or FALSE on failure.
     1248         */
     1249        public function flush( $delay = 0 ) {
     1250                $result = $this->m->flush( $delay );
     1251
     1252                // Only reset the runtime cache if memcached was properly flushed
     1253                if ( Memcached::RES_SUCCESS === $this->getResultCode() )
     1254                        $this->cache = array();
     1255
     1256                return $result;
     1257        }
     1258
     1259        /**
     1260         * Retrieve object from cache.
     1261         *
     1262         * Gets an object from cache based on $key and $group. In order to fully support the $cache_cb and $cas_token
     1263         * parameters, the runtime cache is ignored by this function if either of those values are set. If either of
     1264         * those values are set, the request is made directly to the memcached server for proper handling of the
     1265         * callback and/or token. Note that the $cas_token variable cannot be directly passed to the function. The
     1266         * variable need to be first defined with a non null value.
     1267         *
     1268         * If using the $cache_cb argument, the new value will always have an expiration of time of 0 (forever). This
     1269         * is a limitation of the Memcached PECL extension.
     1270         *
     1271         * @link http://www.php.net/manual/en/memcached.get.php
     1272         *
     1273         * @param   string          $key        The key under which to store the value.
     1274         * @param   string          $group      The group value appended to the $key.
     1275         * @param   bool            $force      Whether or not to force a cache invalidation.
     1276         * @param   null|bool       $found      Variable passed by reference to determine if the value was found or not.
     1277         * @param   string          $server_key The key identifying the server to store the value on.
     1278         * @param   bool            $byKey      True to store in internal cache by key; false to not store by key
     1279         * @param   null|callable   $cache_cb   Read-through caching callback.
     1280         * @param   null|float      $cas_token  The variable to store the CAS token in.
     1281         * @return  bool|mixed                  Cached object value.
     1282         */
     1283        public function get( $key, $group = 'default', $force = false, &$found = null, $server_key = '', $byKey = false, $cache_cb = NULL, &$cas_token = NULL ) {
     1284                $derived_key = $this->buildKey( $key, $group );
     1285
     1286                // Assume object is not found
     1287                $found = false;
     1288
     1289                // If either $cache_db, or $cas_token is set, must hit Memcached and bypass runtime cache
     1290                if ( func_num_args() > 6 && ! in_array( $group, $this->no_mc_groups ) ) {
     1291                        if ( $byKey )
     1292                                $value = $this->m->getByKey( $server_key, $derived_key, $cache_cb, $cas_token );
     1293                        else
     1294                                $value = $this->m->get( $derived_key, $cache_cb, $cas_token );
     1295                } else {
     1296                        if ( isset( $this->cache[$derived_key] ) ) {
     1297                                $found = true;
     1298                                return is_object( $this->cache[$derived_key] ) ? clone $this->cache[$derived_key] : $this->cache[$derived_key];
     1299                        } elseif ( in_array( $group, $this->no_mc_groups ) ) {
     1300                                return false;
     1301                        } else {
     1302                                if ( $byKey )
     1303                                        $value = $this->m->getByKey( $server_key, $derived_key );
     1304                                else
     1305                                        $value = $this->m->get( $derived_key );
     1306                        }
     1307                }
     1308
     1309                if ( Memcached::RES_SUCCESS === $this->getResultCode() ) {
     1310                        $this->add_to_internal_cache( $derived_key, $value );
     1311                        $found = true;
     1312                }
     1313
     1314                return is_object( $value ) ? clone $value : $value;
     1315        }
     1316
     1317        /**
     1318         * Retrieve object from cache from specified server.
     1319         *
     1320         * Gets an object from cache based on $key, $group and $server_key. In order to fully support the $cache_cb and $cas_token
     1321         * parameters, the runtime cache is ignored by this function if either of those values are set. If either of
     1322         * those values are set, the request is made directly to the memcached server for proper handling of the
     1323         * callback and/or token. Note that the $cas_token variable cannot be directly passed to the function. The
     1324         * variable need to be first defined with a non null value.
     1325         *
     1326         * If using the $cache_cb argument, the new value will always have an expiration of time of 0 (forever). This
     1327         * is a limitation of the Memcached PECL extension.
     1328         *
     1329         * @link http://www.php.net/manual/en/memcached.getbykey.php
     1330         *
     1331         * @param   string          $server_key The key identifying the server to store the value on.
     1332         * @param   string          $key        The key under which to store the value.
     1333         * @param   string          $group      The group value appended to the $key.
     1334         * @param   bool            $force      Whether or not to force a cache invalidation.
     1335         * @param   null|bool       $found      Variable passed by reference to determine if the value was found or not.
     1336         * @param   null|string     $cache_cb   Read-through caching callback.
     1337         * @param   null|float      $cas_token  The variable to store the CAS token in.
     1338         * @return  bool|mixed                  Cached object value.
     1339         */
     1340        public function getByKey( $server_key, $key, $group = 'default', $force = false, &$found = null, $cache_cb = NULL, &$cas_token = NULL ) {
     1341                /**
     1342                 * Need to be careful how "get" is called. If you send $cache_cb, and $cas_token, it will hit memcached.
     1343                 * Only send those args if they were sent to this function.
     1344                 */
     1345                if ( func_num_args() > 5 )
     1346                        return $this->get( $key, $group, $force, $found, $server_key, true, $cache_cb, $cas_token );
     1347                else
     1348                        return $this->get( $key, $group, $force, $found, $server_key, true );
     1349        }
     1350
     1351        /**
     1352         * Request multiple keys without blocking.
     1353         *
     1354         * @link http://www.php.net/manual/en/memcached.getdelayed.php
     1355         *
     1356         * @param   string|array    $keys       Array or string of key(s) to request.
     1357         * @param   string|array    $groups     Array or string of group(s) for the key(s). See buildKeys for more on how these are handled.
     1358         * @param   bool            $with_cas   Whether to request CAS token values also.
     1359         * @param   null            $value_cb   The result callback or NULL.
     1360         * @return  bool                        Returns TRUE on success or FALSE on failure.
     1361         */
     1362        public function getDelayed( $keys, $groups = 'default', $with_cas = false, $value_cb = NULL ) {
     1363                $derived_keys = $this->buildKeys( $keys, $groups );
     1364                return $this->m->getDelayed( $derived_keys, $with_cas, $value_cb );
     1365        }
     1366
     1367        /**
     1368         * Request multiple keys without blocking from a specified server.
     1369         *
     1370         * @link http://www.php.net/manual/en/memcached.getdelayed.php
     1371         *
     1372         * @param   string          $server_key The key identifying the server to store the value on.
     1373         * @param   string|array    $keys       Array or string of key(s) to request.
     1374         * @param   string|array    $groups     Array or string of group(s) for the key(s). See buildKeys for more on how these are handled.
     1375         * @param   bool            $with_cas   Whether to request CAS token values also.
     1376         * @param   null            $value_cb   The result callback or NULL.
     1377         * @return  bool                        Returns TRUE on success or FALSE on failure.
     1378         */
     1379        public function getDelayedByKey( $server_key, $keys, $groups = 'default', $with_cas = false, $value_cb = NULL ) {
     1380                $derived_keys = $this->buildKeys( $keys, $groups );
     1381                return $this->m->getDelayedByKey( $server_key, $derived_keys, $with_cas, $value_cb );
     1382        }
     1383
     1384        /**
     1385         * Gets multiple values from memcached in one request.
     1386         *
     1387         * See the buildKeys method definition to understand the $keys/$groups parameters.
     1388         *
     1389         * @link http://www.php.net/manual/en/memcached.getmulti.php
     1390         *
     1391         * @param   array           $keys       Array of keys to retrieve.
     1392         * @param   string|array    $groups     If string, used for all keys. If arrays, corresponds with the $keys array.
     1393         * @param   string          $server_key The key identifying the server to store the value on.
     1394         * @param   null|array      $cas_tokens The variable to store the CAS tokens for the found items.
     1395         * @param   int             $flags      The flags for the get operation.
     1396         * @return  bool|array                  Returns the array of found items or FALSE on failure.
     1397         */
     1398        public function getMulti( $keys, $groups = 'default', $server_key = '', &$cas_tokens = NULL, $flags = NULL ) {
     1399                $derived_keys = $this->buildKeys( $keys, $groups );
     1400
     1401                /**
     1402                 * If either $cas_tokens, or $flags is set, must hit Memcached and bypass runtime cache. Note that
     1403                 * this will purposely ignore no_mc_groups values as they cannot handle CAS tokens or the special
     1404                 * flags; however, if the groups of groups contains a no_mc_group, this is bypassed.
     1405                 */
     1406                if ( func_num_args() > 3 && ! $this->contains_no_mc_group( $groups ) ) {
     1407                        if ( ! empty( $server_key ) )
     1408                                $values = $this->m->getMultiByKey( $server_key, $derived_keys, $cas_tokens, $flags );
     1409                        else
     1410                                $values = $this->m->getMulti( $derived_keys, $cas_tokens, $flags );
     1411                } else {
     1412                        $values = array();
     1413                        $need_to_get = array();
     1414
     1415                        // Pull out values from runtime cache, or mark for retrieval
     1416                        foreach ( $derived_keys as $key ) {
     1417                                if ( isset( $this->cache[$key] ) )
     1418                                        $values[$key] = $this->cache[$key];
     1419                                else
     1420                                        $need_to_get[$key] = $key;
     1421                        }
     1422
     1423                        // Get those keys not found in the runtime cache
     1424                        if ( ! empty( $need_to_get ) ) {
     1425                                if ( ! empty( $server_key ) )
     1426                                        $result = $this->m->getMultiByKey( $server_key, array_keys( $need_to_get ) );
     1427                                else
     1428                                        $result = $this->m->getMulti( array_keys( $need_to_get ) );
     1429                        }
     1430
     1431                        // Merge with values found in runtime cache
     1432                        if ( isset( $result ) && Memcached::RES_SUCCESS === $this->getResultCode() )
     1433                                $values = array_merge( $values, $result );
     1434
     1435                        // If order should be preserved, reorder now
     1436                        if ( ! empty( $need_to_get ) && $flags === Memcached::GET_PRESERVE_ORDER ) {
     1437                                $ordered_values = array();
     1438
     1439                                foreach ( $derived_keys as $key ) {
     1440                                        if ( isset( $values[$key] ) )
     1441                                                $ordered_values[$key] = $values[$key];
     1442                                }
     1443
     1444                                $values = $ordered_values;
     1445                                unset( $ordered_values );
     1446                        }
     1447                }
     1448
     1449                // Add the values to the runtime cache
     1450                $this->cache = array_merge( $this->cache, $values );
     1451
     1452                return $values;
     1453        }
     1454
     1455        /**
     1456         * Gets multiple values from memcached in one request by specified server key.
     1457         *
     1458         * See the buildKeys method definition to understand the $keys/$groups parameters.
     1459         *
     1460         * @link http://www.php.net/manual/en/memcached.getmultibykey.php
     1461         *
     1462         * @param   string          $server_key The key identifying the server to store the value on.
     1463         * @param   array           $keys       Array of keys to retrieve.
     1464         * @param   string|array    $groups     If string, used for all keys. If arrays, corresponds with the $keys array.
     1465         * @param   null|array      $cas_tokens The variable to store the CAS tokens for the found items.
     1466         * @param   int             $flags      The flags for the get operation.
     1467         * @return  bool|array                  Returns the array of found items or FALSE on failure.
     1468         */
     1469        public function getMultiByKey( $server_key, $keys, $groups = 'default', &$cas_tokens = NULL, $flags = NULL ) {
     1470                /**
     1471                 * Need to be careful how "getMulti" is called. If you send $cache_cb, and $cas_token, it will hit memcached.
     1472                 * Only send those args if they were sent to this function.
     1473                 */
     1474                if ( func_num_args() > 3 )
     1475                        return $this->getMulti( $keys, $groups, $server_key, $cas_tokens, $flags );
     1476                else
     1477                        return $this->getMulti( $keys, $groups, $server_key );
     1478        }
     1479
     1480        /**
     1481         * Retrieve a Memcached option value.
     1482         *
     1483         * @link http://www.php.net/manual/en/memcached.getoption.php
     1484         *
     1485         * @param   int         $option     One of the Memcached::OPT_* constants.
     1486         * @return  mixed                   Returns the value of the requested option, or FALSE on error.
     1487         */
     1488        public function getOption( $option ) {
     1489                return $this->m->getOption( $option );
     1490        }
     1491
     1492        /**
     1493         * Return the result code of the last option.
     1494         *
     1495         * @link http://www.php.net/manual/en/memcached.getresultcode.php
     1496         *
     1497         * @return  int     Result code of the last Memcached operation.
     1498         */
     1499        public function getResultCode() {
     1500            return $this->m->getResultCode();
     1501        }
     1502
     1503        /**
     1504         * Return the message describing the result of the last operation.
     1505         *
     1506         * @link    http://www.php.net/manual/en/memcached.getresultmessage.php
     1507         *
     1508         * @return  string      Message describing the result of the last Memcached operation.
     1509         */
     1510        public function getResultMessage() {
     1511            return $this->m->getResultMessage();
     1512        }
     1513
     1514        /**
     1515         * Get server information by key.
     1516         *
     1517         * @link    http://www.php.net/manual/en/memcached.getserverbykey.php
     1518         *
     1519         * @param   string      $server_key     The key identifying the server to store the value on.
     1520         * @return  array                       Array with host, post, and weight on success, FALSE on failure.
     1521         */
     1522        public function getServerByKey( $server_key ) {
     1523                return $this->m->getServerByKey( $server_key );
     1524        }
     1525
     1526        /**
     1527         * Get the list of servers in the pool.
     1528         *
     1529         * @link    http://www.php.net/manual/en/memcached.getserverlist.php
     1530         *
     1531         * @return  array       The list of all servers in the server pool.
     1532         */
     1533        public function getServerList() {
     1534                return $this->m->getServerList();
     1535        }
     1536
     1537        /**
     1538     * Get server pool statistics.
     1539         *
     1540         * @link    http://www.php.net/manual/en/memcached.getstats.php
     1541         *
     1542         * @return  array       Array of server statistics, one entry per server.
     1543         */
     1544        public function getStats() {
     1545                return $this->m->getStats();
     1546        }
     1547
     1548        /**
     1549         * Get server pool memcached version information.
     1550         *
     1551         * @link    http://www.php.net/manual/en/memcached.getversion.php
     1552         *
     1553         * @return  array       Array of server versions, one entry per server.
     1554         */
     1555        public function getVersion() {
     1556                return $this->m->getVersion();
     1557        }
     1558
     1559        /**
     1560         * Increment a numeric item's value.
     1561         *
     1562         * @link http://www.php.net/manual/en/memcached.increment.php
     1563         *
     1564         * @param   string      $key        The key under which to store the value.
     1565         * @param   int         $offset     The amount by which to increment the item's value.
     1566         * @param   string      $group      The group value appended to the $key.
     1567         * @return  int|bool                Returns item's new value on success or FALSE on failure.
     1568         */
     1569        public function increment( $key, $offset = 1, $group = 'default' ) {
     1570                $derived_key = $this->buildKey( $key, $group );
     1571
     1572                // Increment values in no_mc_groups
     1573                if ( in_array( $group, $this->no_mc_groups ) ) {
     1574
     1575                        // Only increment if the key already exists and the number is currently 0 or greater (mimics memcached behavior)
     1576                        if ( isset( $this->cache[$derived_key] ) &&  $this->cache[$derived_key] >= 0 ) {
     1577
     1578                                // If numeric, add; otherwise, consider it 0 and do nothing
     1579                                if ( is_numeric( $this->cache[$derived_key] ) )
     1580                                        $this->cache[$derived_key] += (int) $offset;
     1581                                else
     1582                                        $this->cache[$derived_key] = 0;
     1583
     1584                                // Returned value cannot be less than 0
     1585                                if ( $this->cache[$derived_key] < 0 )
     1586                                        $this->cache[$derived_key] = 0;
     1587
     1588                                return $this->cache[$derived_key];
     1589                        } else {
     1590                                return false;
     1591                        }
     1592                }
     1593
     1594                $result = $this->m->increment( $derived_key, $offset );
     1595
     1596                if ( Memcached::RES_SUCCESS === $this->getResultCode() )
     1597                        $this->add_to_internal_cache( $derived_key, $result );
     1598
     1599                return $result;
     1600        }
     1601
     1602        /**
     1603         * Synonymous with $this->incr.
     1604         *
     1605         * Certain plugins expect an "incr" method on the $wp_object_cache object (e.g., Batcache). Since the original
     1606         * version of this library matched names to the memcached methods, the "incr" method was missing. Adding this
     1607         * method restores compatibility with plugins expecting an "incr" method.
     1608         *
     1609         * @param   string      $key        The key under which to store the value.
     1610         * @param   int         $offset     The amount by which to increment the item's value.
     1611         * @param   string      $group      The group value appended to the $key.
     1612         * @return  int|bool                Returns item's new value on success or FALSE on failure.
     1613         */
     1614        public function incr( $key, $offset = 1, $group = 'default' ) {
     1615                return $this->increment( $key, $offset, $group );
     1616        }
     1617
     1618        /**
     1619         * Prepend data to an existing item.
     1620         *
     1621         * This method should throw an error if it is used with compressed data. This is an expected behavior.
     1622         * Memcached casts the value to be prepended to the initial value to the type of the initial value. Be
     1623         * careful as this leads to unexpected behavior at times. For instance, prepending (float) 45.23 to
     1624         * (int) 23 will result in 45, because the value is first combined (45.2323) then cast to "integer"
     1625         * (the original value), which will be (int) 45. Due to how memcached treats types, the behavior has been
     1626         * mimicked in the internal cache to produce similar results and improve consistency. It is recommend
     1627         * that prepends only occur with data of the same type.
     1628         *
     1629         * @link    http://www.php.net/manual/en/memcached.prepend.php
     1630         *
     1631         * @param   string    $key          The key under which to store the value.
     1632         * @param   string    $value        Must be string as prepending mixed values is not well-defined.
     1633         * @param   string    $group        The group value prepended to the $key.
     1634         * @param   string    $server_key   The key identifying the server to store the value on.
     1635         * @param   bool      $byKey        True to store in internal cache by key; false to not store by key
     1636         * @return  bool                    Returns TRUE on success or FALSE on failure.
     1637         */
     1638        public function prepend( $key, $value, $group = 'default', $server_key = '', $byKey = false ) {
     1639                if ( ! is_string( $value ) && ! is_int( $value ) && ! is_float( $value ) )
     1640                        return false;
     1641
     1642                $derived_key = $this->buildKey( $key, $group );
     1643
     1644                // If group is a non-Memcached group, prepend to runtime cache value, not Memcached
     1645                if ( in_array( $group, $this->no_mc_groups ) ) {
     1646                        if ( ! isset( $this->cache[$derived_key] ) )
     1647                                return false;
     1648
     1649                        $combined = $this->combine_values( $this->cache[$derived_key], $value, 'pre' );
     1650                        $this->add_to_internal_cache( $derived_key, $combined );
     1651                        return true;
     1652                }
     1653
     1654                // Append to Memcached value
     1655                if ( $byKey )
     1656                        $result = $this->m->prependByKey( $server_key, $derived_key, $value );
     1657                else
     1658                        $result = $this->m->prepend( $derived_key, $value );
     1659
     1660                // Store in runtime cache if add was successful
     1661                if ( Memcached::RES_SUCCESS === $this->getResultCode() ) {
     1662                        $combined = $this->combine_values( $this->cache[$derived_key], $value, 'pre' );
     1663                        $this->add_to_internal_cache( $derived_key, $combined );
     1664                }
     1665
     1666                return $result;
     1667        }
     1668
     1669        /**
     1670         * Append data to an existing item by server key.
     1671         *
     1672         * This method should throw an error if it is used with compressed data. This is an expected behavior.
     1673         * Memcached casts the value to be prepended to the initial value to the type of the initial value. Be
     1674         * careful as this leads to unexpected behavior at times. For instance, prepending (float) 45.23 to
     1675         * (int) 23 will result in 45, because the value is first combined (45.2323) then cast to "integer"
     1676         * (the original value), which will be (int) 45. Due to how memcached treats types, the behavior has been
     1677         * mimicked in the internal cache to produce similar results and improve consistency. It is recommend
     1678         * that prepends only occur with data of the same type.
     1679         *
     1680         * @link    http://www.php.net/manual/en/memcached.prependbykey.php
     1681         *
     1682         * @param   string    $server_key   The key identifying the server to store the value on.
     1683         * @param   string    $key          The key under which to store the value.
     1684         * @param   string    $value        Must be string as prepending mixed values is not well-defined.
     1685         * @param   string    $group        The group value prepended to the $key.
     1686         * @return  bool                    Returns TRUE on success or FALSE on failure.
     1687         */
     1688        public function prependByKey( $server_key, $key, $value, $group = 'default' ) {
     1689                return $this->prepend( $key, $value, $group, $server_key, true );
     1690        }
     1691
     1692        /**
     1693         * Replaces a value in cache.
     1694         *
     1695         * This method is similar to "add"; however, is does not successfully set a value if
     1696         * the object's key is not already set in cache.
     1697         *
     1698         * @link    http://www.php.net/manual/en/memcached.replace.php
     1699         *
     1700         * @param   string      $server_key     The key identifying the server to store the value on.
     1701         * @param   string      $key            The key under which to store the value.
     1702         * @param   mixed       $value          The value to store.
     1703         * @param   string      $group          The group value appended to the $key.
     1704         * @param   bool        $byKey          True to store in internal cache by key; false to not store by key
     1705         * @param   int         $expiration     The expiration time, defaults to 0.
     1706         * @return  bool                        Returns TRUE on success or FALSE on failure.
     1707         */
     1708        public function replace( $key, $value, $group = 'default', $expiration = 0, $server_key = '', $byKey = false ) {
     1709                $derived_key = $this->buildKey( $key, $group );
     1710                $expiration  = $this->sanitize_expiration( $expiration );
     1711
     1712                // If group is a non-Memcached group, save to runtime cache, not Memcached
     1713                if ( in_array( $group, $this->no_mc_groups ) ) {
     1714
     1715                        // Replace won't save unless the key already exists; mimic this behavior here
     1716                        if ( ! isset( $this->cache[$derived_key] ) )
     1717                                return false;
     1718
     1719                        $this->cache[$derived_key] = $value;
     1720                        return true;
     1721                }
     1722
     1723                // Save to Memcached
     1724                if ( $byKey )
     1725                        $result = $this->m->replaceByKey( $server_key, $derived_key, $value, $expiration );
     1726                else
     1727                        $result = $this->m->replace( $derived_key, $value, $expiration );
     1728
     1729                // Store in runtime cache if add was successful
     1730                if ( Memcached::RES_SUCCESS === $this->getResultCode() )
     1731                        $this->add_to_internal_cache( $derived_key, $value );
     1732
     1733                return $result;
     1734        }
     1735
     1736        /**
     1737         * Replaces a value in cache on a specific server.
     1738         *
     1739         * This method is similar to "addByKey"; however, is does not successfully set a value if
     1740         * the object's key is not already set in cache.
     1741         *
     1742         * @link    http://www.php.net/manual/en/memcached.addbykey.php
     1743         *
     1744         * @param   string      $server_key     The key identifying the server to store the value on.
     1745         * @param   string      $key            The key under which to store the value.
     1746         * @param   mixed       $value          The value to store.
     1747         * @param   string      $group          The group value appended to the $key.
     1748         * @param   int         $expiration     The expiration time, defaults to 0.
     1749         * @return  bool                        Returns TRUE on success or FALSE on failure.
     1750         */
     1751        public function replaceByKey( $server_key, $key, $value, $group = 'default', $expiration = 0 ) {
     1752                return $this->replace( $key, $value, $group, $expiration, $server_key, true );
     1753        }
     1754
     1755        /**
     1756         * Sets a value in cache.
     1757         *
     1758         * The value is set whether or not this key already exists in memcached.
     1759         *
     1760         * @link http://www.php.net/manual/en/memcached.set.php
     1761         *
     1762         * @param   string      $key        The key under which to store the value.
     1763         * @param   mixed       $value      The value to store.
     1764         * @param   string      $group      The group value appended to the $key.
     1765         * @param   int         $expiration The expiration time, defaults to 0.
     1766         * @param   string      $server_key The key identifying the server to store the value on.
     1767         * @param   bool        $byKey      True to store in internal cache by key; false to not store by key
     1768         * @return  bool                    Returns TRUE on success or FALSE on failure.
     1769         */
     1770        public function set( $key, $value, $group = 'default', $expiration = 0, $server_key = '', $byKey = false ) {
     1771                $derived_key = $this->buildKey( $key, $group );
     1772                $expiration  = $this->sanitize_expiration( $expiration );
     1773
     1774                // If group is a non-Memcached group, save to runtime cache, not Memcached
     1775                if ( in_array( $group, $this->no_mc_groups ) ) {
     1776                        $this->add_to_internal_cache( $derived_key, $value );
     1777                        return true;
     1778                }
     1779
     1780                // Save to Memcached
     1781                if ( $byKey ) {
     1782                        $result = $this->m->setByKey( $server_key, $derived_key, $value, $expiration );
     1783                } else {
     1784                        $result = $this->m->set( $derived_key, $value, $expiration );
     1785                }
     1786
     1787                // Store in runtime cache if add was successful
     1788                if ( Memcached::RES_SUCCESS === $this->getResultCode() )
     1789                        $this->add_to_internal_cache( $derived_key, $value );
     1790
     1791                return $result;
     1792        }
     1793
     1794        /**
     1795         * Sets a value in cache on a specific server.
     1796         *
     1797         * The value is set whether or not this key already exists in memcached.
     1798         *
     1799         * @link    http://www.php.net/manual/en/memcached.setbykey.php
     1800         *
     1801         * @param   string      $server_key     The key identifying the server to store the value on.
     1802         * @param   string      $key            The key under which to store the value.
     1803         * @param   mixed       $value          The value to store.
     1804         * @param   string      $group          The group value appended to the $key.
     1805         * @param   int         $expiration     The expiration time, defaults to 0.
     1806         * @return  bool                        Returns TRUE on success or FALSE on failure.
     1807         */
     1808        public function setByKey( $server_key, $key, $value, $group = 'default', $expiration = 0 ) {
     1809                return $this->set( $key, $value, $group, $expiration, $server_key, true );
     1810        }
     1811
     1812        /**
     1813         * Set multiple values to cache at once.
     1814         *
     1815         * By sending an array of $items to this function, all values are saved at once to
     1816         * memcached, reducing the need for multiple requests to memcached. The $items array
     1817         * keys and values are what are stored to memcached. The keys in the $items array
     1818         * are merged with the $groups array/string value via buildKeys to determine the
     1819         * final key for the object.
     1820         *
     1821         * @link    http://www.php.net/manual/en/memcached.setmulti.php
     1822         *
     1823         * @param   array           $items          An array of key/value pairs to store on the server.
     1824         * @param   string|array    $groups         Group(s) to merge with key(s) in $items.
     1825         * @param   int             $expiration     The expiration time, defaults to 0.
     1826         * @param   string          $server_key     The key identifying the server to store the value on.
     1827         * @param   bool            $byKey          True to store in internal cache by key; false to not store by key
     1828         * @return  bool                            Returns TRUE on success or FALSE on failure.
     1829         */
     1830        public function setMulti( $items, $groups = 'default', $expiration = 0, $server_key = '', $byKey = false ) {
     1831                // Build final keys and replace $items keys with the new keys
     1832                $derived_keys  = $this->buildKeys( array_keys( $items ), $groups );
     1833                $expiration    = $this->sanitize_expiration( $expiration );
     1834                $derived_items = array_combine( $derived_keys, $items );
     1835
     1836                // Do not add to memcached if in no_mc_groups
     1837                foreach ( $derived_items as $derived_key => $value ) {
     1838
     1839                        // Get the individual item's group
     1840                        $key_pieces = explode( ':', $derived_key );
     1841
     1842                        // If group is a non-Memcached group, save to runtime cache, not Memcached
     1843                        if ( in_array( $key_pieces[1], $this->no_mc_groups ) ) {
     1844                                $this->add_to_internal_cache( $derived_key, $value );
     1845                                unset( $derived_items[$derived_key] );
     1846                        }
     1847                }
     1848
     1849                // Save to memcached
     1850                if ( $byKey )
     1851                        $result = $this->m->setMultiByKey( $server_key, $derived_items, $expiration );
     1852                else
     1853                        $result = $this->m->setMulti( $derived_items, $expiration );
     1854
     1855                // Store in runtime cache if add was successful
     1856                if ( Memcached::RES_SUCCESS === $this->getResultCode() )
     1857                        $this->cache = array_merge( $this->cache, $derived_items );
     1858
     1859                return $result;
     1860        }
     1861
     1862        /**
     1863         * Set multiple values to cache at once on specified server.
     1864         *
     1865         * By sending an array of $items to this function, all values are saved at once to
     1866         * memcached, reducing the need for multiple requests to memcached. The $items array
     1867         * keys and values are what are stored to memcached. The keys in the $items array
     1868         * are merged with the $groups array/string value via buildKeys to determine the
     1869         * final key for the object.
     1870         *
     1871         * @link    http://www.php.net/manual/en/memcached.setmultibykey.php
     1872         *
     1873         * @param   string          $server_key     The key identifying the server to store the value on.
     1874         * @param   array           $items          An array of key/value pairs to store on the server.
     1875         * @param   string|array    $groups         Group(s) to merge with key(s) in $items.
     1876         * @param   int             $expiration     The expiration time, defaults to 0.
     1877         * @return  bool                            Returns TRUE on success or FALSE on failure.
     1878         */
     1879        public function setMultiByKey( $server_key, $items, $groups = 'default', $expiration = 0 ) {
     1880                return $this->setMulti( $items, $groups, $expiration, $server_key, true );
     1881        }
     1882
     1883        /**
     1884         * Set a Memcached option.
     1885         *
     1886         * @link    http://www.php.net/manual/en/memcached.setoption.php
     1887         *
     1888         * @param   int         $option     Option name.
     1889         * @param   mixed       $value      Option value.
     1890         * @return  bool                Returns TRUE on success or FALSE on failure.
     1891         */
     1892        public function setOption( $option, $value ) {
     1893                return $this->m->setOption( $option, $value );
     1894        }
     1895
     1896        /**
     1897         * Builds a key for the cached object using the blog_id, key, and group values.
     1898         *
     1899         * @author  Ryan Boren   This function is inspired by the original WP Memcached Object cache.
     1900         * @link    http://wordpress.org/extend/plugins/memcached/
     1901         *
     1902         * @param   string      $key        The key under which to store the value.
     1903         * @param   string      $group      The group value appended to the $key.
     1904         * @return  string
     1905         */
     1906        public function buildKey( $key, $group = 'default' ) {
     1907                if ( empty( $group ) )
     1908                        $group = 'default';
     1909
     1910                if ( false !== array_search( $group, $this->global_groups ) )
     1911                        $prefix = $this->global_prefix;
     1912                else
     1913                        $prefix = $this->blog_prefix;
     1914
     1915                return preg_replace( '/\s+/', '', WP_CACHE_KEY_SALT . "$prefix$group:$key" );
     1916        }
     1917
     1918        /**
     1919         * Creates an array of keys from passed key(s) and group(s).
     1920         *
     1921         * This function takes a string or array of key(s) and group(s) and combines them into a single dimensional
     1922         * array that merges the keys and groups. If the same number of keys and groups exist, the final keys will
     1923         * append $groups[n] to $keys[n]. If there are more keys than groups and the $groups parameter is an array,
     1924         * $keys[n] will be combined with $groups[n] until $groups runs out of values. 'default' will be used for remaining
     1925         * values. If $keys is an array and $groups is a string, all final values will append $groups to $keys[n].
     1926         * If both values are strings, they will be combined into a single string. Note that if more $groups are received
     1927         * than $keys, the method will return an empty array. This method is primarily a helper method for methods
     1928         * that call memcached with an array of keys.
     1929         *
     1930         * @param   string|array    $keys       Key(s) to merge with group(s).
     1931         * @param   string|array    $groups     Group(s) to merge with key(s).
     1932         * @return  array                       Array that combines keys and groups into a single set of memcached keys.
     1933         */
     1934        public function buildKeys( $keys, $groups = 'default' ) {
     1935                $derived_keys = array();
     1936
     1937                // If strings sent, convert to arrays for proper handling
     1938                if ( ! is_array( $groups ) )
     1939                        $groups = (array) $groups;
     1940
     1941                if ( ! is_array( $keys ) )
     1942                        $keys = (array) $keys;
     1943
     1944                // If we have equal numbers of keys and groups, merge $keys[n] and $group[n]
     1945                if ( count( $keys ) == count( $groups ) ) {
     1946                        for ( $i = 0; $i < count( $keys ); $i++ ) {
     1947                                $derived_keys[] = $this->buildKey( $keys[$i], $groups[$i] );
     1948                        }
     1949
     1950                // If more keys are received than groups, merge $keys[n] and $group[n] until no more group are left; remaining groups are 'default'
     1951                } elseif ( count( $keys ) > count( $groups ) ) {
     1952                        for ( $i = 0; $i < count( $keys ); $i++ ) {
     1953                                if ( isset( $groups[$i] ) )
     1954                                        $derived_keys[] = $this->buildKey( $keys[$i], $groups[$i] );
     1955                                elseif ( count( $groups ) == 1 )
     1956                                        $derived_keys[] = $this->buildKey( $keys[$i], $groups[0] );
     1957                                else
     1958                                        $derived_keys[] = $this->buildKey( $keys[$i], 'default' );
     1959                        }
     1960                }
     1961
     1962                return $derived_keys;
     1963        }
     1964
     1965        /**
     1966         * Ensure that a proper expiration time is set.
     1967         *
     1968         * Memcached treats any value over 30 days as a timestamp. If a developer sets the expiration for greater than 30
     1969         * days or less than the current timestamp, the timestamp is in the past and the value isn't cached. This function
     1970         * detects values in that range and corrects them.
     1971         *
     1972         * @param  string|int    $expiration    The dirty expiration time.
     1973         * @return string|int                   The sanitized expiration time.
     1974         */
     1975        public function sanitize_expiration( $expiration ) {
     1976                if ( $expiration > $this->thirty_days && $expiration <= $this->now ) {
     1977                        $expiration = $expiration + $this->now;
     1978                }
     1979
     1980                return $expiration;
     1981        }
     1982
     1983        /**
     1984         * Concatenates two values and casts to type of the first value.
     1985         *
     1986         * This is used in append and prepend operations to match how these functions are handled
     1987         * by memcached. In both cases, whichever value is the original value in the combined value
     1988         * will dictate the type of the combined value.
     1989         *
     1990         * @param   mixed       $original   Original value that dictates the combined type.
     1991         * @param   mixed       $pended     Value to combine with original value.
     1992         * @param   string      $direction  Either 'pre' or 'app'.
     1993         * @return  mixed                   Combined value casted to the type of the first value.
     1994         */
     1995        public function combine_values( $original, $pended, $direction ) {
     1996                $type = gettype( $original );
     1997
     1998                // Combine the values based on direction of the "pend"
     1999                if ( 'pre' == $direction )
     2000                        $combined = $pended . $original;
     2001                else
     2002                        $combined = $original . $pended;
     2003
     2004                // Cast type of combined value
     2005                settype( $combined, $type );
     2006
     2007                return $combined;
     2008        }
     2009
     2010        /**
     2011         * Simple wrapper for saving object to the internal cache.
     2012         *
     2013         * @param   string      $derived_key    Key to save value under.
     2014         * @param   mixed       $value          Object value.
     2015         */
     2016        public function add_to_internal_cache( $derived_key, $value ) {
     2017                if ( is_object( $value ) ) {
     2018                        $value = clone $value;
     2019                }
     2020
     2021                $this->cache[$derived_key] = $value;
     2022        }
     2023
     2024        /**
     2025         * Determines if a no_mc_group exists in a group of groups.
     2026         *
     2027         * @param   mixed   $groups     The groups to search.
     2028         * @return  bool                True if a no_mc_group is present; false if a no_mc_group is not present.
     2029         */
     2030        public function contains_no_mc_group( $groups ) {
     2031                if ( is_scalar( $groups ) )
     2032                        return in_array( $groups, $this->no_mc_groups );
     2033
     2034                if ( ! is_array( $groups ) )
     2035                        return false;
     2036
     2037                foreach ( $groups as $group ) {
     2038                        if ( in_array( $group, $this->no_mc_groups ) )
     2039                                return true;
     2040                }
     2041
     2042                return false;
     2043        }
     2044
     2045        /**
     2046         * Add global groups.
     2047         *
     2048         * @author  Ryan Boren   This function comes straight from the original WP Memcached Object cache
     2049         * @link    http://wordpress.org/extend/plugins/memcached/
     2050         *
     2051         * @param   array       $groups     Array of groups.
     2052         * @return  void
     2053         */
     2054        public function add_global_groups( $groups ) {
     2055                if ( ! is_array( $groups ) )
     2056                        $groups = (array) $groups;
     2057
     2058                $this->global_groups = array_merge( $this->global_groups, $groups);
     2059                $this->global_groups = array_unique( $this->global_groups );
     2060        }
     2061
     2062        /**
     2063         * Add non-persistent groups.
     2064         *
     2065         * @author  Ryan Boren   This function comes straight from the original WP Memcached Object cache
     2066         * @link    http://wordpress.org/extend/plugins/memcached/
     2067         *
     2068         * @param   array       $groups     Array of groups.
     2069         * @return  void
     2070         */
     2071        public function add_non_persistent_groups( $groups ) {
     2072                if ( ! is_array( $groups ) )
     2073                        $groups = (array) $groups;
     2074
     2075                $this->no_mc_groups = array_merge( $this->no_mc_groups, $groups );
     2076                $this->no_mc_groups = array_unique( $this->no_mc_groups );
     2077        }
     2078
     2079        /**
     2080         * Get a value specifically from the internal, run-time cache, not memcached.
     2081         *
     2082         * @param   int|string  $key        Key value.
     2083         * @param   int|string  $group      Group that the value belongs to.
     2084         * @return  bool|mixed              Value on success; false on failure.
     2085         */
     2086        public function get_from_runtime_cache( $key, $group ) {
     2087                $derived_key = $this->buildKey( $key, $group );
     2088
     2089                if ( isset( $this->cache[$derived_key] ) )
     2090                        return $this->cache[$derived_key];
     2091
     2092                return false;
     2093        }
     2094
     2095        /**
     2096         * Switch blog prefix, which changes the cache that is accessed.
     2097         *
     2098         * @param  int     $blog_id    Blog to switch to.
     2099         * @return void
     2100         */
     2101        public function switch_to_blog( $blog_id ) {
     2102                global $table_prefix;
     2103                $blog_id           = (int) $blog_id;
     2104                $this->blog_prefix = ( is_multisite() ? $blog_id : $table_prefix ) . ':';
     2105        }
     2106}
  • new file tests/phpunit/includes/phpunit6-compat.php

    diff --git a/tests/phpunit/includes/phpunit6-compat.php b/tests/phpunit/includes/phpunit6-compat.php
    new file mode 100644
    index 0000000..a5b0a9f
    - +  
     1<?php
     2
     3if ( class_exists( 'PHPUnit\Runner\Version' ) && version_compare( PHPUnit\Runner\Version::id(), '6.0', '>=' ) ) {
     4
     5        class_alias( 'PHPUnit\Framework\TestCase',                   'PHPUnit_Framework_TestCase' );
     6        class_alias( 'PHPUnit\Framework\Exception',                  'PHPUnit_Framework_Exception' );
     7        class_alias( 'PHPUnit\Framework\ExpectationFailedException', 'PHPUnit_Framework_ExpectationFailedException' );
     8        class_alias( 'PHPUnit\Framework\Error\Notice',               'PHPUnit_Framework_Error_Notice' );
     9        class_alias( 'PHPUnit\Framework\Test',                       'PHPUnit_Framework_Test' );
     10        class_alias( 'PHPUnit\Framework\Warning',                    'PHPUnit_Framework_Warning' );
     11        class_alias( 'PHPUnit\Framework\AssertionFailedError',       'PHPUnit_Framework_AssertionFailedError' );
     12        class_alias( 'PHPUnit\Framework\TestSuite',                  'PHPUnit_Framework_TestSuite' );
     13        class_alias( 'PHPUnit\Framework\TestListener',               'PHPUnit_Framework_TestListener' );
     14        class_alias( 'PHPUnit\Util\GlobalState',                     'PHPUnit_Util_GlobalState' );
     15        class_alias( 'PHPUnit\Util\Getopt',                          'PHPUnit_Util_Getopt' );
     16
     17        class PHPUnit_Util_Test extends PHPUnit\Util\Test {
     18
     19                public static function getTickets( $className, $methodName ) {
     20                        $annotations = self::parseTestMethodAnnotations( $className, $methodName );
     21
     22                        $tickets = array();
     23
     24                        if ( isset( $annotations['class']['ticket'] ) ) {
     25                                $tickets = $annotations['class']['ticket'];
     26                        }
     27
     28                        if ( isset( $annotations['method']['ticket'] ) ) {
     29                                $tickets = array_merge( $tickets, $annotations['method']['ticket'] );
     30                        }
     31
     32                        return array_unique( $tickets );
     33                }
     34
     35        }
     36
     37}
  • tests/phpunit/includes/testcase-ajax.php

    diff --git a/tests/phpunit/includes/testcase-ajax.php b/tests/phpunit/includes/testcase-ajax.php
    index 787e6bf..19a87b2 100644
    a b protected function _handleAjax( $action ) { 
    200200                if ( !empty( $buffer ) )
    201201                        $this->_last_response = $buffer;
    202202        }
     203
     204        /**
     205         * PHPUnit 6+ compatibility shim.
     206         *
     207         * @param mixed      $exception
     208         * @param string     $message
     209         * @param int|string $code
     210         */
     211        public function setExpectedException( $exception, $message = '', $code = null ) {
     212                if ( is_callable( 'parent::setExpectedException' ) ) {
     213                        parent::setExpectedException( $exception, $message, $code );
     214                } else {
     215                        $this->expectException( $exception );
     216                        if ( '' !== $message ) {
     217                                $this->expectExceptionMessage( $message );
     218                        }
     219                        if ( null !== $code ) {
     220                                $this->expectExceptionCode( $code );
     221                        }
     222                }
     223        }
    203224}
  • tests/phpunit/includes/testcase-canonical.php

    diff --git a/tests/phpunit/includes/testcase-canonical.php b/tests/phpunit/includes/testcase-canonical.php
    index e0b93c8..a48d716 100644
    a b public static function delete_shared_fixtures() { 
    157157        public function assertCanonical( $test_url, $expected, $ticket = 0, $expected_doing_it_wrong = array() ) {
    158158                $this->expected_doing_it_wrong = array_merge( $this->expected_doing_it_wrong, (array) $expected_doing_it_wrong );
    159159
    160                 if ( $ticket )
    161                         $this->knownWPBug( $ticket );
    162 
    163160                $ticket_ref = ($ticket > 0) ? 'Ticket #' . $ticket : null;
    164161
    165162                if ( is_string($expected) )
    public function assertCanonical( $test_url, $expected, $ticket = 0, $expected_do 
    168165                        $expected = array( 'qv' => $expected );
    169166
    170167                if ( !isset($expected['url']) && !isset($expected['qv']) )
    171                         $this->markTestSkipped('No valid expected output was provided');
     168                        $this->fail( 'No valid expected output was provided' );
    172169
    173170                $this->go_to( home_url( $test_url ) );
    174171
    public function assertCanonical( $test_url, $expected, $ticket = 0, $expected_do 
    181178                        $this->assertEquals( $expected['url'], $parsed_can_url['path'] . (!empty($parsed_can_url['query']) ? '?' . $parsed_can_url['query'] : ''), $ticket_ref );
    182179                }
    183180
     181                // If the test data doesn't include expected query vars, then we're done here
    184182                if ( ! isset($expected['qv']) )
    185183                        return;
    186184
  • tests/phpunit/includes/testcase.php

    diff --git a/tests/phpunit/includes/testcase.php b/tests/phpunit/includes/testcase.php
    index c77511d..ba1c47f 100644
    a b public function skipOnAutomatedBranches() { 
    198198        }
    199199
    200200        /**
     201         * Allow tests to be skipped when Multisite is not in use.
     202         *
     203         * Use in conjunction with the ms-required group.
     204         */
     205        public function skipWithoutMultisite() {
     206                if ( ! is_multisite() ) {
     207                        $this->markTestSkipped( 'Test only runs on Multisite' );
     208                }
     209        }
     210
     211        /**
     212         * Allow tests to be skipped when Multisite is in use.
     213         *
     214         * Use in conjunction with the ms-excluded group.
     215         */
     216        public function skipWithMultisite() {
     217                if ( is_multisite() ) {
     218                        $this->markTestSkipped( 'Test does not run on Multisite' );
     219                }
     220        }
     221
     222        /**
    201223         * Unregister existing post types and register defaults.
    202224         *
    203225         * Run before each test in order to clean up the global scope, in case
    function expectedDeprecated() { 
    388410                        $errors[] = "Unexpected incorrect usage notice for $unexpected";
    389411                }
    390412
    391                 if ( ! empty( $errors ) ) {
    392                         $this->fail( implode( "\n", $errors ) );
     413                // Perform an assertion, but only if there are expected or unexpected deprecated calls or wrongdoings
     414                if ( ! empty( $this->expected_deprecated ) ||
     415                        ! empty( $this->expected_doing_it_wrong ) ||
     416                        ! empty( $this->caught_deprecated ) ||
     417                        ! empty( $this->caught_doing_it_wrong ) ) {
     418                        $this->assertEmpty( $errors, implode( "\n", $errors ) );
    393419                }
    394420        }
    395421
    function assertNotWPError( $actual, $message = '' ) { 
    438464                $this->assertNotInstanceOf( 'WP_Error', $actual, $message );
    439465        }
    440466
     467        function assertIXRError( $actual, $message = '' ) {
     468                $this->assertInstanceOf( 'IXR_Error', $actual, $message );
     469        }
     470
     471        function assertNotIXRError( $actual, $message = '' ) {
     472                if ( $actual instanceof IXR_Error && '' === $message ) {
     473                        $message = $actual->message;
     474                }
     475                $this->assertNotInstanceOf( 'IXR_Error', $actual, $message );
     476        }
     477
    441478        function assertEqualFields( $object, $fields ) {
    442479                foreach( $fields as $field_name => $field_value ) {
    443480                        if ( $object->$field_name != $field_value ) {
    function go_to( $url ) { 
    540577        protected function checkRequirements() {
    541578                parent::checkRequirements();
    542579
     580                $annotations = $this->getAnnotations();
     581
     582                if ( ! empty( $annotations['group'] ) ) {
     583                        if ( in_array( 'ms-required', $annotations['group'], true ) ) {
     584                                $this->skipWithoutMultisite();
     585                        }
     586                        if ( in_array( 'ms-excluded', $annotations['group'], true ) ) {
     587                                $this->skipWithMultisite();
     588                        }
     589                }
     590
    543591                // Core tests no longer check against open Trac tickets, but others using WP_UnitTestCase may do so.
    544592                if ( defined( 'WP_RUN_CORE_TESTS' ) && WP_RUN_CORE_TESTS ) {
    545593                        return;
    protected function checkRequirements() { 
    551599                foreach ( $tickets as $ticket ) {
    552600                        if ( is_numeric( $ticket ) ) {
    553601                                $this->knownWPBug( $ticket );
    554                         } elseif ( 'UT' == substr( $ticket, 0, 2 ) ) {
    555                                 $ticket = substr( $ticket, 2 );
    556                                 if ( $ticket && is_numeric( $ticket ) )
    557                                         $this->knownUTBug( $ticket );
    558602                        } elseif ( 'Plugin' == substr( $ticket, 0, 6 ) ) {
    559603                                $ticket = substr( $ticket, 6 );
    560604                                if ( $ticket && is_numeric( $ticket ) )
    function knownWPBug( $ticket_id ) { 
    574618        }
    575619
    576620        /**
    577          * Skips the current test if there is an open unit tests ticket with id $ticket_id
     621         * @deprecated No longer used since the unit test Trac was merged into Core's.
    578622         */
    579623        function knownUTBug( $ticket_id ) {
    580                 if ( WP_TESTS_FORCE_KNOWN_BUGS || in_array( 'UT' . $ticket_id, self::$forced_tickets ) )
    581                         return;
    582                 if ( ! TracTickets::isTracTicketClosed( 'https://unit-tests.trac.wordpress.org', $ticket_id ) )
    583                         $this->markTestSkipped( sprintf( 'Unit Tests Ticket #%d is not fixed', $ticket_id ) );
     624                return;
    584625        }
    585626
    586627        /**
    function temp_filename() { 
    627668        /**
    628669         * Check each of the WP_Query is_* functions/properties against expected boolean value.
    629670         *
    630          * Any properties that are listed by name as parameters will be expected to be true; any others are
     671         * Any properties that are listed by name as parameters will be expected to be true; all others are
    631672         * expected to be false. For example, assertQueryTrue('is_single', 'is_feed') means is_single()
    632673         * and is_feed() must be true and everything else must be false to pass.
    633674         *
    function assertQueryTrue(/* ... */) { 
    668709                $true = func_get_args();
    669710
    670711                foreach ( $true as $true_thing ) {
    671                         $this->assertContains( $true_thing, $all, "{$true_thing}() is not handled by assertQueryTrue()." );
     712                        $this->assertContains( $true_thing, $all, "Unknown conditional: {$true_thing}." );
    672713                }
    673714
    674715                $passed = true;
    675                 $not_false = $not_true = array(); // properties that were not set to expected values
     716                $message = '';
    676717
    677718                foreach ( $all as $query_thing ) {
    678719                        $result = is_callable( $query_thing ) ? call_user_func( $query_thing ) : $wp_query->$query_thing;
    679720
    680721                        if ( in_array( $query_thing, $true ) ) {
    681722                                if ( ! $result ) {
    682                                         array_push( $not_true, $query_thing );
     723                                        $message .= $query_thing . ' is false but is expected to be true. ' . PHP_EOL;
    683724                                        $passed = false;
    684725                                }
    685726                        } else if ( $result ) {
    686                                 array_push( $not_false, $query_thing );
     727                                $message .= $query_thing . ' is true but is expected to be false. ' . PHP_EOL;
    687728                                $passed = false;
    688729                        }
    689730                }
    690731
    691                 $message = '';
    692                 if ( count($not_true) )
    693                         $message .= implode( $not_true, ', ' ) . ' is expected to be true. ';
    694                 if ( count($not_false) )
    695                         $message .= implode( $not_false, ', ' ) . ' is expected to be false.';
    696                 $this->assertTrue( $passed, $message );
     732                if ( ! $passed ) {
     733                        $this->fail( $message );
     734                }
    697735        }
    698736
    699737        function unlink( $file ) {
  • tests/phpunit/includes/utils.php

    diff --git a/tests/phpunit/includes/utils.php b/tests/phpunit/includes/utils.php
    index 66c8756..96d9bad 100644
    a b function __construct( $in ) { 
    157157        }
    158158
    159159        function parse($in) {
    160                 $parse = xml_parse($this->xml, $in, sizeof($in));
     160                $parse = xml_parse($this->xml, $in, true);
    161161                if (!$parse) {
    162162                        trigger_error(sprintf("XML error: %s at line %d",
    163163                        xml_error_string(xml_get_error_code($this->xml)),
  • tests/phpunit/multisite.xml

    diff --git a/tests/phpunit/multisite.xml b/tests/phpunit/multisite.xml
    index f30452f..1aac733 100644
    a b  
    22                bootstrap="includes/bootstrap.php"
    33        backupGlobals="false"
    44        colors="true"
     5        beStrictAboutTestsThatDoNotTestAnything="true"
    56        >
    67    <php>
    78        <const name="WP_TESTS_MULTISITE" value="1" />
     
    2425        <exclude>
    2526            <group>ajax</group>
    2627            <group>ms-files</group>
     28            <group>ms-excluded</group>
    2729            <group>external-http</group>
    2830            <group>oembed-headers</group>
    2931        </exclude>
  • tests/phpunit/tests/adminbar.php

    diff --git a/tests/phpunit/tests/adminbar.php b/tests/phpunit/tests/adminbar.php
    index c9f0873..b6ec315 100644
    a b function test_merging_existing_meta_values() { 
    7272
    7373        /**
    7474         * @ticket 25162
     75         * @group ms-excluded
    7576         */
    7677        public function test_admin_bar_contains_correct_links_for_users_with_no_role() {
    77                 if ( is_multisite() ) {
    78                         $this->markTestSkipped( 'Test does not run in multisite' );
    79                 }
    80 
    8178                $this->assertFalse( user_can( self::$no_role_id, 'read' ) );
    8279
    8380                wp_set_current_user( self::$no_role_id );
    public function test_admin_bar_contains_correct_links_for_users_with_no_role() { 
    10097
    10198        /**
    10299         * @ticket 25162
     100         * @group ms-excluded
    103101         */
    104102        public function test_admin_bar_contains_correct_links_for_users_with_role() {
    105                 if ( is_multisite() ) {
    106                         $this->markTestSkipped( 'Test does not run in multisite' );
    107                 }
    108 
    109103                $this->assertTrue( user_can( self::$editor_id, 'read' ) );
    110104
    111105                wp_set_current_user( self::$editor_id );
    public function test_admin_bar_contains_correct_links_for_users_with_role() { 
    131125        /**
    132126         * @ticket 25162
    133127         * @group multisite
     128         * @group ms-required
    134129         */
    135130        public function test_admin_bar_contains_correct_links_for_users_with_no_role_on_blog() {
    136                 if ( ! is_multisite() ) {
    137                         $this->markTestSkipped( 'Test only runs in multisite' );
    138                 }
    139 
    140131                $blog_id = self::factory()->blog->create( array(
    141132                        'user_id' => self::$admin_id,
    142133                ) );
    public function test_admin_bar_contains_correct_links_for_users_with_no_role_on_ 
    181172        /**
    182173         * @ticket 25162
    183174         * @group multisite
     175         * @group ms-required
    184176         */
    185177        public function test_admin_bar_contains_correct_links_for_users_with_no_role_on_network() {
    186                 if ( ! is_multisite() ) {
    187                         $this->markTestSkipped( 'Test only runs in multisite' );
    188                 }
    189 
    190178                $this->assertTrue( user_can( self::$admin_id, 'read' ) );
    191179                $this->assertFalse( user_can( self::$no_role_id, 'read' ) );
    192180
    public function test_admin_bar_has_no_archives_link_for_pages() { 
    425413
    426414        /**
    427415         * @ticket 37949
     416         * @group ms-excluded
    428417         */
    429418        public function test_admin_bar_contains_correct_about_link_for_users_with_role() {
    430                 if ( is_multisite() ) {
    431                         $this->markTestSkipped( 'Test does not run in multisite' );
    432                 }
    433 
    434419                wp_set_current_user( self::$editor_id );
    435420
    436421                $wp_admin_bar = $this->get_standard_admin_bar();
    public function test_admin_bar_contains_correct_about_link_for_users_with_role() 
    445430
    446431        /**
    447432         * @ticket 37949
     433         * @group ms-excluded
    448434         */
    449435        public function test_admin_bar_contains_correct_about_link_for_users_with_no_role() {
    450                 if ( is_multisite() ) {
    451                         $this->markTestSkipped( 'Test does not run in multisite' );
    452                 }
    453 
    454436                wp_set_current_user( self::$no_role_id );
    455437
    456438                $wp_admin_bar = $this->get_standard_admin_bar();
    public function test_admin_bar_contains_correct_about_link_for_users_with_no_rol 
    467449        /**
    468450         * @ticket 37949
    469451         * @group multisite
     452         * @group ms-required
    470453         */
    471454        public function test_admin_bar_contains_correct_about_link_for_users_with_no_role_in_multisite() {
    472                 if ( ! is_multisite() ) {
    473                         $this->markTestSkipped( 'Test only runs in multisite' );
    474                 }
    475 
    476455                // User is not a member of a site.
    477456                remove_user_from_blog( self::$no_role_id, get_current_blog_id() );
    478457
    public function test_customize_link() { 
    586565
    587566        /**
    588567         * @ticket 39082
     568         * @group ms-required
    589569         */
    590570        public function test_my_sites_network_menu_for_regular_user() {
    591                 if ( ! is_multisite() ) {
    592                         $this->markTestSkipped( 'Test only runs in multisite' );
    593                 }
    594 
    595571                wp_set_current_user( self::$editor_id );
    596572
    597573                $wp_admin_bar = $this->get_standard_admin_bar();
    public function test_my_sites_network_menu_for_regular_user() { 
    604580
    605581        /**
    606582         * @ticket 39082
     583         * @group ms-required
    607584         */
    608585        public function test_my_sites_network_menu_for_super_admin() {
    609                 if ( ! is_multisite() ) {
    610                         $this->markTestSkipped( 'Test only runs in multisite' );
    611                 }
    612 
    613586                wp_set_current_user( self::$editor_id );
    614587
    615588                grant_super_admin( self::$editor_id );
    public function test_my_sites_network_menu_for_super_admin() { 
    624597
    625598        /**
    626599         * @ticket 39082
     600         * @group ms-required
    627601         */
    628602        public function test_my_sites_network_menu_for_regular_user_with_network_caps() {
    629603                global $current_user;
    630604
    631                 if ( ! is_multisite() ) {
    632                         $this->markTestSkipped( 'Test only runs in multisite' );
    633                 }
    634 
    635605                $network_user_caps = array( 'manage_network', 'manage_network_themes', 'manage_network_plugins' );
    636606
    637607                wp_set_current_user( self::$editor_id );
  • tests/phpunit/tests/ajax/Compression.php

    diff --git a/tests/phpunit/tests/ajax/Compression.php b/tests/phpunit/tests/ajax/Compression.php
    index d82e0c5..1e65d71 100644
    a b public function test_text() { 
    5757        public function test_gzdeflate() {
    5858
    5959                if ( !function_exists( 'gzdeflate' ) ) {
    60                         $this->markTestSkipped( 'gzdeflate function not available' );
     60                        $this->fail( 'gzdeflate function not available' );
    6161                }
    6262
    6363                // Become an administrator
    public function test_gzdeflate() { 
    8484        public function test_gzencode() {
    8585
    8686                if ( !function_exists('gzencode') ) {
    87                         $this->markTestSkipped( 'gzencode function not available' );
     87                        $this->fail( 'gzencode function not available' );
    8888                }
    8989
    9090                // Become an administrator
  • tests/phpunit/tests/comment/checkComment.php

    diff --git a/tests/phpunit/tests/comment/checkComment.php b/tests/phpunit/tests/comment/checkComment.php
    index 0bedc4a..b33ccd7 100644
    a b public function test_should_return_false_when_content_matches_moderation_key() { 
    8383        }
    8484
    8585        public function test_should_return_true_when_content_does_not_match_moderation_keys() {
     86                update_option( 'comment_whitelist', 0 );
     87
    8688                $author       = 'WendytheBuilder';
    8789                $author_email = 'wendy@example.com';
    8890                $author_url   = 'http://example.com';
    public function test_should_return_true_when_content_does_not_match_moderation_k 
    9395
    9496                update_option( 'moderation_keys',"foo\nbar" );
    9597                $results = check_comment( $author, $author_email, $author_url, $comment, $author_ip, $user_agent, $comment_type );
    96                 $this->assertFalse( $results );
     98                $this->assertTrue( $results );
    9799        }
    98100
    99101        public function test_should_return_false_when_link_count_exceeds_comment_max_length_setting() {
  • tests/phpunit/tests/customize/manager.php

    diff --git a/tests/phpunit/tests/customize/manager.php b/tests/phpunit/tests/customize/manager.php
    index 16d1e4a..c141e38 100644
    a b function filter_customize_dynamic_setting_class_for_test_dynamic_settings( $sett 
    20272027        }
    20282028
    20292029        /**
    2030          * Test is_ios() method.
    2031          *
    2032          * @see WP_Customize_Manager::is_ios()
    2033          */
    2034         function test_is_ios() {
    2035                 $this->markTestSkipped( 'WP_Customize_Manager::is_ios() cannot be tested because it uses wp_is_mobile() which contains a static var.' );
    2036         }
    2037 
    2038         /**
    20392030         * Test get_document_title_template() method.
    20402031         *
    20412032         * @see WP_Customize_Manager::get_document_title_template()
  • tests/phpunit/tests/customize/setting.php

    diff --git a/tests/phpunit/tests/customize/setting.php b/tests/phpunit/tests/customize/setting.php
    index 3ee1a8c..2450ec2 100644
    a b function test_is_current_blog_previewed() { 
    561561         *
    562562         * @ticket 31428
    563563         * @group multisite
     564         * @group ms-required
    564565         */
    565566        function test_previewing_with_switch_to_blog() {
    566                 if ( ! is_multisite() ) {
    567                         $this->markTestSkipped( 'Cannot test WP_Customize_Setting::is_current_blog_previewed() with switch_to_blog() if not on multisite.' );
    568                 }
    569 
    570567                wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
    571568                $type = 'option';
    572569                $name = 'blogdescription';
  • tests/phpunit/tests/db.php

    diff --git a/tests/phpunit/tests/db.php b/tests/phpunit/tests/db.php
    index 9595d3d..ab4186c 100644
    a b function test_mysqli_flush_sync() { 
    507507
    508508                if ( count( $wpdb->get_results( 'SHOW CREATE PROCEDURE `test_mysqli_flush_sync_procedure`' ) ) < 1 ) {
    509509                        $wpdb->suppress_errors( $suppress );
    510                         $this->markTestSkipped( 'procedure could not be created (missing privileges?)' );
     510                        $this->fail( 'procedure could not be created (missing privileges?)' );
    511511                }
    512512
    513513                $post_id = self::factory()->post->create();
  • tests/phpunit/tests/external-http/basic.php

    diff --git a/tests/phpunit/tests/external-http/basic.php b/tests/phpunit/tests/external-http/basic.php
    index e84ab6a..8799746 100644
    a b function test_readme() { 
    1414
    1515                $response = wp_remote_get( 'https://secure.php.net/supported-versions.php' );
    1616                if ( 200 != wp_remote_retrieve_response_code( $response ) ) {
    17                         $this->markTestSkipped( 'Could not contact PHP.net to check versions.' );
     17                        $this->fail( 'Could not contact PHP.net to check versions.' );
    1818                }
    1919                $php = wp_remote_retrieve_body( $response );
    2020
    function test_readme() { 
    2626
    2727                $response = wp_remote_get( "https://dev.mysql.com/doc/relnotes/mysql/{$matches[1]}/en/" );
    2828                if ( 200 != wp_remote_retrieve_response_code( $response ) ) {
    29                         $this->markTestSkipped( 'Could not contact dev.MySQL.com to check versions.' );
     29                        $this->fail( 'Could not contact dev.MySQL.com to check versions.' );
    3030                }
    3131                $mysql = wp_remote_retrieve_body( $response );
    3232
  • tests/phpunit/tests/feed/rss2.php

    diff --git a/tests/phpunit/tests/feed/rss2.php b/tests/phpunit/tests/feed/rss2.php
    index d48bc88..f0d7919 100644
    a b function test_channel_pubdate_element_translated() { 
    162162                $this->assertNotContains( 'Tue_Translated', $pubdate[0]['content'] );
    163163        }
    164164
    165         /**
    166          * @ticket UT32
    167          */
    168165        function test_item_elements() {
    169166                $this->go_to( '/?feed=rss2' );
    170167                $feed = $this->do_rss2();
  • tests/phpunit/tests/functions.php

    diff --git a/tests/phpunit/tests/functions.php b/tests/phpunit/tests/functions.php
    index 47704f8..252d890 100644
    a b function test_bool_from_yn() { 
    6161        }
    6262
    6363        function test_path_is_absolute() {
    64                 if ( !is_callable('path_is_absolute') )
    65                         $this->markTestSkipped();
    66 
    6764                $absolute_paths = array(
    6865                        '/',
    6966                        '/foo/',
    function test_path_is_absolute() { 
    8178        }
    8279
    8380        function test_path_is_not_absolute() {
    84                 if ( !is_callable('path_is_absolute') )
    85                         $this->markTestSkipped();
    86 
    8781                $relative_paths = array(
    8882                        '',
    8983                        '.',
    function test_wp_check_filetype_and_ext( $file, $filename, $expected ) { 
    941935
    942936        /**
    943937         * @ticket 39550
     938         * @group ms-excluded
    944939         */
    945940        function test_wp_check_filetype_and_ext_with_filtered_svg() {
    946941                if ( ! extension_loaded( 'fileinfo' ) ) {
    947942                        $this->markTestSkipped( 'The fileinfo PHP extension is not loaded.' );
    948943                }
    949944
    950                 if ( is_multisite() ) {
    951                         $this->markTestSkipped( 'Test does not run in multisite' );
    952                 }
    953 
    954945                $file = DIR_TESTDATA . '/uploads/video-play.svg';
    955946                $filename = 'video-play.svg';
    956947
    function test_wp_check_filetype_and_ext_with_filtered_svg() { 
    969960
    970961        /**
    971962         * @ticket 39550
     963         * @group ms-excluded
    972964         */
    973965        function test_wp_check_filetype_and_ext_with_filtered_woff() {
    974966                if ( ! extension_loaded( 'fileinfo' ) ) {
    975967                        $this->markTestSkipped( 'The fileinfo PHP extension is not loaded.' );
    976968                }
    977969
    978                 if ( is_multisite() ) {
    979                         $this->markTestSkipped( 'Test does not run in multisite' );
    980                 }
    981 
    982970                $file = DIR_TESTDATA . '/uploads/dashicons.woff';
    983971                $filename = 'dashicons.woff';
    984972
  • tests/phpunit/tests/functions/deprecated.php

    diff --git a/tests/phpunit/tests/functions/deprecated.php b/tests/phpunit/tests/functions/deprecated.php
    index 542ea39..9735fd8 100644
    a b protected function was_deprecated( $type, $name ) { 
    140140         */
    141141        public function test_wp_save_image_file_deprecated_with_gd_resource() {
    142142                if ( !function_exists( 'imagejpeg' ) )
    143                         $this->markTestSkipped( 'jpeg support unavailable' );
     143                        $this->fail( 'jpeg support unavailable' );
    144144
    145145                // Call wp_save_image_file
    146146                include_once( ABSPATH . 'wp-admin/includes/image-edit.php' );
    public function test_wp_save_image_file_deprecated_with_gd_resource() { 
    161161         */
    162162        public function test_wp_save_image_file_not_deprecated_with_wp_image_editor() {
    163163                if ( !function_exists( 'imagejpeg' ) )
    164                         $this->markTestSkipped( 'jpeg support unavailable' );
     164                        $this->fail( 'jpeg support unavailable' );
    165165
    166166                // Call wp_save_image_file
    167167                include_once( ABSPATH . 'wp-admin/includes/image-edit.php' );
  • tests/phpunit/tests/general/template.php

    diff --git a/tests/phpunit/tests/general/template.php b/tests/phpunit/tests/general/template.php
    index 16007cf..4d47a4d 100644
    a b function test_has_site_icon() { 
    7272        /**
    7373         * @group site_icon
    7474         * @group multisite
     75         * @group ms-required
    7576         */
    7677        function test_has_site_icon_returns_true_when_called_for_other_site_with_site_icon_set() {
    77                 if ( ! is_multisite() ) {
    78                         $this->markTestSkipped( 'This test requires multisite.' );
    79                 }
    80 
    8178                $blog_id = $this->factory->blog->create();
    8279                switch_to_blog( $blog_id );
    8380                $this->_set_site_icon();
    function test_has_site_icon_returns_true_when_called_for_other_site_with_site_ic 
    8986        /**
    9087         * @group site_icon
    9188         * @group multisite
     89         * @group ms-required
    9290         */
    9391        function test_has_site_icon_returns_false_when_called_for_other_site_without_site_icon_set() {
    94                 if ( ! is_multisite() ) {
    95                         $this->markTestSkipped( 'This test requires multisite.' );
    96                 }
    97 
    9892                $blog_id = $this->factory->blog->create();
    9993
    10094                $this->assertFalse( has_site_icon( $blog_id ) );
    function test_has_custom_logo() { 
    264258        /**
    265259         * @group custom_logo
    266260         * @group multisite
     261         * @group ms-required
    267262         */
    268263        function test_has_custom_logo_returns_true_when_called_for_other_site_with_custom_logo_set() {
    269                 if ( ! is_multisite() ) {
    270                         $this->markTestSkipped( 'This test requires multisite.' );
    271                 }
    272 
    273264                $blog_id = $this->factory->blog->create();
    274265                switch_to_blog( $blog_id );
    275266                $this->_set_custom_logo();
    function test_has_custom_logo_returns_true_when_called_for_other_site_with_custo 
    281272        /**
    282273         * @group custom_logo
    283274         * @group multisite
     275         * @group ms-required
    284276         */
    285277        function test_has_custom_logo_returns_false_when_called_for_other_site_without_custom_logo_set() {
    286                 if ( ! is_multisite() ) {
    287                         $this->markTestSkipped( 'This test requires multisite.' );
    288                 }
    289 
    290278                $blog_id = $this->factory->blog->create();
    291279
    292280                $this->assertFalse( has_custom_logo( $blog_id ) );
    function test_get_custom_logo() { 
    312300        /**
    313301         * @group custom_logo
    314302         * @group multisite
     303         * @group ms-required
    315304         */
    316305        function test_get_custom_logo_returns_logo_when_called_for_other_site_with_custom_logo_set() {
    317                 if ( ! is_multisite() ) {
    318                         $this->markTestSkipped( 'This test requires multisite.' );
    319                 }
    320 
    321306                $blog_id = $this->factory->blog->create();
    322307                switch_to_blog( $blog_id );
    323308
    function test_get_the_modified_time_with_post_id() { 
    534519
    535520        /**
    536521         * @ticket 38253
     522         * @group ms-required
    537523         */
    538524        function test_get_site_icon_url_preserves_switched_state() {
    539                 if ( ! is_multisite() ) {
    540                         $this->markTestSkipped( 'This test requires multisite.' );
    541                 }
    542 
    543525                $blog_id = $this->factory->blog->create();
    544526                switch_to_blog( $blog_id );
    545527
    function test_get_site_icon_url_preserves_switched_state() { 
    556538
    557539        /**
    558540         * @ticket 38253
     541         * @group ms-required
    559542         */
    560543        function test_has_custom_logo_preserves_switched_state() {
    561                 if ( ! is_multisite() ) {
    562                         $this->markTestSkipped( 'This test requires multisite.' );
    563                 }
    564 
    565544                $blog_id = $this->factory->blog->create();
    566545                switch_to_blog( $blog_id );
    567546
    function test_has_custom_logo_preserves_switched_state() { 
    578557
    579558        /**
    580559         * @ticket 38253
     560         * @group ms-required
    581561         */
    582562        function test_get_custom_logo_preserves_switched_state() {
    583                 if ( ! is_multisite() ) {
    584                         $this->markTestSkipped( 'This test requires multisite.' );
    585                 }
    586 
    587563                $blog_id = $this->factory->blog->create();
    588564                switch_to_blog( $blog_id );
    589565
  • tests/phpunit/tests/http/base.php

    diff --git a/tests/phpunit/tests/http/base.php b/tests/phpunit/tests/http/base.php
    index a546fb7..a879278 100644
    a b function test_cookie_handling() { 
    384384         */
    385385        function test_ssl() {
    386386                if ( ! wp_http_supports( array( 'ssl' ) ) )
    387                         $this->markTestSkipped( 'This install of PHP does not support SSL' );
     387                        $this->fail( 'This install of PHP does not support SSL' );
    388388
    389389                $res = wp_remote_get( 'https://wordpress.org/' );
    390390                $this->assertNotWPError( $res );
  • tests/phpunit/tests/image/editor_gd.php

    diff --git a/tests/phpunit/tests/image/editor_gd.php b/tests/phpunit/tests/image/editor_gd.php
    index ecb599e..cdfc207 100644
    a b public function test_flip() { 
    468468         */
    469469        public function test_image_preserves_alpha_on_resize() {
    470470                if ( ! ( imagetypes() & IMG_PNG ) ) {
    471                         $this->markTestSkipped( 'This test requires PHP to be compiled with PNG support.' );
     471                        $this->fail( 'This test requires PHP to be compiled with PNG support.' );
    472472                }
    473473
    474474                $file = DIR_TESTDATA . '/images/transparent.png';
    public function test_image_preserves_alpha_on_resize() { 
    495495         */
    496496        public function test_image_preserves_alpha() {
    497497                if ( ! ( imagetypes() & IMG_PNG ) ) {
    498                         $this->markTestSkipped( 'This test requires PHP to be compiled with PNG support.' );
     498                        $this->fail( 'This test requires PHP to be compiled with PNG support.' );
    499499                }
    500500
    501501                $file = DIR_TESTDATA . '/images/transparent.png';
    public function test_image_preserves_alpha() { 
    521521         */
    522522        public function test_image_preserves_alpha_on_rotate() {
    523523                if ( ! ( imagetypes() & IMG_PNG ) ) {
    524                         $this->markTestSkipped( 'This test requires PHP to be compiled with PNG support.' );
     524                        $this->fail( 'This test requires PHP to be compiled with PNG support.' );
    525525                }
    526526
    527527                $file = DIR_TESTDATA . '/images/transparent.png';
  • tests/phpunit/tests/image/functions.php

    diff --git a/tests/phpunit/tests/image/functions.php b/tests/phpunit/tests/image/functions.php
    index 7ed2f0b..27bdbf3 100644
    a b public function test_load_directory() { 
    289289
    290290        public function test_wp_crop_image_file() {
    291291                if ( !function_exists( 'imagejpeg' ) )
    292                         $this->markTestSkipped( 'jpeg support unavailable' );
     292                        $this->fail( 'jpeg support unavailable' );
    293293
    294294                $file = wp_crop_image( DIR_TESTDATA . '/images/canola.jpg',
    295295                                                          0, 0, 100, 100, 100, 100 );
    public function test_wp_crop_image_file() { 
    305305
    306306        public function test_wp_crop_image_url() {
    307307                if ( !function_exists( 'imagejpeg' ) )
    308                         $this->markTestSkipped( 'jpeg support unavailable' );
     308                        $this->fail( 'jpeg support unavailable' );
    309309
    310310                if ( ! extension_loaded( 'openssl' ) ) {
    311311                        $this->markTestSkipped( 'Tests_Image_Functions::test_wp_crop_image_url() requires openssl.' );
  • tests/phpunit/tests/image/intermediate_size.php

    diff --git a/tests/phpunit/tests/image/intermediate_size.php b/tests/phpunit/tests/image/intermediate_size.php
    index 09419a2..3fcdf8c 100644
    a b function test_make_intermediate_size_no_size() { 
    3030
    3131        function test_make_intermediate_size_width() {
    3232                if ( !function_exists( 'imagejpeg' ) )
    33                         $this->markTestSkipped( 'jpeg support unavailable' );
     33                        $this->fail( 'jpeg support unavailable' );
    3434
    3535                $image = image_make_intermediate_size( DIR_TESTDATA . '/images/a2-small.jpg', 100, 0, false );
    3636
    function test_make_intermediate_size_width() { 
    3939
    4040        function test_make_intermediate_size_height() {
    4141                if ( !function_exists( 'imagejpeg' ) )
    42                         $this->markTestSkipped( 'jpeg support unavailable' );
     42                        $this->fail( 'jpeg support unavailable' );
    4343
    4444                $image = image_make_intermediate_size( DIR_TESTDATA . '/images/a2-small.jpg', 0, 75, false );
    4545
    function test_make_intermediate_size_height() { 
    4848
    4949        function test_make_intermediate_size_successful() {
    5050                if ( !function_exists( 'imagejpeg' ) )
    51                         $this->markTestSkipped( 'jpeg support unavailable' );
     51                        $this->fail( 'jpeg support unavailable' );
    5252
    5353                $image = image_make_intermediate_size( DIR_TESTDATA . '/images/a2-small.jpg', 100, 75, true );
    5454
  • tests/phpunit/tests/image/meta.php

    diff --git a/tests/phpunit/tests/image/meta.php b/tests/phpunit/tests/image/meta.php
    index 30613d4..f132d90 100644
    a b function setUp() { 
    1111                        $this->markTestSkipped( 'The gd PHP extension is not loaded.' );
    1212                if ( ! extension_loaded( 'exif' ) )
    1313                        $this->markTestSkipped( 'The exif PHP extension is not loaded.' );
    14                 if ( ! is_callable( 'wp_read_image_metadata' ) )
    15                         $this->markTestSkipped( 'wp_read_image_metadata() is not callable.' );
    1614                parent::setUp();
    1715        }
    1816
  • tests/phpunit/tests/image/resize.php

    diff --git a/tests/phpunit/tests/image/resize.php b/tests/phpunit/tests/image/resize.php
    index 807b51c..a775eb5 100644
    a b function test_resize_png() { 
    4242                $image = $this->resize_helper( DIR_TESTDATA.'/images/test-image.png', 25, 25 );
    4343
    4444                if ( ! is_string( $image ) ) {  // WP_Error, stop GLib-GObject-CRITICAL assertion
    45                         $this->markTestSkipped( sprintf( 'No PNG support in the editor engine %s on this system', $this->editor_engine ) );
    46                         return;
     45                        $this->fail( sprintf( 'No PNG support in the editor engine %s on this system', $this->editor_engine ) );
    4746                }
    4847
    4948                $this->assertEquals( 'test-image-25x25.png', basename( $image ) );
    function test_resize_gif() { 
    5958                $image = $this->resize_helper( DIR_TESTDATA.'/images/test-image.gif', 25, 25 );
    6059
    6160                if ( ! is_string( $image ) ) {  // WP_Error, stop GLib-GObject-CRITICAL assertion
    62                         $this->markTestSkipped( sprintf( 'No GIF support in the editor engine %s on this system', $this->editor_engine ) );
    63                         return;
     61                        $this->fail( sprintf( 'No GIF support in the editor engine %s on this system', $this->editor_engine ) );
    6462                }
    6563
    6664                $this->assertEquals( 'test-image-25x25.gif', basename( $image ) );
  • tests/phpunit/tests/image/size.php

    diff --git a/tests/phpunit/tests/image/size.php b/tests/phpunit/tests/image/size.php
    index 497946c..c27bbcf 100644
    a b  
    88class Tests_Image_Size extends WP_UnitTestCase {
    99
    1010        function test_constrain_dims_zero() {
    11                 if (!is_callable('wp_constrain_dimensions'))
    12                         $this->markTestSkipped('wp_constrain_dimensions() is not callable.');
    13 
    1411                // no constraint - should have no effect
    1512                $out = wp_constrain_dimensions(640, 480, 0, 0);
    1613                $this->assertSame( array( 640, 480 ), $out );
    function test_constrain_dims_zero() { 
    2623        }
    2724
    2825        function test_constrain_dims_smaller() {
    29                 if (!is_callable('wp_constrain_dimensions'))
    30                         $this->markTestSkipped('wp_constrain_dimensions() is not callable.');
    31 
    3226                // image size is smaller than the constraint - no effect
    3327                $out = wp_constrain_dimensions(500, 600, 1024, 768);
    3428                $this->assertSame( array( 500, 600 ), $out );
    function test_constrain_dims_smaller() { 
    4135        }
    4236
    4337        function test_constrain_dims_equal() {
    44                 if (!is_callable('wp_constrain_dimensions'))
    45                         $this->markTestSkipped('wp_constrain_dimensions() is not callable.');
    46 
    4738                // image size is equal to the constraint - no effect
    4839                $out = wp_constrain_dimensions(1024, 768, 1024, 768);
    4940                $this->assertSame( array( 1024, 768 ), $out );
    function test_constrain_dims_equal() { 
    5647        }
    5748
    5849        function test_constrain_dims_larger() {
    59                 if (!is_callable('wp_constrain_dimensions'))
    60                         $this->markTestSkipped('wp_constrain_dimensions() is not callable.');
    61 
    6250                // image size is larger than the constraint - result should be constrained
    6351                $out = wp_constrain_dimensions(1024, 768, 500, 600);
    6452                $this->assertSame( array( 500, 375 ), $out );
    function test_constrain_dims_larger() { 
    8169        }
    8270
    8371        function test_constrain_dims_boundary() {
    84                 if (!is_callable('wp_constrain_dimensions'))
    85                         $this->markTestSkipped('wp_constrain_dimensions() is not callable.');
    86 
    8772                // one dimension is larger than the constraint, one smaller - result should be constrained
    8873                $out = wp_constrain_dimensions(1024, 768, 500, 800);
    8974                $this->assertSame( array( 500, 375 ), $out );
  • tests/phpunit/tests/import/import.php

    diff --git a/tests/phpunit/tests/import/import.php b/tests/phpunit/tests/import/import.php
    index fa0bcbb..9303444 100644
    a b function setUp() { 
    1818                add_filter( 'import_allow_create_users', '__return_true' );
    1919
    2020                if ( ! file_exists( DIR_TESTDATA . '/plugins/wordpress-importer/wordpress-importer.php' ) ) {
    21                         $this->markTestSkipped( 'WordPress Importer plugin is not installed.' );
     21                        $this->fail( 'WordPress Importer plugin is not installed.' );
    2222                }
    2323
    2424                require_once DIR_TESTDATA . '/plugins/wordpress-importer/wordpress-importer.php';
  • tests/phpunit/tests/import/parser.php

    diff --git a/tests/phpunit/tests/import/parser.php b/tests/phpunit/tests/import/parser.php
    index 3e2ee20..890fd0a 100644
    a b function setUp() { 
    1616                        define( 'WP_LOAD_IMPORTERS', true );
    1717
    1818                if ( ! file_exists( DIR_TESTDATA . '/plugins/wordpress-importer/wordpress-importer.php' ) ) {
    19                         $this->markTestSkipped( 'WordPress Importer plugin is not installed.' );
     19                        $this->fail( 'WordPress Importer plugin is not installed.' );
    2020                }
    2121
    2222                require_once DIR_TESTDATA . '/plugins/wordpress-importer/wordpress-importer.php';
  • tests/phpunit/tests/import/postmeta.php

    diff --git a/tests/phpunit/tests/import/postmeta.php b/tests/phpunit/tests/import/postmeta.php
    index 0fd8dae..bf468a1 100644
    a b function setUp() { 
    1616                        define( 'WP_LOAD_IMPORTERS', true );
    1717
    1818                if ( ! file_exists( DIR_TESTDATA . '/plugins/wordpress-importer/wordpress-importer.php' ) ) {
    19                         $this->markTestSkipped( 'WordPress Importer plugin is not installed.' );
     19                        $this->fail( 'WordPress Importer plugin is not installed.' );
    2020                }
    2121
    2222                require_once DIR_TESTDATA . '/plugins/wordpress-importer/wordpress-importer.php';
  • tests/phpunit/tests/l10n/getLocale.php

    diff --git a/tests/phpunit/tests/l10n/getLocale.php b/tests/phpunit/tests/l10n/getLocale.php
    index 64b9900..ac9e429 100644
    a b public function test_should_respect_locale_global() { 
    1717                $this->assertSame( 'foo', $found );
    1818        }
    1919
     20        /**
     21         * @group ms-required
     22         */
    2023        public function test_local_option_should_take_precedence_on_multisite() {
    21                 if ( ! is_multisite() ) {
    22                         $this->markTestSkipped( __METHOD__ . ' requires Multisite' );
    23                 }
    24 
    2524                global $locale;
    2625                $old_locale = $locale;
    2726                $locale = null;
    public function test_local_option_should_take_precedence_on_multisite() { 
    3534                $this->assertSame( 'en_GB', $found );
    3635        }
    3736
     37        /**
     38         * @group ms-required
     39         */
    3840        public function test_network_option_should_be_fallback_on_multisite() {
    3941                if ( ! is_multisite() ) {
    4042                        $this->markTestSkipped( __METHOD__ . ' requires Multisite' );
    public function test_network_option_should_be_fallback_on_multisite() { 
    5254                $this->assertSame( 'es_ES', $found );
    5355        }
    5456
     57        /**
     58         * @group ms-excluded
     59         */
    5560        public function test_option_should_be_respected_on_nonmultisite() {
    5661                if ( is_multisite() ) {
    5762                        $this->markTestSkipped( __METHOD__ . ' does not apply to Multisite' );
  • tests/phpunit/tests/l10n/getUserLocale.php

    diff --git a/tests/phpunit/tests/l10n/getUserLocale.php b/tests/phpunit/tests/l10n/getUserLocale.php
    index c556426..d83b3e9 100644
    a b public function test_site_locale_is_not_affected_on_frontend() { 
    6666                $this->assertSame( 'en_US', get_locale() );
    6767        }
    6868
     69        /**
     70         * @group ms-required
     71         */
    6972        public function test_user_locale_is_same_across_network() {
    7073                if ( ! is_multisite() ) {
    7174                        $this->markTestSkipped( __METHOD__ . ' requires multisite' );
  • tests/phpunit/tests/link/getDashboardUrl.php

    diff --git a/tests/phpunit/tests/link/getDashboardUrl.php b/tests/phpunit/tests/link/getDashboardUrl.php
    index 4a6be8b..8557be1 100644
    a b public function test_get_dashboard_url_for_user_with_no_sites() { 
    3838
    3939        /**
    4040         * @ticket 39065
     41         * @group ms-required
    4142         */
    4243        public function test_get_dashboard_url_for_network_administrator_with_no_sites() {
    43                 if ( ! is_multisite() ) {
    44                         $this->markTestSkipped( 'Test only runs in multisite.' );
    45                 }
    46 
    4744                grant_super_admin( self::$user_id );
    4845
    4946                add_filter( 'get_blogs_of_user', '__return_empty_array' );
    public function test_get_dashboard_url_for_network_administrator_with_no_sites() 
    5855
    5956        /**
    6057         * @ticket 39065
     58         * @group ms-required
    6159         */
    6260        public function test_get_dashboard_url_for_administrator_of_different_site() {
    63                 if ( ! is_multisite() ) {
    64                         $this->markTestSkipped( 'Test only runs in multisite.' );
    65                 }
    66 
    6761                $site_id = self::factory()->blog->create( array( 'user_id' => self::$user_id ) );
    6862
    6963                remove_user_from_blog( self::$user_id, get_current_blog_id() );
  • tests/phpunit/tests/multisite/network.php

    diff --git a/tests/phpunit/tests/multisite/network.php b/tests/phpunit/tests/multisite/network.php
    index ffd976e..71e3ed8 100644
    a b function test_get_dashboard_blog() { 
    376376                $dashboard_blog = get_dashboard_blog();
    377377                $this->assertEquals( $blog_id, $dashboard_blog->blog_id );
    378378        }
     379
     380        /**
     381         * @ticket 37528
     382         */
     383        function test_wp_update_network_site_counts() {
     384                update_network_option( null, 'blog_count', 40 );
     385
     386                $expected = get_sites( array(
     387                        'network_id' => get_current_network_id(),
     388                        'spam'       => 0,
     389                        'deleted'    => 0,
     390                        'archived'   => 0,
     391                        'count'      => true,
     392                ) );
     393
     394                wp_update_network_site_counts();
     395
     396                $result = get_blog_count();
     397                $this->assertEquals( $expected, $result );
     398        }
     399
     400        /**
     401         * @ticket 37528
     402         */
     403        function test_wp_update_network_site_counts_on_different_network() {
     404                update_network_option( self::$different_network_id, 'blog_count', 40 );
     405
     406                wp_update_network_site_counts( self::$different_network_id );
     407
     408                $result = get_blog_count( self::$different_network_id );
     409                $this->assertEquals( 3, $result );
     410        }
     411
     412        /**
     413         * @ticket 40349
     414         */
     415        public function test_wp_update_network_user_counts() {
     416                global $wpdb;
     417
     418                update_network_option( null, 'user_count', 40 );
     419
     420                $expected = $wpdb->get_var( "SELECT COUNT(ID) as c FROM $wpdb->users WHERE spam = '0' AND deleted = '0'" );
     421
     422                wp_update_network_user_counts();
     423
     424                $result = get_user_count();
     425                $this->assertEquals( $expected, $result );
     426        }
     427
     428        /**
     429         * @ticket 40349
     430         */
     431        public function test_wp_update_network_user_counts_on_different_network() {
     432                global $wpdb;
     433
     434                update_network_option( self::$different_network_id, 'user_count', 40 );
     435
     436                $expected = $wpdb->get_var( "SELECT COUNT(ID) as c FROM $wpdb->users WHERE spam = '0' AND deleted = '0'" );
     437
     438                wp_update_network_user_counts( self::$different_network_id );
     439
     440                $result = get_user_count( self::$different_network_id );
     441                $this->assertEquals( $expected, $result );
     442        }
     443
     444        /**
     445         * @ticket 40386
     446         */
     447        public function test_wp_update_network_counts() {
     448                delete_network_option( null, 'site_count' );
     449                delete_network_option( null, 'user_count' );
     450
     451                wp_update_network_counts();
     452
     453                $site_count = (int) get_blog_count();
     454                $user_count = (int) get_user_count();
     455
     456                $this->assertTrue( $site_count > 0 && $user_count > 0 );
     457        }
     458
     459        /**
     460         * @ticket 40386
     461         */
     462        public function test_wp_update_network_counts_on_different_network() {
     463                delete_network_option( self::$different_network_id, 'site_count' );
     464                delete_network_option( self::$different_network_id, 'user_count' );
     465
     466                wp_update_network_counts( self::$different_network_id );
     467
     468                $site_count = (int) get_blog_count( self::$different_network_id );
     469                $user_count = (int) get_user_count( self::$different_network_id );
     470
     471                $this->assertTrue( $site_count > 0 && $user_count > 0 );
     472        }
    379473}
    380474
    381475endif;
  • tests/phpunit/tests/multisite/siteDetails.php

    diff --git a/tests/phpunit/tests/multisite/siteDetails.php b/tests/phpunit/tests/multisite/siteDetails.php
    index c58360b..bce6aaea 100644
    a b public function test_site_details_cached_including_false_values() { 
    144144
    145145                $this->assertNotFalse( $cached_details );
    146146        }
     147
     148        public function test_site_details_filter_with_blogname() {
     149                add_filter( 'site_details', array( $this, '_filter_site_details_blogname' ) );
     150                $site = get_site();
     151                $blogname = $site->blogname;
     152                remove_filter( 'site_details', array( $this, '_filter_site_details_blogname' ) );
     153
     154                $this->assertSame( 'Foo Bar', $blogname );
     155        }
     156
     157        public function _filter_site_details_blogname( $details ) {
     158                $details->blogname = 'Foo Bar';
     159                return $details;
     160        }
     161
     162        /**
     163         * @ticket 40458
     164         */
     165        public function test_site_details_filter_with_custom_value_isetter() {
     166                add_filter( 'site_details', array( $this, '_filter_site_details_custom_value' ) );
     167                $site = get_site();
     168                $custom_value_isset = isset( $site->custom_value );
     169                remove_filter( 'site_details', array( $this, '_filter_site_details_custom_value' ) );
     170
     171                $this->assertTrue( $custom_value_isset );
     172        }
     173
     174        /**
     175         * @ticket 40458
     176         */
     177        public function test_site_details_filter_with_custom_value_getter() {
     178                add_filter( 'site_details', array( $this, '_filter_site_details_custom_value' ) );
     179                $site = get_site();
     180                $custom_value = $site->custom_value;
     181                remove_filter( 'site_details', array( $this, '_filter_site_details_custom_value' ) );
     182
     183                $this->assertSame( 'foo', $custom_value );
     184        }
     185
     186        public function _filter_site_details_custom_value( $details ) {
     187                $details->custom_value = 'foo';
     188                return $details;
     189        }
    147190}
    148191
    149192endif;
  • tests/phpunit/tests/oembed/controller.php

    diff --git a/tests/phpunit/tests/oembed/controller.php b/tests/phpunit/tests/oembed/controller.php
    index 3c9d051..de41b0d 100644
    a b function test_request_xml() { 
    253253
    254254        /**
    255255         * @group multisite
     256         * @group ms-required
    256257         */
    257258        function test_request_ms_child_in_root_blog() {
    258                 if ( ! is_multisite() ) {
    259                         $this->markTestSkipped( __METHOD__ . ' is a multisite-only test.' );
    260                 }
    261 
    262259                $child = self::factory()->blog->create();
    263260                switch_to_blog( $child );
    264261
  • tests/phpunit/tests/oembed/template.php

    diff --git a/tests/phpunit/tests/oembed/template.php b/tests/phpunit/tests/oembed/template.php
    index 48245d1..7c82529 100644
    a b function test_js_no_ampersands_in_compiled() { 
    303303
    304304                $file = dirname( ABSPATH ) . '/build/' . WPINC . '/js/wp-embed.min.js';
    305305                if ( ! file_exists( $file ) ) {
    306                         $this->markTestSkipped( "This test is for the compiled wp-embed.min.js file." );
     306                        return;
    307307                }
    308308                $this->assertNotContains( '&', file_get_contents( $file ) );
    309309        }
  • tests/phpunit/tests/option/networkOption.php

    diff --git a/tests/phpunit/tests/option/networkOption.php b/tests/phpunit/tests/option/networkOption.php
    index 17e96bd..656fcab 100644
    a b  
    1111 * @group multisite
    1212 */
    1313class Tests_Option_NetworkOption extends WP_UnitTestCase {
    14         function test_add_network_option_not_available_on_other_network() {
    15                 if ( ! is_multisite() ) {
    16                         $this->markTestSkipped( 'Test requires multisite' );
    17                 }
    1814
     15        /**
     16         * @group ms-required
     17         */
     18        function test_add_network_option_not_available_on_other_network() {
    1919                $id = self::factory()->network->create();
    2020                $option = __FUNCTION__;
    2121                $value = __FUNCTION__;
    function test_add_network_option_not_available_on_other_network() { 
    2424                $this->assertFalse( get_network_option( $id, $option, false ) );
    2525        }
    2626
     27        /**
     28         * @group ms-required
     29         */
    2730        function test_add_network_option_available_on_same_network() {
    28                 if ( ! is_multisite() ) {
    29                         $this->markTestSkipped( 'Test requires multisite' );
    30                 }
    31 
    3231                $id = self::factory()->network->create();
    3332                $option = __FUNCTION__;
    3433                $value = __FUNCTION__;
    function test_add_network_option_available_on_same_network() { 
    3736                $this->assertEquals( $value, get_network_option( $id, $option, false ) );
    3837        }
    3938
     39        /**
     40         * @group ms-required
     41         */
    4042        function test_delete_network_option_on_only_one_network() {
    41                 if ( ! is_multisite() ) {
    42                         $this->markTestSkipped( 'Test requires multisite' );
    43                 }
    44 
    4543                $id = self::factory()->network->create();
    4644                $option = __FUNCTION__;
    4745                $value = __FUNCTION__;
    function test_delete_network_option_on_only_one_network() { 
    5452
    5553        /**
    5654         * @ticket 22846
     55         * @group ms-excluded
    5756         */
    5857        public function test_add_network_option_is_not_stored_as_autoload_option() {
    5958                $key = __FUNCTION__;
    6059
    61                 if ( is_multisite() ) {
    62                         $this->markTestSkipped( 'Does not apply when used in multisite.' );
    63                 }
    64 
    6560                add_network_option( null, $key, 'Not an autoload option' );
    6661
    6762                $options = wp_load_alloptions();
    public function test_add_network_option_is_not_stored_as_autoload_option() { 
    7166
    7267        /**
    7368         * @ticket 22846
     69         * @group ms-excluded
    7470         */
    7571        public function test_update_network_option_is_not_stored_as_autoload_option() {
    7672                $key = __FUNCTION__;
    7773
    78                 if ( is_multisite() ) {
    79                         $this->markTestSkipped( 'Does not apply when used in multisite.' );
    80                 }
    81 
    8274                update_network_option( null, $key, 'Not an autoload option' );
    8375
    8476                $options = wp_load_alloptions();
  • tests/phpunit/tests/option/siteTransient.php

    diff --git a/tests/phpunit/tests/option/siteTransient.php b/tests/phpunit/tests/option/siteTransient.php
    index 4a9f0e2..8a2965f 100644
    a b function test_serialized_data() { 
    4444
    4545        /**
    4646         * @ticket 22846
     47         * @group ms-excluded
    4748         */
    4849        public function test_set_site_transient_is_not_stored_as_autoload_option() {
    4950                $key = 'not_autoloaded';
    5051
    51                 if ( is_multisite() ) {
    52                         $this->markTestSkipped( 'Does not apply when used in multisite.' );
    53                 }
    5452                set_site_transient( $key, 'Not an autoload option' );
    5553
    5654                $options = wp_load_alloptions();
  • tests/phpunit/tests/post/attachments.php

    diff --git a/tests/phpunit/tests/post/attachments.php b/tests/phpunit/tests/post/attachments.php
    index 3df4ce4..306192c 100644
    a b function test_insert_image_no_thumb() { 
    5757
    5858        function test_insert_image_thumb_only() {
    5959                if ( !function_exists( 'imagejpeg' ) )
    60                         $this->markTestSkipped( 'jpeg support unavailable' );
     60                        $this->fail( 'jpeg support unavailable' );
    6161
    6262                update_option( 'medium_size_w', 0 );
    6363                update_option( 'medium_size_h', 0 );
    function test_insert_image_thumb_only() { 
    109109
    110110        function test_insert_image_medium_sizes() {
    111111                if ( !function_exists( 'imagejpeg' ) )
    112                         $this->markTestSkipped( 'jpeg support unavailable' );
     112                        $this->fail( 'jpeg support unavailable' );
    113113
    114114                update_option('medium_size_w', 400);
    115115                update_option('medium_size_h', 0);
    function test_insert_image_medium_sizes() { 
    167167
    168168        function test_insert_image_delete() {
    169169                if ( !function_exists( 'imagejpeg' ) )
    170                         $this->markTestSkipped( 'jpeg support unavailable' );
     170                        $this->fail( 'jpeg support unavailable' );
    171171
    172172                update_option('medium_size_w', 400);
    173173                update_option('medium_size_h', 0);
  • tests/phpunit/tests/rest-api/rest-posts-controller.php

    diff --git a/tests/phpunit/tests/rest-api/rest-posts-controller.php b/tests/phpunit/tests/rest-api/rest-posts-controller.php
    index 3aa91e4..de9b0db 100644
    a b public function test_get_items_with_orderby_relevance_missing_search() { 
    569569                $this->assertErrorResponse( 'rest_no_search_term_defined', $response, 400 );
    570570        }
    571571
    572         public function test_get_items_ignore_sticky_posts_by_default() {
    573                 $this->markTestSkipped( 'Broken, see https://github.com/WP-API/WP-API/issues/2210' );
    574                 $post_id1 = $this->factory->post->create( array( 'post_status' => 'publish', 'post_date' => '2015-01-01 12:00:00', 'post_date_gmt' => '2015-01-01 12:00:00' ) );
    575                 $post_id2 = $this->factory->post->create( array( 'post_status' => 'publish', 'post_date' => '2015-01-02 12:00:00', 'post_date_gmt' => '2015-01-02 12:00:00' ) );
    576                 $post_id3 = $this->factory->post->create( array( 'post_status' => 'publish', 'post_date' => '2015-01-03 12:00:00', 'post_date_gmt' => '2015-01-03 12:00:00' ) );
    577                 stick_post( $post_id2 );
    578 
    579                 // No stickies by default
    580                 $request = new WP_REST_Request( 'GET', '/wp/v2/posts' );
    581                 $response = $this->server->dispatch( $request );
    582                 $data = $response->get_data();
    583                 $this->assertEquals( array( self::$post_id, $post_id3, $post_id2, $post_id1 ), wp_list_pluck( $data, 'id' ) );
    584 
    585                 // Permit stickies
    586                 $request = new WP_REST_Request( 'GET', '/wp/v2/posts' );
    587                 $request->set_param( 'ignore_sticky_posts', false );
    588                 $response = $this->server->dispatch( $request );
    589                 $data = $response->get_data();
    590                 $this->assertEquals( array( $post_id2, self::$post_id, $post_id3, $post_id1 ), wp_list_pluck( $data, 'id' ) );
    591         }
    592 
    593572        public function test_get_items_offset_query() {
    594573                $id1 = self::$post_id;
    595574                $id2 = $this->factory->post->create( array( 'post_status' => 'publish' ) );
  • tests/phpunit/tests/rest-api/rest-users-controller.php

    diff --git a/tests/phpunit/tests/rest-api/rest-users-controller.php b/tests/phpunit/tests/rest-api/rest-users-controller.php
    index 1a81e42..44853aa 100644
    a b public function test_create_item_illegal_username() { 
    992992                $this->assertEquals( 'Sorry, that username is not allowed.', $errors['username'] );
    993993        }
    994994
     995        /**
     996         * @group ms-required
     997         */
    995998        public function test_create_new_network_user_on_site_does_not_add_user_to_sub_site() {
    996                 if ( ! is_multisite() ) {
    997                         $this->markTestSkipped( 'Test requires multisite.' );
    998                 }
    999 
    1000999                $this->allow_user_to_manage_multisite();
    10011000
    10021001                $params = array(
    public function test_create_new_network_user_on_site_does_not_add_user_to_sub_si 
    10211020                $this->assertFalse( $user_is_member );
    10221021        }
    10231022
     1023        /**
     1024         * @group ms-required
     1025         */
    10241026        public function test_create_new_network_user_on_sub_site_adds_user_to_site() {
    1025                 if ( ! is_multisite() ) {
    1026                         $this->markTestSkipped( 'Test requires multisite.' );
    1027                 }
    1028 
    10291027                $this->allow_user_to_manage_multisite();
    10301028
    10311029                $params = array(
    public function test_create_new_network_user_on_sub_site_adds_user_to_site() { 
    10541052                $this->assertTrue( $user_is_member );
    10551053        }
    10561054
     1055        /**
     1056         * @group ms-required
     1057         */
    10571058        public function test_create_existing_network_user_on_sub_site_has_error() {
    1058                 if ( ! is_multisite() ) {
    1059                         $this->markTestSkipped( 'Test requires multisite.' );
    1060                 }
    1061 
    10621059                $this->allow_user_to_manage_multisite();
    10631060
    10641061                $params = array(
    public function test_update_user_role_invalid_privilege_escalation() { 
    14411438                $this->assertArrayNotHasKey( 'administrator', $user->caps );
    14421439        }
    14431440
     1441        /**
     1442         * @group ms-excluded
     1443         */
    14441444        public function test_update_user_role_invalid_privilege_deescalation() {
    1445                 if ( is_multisite() ) {
    1446                         return $this->markTestSkipped( 'Test only intended for single site.' );
    1447                 }
    1448 
    14491445                $user_id = $this->factory->user->create( array( 'role' => 'administrator' ) );
    14501446
    14511447                wp_set_current_user( $user_id );
    public function test_update_user_role_invalid_privilege_deescalation() { 
    14711467                $this->assertArrayNotHasKey( 'editor', $user->caps );
    14721468        }
    14731469
     1470        /**
     1471         * @group ms-required
     1472         */
    14741473        public function test_update_user_role_privilege_deescalation_multisite() {
    1475                 if ( ! is_multisite() ) {
    1476                         return $this->markTestSkipped( 'Test only intended for multisite.' );
    1477                 }
    1478 
    14791474                $user_id = $this->factory->user->create( array( 'role' => 'administrator' ) );
    14801475
    14811476                wp_set_current_user( $user_id );
    public function test_additional_field_update_errors() { 
    22202215
    22212216        /**
    22222217         * @ticket 39701
     2218         * @group ms-required
    22232219         */
    22242220        public function test_get_item_from_different_site_as_site_administrator() {
    2225                 if ( ! is_multisite() ) {
    2226                         $this->markTestSkipped( 'Test only runs in multisite' );
    2227                 }
    2228 
    22292221                switch_to_blog( self::$site );
    22302222                $user_id = $this->factory->user->create( array(
    22312223                        'role' => 'author',
    public function test_get_item_from_different_site_as_site_administrator() { 
    22412233
    22422234        /**
    22432235         * @ticket 39701
     2236         * @group ms-required
    22442237         */
    22452238        public function test_get_item_from_different_site_as_network_administrator() {
    2246                 if ( ! is_multisite() ) {
    2247                         $this->markTestSkipped( 'Test only runs in multisite' );
    2248                 }
    2249 
    22502239                switch_to_blog( self::$site );
    22512240                $user_id = $this->factory->user->create( array(
    22522241                        'role' => 'author',
    public function test_get_item_from_different_site_as_network_administrator() { 
    22622251
    22632252        /**
    22642253         * @ticket 39701
     2254         * @group ms-required
    22652255         */
    22662256        public function test_update_item_from_different_site_as_site_administrator() {
    2267                 if ( ! is_multisite() ) {
    2268                         $this->markTestSkipped( 'Test only runs in multisite' );
    2269                 }
    2270 
    22712257                switch_to_blog( self::$site );
    22722258                $user_id = $this->factory->user->create( array(
    22732259                        'role' => 'author',
    public function test_update_item_from_different_site_as_site_administrator() { 
    22852271
    22862272        /**
    22872273         * @ticket 39701
     2274         * @group ms-required
    22882275         */
    22892276        public function test_update_item_from_different_site_as_network_administrator() {
    2290                 if ( ! is_multisite() ) {
    2291                         $this->markTestSkipped( 'Test only runs in multisite' );
    2292                 }
    2293 
    22942277                switch_to_blog( self::$site );
    22952278                $user_id = $this->factory->user->create( array(
    22962279                        'role' => 'author',
    public function test_update_item_from_different_site_as_network_administrator() 
    23082291
    23092292        /**
    23102293         * @ticket 39701
     2294         * @group ms-required
    23112295         */
    23122296        public function test_delete_item_from_different_site_as_site_administrator() {
    2313                 if ( ! is_multisite() ) {
    2314                         $this->markTestSkipped( 'Test only runs in multisite' );
    2315                 }
    2316 
    23172297                switch_to_blog( self::$site );
    23182298                $user_id = $this->factory->user->create( array(
    23192299                        'role' => 'author',
    public function test_delete_item_from_different_site_as_site_administrator() { 
    23312311
    23322312        /**
    23332313         * @ticket 39701
     2314         * @group ms-required
    23342315         */
    23352316        public function test_delete_item_from_different_site_as_network_administrator() {
    2336                 if ( ! is_multisite() ) {
    2337                         $this->markTestSkipped( 'Test only runs in multisite' );
    2338                 }
    2339 
    23402317                switch_to_blog( self::$site );
    23412318                $user_id = $this->factory->user->create( array(
    23422319                        'role' => 'author',
  • tests/phpunit/tests/rewrite.php

    diff --git a/tests/phpunit/tests/rewrite.php b/tests/phpunit/tests/rewrite.php
    index dfa9749..5f75149 100644
    a b function test_url_to_postid_set_url_scheme_http_to_https() { 
    119119        /**
    120120         * @ticket 35531
    121121         * @group multisite
     122         * @group ms-required
    122123         */
    123124        function test_url_to_postid_of_http_site_when_current_site_uses_https() {
    124                 if ( ! is_multisite() ) {
    125                         $this->markTestSkipped( 'This test requires multisite' );
    126                 }
    127 
    128125                $_SERVER['HTTPS'] = 'on';
    129126
    130127                $network_home = home_url();
    function test_url_to_postid_home_url_collision() { 
    315312
    316313        /**
    317314         * Reveals bug introduced in WP 3.0
    318          *
    319          * Run tests using multisite `phpunit -c multisite`
     315         * @group ms-required
    320316         */
    321317        function test_url_to_postid_ms_home_url_collision() {
    322 
    323                 if ( ! is_multisite() ) {
    324                         $this->markTestSkipped( 'test_url_to_postid_ms_home_url_collision requires multisite' );
    325                         return false;
    326                 }
    327 
    328318                $blog_id = self::factory()->blog->create( array( 'path' => '/example' ) );
    329319                switch_to_blog( $blog_id );
    330320
  • tests/phpunit/tests/term/query.php

    diff --git a/tests/phpunit/tests/term/query.php b/tests/phpunit/tests/term/query.php
    index 4a15f1e..b2e2a27 100644
    a b public function test_count_query_cache_should_be_invalidated_with_incrementor_bu 
    381381                $count = $query->get_terms();
    382382                $this->assertEquals( 1, $count );
    383383        }
     384
     385        /**
     386         * @ticket 40496
     387         */
     388        public function test_get_the_terms_should_respect_taxonomy_orderby() {
     389                register_taxonomy( 'wptests_tax', 'post', array(
     390                        'sort' => true,
     391                        'args' => array(
     392                                'orderby' => 'term_order',
     393                        ),
     394                ) );
     395                $term_ids = self::factory()->term->create_many( 2, array(
     396                        'taxonomy' => 'wptests_tax',
     397                ) );
     398                $post_id = self::factory()->post->create();
     399                wp_set_object_terms( $post_id, array( $term_ids[0], $term_ids[1] ), 'wptests_tax' );
     400                $terms = get_the_terms( $post_id, 'wptests_tax' );
     401                $this->assertEquals( array( $term_ids[0], $term_ids[1] ), wp_list_pluck( $terms, 'term_id' ) );
     402                // Flip the order
     403                wp_set_object_terms( $post_id, array( $term_ids[1], $term_ids[0] ), 'wptests_tax' );
     404                $terms = get_the_terms( $post_id, 'wptests_tax' );
     405                $this->assertEquals( array( $term_ids[1], $term_ids[0] ), wp_list_pluck( $terms, 'term_id' ) );
     406        }
     407
     408        /**
     409         * @ticket 40496
     410         */
     411        public function test_wp_get_object_terms_should_respect_taxonomy_orderby() {
     412                register_taxonomy( 'wptests_tax', 'post', array(
     413                        'sort' => true,
     414                        'args' => array(
     415                                'orderby' => 'term_order',
     416                        ),
     417                ) );
     418                $term_ids = self::factory()->term->create_many( 2, array(
     419                        'taxonomy' => 'wptests_tax',
     420                ) );
     421                $post_id = self::factory()->post->create();
     422                wp_set_object_terms( $post_id, array( $term_ids[0], $term_ids[1] ), 'wptests_tax' );
     423                $terms = wp_get_object_terms( $post_id, array( 'category', 'wptests_tax' ) );
     424                $this->assertEquals( array( $term_ids[0], $term_ids[1], 1 ), wp_list_pluck( $terms, 'term_id' ) );
     425                // Flip the order
     426                wp_set_object_terms( $post_id, array( $term_ids[1], $term_ids[0] ), 'wptests_tax' );
     427                $terms = wp_get_object_terms( $post_id, array( 'category', 'wptests_tax' ) );
     428                $this->assertEquals( array( $term_ids[1], $term_ids[0], 1 ), wp_list_pluck( $terms, 'term_id' ) );
     429        }
    384430}
  • tests/phpunit/tests/theme.php

    diff --git a/tests/phpunit/tests/theme.php b/tests/phpunit/tests/theme.php
    index 2e76f7c..452a836 100644
    a b function test_wp_get_theme_contents() { 
    189189        function test_default_theme_in_default_theme_list() {
    190190                $latest_default_theme = WP_Theme::get_core_default_theme();
    191191                if ( ! $latest_default_theme->exists() || 'twenty' !== substr( $latest_default_theme->get_stylesheet(), 0, 6 ) ) {
    192                         $this->markTestSkipped( 'No Twenty* series default themes are installed' );
     192                        $this->fail( 'No Twenty* series default themes are installed' );
    193193                }
    194194                $this->assertContains( $latest_default_theme->get_stylesheet(), $this->default_themes );
    195195        }
  • tests/phpunit/tests/theme/WPTheme.php

    diff --git a/tests/phpunit/tests/theme/WPTheme.php b/tests/phpunit/tests/theme/WPTheme.php
    index 5f01a25..da7374e 100644
    a b function test_display_method_on_get_method_failure() { 
    145145         * Enable a single theme on a network.
    146146         *
    147147         * @ticket 30594
     148         * @group ms-required
    148149         */
    149150        function test_wp_theme_network_enable_single_theme() {
    150                 if ( ! is_multisite() ) {
    151                         $this->markTestSkipped( 'This test requires multisite' );
    152                 }
    153 
    154151                $theme = 'testtheme-1';
    155152                $current_allowed_themes = get_site_option( 'allowedthemes' );
    156153                WP_Theme::network_enable_theme( $theme );
    function test_wp_theme_network_enable_single_theme() { 
    165162         * Enable multiple themes on a network.
    166163         *
    167164         * @ticket 30594
     165         * @group ms-required
    168166         */
    169167        function test_wp_theme_network_enable_multiple_themes() {
    170                 if ( ! is_multisite() ) {
    171                         $this->markTestSkipped( 'This test requires multisite' );
    172                 }
    173 
    174168                $themes = array( 'testtheme-2', 'testtheme-3' );
    175169                $current_allowed_themes = get_site_option( 'allowedthemes' );
    176170                WP_Theme::network_enable_theme( $themes );
    function test_wp_theme_network_enable_multiple_themes() { 
    185179         * Disable a single theme on a network.
    186180         *
    187181         * @ticket 30594
     182         * @group ms-required
    188183         */
    189184        function test_network_disable_single_theme() {
    190                 if ( ! is_multisite() ) {
    191                         $this->markTestSkipped( 'This test requires multisite' );
    192                 }
    193 
    194185                $current_allowed_themes = get_site_option( 'allowedthemes' );
    195186
    196187                $allowed_themes = array( 'existing-1' => true, 'existing-2' => true, 'existing-3' => true );
    function test_network_disable_single_theme() { 
    209200         * Disable multiple themes on a network.
    210201         *
    211202         * @ticket 30594
     203         * @group ms-required
    212204         */
    213205        function test_network_disable_multiple_themes() {
    214                 if ( ! is_multisite() ) {
    215                         $this->markTestSkipped( 'This test requires multisite' );
    216                 }
    217 
    218206                $current_allowed_themes = get_site_option( 'allowedthemes' );
    219207
    220208                $allowed_themes = array( 'existing-4' => true, 'existing-5' => true, 'existing-6' => true );
  • tests/phpunit/tests/upload.php

    diff --git a/tests/phpunit/tests/upload.php b/tests/phpunit/tests/upload.php
    index 361b2f0..3f2028d 100644
    a b class Tests_Upload extends WP_UnitTestCase { 
    88        var $siteurl;
    99
    1010        function setUp() {
    11                 if ( is_multisite() ) {
    12                         $this->knownUTBug( 35 );
    13                 }
    14 
    1511                $this->_reset_options();
    1612                parent::setUp();
    1713        }
  • tests/phpunit/tests/user.php

    diff --git a/tests/phpunit/tests/user.php b/tests/phpunit/tests/user.php
    index 3d38089..b2b87d1 100644
    a b function test_illegal_user_logins_single_wp_create_user( $user_login ) { 
    649649
    650650        /**
    651651         * @ticket 27317
     652         * @group ms-required
    652653         */
    653654        function test_illegal_user_logins_multisite() {
    654                 if ( ! is_multisite() ) {
    655                         $this->markTestSkipped( __METHOD__ . ' requires multisite.' );
    656                 }
    657 
    658655                $user_data = array(
    659656                        'user_login' => 'testuser',
    660657                        'user_email' => 'testuser@example.com',
  • tests/phpunit/tests/user/capabilities.php

    diff --git a/tests/phpunit/tests/user/capabilities.php b/tests/phpunit/tests/user/capabilities.php
    index 88de406..2412704 100644
    a b function _meta_filter( $meta_value, $meta_key, $meta_type ) { 
    226226                        'manage_network_themes'  => array(),
    227227                        'manage_network_options' => array(),
    228228                        'delete_site'            => array(),
     229                        'upgrade_network'        => array(),
    229230
    230231                        'setup_network'          => array( 'administrator' ),
    231232                        'upload_plugins'         => array( 'administrator' ),
    function _meta_filter( $meta_value, $meta_key, $meta_type ) { 
    259260                        'upload_plugins'         => array(),
    260261                        'upload_themes'          => array(),
    261262                        'edit_css'               => array(),
     263                        'upgrade_network'        => array(),
    262264
    263265                        'customize'              => array( 'administrator' ),
    264266                        'delete_site'            => array( 'administrator' ),
    public function data_user_with_role_can_edit_others_posts() { 
    609611                return $data;
    610612        }
    611613
     614        /**
     615         * @group ms-required
     616         */
    612617        function test_super_admin_caps() {
    613                 if ( ! is_multisite() ) {
    614                         $this->markTestSkipped( 'Test only runs in multisite' );
    615                         return;
    616                 }
    617618                $caps = $this->getAllCapsAndRoles();
    618619                $user = self::$super_admin;
    619620
    function test_current_user_can_for_blog() { 
    13531354                wp_set_current_user( $old_uid );
    13541355        }
    13551356
     1357        /**
     1358         * @group ms-required
     1359         */
    13561360        function test_borked_current_user_can_for_blog() {
    1357                 if ( ! is_multisite() ) {
    1358                         $this->markTestSkipped( 'Test only runs in multisite' );
    1359                         return;
    1360                 }
    1361 
    13621361                $orig_blog_id = get_current_blog_id();
    13631362                $blog_id = self::factory()->blog->create();
    13641363
    function test_subscriber_cant_edit_posts() { 
    14141413                $this->assertFalse( current_user_can( 'edit_post', $post + 1 ) );
    14151414        }
    14161415
     1416        /**
     1417         * @group ms-required
     1418         */
    14171419        function test_multisite_administrator_can_not_edit_users() {
    1418                 if ( ! is_multisite() ) {
    1419                         $this->markTestSkipped( 'Test only runs in multisite' );
    1420                         return;
    1421                 }
    1422 
    14231420                $user = self::$users['administrator'];
    14241421                $other_user = self::$users['subscriber'];
    14251422
    public function test_only_admins_and_super_admins_can_remove_users() { 
    14481445                $this->assertFalse( user_can( self::$users['subscriber']->ID,   'remove_user', self::$users['subscriber']->ID ) );
    14491446        }
    14501447
     1448        /**
     1449         * @group ms-required
     1450         */
    14511451        public function test_only_super_admins_can_delete_users_on_multisite() {
    1452                 if ( ! is_multisite() ) {
    1453                         $this->markTestSkipped( 'Test only runs on multisite' );
    1454                 }
    1455 
    14561452                $this->assertTrue( user_can( self::$super_admin->ID,             'delete_user', self::$users['subscriber']->ID ) );
    14571453
    14581454                $this->assertFalse( user_can( self::$users['administrator']->ID, 'delete_user', self::$users['subscriber']->ID ) );
    public function test_only_super_admins_can_delete_users_on_multisite() { 
    14621458                $this->assertFalse( user_can( self::$users['subscriber']->ID,    'delete_user', self::$users['subscriber']->ID ) );
    14631459        }
    14641460
     1461        /**
     1462         * @group ms-excluded
     1463         */
    14651464        public function test_only_admins_can_delete_users_on_single_site() {
    1466                 if ( is_multisite() ) {
    1467                         $this->markTestSkipped( 'Test does not run on multisite' );
    1468                 }
    1469 
    14701465                $this->assertTrue( user_can( self::$users['administrator']->ID, 'delete_user', self::$users['subscriber']->ID ) );
    14711466
    14721467                $this->assertFalse( user_can( self::$users['editor']->ID,       'delete_user', self::$users['subscriber']->ID ) );
    function test_contributor_cannot_edit_scheduled_post() { 
    15201515
    15211516        }
    15221517
     1518        /**
     1519         * @group ms-required
     1520         */
    15231521        function test_multisite_administrator_with_manage_network_users_can_edit_users() {
    1524                 if ( ! is_multisite() ) {
    1525                         $this->markTestSkipped( 'Test only runs in multisite' );
    1526                         return;
    1527                 }
    1528 
    15291522                $user = self::$users['administrator'];
    15301523                $user->add_cap( 'manage_network_users' );
    15311524                $other_user = self::$users['subscriber'];
    function test_multisite_administrator_with_manage_network_users_can_edit_users() 
    15391532                $this->assertTrue( $can_edit_user );
    15401533        }
    15411534
     1535        /**
     1536         * @group ms-required
     1537         */
    15421538        function test_multisite_administrator_with_manage_network_users_can_not_edit_super_admin() {
    1543                 if ( ! is_multisite() ) {
    1544                         $this->markTestSkipped( 'Test only runs in multisite' );
    1545                         return;
    1546                 }
    1547 
    15481539                $user = self::$users['administrator'];
    15491540                $user->add_cap( 'manage_network_users' );
    15501541
    function test_multisite_administrator_with_manage_network_users_can_not_edit_sup 
    15591550
    15601551        /**
    15611552         * @ticket 16956
     1553         * @expectedIncorrectUsage map_meta_cap
    15621554         */
    15631555        function test_require_edit_others_posts_if_post_type_doesnt_exist() {
    15641556                register_post_type( 'existed' );
    function test_require_edit_others_posts_if_post_type_doesnt_exist() { 
    15681560                $subscriber_id = self::$users['subscriber']->ID;
    15691561                $editor_id = self::$users['editor']->ID;
    15701562
    1571                 $this->setExpectedIncorrectUsage( 'map_meta_cap' );
    15721563                foreach ( array( 'delete_post', 'edit_post', 'read_post', 'publish_post' ) as $cap ) {
    15731564                        wp_set_current_user( $subscriber_id );
    15741565                        $this->assertSame( array( 'edit_others_posts' ), map_meta_cap( $cap, $subscriber_id, $post_id ) );
    public function testNonLoggedInUsersHaveNoCapabilities() { 
    16361627                        $this->assertFalse( current_user_can( $cap ), "Non-logged-in user should not have the {$cap} capability" );
    16371628                }
    16381629
     1630                // Special cases for link manager and unfiltered uploads:
     1631                $this->assertFalse( current_user_can( 'manage_links' ), "Non-logged-in user should not have the manage_links capability" );
     1632                $this->assertFalse( current_user_can( 'unfiltered_upload' ), "Non-logged-in user should not have the unfiltered_upload capability" );
     1633
    16391634                $this->assertFalse( current_user_can( 'start_a_fire' ), "Non-logged-in user should not have a custom capability" );
    16401635                $this->assertFalse( current_user_can( 'do_not_allow' ), "Non-logged-in user should not have the do_not_allow capability" );
    16411636        }
    public function test_user_cannot_add_user_meta() { 
    17621757
    17631758        /**
    17641759         * @ticket 39063
     1760         * @group ms-required
    17651761         */
    17661762        public function test_only_super_admins_can_remove_themselves_on_multisite() {
    1767                 if ( ! is_multisite() ) {
    1768                         $this->markTestSkipped( 'Test only runs in multisite.' );
    1769                 }
    1770 
    17711763                $this->assertTrue( user_can( self::$super_admin->ID, 'remove_user', self::$super_admin->ID ) );
    17721764
    17731765                $this->assertFalse( user_can( self::$users['administrator']->ID, 'remove_user', self::$users['administrator']->ID ) );
  • tests/phpunit/tests/user/countUsers.php

    diff --git a/tests/phpunit/tests/user/countUsers.php b/tests/phpunit/tests/user/countUsers.php
    index d3192bb..f5fa6b9 100644
    a b class Tests_User_CountUsers extends WP_UnitTestCase { 
    99         * @ticket 22993
    1010         *
    1111         * @dataProvider data_count_users_strategies
     12         * @group ms-excluded
    1213         */
    1314        public function test_count_users_is_accurate( $strategy ) {
    14 
    15                 if ( is_multisite() ) {
    16                         $this->markTestSkipped( 'Test does not run on multisite' );
    17                 }
    18 
    1915                // Setup users
    2016                $admin = self::factory()->user->create( array(
    2117                        'role' => 'administrator',
    public function test_count_users_is_accurate( $strategy ) { 
    5753        /**
    5854         * @ticket 22993
    5955         * @group multisite
     56         * @group ms-required
    6057         *
    6158         * @dataProvider data_count_users_strategies
    6259         */
    6360        public function test_count_users_multisite_is_accurate( $strategy ) {
    64 
    65                 if ( ! is_multisite() ) {
    66                         $this->markTestSkipped( 'Test requires multisite' );
    67                 }
    68 
    6961                // Setup users
    7062                $admin = self::factory()->user->create( array(
    7163                        'role' => 'administrator',
    public function test_count_users_is_accurate_with_multiple_roles( $strategy ) { 
    175167
    176168        }
    177169
     170        /**
     171         * @ticket 29785
     172         *
     173         * @dataProvider data_count_users_strategies
     174         */
     175        public function test_count_users_should_not_count_users_who_are_not_in_posts_table( $strategy ) {
     176                global $wpdb;
     177
     178                // Get a 'before' count for comparison.
     179                $count = count_users( $strategy );
     180
     181                $u = self::factory()->user->create( array(
     182                        'role' => 'editor',
     183                ) );
     184
     185                // Manually delete the user, but leave the capabilities usermeta.
     186                $wpdb->delete( $wpdb->users, array(
     187                        'ID' => $u,
     188                ) );
     189
     190                $count2 = count_users( $strategy );
     191
     192                $this->assertEqualSets( $count, $count2 );
     193        }
     194
    178195        function data_count_users_strategies() {
    179196                return array(
    180197                        array(
  • tests/phpunit/tests/user/mapMetaCap.php

    diff --git a/tests/phpunit/tests/user/mapMetaCap.php b/tests/phpunit/tests/user/mapMetaCap.php
    index c017293..f98c87b 100644
    a b function test_capability_type_post_with_all_meta_caps_renamed_mapped() { 
    213213        }
    214214
    215215        function test_unfiltered_html_cap() {
    216                 if ( defined( 'DISALLOW_UNFILTERED_HTML' ) && DISALLOW_UNFILTERED_HTML )
    217                         $this->markTestSkipped( 'DISALLOW_UNFILTERED_HTML is defined.' );
     216                if ( defined( 'DISALLOW_UNFILTERED_HTML' ) ) {
     217                        $this->assertFalse( DISALLOW_UNFILTERED_HTML );
     218                }
     219
    218220                if ( is_multisite() ) {
    219221                        $this->assertEquals( array( 'do_not_allow' ), map_meta_cap( 'unfiltered_html', 0 ) );
    220222                        $this->assertEquals( array( 'unfiltered_html' ), map_meta_cap( 'unfiltered_html', self::$user_id ) );
    function test_unfiltered_html_cap() { 
    227229         * @ticket 20488
    228230         */
    229231        function test_file_edit_caps_not_reliant_on_unfiltered_html_constant() {
    230                 if ( defined( 'DISALLOW_FILE_MODS' ) || defined( 'DISALLOW_FILE_EDIT' ) )
    231                         $this->markTestSkipped('DISALLOW_FILE_MODS or DISALLOW_FILE_EDIT is defined.');
     232                $this->assertFalse( defined( 'DISALLOW_FILE_MODS' ) );
     233                $this->assertFalse( defined( 'DISALLOW_FILE_EDIT' ) );
    232234
    233                 if ( defined( 'DISALLOW_UNFILTERED_HTML' ) ) {
    234                         if ( ! DISALLOW_UNFILTERED_HTML )
    235                                 $this->markTestSkipped( 'DISALLOW_UNFILTERED_HTML is defined.' );
    236                 } else {
     235                if ( ! defined( 'DISALLOW_UNFILTERED_HTML' ) ) {
    237236                        define( 'DISALLOW_UNFILTERED_HTML', true );
    238237                }
    239238
     239                $this->assertTrue( DISALLOW_UNFILTERED_HTML );
    240240                $this->assertEquals( array( 'update_core' ), map_meta_cap( 'update_core', self::$user_id ) );
    241241                $this->assertEquals( array( 'edit_plugins' ), map_meta_cap( 'edit_plugins', self::$user_id ) );
    242242        }
  • tests/phpunit/tests/user/query.php

    diff --git a/tests/phpunit/tests/user/query.php b/tests/phpunit/tests/user/query.php
    index 2cadc91..ee2f3d8 100644
    a b public function test_roles_and_caps_should_be_populated_for_default_value_of_blo 
    551551                $this->assertSame( array( 'author' => true ), $user->caps );
    552552        }
    553553
     554        /**
     555         * @group ms-excluded
     556         */
    554557        public function test_roles_and_caps_should_be_populated_for_explicit_value_of_blog_id_on_nonms() {
    555                 if ( is_multisite() ) {
    556                         $this->markTestSkipped( __METHOD__ . ' is a non-multisite-only test.' );
    557                 }
    558 
    559558                $query = new WP_User_Query( array(
    560559                        'include' => self::$author_ids[0],
    561560                        'blog_id' => get_current_blog_id(),
    public function test_roles_and_caps_should_be_populated_for_explicit_value_of_bl 
    569568                $this->assertSame( array( 'author' => true ), $user->caps );
    570569        }
    571570
     571        /**
     572         * @group ms-required
     573         */
    572574        public function test_roles_and_caps_should_be_populated_for_explicit_value_of_current_blog_id_on_ms() {
    573                 if ( ! is_multisite() ) {
    574                         $this->markTestSkipped( __METHOD__ . ' is a multisite-only test.' );
    575                 }
    576 
    577575                $query = new WP_User_Query( array(
    578576                        'include' => self::$author_ids[0],
    579577                        'blog_id' => get_current_blog_id(),
    public function test_roles_and_caps_should_be_populated_for_explicit_value_of_cu 
    587585                $this->assertSame( array( 'author' => true ), $user->caps );
    588586        }
    589587
     588        /**
     589         * @group ms-required
     590         */
    590591        public function test_roles_and_caps_should_be_populated_for_explicit_value_of_different_blog_id_on_ms_when_fields_all_with_meta() {
    591                 if ( ! is_multisite() ) {
    592                         $this->markTestSkipped( __METHOD__ . ' is a multisite-only test.' );
    593                 }
    594 
    595592                $b = self::factory()->blog->create();
    596593
    597594                add_user_to_blog( $b, self::$author_ids[0], 'author' );
    public function test_roles_and_caps_should_be_populated_for_explicit_value_of_di 
    612609
    613610        /**
    614611         * @ticket 31878
     612         * @group ms-required
    615613         */
    616614        public function test_roles_and_caps_should_be_populated_for_explicit_value_of_different_blog_id_on_ms_when_fields_all() {
    617                 if ( ! is_multisite() ) {
    618                         $this->markTestSkipped( __METHOD__ . ' is a multisite-only test.' );
    619                 }
    620 
    621615                $b = self::factory()->blog->create();
    622616                add_user_to_blog( $b, self::$author_ids[0], 'author' );
    623617
    public function test_roles_and_caps_should_be_populated_for_explicit_value_of_di 
    637631
    638632        /**
    639633         * @ticket 32019
     634         * @group ms-required
    640635         */
    641636        public function test_who_authors() {
    642                 if ( ! is_multisite() ) {
    643                         $this->markTestSkipped( __METHOD__ . ' requires multisite.' );
    644                 }
    645 
    646637                $b = self::factory()->blog->create();
    647638
    648639                add_user_to_blog( $b, self::$author_ids[0], 'subscriber' );
    public function test_who_authors() { 
    663654
    664655        /**
    665656         * @ticket 32019
     657         * @group ms-required
    666658         */
    667659        public function test_who_authors_should_work_alongside_meta_query() {
    668                 if ( ! is_multisite() ) {
    669                         $this->markTestSkipped( __METHOD__ . ' requires multisite.' );
    670                 }
    671 
    672660                $b = self::factory()->blog->create();
    673661
    674662                add_user_to_blog( $b, self::$author_ids[0], 'subscriber' );
    public function test_who_authors_should_work_alongside_meta_query() { 
    698686
    699687        /**
    700688         * @ticket 36724
     689         * @group ms-required
    701690         */
    702691        public function test_who_authors_should_work_alongside_meta_params() {
    703                 if ( ! is_multisite() ) {
    704                         $this->markTestSkipped( __METHOD__ . ' requires multisite.' );
    705                 }
    706 
    707692                $b = self::factory()->blog->create();
    708693
    709694                add_user_to_blog( $b, self::$author_ids[0], 'subscriber' );
    public function test_has_published_posts_should_ignore_non_published_posts() { 
    791776
    792777        /**
    793778         * @ticket 32250
     779         * @group ms-required
    794780         */
    795781        public function test_has_published_posts_should_respect_blog_id() {
    796                 if ( ! is_multisite() ) {
    797                         $this->markTestSkipped( __METHOD__ . ' requires multisite.' );
    798                 }
    799 
    800782                $blogs = self::factory()->blog->create_many( 2 );
    801783
    802784                add_user_to_blog( $blogs[0], self::$author_ids[0], 'author' );
    public function test_role__not_in_user_without_role() { 
    13581340
    13591341        /**
    13601342         * @ticket 22212
     1343         * @group ms-required
    13611344         */
    13621345        public function test_blog_id_should_restrict_by_blog_without_requiring_a_named_role() {
    1363                 if ( ! is_multisite() ) {
    1364                         $this->markTestSkipped( __METHOD__ . ' requires multisite.' );
    1365                 }
    1366 
    13671346                $sites = self::factory()->blog->create_many( 2 );
    13681347
    13691348                add_user_to_blog( $sites[0], self::$author_ids[0], 'author' );
    public function test_blog_id_should_restrict_by_blog_without_requiring_a_named_r 
    13801359        /**
    13811360         * @ticket 22212
    13821361         * @ticket 21119
     1362         * @group ms-required
    13831363         */
    13841364        public function test_calling_prepare_query_a_second_time_should_not_add_another_cap_query_on_multisite() {
    1385                 if ( ! is_multisite() ) {
    1386                         $this->markTestSkipped( __METHOD__ . ' requires Multisite.' );
    1387                 }
    1388 
    13891365                $site_id = get_current_blog_id();
    13901366                add_user_to_blog( $site_id, self::$author_ids[0], 'author' );
    13911367
  • tests/phpunit/tests/user/wpAuthenticateSpamCheck.php

    diff --git a/tests/phpunit/tests/user/wpAuthenticateSpamCheck.php b/tests/phpunit/tests/user/wpAuthenticateSpamCheck.php
    index 7f3b164..78cbdcd 100644
    a b  
    44 * @group user
    55 */
    66class Tests_User_WpAuthenticateSpamCheck extends WP_UnitTestCase {
    7         function test_wp_authenticate_spam_check_returns_user_when_single_site() {
    8                 if ( is_multisite() ) {
    9                         $this->markTestSkipped( 'This test applies to single site only.' );
    10                 }
    117
     8        /**
     9         * @group ms-excluded
     10         */
     11        function test_wp_authenticate_spam_check_returns_user_when_single_site() {
    1212                $user_id = self::factory()->user->create( array( 'role' => 'contributor' ) );
    1313                $user = new WP_User( $user_id );
    1414                $actual_user = wp_authenticate_spam_check( $user );
    function test_wp_authenticate_spam_check_returns_user_when_single_site() { 
    1717                $this->assertEquals( $user->user_login, $actual_user->user_login );
    1818        }
    1919
     20        /**
     21         * @group ms-required
     22         */
    2023        function test_wp_authenticate_spam_check_returns_user_when_not_flagged() {
    21                 if ( ! is_multisite() ) {
    22                         $this->markTestSkipped( 'This test applies to multisite only.' );
    23                 }
    24 
    2524                $user_id = self::factory()->user->create( array( 'role' => 'contributor' ) );
    2625                $user = new WP_User( $user_id );
    2726                $actual_user = wp_authenticate_spam_check( $user );
    function test_wp_authenticate_spam_check_returns_user_when_not_flagged() { 
    3029                $this->assertEquals( $user->user_login, $actual_user->user_login );
    3130        }
    3231
     32        /**
     33         * @group ms-required
     34         */
    3335        function test_wp_authenticate_spam_check_returns_wp_error_when_flagged() {
    34                 if ( ! is_multisite() ) {
    35                         $this->markTestSkipped( 'This test applies to multisite only.' );
    36                 }
    37 
    3836                $user_id = self::factory()->user->create( array( 'role' => 'contributor' ) );
    3937                update_user_status( $user_id, 'spam', 1 );
    4038                $user = new WP_User( $user_id );
  • tests/phpunit/tests/user/wpDeleteUser.php

    diff --git a/tests/phpunit/tests/user/wpDeleteUser.php b/tests/phpunit/tests/user/wpDeleteUser.php
    index 60e7caf..7f7e902 100644
    a b function test_wp_delete_user_reassignment_clears_post_caches() { 
    123123                $this->assertEquals( $reassign, $post->post_author );
    124124        }
    125125
     126        /**
     127         * @group ms-excluded
     128         */
    126129        public function test_numeric_string_user_id() {
    127                 if ( is_multisite() ) {
    128                         $this->markTestSkipped( 'wp_delete_user() does not delete user records in Multisite.' );
    129                 }
    130 
    131130                $u = self::factory()->user->create();
    132131
    133132                $u_string = (string) $u;
    public function test_should_return_false_for_non_numeric_string_user_id() { 
    144143
    145144        /**
    146145         * @ticket 33800
     146         * @group ms-excluded
    147147         */
    148148        public function test_should_return_false_for_object_user_id() {
    149                 if ( is_multisite() ) {
    150                         $this->markTestSkipped( 'wp_delete_user() does not delete user records in Multisite.' );
    151                 }
    152 
    153149                $u_obj = self::factory()->user->create_and_get();
    154150                $this->assertFalse( wp_delete_user( $u_obj ) );
    155151                $this->assertEquals( $u_obj->ID, username_exists( $u_obj->user_login ) );
  • tests/phpunit/tests/user/wpGetUsersWithNoRole.php

    diff --git a/tests/phpunit/tests/user/wpGetUsersWithNoRole.php b/tests/phpunit/tests/user/wpGetUsersWithNoRole.php
    index cd7b118..82c0da7 100644
    a b class Tests_User_GetUsersWithNoRole extends WP_UnitTestCase { 
    77
    88        /**
    99         * @ticket 22993
     10         * @group ms-excluded
    1011         */
    1112        public function test_get_users_with_no_role_is_accurate() {
    12 
    13                 if ( is_multisite() ) {
    14                         $this->markTestSkipped( 'Test does not run on multisite' );
    15                 }
    16 
    1713                // Setup users
    1814                $admin = self::factory()->user->create( array(
    1915                        'role' => 'administrator',
    public function test_get_users_with_no_role_is_accurate() { 
    4137        /**
    4238         * @ticket 22993
    4339         * @group multisite
     40         * @group ms-required
    4441         */
    4542        public function test_get_users_with_no_role_multisite_is_accurate() {
    46 
    47                 if ( ! is_multisite() ) {
    48                         $this->markTestSkipped( 'Test requires multisite' );
    49                 }
    50 
    5143                // Setup users
    5244                $admin = self::factory()->user->create( array(
    5345                        'role' => 'administrator',
  • tests/phpunit/tests/xmlrpc/basic.php

    diff --git a/tests/phpunit/tests/xmlrpc/basic.php b/tests/phpunit/tests/xmlrpc/basic.php
    index bbbcbd7..7818fdb 100644
    a b class Tests_XMLRPC_Basic extends WP_XMLRPC_UnitTestCase { 
    1111        function test_enabled() {
    1212                $result = $this->myxmlrpcserver->wp_getOptions( array( 1, 'username', 'password' ) );
    1313
    14                 $this->assertInstanceOf( 'IXR_Error', $result );
     14                $this->assertIXRError( $result );
    1515                // If disabled, 405 would result.
    1616                $this->assertEquals( 403, $result->code );
    1717        }
  • tests/phpunit/tests/xmlrpc/mt/getRecentPostTitles.php

    diff --git a/tests/phpunit/tests/xmlrpc/mt/getRecentPostTitles.php b/tests/phpunit/tests/xmlrpc/mt/getRecentPostTitles.php
    index 8d9c027..7c36f97 100644
    a b class Tests_XMLRPC_mt_getRecentPostTitles extends WP_XMLRPC_UnitTestCase { 
    77
    88        function test_invalid_username_password() {
    99                $result = $this->myxmlrpcserver->mt_getRecentPostTitles( array( 1, 'username', 'password' ) );
    10                 $this->assertInstanceOf( 'IXR_Error', $result );
     10                $this->assertIXRError( $result );
    1111                $this->assertEquals( 403, $result->code );
    1212        }
    1313
    function test_no_posts() { 
    1515                $this->make_user_by_role( 'author' );
    1616
    1717                $result = $this->myxmlrpcserver->mt_getRecentPostTitles( array( 1, 'author', 'author' ) );
    18                 $this->assertInstanceOf( 'IXR_Error', $result );
     18                $this->assertIXRError( $result );
    1919                $this->assertEquals( 500, $result->code );
    2020        }
    2121
    function test_no_editable_posts() { 
    2525                self::factory()->post->create( array( 'post_author' => $editor ) );
    2626
    2727                $result = $this->myxmlrpcserver->mt_getRecentPostTitles( array( 1, 'author', 'author' ) );
    28                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     28                $this->assertNotIXRError( $result );
    2929                $this->assertEquals( 0, count( $result ) );
    3030        }
    3131
    function test_date() { 
    3535                self::factory()->post->create();
    3636
    3737                $results = $this->myxmlrpcserver->mt_getRecentPostTitles( array( 1, 'author', 'author' ) );
    38                 $this->assertNotInstanceOf( 'IXR_Error', $results );
     38                $this->assertNotIXRError( $results );
    3939
    4040                foreach( $results as $result ) {
    4141                        $post = get_post( $result['postid'] );
  • tests/phpunit/tests/xmlrpc/mw/editPost.php

    diff --git a/tests/phpunit/tests/xmlrpc/mw/editPost.php b/tests/phpunit/tests/xmlrpc/mw/editPost.php
    index e265b88..39a937d 100644
    a b class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase { 
    88        function test_invalid_username_password() {
    99                $post = array();
    1010                $result = $this->myxmlrpcserver->mw_editPost( array( 1, 'username', 'password', $post ) );
    11                 $this->assertInstanceOf( 'IXR_Error', $result );
     11                $this->assertIXRError( $result );
    1212                $this->assertEquals( 403, $result->code );
    1313        }
    1414
    function test_edit_own_post() { 
    2020                $new_title = 'Post test (updated)';
    2121                $post2 = array( 'title' => $new_title );
    2222                $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'contributor', 'contributor', $post2 ) );
    23                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     23                $this->assertNotIXRError( $result );
    2424                $this->assertTrue($result);
    2525
    2626                $out = get_post( $post_id );
    function test_capable_edit_others_post() { 
    3737                $new_title = 'Post test (updated)';
    3838                $post2 = array( 'title' => $new_title );
    3939                $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'editor', 'editor', $post2 ) );
    40                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     40                $this->assertNotIXRError( $result );
    4141                $this->assertTrue($result);
    4242
    4343                $out = get_post( $post_id );
    function test_incapable_edit_others_post() { 
    5555                $new_title = 'Post test (updated)';
    5656                $post2 = array( 'title' => $new_title );
    5757                $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'contributor', 'contributor', $post2 ) );
    58                 $this->assertInstanceOf( 'IXR_Error', $result );
     58                $this->assertIXRError( $result );
    5959                $this->assertEquals( 401, $result->code );
    6060
    6161                $out = get_post( $post_id );
    function test_capable_reassign_author() { 
    7272
    7373                $post2 = array( 'wp_author_id' => $author_id );
    7474                $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'editor', 'editor', $post2 ) );
    75                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     75                $this->assertNotIXRError( $result );
    7676                $this->assertTrue($result);
    7777
    7878                $out = get_post( $post_id );
    function test_incapable_reassign_author() { 
    8888
    8989                $post2 = array( 'wp_author_id' => $author_id );
    9090                $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'contributor', 'contributor', $post2 ) );
    91                 $this->assertInstanceOf( 'IXR_Error', $result );
     91                $this->assertIXRError( $result );
    9292                $this->assertEquals( 401, $result->code );
    9393
    9494                $out = get_post( $post_id );
    function test_capable_reassign_author_to_self() { 
    107107
    108108                $post2 = array( 'wp_author_id' => $editor_id );
    109109                $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'editor', 'editor', $post2 ) );
    110                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     110                $this->assertNotIXRError( $result );
    111111                $this->assertTrue($result);
    112112
    113113                $out = get_post( $post_id );
    function test_post_thumbnail() { 
    131131                // add post thumbnail to post that does not have one
    132132                $post2 = array( 'wp_post_thumbnail' => $attachment_id );
    133133                $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'author', 'author', $post2 ) );
    134                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     134                $this->assertNotIXRError( $result );
    135135                $this->assertEquals( $attachment_id, get_post_meta( $post_id, '_thumbnail_id', true ) );
    136136
    137137                // edit the post without supplying a post_thumbnail and check that it didn't change
    138138                $post3 = array( 'post_content' => 'Updated post' );
    139139                $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'author', 'author', $post3 ) );
    140                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     140                $this->assertNotIXRError( $result );
    141141                $this->assertEquals( $attachment_id, get_post_meta( $post_id, '_thumbnail_id', true ) );
    142142
    143143                // create another attachment
    function test_post_thumbnail() { 
    146146                // change the post's post_thumbnail
    147147                $post4 = array( 'wp_post_thumbnail' => $attachment2_id );
    148148                $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'author', 'author', $post4 ) );
    149                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     149                $this->assertNotIXRError( $result );
    150150                $this->assertEquals( $attachment2_id, get_post_meta( $post_id, '_thumbnail_id', true ) );
    151151
    152152                // unset the post's post_thumbnail
    153153                $post5 = array( 'wp_post_thumbnail' => '' );
    154154                $result = $this->myxmlrpcserver->mw_editPost( array($post_id, 'author', 'author', $post5 ) );
    155                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     155                $this->assertNotIXRError( $result );
    156156                $this->assertEquals( '', get_post_meta( $post_id, '_thumbnail_id', true ) );
    157157
    158158                remove_theme_support( 'post-thumbnails' );
    function test_edit_basic_post_info() { 
    166166
    167167                $post2 = array( 'title' => 'New Title', 'post_author' => $contributor_id );
    168168                $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'contributor', 'contributor', $post2 ) );
    169                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     169                $this->assertNotIXRError( $result );
    170170                $this->assertTrue($result);
    171171
    172172                $out = get_post( $post_id );
    function test_edit_basic_post_info() { 
    174174
    175175                $post3 = array( 'description' => 'New Content', 'post_author' => $contributor_id );
    176176                $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'contributor', 'contributor', $post3 ) );
    177                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     177                $this->assertNotIXRError( $result );
    178178                $this->assertTrue($result);
    179179
    180180                $out = get_post( $post_id );
    function test_edit_basic_post_info() { 
    183183
    184184                $post4 = array( 'mt_excerpt' => 'New Excerpt', 'post_author' => $contributor_id );
    185185                $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'contributor', 'contributor', $post4 ) );
    186                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     186                $this->assertNotIXRError( $result );
    187187                $this->assertTrue($result);
    188188
    189189                $out = get_post( $post_id );
    function test_make_post_sticky() { 
    202202                $post_id = wp_insert_post( $post );
    203203
    204204                $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'editor', 'editor', array( 'sticky' => '1' ) ) );
    205                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     205                $this->assertNotIXRError( $result );
    206206                $this->assertTrue( $result );
    207207        }
    208208
    function test_change_post_type() { 
    215215
    216216                $post2 = array( 'post_type' => 'page' );
    217217                $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'contributor', 'contributor', $post2 ) );
    218                 $this->assertInstanceOf( 'IXR_Error', $result );
     218                $this->assertIXRError( $result );
    219219                $this->assertEquals( $result->code, 401 );
    220220        }
    221221
  • tests/phpunit/tests/xmlrpc/mw/getPost.php

    diff --git a/tests/phpunit/tests/xmlrpc/mw/getPost.php b/tests/phpunit/tests/xmlrpc/mw/getPost.php
    index 0d433d0..924d6ff 100644
    a b public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) { 
    1919
    2020        function test_invalid_username_password() {
    2121                $result = $this->myxmlrpcserver->mw_getPost( array( self::$post_id, 'username', 'password' ) );
    22                 $this->assertInstanceOf( 'IXR_Error', $result );
     22                $this->assertIXRError( $result );
    2323                $this->assertEquals( 403, $result->code );
    2424        }
    2525
    function test_incapable_user() { 
    2727                $this->make_user_by_role( 'subscriber' );
    2828
    2929                $result = $this->myxmlrpcserver->mw_getPost( array( self::$post_id, 'subscriber', 'subscriber' ) );
    30                 $this->assertInstanceOf( 'IXR_Error', $result );
     30                $this->assertIXRError( $result );
    3131                $this->assertEquals( 401, $result->code );
    3232        }
    3333
    function test_incapable_user() { 
    3636         */
    3737        function test_invalid_postid() {
    3838                $result = $this->myxmlrpcserver->mw_getPost( array( 9999, 'author', 'author' ) );
    39                 $this->assertInstanceOf( 'IXR_Error', $result );
     39                $this->assertIXRError( $result );
    4040                $this->assertEquals( 404, $result->code );
    4141        }
    4242
    function test_valid_post() { 
    4545
    4646                $fields = array( 'post' );
    4747                $result = $this->myxmlrpcserver->mw_getPost( array( self::$post_id, 'author', 'author' ) );
    48                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     48                $this->assertNotIXRError( $result );
    4949
    5050                // Check data types
    5151                $this->assertInternalType( 'string', $result['userid'] );
    function test_post_thumbnail() { 
    9696
    9797                $fields = array( 'post' );
    9898                $result = $this->myxmlrpcserver->mw_getPost( array( self::$post_id, 'author', 'author' ) );
    99                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     99                $this->assertNotIXRError( $result );
    100100
    101101                $this->assertInternalType( 'string', $result['wp_post_thumbnail'] );
    102102                $this->assertStringMatchesFormat( '%d', $result['wp_post_thumbnail'] );
    function test_post_thumbnail() { 
    108108        function test_date() {
    109109                $fields = array( 'post' );
    110110                $result = $this->myxmlrpcserver->mw_getPost( array( self::$post_id, 'author', 'author' ) );
    111                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     111                $this->assertNotIXRError( $result );
    112112
    113113                $this->assertInstanceOf( 'IXR_Date', $result['dateCreated'] );
    114114                $this->assertInstanceOf( 'IXR_Date', $result['date_created_gmt'] );
  • tests/phpunit/tests/xmlrpc/mw/getRecentPosts.php

    diff --git a/tests/phpunit/tests/xmlrpc/mw/getRecentPosts.php b/tests/phpunit/tests/xmlrpc/mw/getRecentPosts.php
    index a3b7cd4..8ab7627 100644
    a b public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) { 
    2020
    2121        function test_invalid_username_password() {
    2222                $result = $this->myxmlrpcserver->mw_getRecentPosts( array( 1, 'username', 'password' ) );
    23                 $this->assertInstanceOf( 'IXR_Error', $result );
     23                $this->assertIXRError( $result );
    2424                $this->assertEquals( 403, $result->code );
    2525        }
    2626
    function test_no_editing_privileges() { 
    3131                $this->make_user_by_role( 'subscriber' );
    3232
    3333                $result = $this->myxmlrpcserver->mw_getRecentPosts( array( 1, 'subscriber', 'subscriber' ) );
    34                 $this->assertInstanceOf( 'IXR_Error', $result );
     34                $this->assertIXRError( $result );
    3535                $this->assertEquals( 401, $result->code );
    3636        }
    3737
    function test_no_editable_posts() { 
    3939                wp_delete_post( self::$post_id, true );
    4040
    4141                $result = $this->myxmlrpcserver->mw_getRecentPosts( array( 1, 'author', 'author' ) );
    42                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     42                $this->assertNotIXRError( $result );
    4343                $this->assertEquals( 0, count( $result ) );
    4444        }
    4545
    function test_valid_post() { 
    4848
    4949                $fields = array( 'post' );
    5050                $results = $this->myxmlrpcserver->mw_getRecentPosts( array( 1, 'author', 'author' ) );
    51                 $this->assertNotInstanceOf( 'IXR_Error', $results );
     51                $this->assertNotIXRError( $results );
    5252
    5353                foreach( $results as $result ) {
    5454                        $post = get_post( $result['postid'] );
    function test_post_thumbnail() { 
    9999                set_post_thumbnail( self::$post_id, $attachment_id );
    100100
    101101                $results = $this->myxmlrpcserver->mw_getRecentPosts( array( self::$post_id, 'author', 'author' ) );
    102                 $this->assertNotInstanceOf( 'IXR_Error', $results );
     102                $this->assertNotIXRError( $results );
    103103
    104104                foreach( $results as $result ) {
    105105                        $this->assertInternalType( 'string', $result['wp_post_thumbnail'] );
    function test_date() { 
    119119                $this->make_user_by_role( 'editor' );
    120120
    121121                $results = $this->myxmlrpcserver->mw_getRecentPosts( array( 1, 'editor', 'editor' ) );
    122                 $this->assertNotInstanceOf( 'IXR_Error', $results );
     122                $this->assertNotIXRError( $results );
    123123
    124124                foreach( $results as $result ) {
    125125                        $post = get_post( $result['postid'] );
  • tests/phpunit/tests/xmlrpc/mw/newPost.php

    diff --git a/tests/phpunit/tests/xmlrpc/mw/newPost.php b/tests/phpunit/tests/xmlrpc/mw/newPost.php
    index 01316e6..06aaafc 100644
    a b class Tests_XMLRPC_mw_newPost extends WP_XMLRPC_UnitTestCase { 
    88        function test_invalid_username_password() {
    99                $post = array();
    1010                $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'username', 'password', $post ) );
    11                 $this->assertInstanceOf( 'IXR_Error', $result );
     11                $this->assertIXRError( $result );
    1212                $this->assertEquals( 403, $result->code );
    1313        }
    1414
    function test_incapable_user() { 
    1717
    1818                $post = array();
    1919                $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'subscriber', 'subscriber', $post ) );
    20                 $this->assertInstanceOf( 'IXR_Error', $result );
     20                $this->assertIXRError( $result );
    2121                $this->assertEquals( 401, $result->code );
    2222        }
    2323
    function test_no_content() { 
    2626
    2727                $post = array();
    2828                $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'author', 'author', $post ) );
    29                 $this->assertInstanceOf( 'IXR_Error', $result );
     29                $this->assertIXRError( $result );
    3030                $this->assertEquals( 500, $result->code );
    3131                $this->assertEquals( 'Content, title, and excerpt are empty.', $result->message );
    3232        }
    function test_basic_content() { 
    3636
    3737                $post = array( 'title' => 'Test' );
    3838                $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'author', 'author', $post ) );
    39                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     39                $this->assertNotIXRError( $result );
    4040                $this->assertStringMatchesFormat( '%d', $result );
    4141        }
    4242
    function test_ignore_id() { 
    4545
    4646                $post = array( 'title' => 'Test', 'ID' => 103948 );
    4747                $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'author', 'author', $post ) );
    48                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     48                $this->assertNotIXRError( $result );
    4949                $this->assertNotEquals( '103948', $result );
    5050        }
    5151
    function test_capable_publish() { 
    5454
    5555                $post = array( 'title' => 'Test', 'post_status' => 'publish' );
    5656                $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'author', 'author', $post ) );
    57                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     57                $this->assertNotIXRError( $result );
    5858        }
    5959
    6060        function test_incapable_publish() {
    function test_incapable_publish() { 
    6262
    6363                $post = array( 'title' => 'Test', 'post_status' => 'publish' );
    6464                $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'contributor', 'contributor', $post ) );
    65                 $this->assertInstanceOf( 'IXR_Error', $result );
     65                $this->assertIXRError( $result );
    6666                $this->assertEquals( 401, $result->code );
    6767        }
    6868
    function test_capable_other_author() { 
    7272
    7373                $post = array( 'title' => 'Test', 'wp_author_id' => $other_author_id );
    7474                $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'editor', 'editor', $post ) );
    75                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     75                $this->assertNotIXRError( $result );
    7676        }
    7777
    7878        function test_incapable_other_author() {
    function test_incapable_other_author() { 
    8181
    8282                $post = array( 'title' => 'Test', 'wp_author_id' => $other_author_id );
    8383                $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'contributor', 'contributor', $post ) );
    84                 $this->assertInstanceOf( 'IXR_Error', $result );
     84                $this->assertIXRError( $result );
    8585                $this->assertEquals( 401, $result->code );
    8686        }
    8787
    function test_invalid_author() { 
    9393
    9494                $post = array( 'title' => 'Test', 'wp_author_id' => 99999999 );
    9595                $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'editor', 'editor', $post ) );
    96                 $this->assertInstanceOf( 'IXR_Error', $result );
     96                $this->assertIXRError( $result );
    9797                $this->assertEquals( 404, $result->code );
    9898        }
    9999
    function test_empty_author() { 
    102102
    103103                $post = array( 'title' => 'Test' );
    104104                $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'author', 'author', $post ) );
    105                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     105                $this->assertNotIXRError( $result );
    106106                $this->assertStringMatchesFormat( '%d', $result );
    107107
    108108                $out = get_post( $result );
    function test_post_thumbnail() { 
    121121
    122122                $post = array( 'title' => 'Post Thumbnail Test', 'wp_post_thumbnail' => $attachment_id );
    123123                $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'author', 'author', $post ) );
    124                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     124                $this->assertNotIXRError( $result );
    125125                $this->assertEquals( $attachment_id, get_post_meta( $result, '_thumbnail_id', true ) );
    126126
    127127                remove_theme_support( 'post-thumbnails' );
    function test_incapable_set_post_type_as_page() { 
    132132
    133133                $post = array( 'title' => 'Test', 'post_type' => 'page' );
    134134                $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'author', 'author', $post ) );
    135                 $this->assertInstanceOf( 'IXR_Error', $result );
     135                $this->assertIXRError( $result );
    136136                $this->assertEquals( 401, $result->code );
    137137        }
    138138
    function test_capable_set_post_type_as_page() { 
    141141
    142142                $post = array( 'title' => 'Test', 'post_type' => 'page' );
    143143                $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'editor', 'editor', $post ) );
    144                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     144                $this->assertNotIXRError( $result );
    145145                $this->assertStringMatchesFormat( '%d', $result );
    146146
    147147                $out = get_post( $result );
    function test_draft_post_date() { 
    162162                        'post_status' => 'draft'
    163163                );
    164164                $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'editor', 'editor', $post ) );
    165                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     165                $this->assertNotIXRError( $result );
    166166                $this->assertStringMatchesFormat( '%d', $result );
    167167
    168168                $out = get_post( $result );
  • tests/phpunit/tests/xmlrpc/wp/deletePost.php

    diff --git a/tests/phpunit/tests/xmlrpc/wp/deletePost.php b/tests/phpunit/tests/xmlrpc/wp/deletePost.php
    index e7284a7..d2a5bc6 100644
    a b class Tests_XMLRPC_wp_deletePost extends WP_XMLRPC_UnitTestCase { 
    77
    88        function test_invalid_username_password() {
    99                $result = $this->myxmlrpcserver->wp_deletePost( array( 1, 'username', 'password', 0 ) );
    10                 $this->assertInstanceOf( 'IXR_Error', $result );
     10                $this->assertIXRError( $result );
    1111                $this->assertEquals( 403, $result->code );
    1212        }
    1313
    function test_invalid_post() { 
    1515                $this->make_user_by_role( 'editor' );
    1616
    1717                $result = $this->myxmlrpcserver->wp_deletePost( array( 1, 'editor', 'editor', 340982340 ) );
    18                 $this->assertInstanceOf( 'IXR_Error', $result );
     18                $this->assertIXRError( $result );
    1919                $this->assertEquals( 404, $result->code );
    2020        }
    2121
    function test_incapable_user() { 
    2424                $post_id = self::factory()->post->create();
    2525
    2626                $result = $this->myxmlrpcserver->wp_deletePost( array( 1, 'subscriber', 'subscriber', $post_id ) );
    27                 $this->assertInstanceOf( 'IXR_Error', $result );
     27                $this->assertIXRError( $result );
    2828                $this->assertEquals( 401, $result->code );
    2929        }
    3030
    function test_post_deleted() { 
    3333                $post_id = self::factory()->post->create();
    3434
    3535                $result = $this->myxmlrpcserver->wp_deletePost( array( 1, 'editor', 'editor', $post_id ) );
    36                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     36                $this->assertNotIXRError( $result );
    3737                $this->assertTrue( $result );
    3838
    3939                $post = get_post( $post_id );
  • tests/phpunit/tests/xmlrpc/wp/deleteTerm.php

    diff --git a/tests/phpunit/tests/xmlrpc/wp/deleteTerm.php b/tests/phpunit/tests/xmlrpc/wp/deleteTerm.php
    index ee95c6a..94e25c9 100644
    a b public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) { 
    1414
    1515        function test_invalid_username_password() {
    1616                $result = $this->myxmlrpcserver->wp_deleteTerm( array( 1, 'username', 'password', 'category', 0 ) );
    17                 $this->assertInstanceOf( 'IXR_Error', $result );
     17                $this->assertIXRError( $result );
    1818                $this->assertEquals( 403, $result->code );
    1919        }
    2020
    function test_empty_taxonomy() { 
    2222                $this->make_user_by_role( 'subscriber' );
    2323
    2424                $result = $this->myxmlrpcserver->wp_deleteTerm( array( 1, 'subscriber', 'subscriber', '', 0 ) );
    25                 $this->assertInstanceOf( 'IXR_Error', $result );
     25                $this->assertIXRError( $result );
    2626                $this->assertEquals( 403, $result->code );
    2727                $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message );
    2828        }
    function test_invalid_taxonomy() { 
    3131                $this->make_user_by_role( 'subscriber' );
    3232
    3333                $result = $this->myxmlrpcserver->wp_deleteTerm( array( 1, 'subscriber', 'subscriber', 'not_existing', 0 ) );
    34                 $this->assertInstanceOf( 'IXR_Error', $result );
     34                $this->assertIXRError( $result );
    3535                $this->assertEquals( 403, $result->code );
    3636                $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message );
    3737        }
    function test_incapable_user() { 
    4040                $this->make_user_by_role( 'subscriber' );
    4141
    4242                $result = $this->myxmlrpcserver->wp_deleteTerm( array( 1, 'subscriber', 'subscriber', 'category', self::$term_id ) );
    43                 $this->assertInstanceOf( 'IXR_Error', $result );
     43                $this->assertIXRError( $result );
    4444                $this->assertEquals( 401, $result->code );
    4545                $this->assertEquals( __( 'Sorry, you are not allowed to delete this term.' ), $result->message );
    4646        }
    function test_empty_term() { 
    4949                $this->make_user_by_role( 'editor' );
    5050
    5151                $result = $this->myxmlrpcserver->wp_deleteTerm( array( 1, 'editor', 'editor', 'category', '' ) );
    52                 $this->assertInstanceOf( 'IXR_Error', $result );
     52                $this->assertIXRError( $result );
    5353                $this->assertEquals( 500, $result->code );
    5454                $this->assertEquals( __('Empty Term'), $result->message );
    5555        }
    function test_invalid_term() { 
    5858                $this->make_user_by_role( 'editor' );
    5959
    6060                $result = $this->myxmlrpcserver->wp_deleteTerm( array( 1, 'editor', 'editor', 'category', 9999 ) );
    61                 $this->assertInstanceOf( 'IXR_Error', $result );
     61                $this->assertIXRError( $result );
    6262                $this->assertEquals( 404, $result->code );
    6363                $this->assertEquals( __( 'Invalid term ID.' ), $result->message );
    6464        }
    function test_term_deleted() { 
    6767                $this->make_user_by_role( 'editor' );
    6868
    6969                $result = $this->myxmlrpcserver->wp_deleteTerm( array( 1, 'editor', 'editor', 'category', self::$term_id ) );
    70                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     70                $this->assertNotIXRError( $result );
    7171                $this->assertInternalType( 'boolean', $result );
    7272        }
    7373}
  • tests/phpunit/tests/xmlrpc/wp/editComment.php

    diff --git a/tests/phpunit/tests/xmlrpc/wp/editComment.php b/tests/phpunit/tests/xmlrpc/wp/editComment.php
    index b43beb6..fcb3bb5 100644
    a b function test_author_can_edit_own_comment() { 
    2222                $result = $this->myxmlrpcserver->wp_editComment( array( 1, 'author', 'author', $comment_id, array(
    2323                        'status' => 'hold'
    2424                ) ) );
    25                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     25                $this->assertNotIXRError( $result );
    2626                $this->assertTrue( $result );
    2727        }
    2828
    function test_author_cannot_edit_others_comment() { 
    4242                ) );
    4343
    4444                $result = $this->myxmlrpcserver->wp_editComment( array( 1, 'author', 'author', $comment_id, array( 'status' => 'hold' ) ) );
    45                 $this->assertInstanceOf( 'IXR_Error', $result );
     45                $this->assertIXRError( $result );
    4646                $this->assertEquals( 403, $result->code );
    4747                $this->assertEquals( __( 'Sorry, you are not allowed to moderate or edit this comment.' ), $result->message );
    4848        }
  • tests/phpunit/tests/xmlrpc/wp/editPost.php

    diff --git a/tests/phpunit/tests/xmlrpc/wp/editPost.php b/tests/phpunit/tests/xmlrpc/wp/editPost.php
    index 373d458..55f5be9 100644
    a b class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { 
    77
    88        function test_invalid_username_password() {
    99                $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'username', 'password', 0, array() ) );
    10                 $this->assertInstanceOf( 'IXR_Error', $result );
     10                $this->assertIXRError( $result );
    1111                $this->assertEquals( 403, $result->code );
    1212        }
    1313
    function test_edit_own_post() { 
    2020                $new_title = 'Post test (updated)';
    2121                $post2 = array( 'post_title' => $new_title );
    2222                $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'contributor', 'contributor', $post_id, $post2 ) );
    23                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     23                $this->assertNotIXRError( $result );
    2424                $this->assertTrue($result);
    2525
    2626                $out = get_post( $post_id );
    function test_capable_edit_others_post() { 
    3737                $new_title = 'Post test (updated)';
    3838                $post2 = array( 'post_title' => $new_title );
    3939                $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, $post2 ) );
    40                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     40                $this->assertNotIXRError( $result );
    4141                $this->assertTrue($result);
    4242
    4343                $out = get_post( $post_id );
    function test_incapable_edit_others_post() { 
    5555                $new_title = 'Post test (updated)';
    5656                $post2 = array( 'post_title' => $new_title );
    5757                $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'contributor', 'contributor', $post_id, $post2 ) );
    58                 $this->assertInstanceOf( 'IXR_Error', $result );
     58                $this->assertIXRError( $result );
    5959                $this->assertEquals( 401, $result->code );
    6060
    6161                $out = get_post( $post_id );
    function test_capable_reassign_author() { 
    7272
    7373                $post2 = array( 'post_author' => $author_id );
    7474                $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, $post2 ) );
    75                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     75                $this->assertNotIXRError( $result );
    7676                $this->assertTrue($result);
    7777
    7878                $out = get_post( $post_id );
    function test_incapable_reassign_author() { 
    8888
    8989                $post2 = array( 'post_author' => $author_id );
    9090                $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'contributor', 'contributor', $post_id, $post2 ) );
    91                 $this->assertInstanceOf( 'IXR_Error', $result );
     91                $this->assertIXRError( $result );
    9292                $this->assertEquals( 401, $result->code );
    9393
    9494                $out = get_post( $post_id );
    function test_capable_reassign_author_to_self() { 
    107107
    108108                $post2 = array( 'post_author' => $editor_id );
    109109                $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, $post2 ) );
    110                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     110                $this->assertNotIXRError( $result );
    111111                $this->assertTrue($result);
    112112
    113113                $out = get_post( $post_id );
    function test_post_thumbnail() { 
    131131                // add post thumbnail to post that does not have one
    132132                $post2 = array( 'post_thumbnail' => $attachment_id );
    133133                $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'author', 'author', $post_id, $post2 ) );
    134                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     134                $this->assertNotIXRError( $result );
    135135                $this->assertEquals( $attachment_id, get_post_meta( $post_id, '_thumbnail_id', true ) );
    136136
    137137                // fetch the post to verify that it appears
    138138                $result = $this->myxmlrpcserver->wp_getPost( array( 1, 'author', 'author', $post_id ) );
    139                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     139                $this->assertNotIXRError( $result );
    140140                $this->assertArrayHasKey( 'post_thumbnail', $result );
    141141                $this->assertInternalType( 'array', $result['post_thumbnail'] );
    142142                $this->assertEquals( $attachment_id, $result['post_thumbnail']['attachment_id'] );
    function test_post_thumbnail() { 
    144144                // edit the post without supplying a post_thumbnail and check that it didn't change
    145145                $post3 = array( 'post_content' => 'Updated post' );
    146146                $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'author', 'author', $post_id, $post3 ) );
    147                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     147                $this->assertNotIXRError( $result );
    148148                $this->assertEquals( $attachment_id, get_post_meta( $post_id, '_thumbnail_id', true ) );
    149149
    150150                // create another attachment
    function test_post_thumbnail() { 
    153153                // change the post's post_thumbnail
    154154                $post4 = array( 'post_thumbnail' => $attachment2_id );
    155155                $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'author', 'author', $post_id, $post4 ) );
    156                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     156                $this->assertNotIXRError( $result );
    157157                $this->assertEquals( $attachment2_id, get_post_meta( $post_id, '_thumbnail_id', true ) );
    158158
    159159                // unset the post's post_thumbnail
    160160                $post5 = array( 'post_thumbnail' => '' );
    161161                $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'author', 'author', $post_id, $post5 ) );
    162                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     162                $this->assertNotIXRError( $result );
    163163                $this->assertEquals( '', get_post_meta( $post_id, '_thumbnail_id', true ) );
    164164
    165165                // use invalid ID
    166166                $post6 = array( 'post_thumbnail' => 398420983409 );
    167167                $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'author', 'author', $post_id, $post6 ) );
    168                 $this->assertInstanceOf( 'IXR_Error', $result );
     168                $this->assertIXRError( $result );
    169169                $this->assertEquals( 404, $result->code );
    170170
    171171                remove_theme_support( 'post-thumbnails' );
    function test_edit_custom_fields() { 
    191191                );
    192192
    193193                $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'contributor', 'contributor', $post_id, $post2 ) );
    194                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     194                $this->assertNotIXRError( $result );
    195195                $this->assertTrue($result);
    196196
    197197                $out = get_post( $post_id );
    function test_capable_unsticky() { 
    213213
    214214                $post2 = array( 'sticky' => false );
    215215                $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, $post2 ) );
    216                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     216                $this->assertNotIXRError( $result );
    217217                $this->assertFalse( is_sticky( $post_id ) );
    218218        }
    219219
    function test_password_transition_unsticky() { 
    225225
    226226                $post2 = array( 'post_password' => 'foobar',  'sticky' => false );
    227227                $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, $post2 ) );
    228                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     228                $this->assertNotIXRError( $result );
    229229                $this->assertFalse( is_sticky( $post_id ) );
    230230        }
    231231
    function test_if_not_modified_since() { 
    245245                // Modify the day old post. In this case, we think it was last modified yesterday.
    246246                $struct = array( 'post_content' => 'First edit', 'if_not_modified_since' => new IXR_Date( $yesterday ) );
    247247                $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, $struct ) );
    248                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     248                $this->assertNotIXRError( $result );
    249249
    250250                // Make sure the edit went through.
    251251                $this->assertEquals( 'First edit', get_post( $post_id )->post_content );
    function test_if_not_modified_since() { 
    253253                // Modify it again. We think it was last modified yesterday, but we actually just modified it above.
    254254                $struct = array( 'post_content' => 'Second edit', 'if_not_modified_since' => new IXR_Date( $yesterday ) );
    255255                $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, $struct ) );
    256                 $this->assertInstanceOf( 'IXR_Error', $result );
     256                $this->assertIXRError( $result );
    257257                $this->assertEquals( 409, $result->code );
    258258
    259259                // Make sure the edit did not go through.
    function test_edit_attachment() { 
    273273
    274274                $struct = array( 'post_content' => 'First edit' );
    275275                $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, $struct ) );
    276                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     276                $this->assertNotIXRError( $result );
    277277
    278278                // Make sure that the post status is still inherit
    279279                $this->assertEquals( 'inherit', get_post( $post_id )->post_status );
    function test_use_invalid_post_status() { 
    290290
    291291                $struct = array( 'post_status' => 'doesnt_exists' );
    292292                $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, $struct ) );
    293                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     293                $this->assertNotIXRError( $result );
    294294
    295295                // Make sure that the post status is still inherit
    296296                $this->assertEquals( 'draft', get_post( $post_id )->post_status );
    function test_loss_of_categories_on_edit() { 
    309309                $this->assertContains( $term_id, $term_ids );
    310310
    311311                $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, array( 'ID' => $post_id, 'post_title' => 'Updated' ) ) );
    312                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     312                $this->assertNotIXRError( $result );
    313313                $this->assertEquals( 'Updated', get_post( $post_id )->post_title );
    314314
    315315                $term_ids = wp_list_pluck( get_the_category( $post_id ), 'term_id' );
    function test_clear_categories_on_edit() { 
    336336                        )
    337337                );
    338338                $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, $new_post_content ) );
    339                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     339                $this->assertNotIXRError( $result );
    340340                $this->assertEquals( 'Updated', get_post( $post_id )->post_title );
    341341
    342342                $term_ids = wp_list_pluck( get_the_category( $post_id ), 'term_id' );
  • tests/phpunit/tests/xmlrpc/wp/editProfile.php

    diff --git a/tests/phpunit/tests/xmlrpc/wp/editProfile.php b/tests/phpunit/tests/xmlrpc/wp/editProfile.php
    index 525f6a5..6e3ced5 100644
    a b class Tests_XMLRPC_wp_editProfile extends WP_XMLRPC_UnitTestCase { 
    88
    99        function test_invalid_username_password() {
    1010                $result = $this->myxmlrpcserver->wp_editProfile( array( 1, 'username', 'password', array() ) );
    11                 $this->assertInstanceOf( 'IXR_Error', $result );
     11                $this->assertIXRError( $result );
    1212                $this->assertEquals( 403, $result->code );
    1313        }
    1414
    function test_subscriber_profile() { 
    2525            'bio' => rand_str(200)
    2626        );
    2727        $result = $this->myxmlrpcserver->wp_editProfile( array( 1, 'subscriber', 'subscriber', $new_data ) );
    28         $this->assertNotInstanceOf( 'IXR_Error', $result );
     28        $this->assertNotIXRError( $result );
    2929        $this->assertTrue( $result );
    3030
    3131        // verify that the new values were stored
    function test_ignore_password_change() { 
    4545        $new_data = array( 'password' => $new_pass );
    4646
    4747        $result = $this->myxmlrpcserver->wp_editProfile( array( 1, 'author', 'author', $new_data ) );
    48         $this->assertNotInstanceOf( 'IXR_Error', $result );
     48        $this->assertNotIXRError( $result );
    4949        $this->assertTrue( $result );
    5050
    5151        $auth_old = wp_authenticate( 'author', 'author' );
    function test_ignore_email_change() { 
    6060        $new_data = array( 'email' => $new_email );
    6161
    6262        $result = $this->myxmlrpcserver->wp_editProfile( array( 1, 'editor', 'editor', $new_data ) );
    63         $this->assertNotInstanceOf( 'IXR_Error', $result );
     63        $this->assertNotIXRError( $result );
    6464        $this->assertTrue( $result );
    6565
    6666        $user_data = get_userdata( $editor_id );
  • tests/phpunit/tests/xmlrpc/wp/editTerm.php

    diff --git a/tests/phpunit/tests/xmlrpc/wp/editTerm.php b/tests/phpunit/tests/xmlrpc/wp/editTerm.php
    index b3f22d2..1e62de9 100644
    a b public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) { 
    2222
    2323        function test_invalid_username_password() {
    2424                $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'username', 'password', 'category', 1 ) );
    25                 $this->assertInstanceOf( 'IXR_Error', $result );
     25                $this->assertIXRError( $result );
    2626                $this->assertEquals( 403, $result->code );
    2727        }
    2828
    function test_empty_taxonomy() { 
    3030                $this->make_user_by_role( 'subscriber' );
    3131
    3232                $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'subscriber', 'subscriber', '', array( 'taxonomy' => '' ) ) );
    33                 $this->assertInstanceOf( 'IXR_Error', $result );
     33                $this->assertIXRError( $result );
    3434                $this->assertEquals( 403, $result->code );
    3535                $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message );
    3636        }
    function test_invalid_taxonomy() { 
    3939                $this->make_user_by_role( 'subscriber' );
    4040
    4141                $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'subscriber', 'subscriber', self::$parent_term, array( 'taxonomy' => 'not_existing' ) ) );
    42                 $this->assertInstanceOf( 'IXR_Error', $result );
     42                $this->assertIXRError( $result );
    4343                $this->assertEquals( 403, $result->code );
    4444                $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message );
    4545        }
    function test_incapable_user() { 
    4848                $this->make_user_by_role( 'subscriber' );
    4949
    5050                $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'subscriber', 'subscriber', self::$parent_term, array( 'taxonomy' => 'category' ) ) );
    51                 $this->assertInstanceOf( 'IXR_Error', $result );
     51                $this->assertIXRError( $result );
    5252                $this->assertEquals( 401, $result->code );
    5353                $this->assertEquals( __( 'Sorry, you are not allowed to edit this term.' ), $result->message );
    5454        }
    function test_term_not_exists() { 
    5757                $this->make_user_by_role( 'editor' );
    5858
    5959                $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', 9999, array( 'taxonomy' => 'category' ) ) );
    60                 $this->assertInstanceOf( 'IXR_Error', $result );
     60                $this->assertIXRError( $result );
    6161                $this->assertEquals( 404, $result->code );
    6262                $this->assertEquals(  __( 'Invalid term ID.' ), $result->message );
    6363        }
    function test_empty_term() { 
    6666                $this->make_user_by_role( 'editor' );
    6767
    6868                $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', '', array( 'taxonomy' => 'category' ) ) );
    69                 $this->assertInstanceOf( 'IXR_Error', $result );
     69                $this->assertIXRError( $result );
    7070                $this->assertEquals( 500, $result->code );
    7171                $this->assertEquals( __('Empty Term'), $result->message );
    7272        }
    function test_empty_term_name() { 
    7575                $this->make_user_by_role( 'editor' );
    7676
    7777                $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$parent_term, array( 'taxonomy' => 'category', 'name' => '' ) ) );
    78                 $this->assertInstanceOf( 'IXR_Error', $result );
     78                $this->assertIXRError( $result );
    7979                $this->assertEquals( 403, $result->code );
    8080                $this->assertEquals( __( 'The term name cannot be empty.' ), $result->message );
    8181        }
    function test_parent_for_nonhierarchical() { 
    8484                $this->make_user_by_role( 'editor' );
    8585
    8686                $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$post_tag, array( 'taxonomy' => 'post_tag', 'parent' => self::$parent_term ) ) );
    87                 $this->assertInstanceOf( 'IXR_Error', $result );
     87                $this->assertIXRError( $result );
    8888                $this->assertEquals( 403, $result->code );
    8989                $this->assertEquals( __( "This taxonomy is not hierarchical so you can't set a parent." ), $result->message );
    9090        }
    function test_parent_empty() { 
    9393                $this->make_user_by_role( 'editor' );
    9494
    9595                $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$child_term, array( 'taxonomy' => 'category', 'parent' => '', 'name' => 'test' ) ) );
    96                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     96                $this->assertNotIXRError( $result );
    9797                $this->assertTrue( $result );
    9898        }
    9999
    function test_parent_null() { 
    102102
    103103                $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$child_term, array( 'taxonomy' => 'category', 'parent' => NULL, 'name' => 'test' ) ) );
    104104
    105                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     105                $this->assertNotIXRError( $result );
    106106                $this->assertInternalType( 'boolean', $result );
    107107
    108108                $term = get_term( self::$child_term, 'category' );
    function test_parent_invalid() { 
    113113                $this->make_user_by_role( 'editor' );
    114114
    115115                $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$child_term, array( 'taxonomy' => 'category', 'parent' => 'dasda', 'name' => 'test' ) ) );
    116                 $this->assertInstanceOf( 'IXR_Error', $result );
     116                $this->assertIXRError( $result );
    117117                $this->assertEquals( 500, $result->code );
    118118        }
    119119
    function test_parent_not_existing() { 
    121121                $this->make_user_by_role( 'editor' );
    122122
    123123                $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$child_term, array( 'taxonomy' => 'category', 'parent' => 9999, 'name' => 'test' ) ) );
    124                 $this->assertInstanceOf( 'IXR_Error', $result );
     124                $this->assertIXRError( $result );
    125125                $this->assertEquals( 403, $result->code );
    126126                $this->assertEquals( __( 'Parent term does not exist.' ), $result->message );
    127127        }
    function test_parent_duplicate_slug() { 
    131131
    132132                $parent_term = get_term_by( 'id', self::$parent_term, 'category' );
    133133                $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$child_term, array( 'taxonomy' => 'category', 'slug' => $parent_term->slug ) ) );
    134                 $this->assertInstanceOf( 'IXR_Error', $result );
     134                $this->assertIXRError( $result );
    135135                $this->assertEquals( 500, $result->code );
    136136                $this->assertEquals( htmlspecialchars( sprintf( __('The slug &#8220;%s&#8221; is already in use by another term'), $parent_term->slug ) ), $result->message );
    137137        }
    function test_edit_all_fields() { 
    142142                $fields = array( 'taxonomy' => 'category', 'name' => 'Child 2', 'parent' => self::$parent_term, 'description' => 'Child term', 'slug' => 'child_2' );
    143143                $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$child_term, $fields ) );
    144144
    145                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     145                $this->assertNotIXRError( $result );
    146146                $this->assertInternalType( 'boolean', $result );
    147147        }
    148148}
  • tests/phpunit/tests/xmlrpc/wp/getComment.php

    diff --git a/tests/phpunit/tests/xmlrpc/wp/getComment.php b/tests/phpunit/tests/xmlrpc/wp/getComment.php
    index d66ccd8..57ad899 100644
    a b public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) { 
    3535
    3636        function test_invalid_username_password() {
    3737                $result = $this->myxmlrpcserver->wp_getComment( array( 1, 'username', 'password', self::$parent_comment_id ) );
    38                 $this->assertInstanceOf( 'IXR_Error', $result );
     38                $this->assertIXRError( $result );
    3939                $this->assertEquals( 403, $result->code );
    4040        }
    4141
    function test_incapable_user() { 
    4343                $this->make_user_by_role( 'contributor' );
    4444
    4545                $result = $this->myxmlrpcserver->wp_getComment( array( 1, 'contributor', 'contributor', self::$parent_comment_id ) );
    46                 $this->assertInstanceOf( 'IXR_Error', $result );
     46                $this->assertIXRError( $result );
    4747                $this->assertEquals( 403, $result->code );
    4848        }
    4949
    function test_valid_comment() { 
    5151                $this->make_user_by_role( 'editor' );
    5252
    5353                $result = $this->myxmlrpcserver->wp_getComment( array( 1, 'editor', 'editor', self::$parent_comment_id ) );
    54                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     54                $this->assertNotIXRError( $result );
    5555
    5656                // Check data types
    5757                $this->assertInternalType( 'string', $result['user_id'] );
    function test_valid_child_comment() { 
    8787                $this->make_user_by_role( 'editor' );
    8888
    8989                $result = $this->myxmlrpcserver->wp_getComment( array( 1, 'editor', 'editor', self::$child_comment_id ) );
    90                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     90                $this->assertNotIXRError( $result );
    9191
    9292                $this->assertEquals( self::$child_comment_id, $result['comment_id'] );
    9393                $this->assertEquals( self::$parent_comment_id, $result['parent'] );
    function test_invalid_id() { 
    9797                $this->make_user_by_role( 'editor' );
    9898
    9999                $result = $this->myxmlrpcserver->wp_getComment( array( 1, 'editor', 'editor', 123456789 ) );
    100                 $this->assertInstanceOf( 'IXR_Error', $result );
     100                $this->assertIXRError( $result );
    101101                $this->assertEquals( 404, $result->code );
    102102        }
    103103}
     104 No newline at end of file
  • tests/phpunit/tests/xmlrpc/wp/getComments.php

    diff --git a/tests/phpunit/tests/xmlrpc/wp/getComments.php b/tests/phpunit/tests/xmlrpc/wp/getComments.php
    index a4bdf22..49b7253 100644
    a b class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase { 
    88
    99        function test_invalid_username_password() {
    1010                $result = $this->myxmlrpcserver->wp_getComments( array( 1, 'username', 'password', array() ) );
    11                 $this->assertInstanceOf( 'IXR_Error', $result );
     11                $this->assertIXRError( $result );
    1212                $this->assertEquals( 403, $result->code );
    1313        }
    1414
    function test_incapable_user() { 
    1616                $this->make_user_by_role( 'contributor' );
    1717
    1818                $result = $this->myxmlrpcserver->wp_getComments( array( 1, 'contributor', 'contributor', array() ) );
    19                 $this->assertInstanceOf( 'IXR_Error', $result );
     19                $this->assertIXRError( $result );
    2020                $this->assertEquals( 401, $result->code );
    2121        }
    2222
    function test_capable_user() { 
    2727                $this->make_user_by_role( 'editor' );
    2828
    2929                $results = $this->myxmlrpcserver->wp_getComments( array( 1, 'editor', 'editor', array() ) );
    30                 $this->assertNotInstanceOf( 'IXR_Error', $results );
     30                $this->assertNotIXRError( $results );
    3131
    3232                foreach( $results as $result ) {
    3333                        $comment = get_comment( $result['comment_id'], ARRAY_A );
    function test_post_filter() { 
    4444                $results = $this->myxmlrpcserver->wp_getComments( array( 1, 'editor', 'editor', array(
    4545                        'post_id' => $this->post_id
    4646                ) ) );
    47                 $this->assertNotInstanceOf( 'IXR_Error', $results );
     47                $this->assertNotIXRError( $results );
    4848
    4949                foreach( $results as $result ) {
    5050                        $this->assertEquals( $this->post_id, $result['post_id'] );
    function test_number_filter() { 
    6060                $results = $this->myxmlrpcserver->wp_getComments( array( 1, 'editor', 'editor', array(
    6161                        'post_id' => $this->post_id,
    6262                ) ) );
    63                 $this->assertNotInstanceOf( 'IXR_Error', $results );
     63                $this->assertNotIXRError( $results );
    6464
    6565                // if no 'number' filter is specified, default should be 10
    6666                $this->assertCount( 10, $results );
    function test_number_filter() { 
    6969                        'post_id' => $this->post_id,
    7070                        'number' => 5
    7171                ) ) );
    72                 $this->assertNotInstanceOf( 'IXR_Error', $results2 );
     72                $this->assertNotIXRError( $results2 );
    7373                $this->assertCount( 5, $results2 );
    7474        }
    7575
    function test_contributor_capabilities() { 
    104104                ) );
    105105
    106106                $result = $this->myxmlrpcserver->wp_getComments( array( 1, 'contributor', 'contributor' ) );
    107                 $this->assertInstanceOf( 'IXR_Error', $result );
     107                $this->assertIXRError( $result );
    108108                $this->assertEquals( 401, $result->code );
    109109        }
    110110
    function test_author_capabilities() { 
    140140                $result1 = $this->myxmlrpcserver->wp_getComments( array( 1, 'author', 'author', array(
    141141                        'post_id' => $author_post_id
    142142                ) ) );
    143                 $this->assertInstanceOf( 'IXR_Error', $result1 );
     143                $this->assertIXRError( $result1 );
    144144
    145145                $result2 = $this->myxmlrpcserver->wp_getComments( array( 1, 'author', 'author', array(
    146146                        'status' => 'approve',
    function test_author_capabilities() { 
    153153                $result3 = $this->myxmlrpcserver->wp_getComments( array( 1, 'author', 'author', array(
    154154                        'post_id' => $editor_post_id
    155155                ) ) );
    156                 $this->assertInstanceOf( 'IXR_Error', $result3 );
     156                $this->assertIXRError( $result3 );
    157157
    158158                $result4 = $this->myxmlrpcserver->wp_getComments( array( 1, 'author', 'author', array(
    159159                        'status' => 'approve',
  • tests/phpunit/tests/xmlrpc/wp/getMediaItem.php

    diff --git a/tests/phpunit/tests/xmlrpc/wp/getMediaItem.php b/tests/phpunit/tests/xmlrpc/wp/getMediaItem.php
    index 7b99dd5..a091f1c 100644
    a b function tearDown() { 
    3838
    3939        function test_invalid_username_password() {
    4040                $result = $this->myxmlrpcserver->wp_getMediaItem( array( 1, 'username', 'password', 0 ) );
    41                 $this->assertInstanceOf( 'IXR_Error', $result );
     41                $this->assertIXRError( $result );
    4242                $this->assertEquals( 403, $result->code );
    4343        }
    4444
    function test_valid_media_item() { 
    4747
    4848                $fields = array( 'post' );
    4949                $result = $this->myxmlrpcserver->wp_getMediaItem( array( 1, 'author', 'author', $this->attachment_id, $fields ) );
    50                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     50                $this->assertNotIXRError( $result );
    5151
    5252                // Check data types
    5353                $this->assertInternalType( 'string', $result['attachment_id'] );
  • tests/phpunit/tests/xmlrpc/wp/getOptions.php

    diff --git a/tests/phpunit/tests/xmlrpc/wp/getOptions.php b/tests/phpunit/tests/xmlrpc/wp/getOptions.php
    index 8b095f6..0dffcff 100644
    a b class Tests_XMLRPC_wp_getOptions extends WP_XMLRPC_UnitTestCase { 
    77
    88        function test_invalid_username_password() {
    99                $result = $this->myxmlrpcserver->wp_getOptions( array( 1, 'username', 'password' ) );
    10                 $this->assertInstanceOf( 'IXR_Error', $result );
     10                $this->assertIXRError( $result );
    1111                $this->assertEquals( 403, $result->code );
    1212        }
    1313
  • tests/phpunit/tests/xmlrpc/wp/getPage.php

    diff --git a/tests/phpunit/tests/xmlrpc/wp/getPage.php b/tests/phpunit/tests/xmlrpc/wp/getPage.php
    index 0f377b1..eb57239 100644
    a b public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) { 
    2020
    2121        function test_invalid_username_password() {
    2222                $result = $this->myxmlrpcserver->wp_getPage( array( 1, self::$post_id, 'username', 'password' ) );
    23                 $this->assertInstanceOf( 'IXR_Error', $result );
     23                $this->assertIXRError( $result );
    2424                $this->assertEquals( 403, $result->code );
    2525        }
    2626
    function test_invalid_pageid() { 
    3131                $this->make_user_by_role( 'editor' );
    3232
    3333                $result = $this->myxmlrpcserver->wp_getPage( array( 1, 9999, 'editor', 'editor' ) );
    34                 $this->assertInstanceOf( 'IXR_Error', $result );
     34                $this->assertIXRError( $result );
    3535                $this->assertEquals( 404, $result->code );
    3636        }
    3737
    function test_valid_page() { 
    3939                $this->make_user_by_role( 'editor' );
    4040
    4141                $result = $this->myxmlrpcserver->wp_getPage( array( 1, self::$post_id, 'editor', 'editor' ) );
    42                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     42                $this->assertNotIXRError( $result );
    4343
    4444                // Check data types
    4545                $this->assertInternalType( 'string', $result['userid'] );
    function test_date() { 
    8080                $this->make_user_by_role( 'editor' );
    8181
    8282                $result = $this->myxmlrpcserver->wp_getPage( array( 1, self::$post_id, 'editor', 'editor' ) );
    83                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     83                $this->assertNotIXRError( $result );
    8484
    8585                $this->assertInstanceOf( 'IXR_Date', $result['dateCreated'] );
    8686                $this->assertInstanceOf( 'IXR_Date', $result['date_created_gmt'] );
  • tests/phpunit/tests/xmlrpc/wp/getPageList.php

    diff --git a/tests/phpunit/tests/xmlrpc/wp/getPageList.php b/tests/phpunit/tests/xmlrpc/wp/getPageList.php
    index ef8f793..0e924c4 100644
    a b public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) { 
    2020
    2121        function test_invalid_username_password() {
    2222                $result = $this->myxmlrpcserver->wp_getPageList( array( 1, 'username', 'password' ) );
    23                 $this->assertInstanceOf( 'IXR_Error', $result );
     23                $this->assertIXRError( $result );
    2424                $this->assertEquals( 403, $result->code );
    2525        }
    2626
    function test_incapable_user() { 
    2828                $this->make_user_by_role( 'contributor' );
    2929
    3030                $result = $this->myxmlrpcserver->wp_getPageList( array( 1, 'contributor', 'contributor' ) );
    31                 $this->assertInstanceOf( 'IXR_Error', $result );
     31                $this->assertIXRError( $result );
    3232                $this->assertEquals( 401, $result->code );
    3333        }
    3434
    function test_date() { 
    3636                $this->make_user_by_role( 'editor' );
    3737
    3838                $results = $this->myxmlrpcserver->wp_getPageList( array( 1, 'editor', 'editor' ) );
    39                 $this->assertNotInstanceOf( 'IXR_Error', $results );
     39                $this->assertNotIXRError( $results );
    4040
    4141                foreach( $results as $result ) {
    4242                        $page = get_post( $result->page_id );
  • tests/phpunit/tests/xmlrpc/wp/getPages.php

    diff --git a/tests/phpunit/tests/xmlrpc/wp/getPages.php b/tests/phpunit/tests/xmlrpc/wp/getPages.php
    index 4242387..f528d83 100644
    a b public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) { 
    2626
    2727        function test_invalid_username_password() {
    2828                $result = $this->myxmlrpcserver->wp_getPages( array( 1, 'username', 'password' ) );
    29                 $this->assertInstanceOf( 'IXR_Error', $result );
     29                $this->assertIXRError( $result );
    3030                $this->assertEquals( 403, $result->code );
    3131        }
    3232
    function test_incapable_user() { 
    3434                $this->make_user_by_role( 'contributor' );
    3535
    3636                $result = $this->myxmlrpcserver->wp_getPages( array( 1, 'contributor', 'contributor' ) );
    37                 $this->assertInstanceOf( 'IXR_Error', $result );
     37                $this->assertIXRError( $result );
    3838                $this->assertEquals( 401, $result->code );
    3939        }
    4040
    4141        function test_capable_user() {
    4242                $results = $this->myxmlrpcserver->wp_getPages( array( 1, 'administrator', 'administrator' ) );
    43                 $this->assertNotInstanceOf( 'IXR_Error', $results );
     43                $this->assertNotIXRError( $results );
    4444
    4545                foreach( $results as $result ) {
    4646                        $page = get_post( $result['page_id'] );
    function test_semi_capable_user() { 
    6565                add_filter( 'map_meta_cap', array( $this, 'remove_editor_edit_page_cap') , 10, 4 );
    6666
    6767                $results = $this->myxmlrpcserver->wp_getPages( array( 1, 'editor', 'editor' ) );
    68                 $this->assertNotInstanceOf( 'IXR_Error', $results );
     68                $this->assertNotIXRError( $results );
    6969
    7070                $found_incapable = false;
    7171                foreach( $results as $result ) {
    7272                        // WP#20629
    73                         $this->assertNotInstanceOf( 'IXR_Error', $result );
     73                        $this->assertNotIXRError( $result );
    7474
    7575                        if ( $result['page_id'] == self::$post_id ) {
    7676                                $found_incapable = true;
  • tests/phpunit/tests/xmlrpc/wp/getPost.php

    diff --git a/tests/phpunit/tests/xmlrpc/wp/getPost.php b/tests/phpunit/tests/xmlrpc/wp/getPost.php
    index 6e6ecae..b33f8a3 100644
    a b function setUp() { 
    2727
    2828        function test_invalid_username_password() {
    2929                $result = $this->myxmlrpcserver->wp_getPost( array( 1, 'username', 'password', 1 ) );
    30                 $this->assertInstanceOf( 'IXR_Error', $result );
     30                $this->assertIXRError( $result );
    3131                $this->assertEquals( 403, $result->code );
    3232        }
    3333
    function test_valid_post() { 
    3636
    3737                $fields = array( 'post', 'custom_fields' );
    3838                $result = $this->myxmlrpcserver->wp_getPost( array( 1, 'author', 'author', $this->post_id, $fields ) );
    39                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     39                $this->assertNotIXRError( $result );
    4040
    4141                // Check data types
    4242                $this->assertInternalType( 'string', $result['post_id'] );
    function test_valid_post() { 
    7979        function test_no_fields() {
    8080                $fields = array();
    8181                $result = $this->myxmlrpcserver->wp_getPost( array( 1, 'author', 'author', $this->post_id, $fields ) );
    82                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     82                $this->assertNotIXRError( $result );
    8383
    8484                // when no fields are requested, only the IDs should be returned
    8585                $this->assertEquals( 1, count( $result ) );
    function test_no_fields() { 
    8888
    8989        function test_default_fields() {
    9090                $result = $this->myxmlrpcserver->wp_getPost( array( 1, 'author', 'author', $this->post_id ) );
    91                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     91                $this->assertNotIXRError( $result );
    9292
    9393                $this->assertArrayHasKey( 'post_id', $result );
    9494                $this->assertArrayHasKey( 'link', $result ); // random field from 'posts' group
    function test_default_fields() { 
    9999        function test_date() {
    100100                $fields = array( 'post' );
    101101                $result = $this->myxmlrpcserver->wp_getPost( array( 1, 'author', 'author', $this->post_id, $fields ) );
    102                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     102                $this->assertNotIXRError( $result );
    103103
    104104                $this->assertInstanceOf( 'IXR_Date', $result['post_date'] );
    105105                $this->assertInstanceOf( 'IXR_Date', $result['post_date_gmt'] );
    function test_valid_page() { 
    130130                ) );
    131131
    132132                $result = $this->myxmlrpcserver->wp_getPost( array( 1, 'editor', 'editor', $child_page_id ) );
    133                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     133                $this->assertNotIXRError( $result );
    134134
    135135                $this->assertInternalType( 'string', $result['post_id'] );
    136136                $this->assertInternalType( 'string', $result['post_parent'] );
  • tests/phpunit/tests/xmlrpc/wp/getPostType.php

    diff --git a/tests/phpunit/tests/xmlrpc/wp/getPostType.php b/tests/phpunit/tests/xmlrpc/wp/getPostType.php
    index a00dbda..cef0fd6 100644
    a b function tearDown() { 
    3131
    3232        function test_invalid_username_password() {
    3333                $result = $this->myxmlrpcserver->wp_getPostType( array( 1, 'username', 'password', 'post' ) );
    34                 $this->assertInstanceOf( 'IXR_Error', $result );
     34                $this->assertIXRError( $result );
    3535                $this->assertEquals( 403, $result->code );
    3636        }
    3737
    function test_invalid_post_type_name() { 
    3939                $this->make_user_by_role( 'editor' );
    4040
    4141                $result = $this->myxmlrpcserver->wp_getPostType( array( 1, 'editor', 'editor', 'foobar' ) );
    42                 $this->assertInstanceOf( 'IXR_Error', $result );
     42                $this->assertIXRError( $result );
    4343                $this->assertEquals( 403, $result->code );
    4444        }
    4545
    function test_valid_post_type_name() { 
    4747                $this->make_user_by_role( 'editor' );
    4848
    4949                $result = $this->myxmlrpcserver->wp_getPostType( array( 1, 'editor', 'editor', 'post' ) );
    50                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     50                $this->assertNotIXRError( $result );
    5151        }
    5252
    5353        function test_incapable_user() {
    5454                $this->make_user_by_role( 'subscriber' );
    5555
    5656                $result = $this->myxmlrpcserver->wp_getPostType( array( 1, 'subscriber', 'subscriber', 'post' ) );
    57                 $this->assertInstanceOf( 'IXR_Error', $result );
     57                $this->assertIXRError( $result );
    5858                $this->assertEquals( 401, $result->code );
    5959        }
    6060
    function test_valid_type() { 
    6262                $this->make_user_by_role( 'editor' );
    6363
    6464                $result = $this->myxmlrpcserver->wp_getPostType( array( 1, 'editor', 'editor', $this->cpt_name, array( 'labels', 'cap', 'menu', 'taxonomies' ) ) );
    65                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     65                $this->assertNotIXRError( $result );
    6666
    6767                // check data types
    6868                $this->assertInternalType( 'string', $result['name'] );
  • tests/phpunit/tests/xmlrpc/wp/getPostTypes.php

    diff --git a/tests/phpunit/tests/xmlrpc/wp/getPostTypes.php b/tests/phpunit/tests/xmlrpc/wp/getPostTypes.php
    index ae78a5d..7188411 100644
    a b  
    66class Tests_XMLRPC_wp_getPostTypes extends WP_XMLRPC_UnitTestCase {
    77        function test_invalid_username_password() {
    88                $result = $this->myxmlrpcserver->wp_getPostTypes( array( 1, 'username', 'password', 'post' ) );
    9                 $this->assertInstanceOf( 'IXR_Error', $result );
     9                $this->assertIXRError( $result );
    1010                $this->assertEquals( 403, $result->code );
    1111        }
    1212
    function test_incapable_user() { 
    1414                $this->make_user_by_role( 'subscriber' );
    1515
    1616                $result = $this->myxmlrpcserver->wp_getPostTypes( array( 1, 'subscriber', 'subscriber' ) );
    17                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     17                $this->assertNotIXRError( $result );
    1818                $this->assertInternalType( 'array', $result );
    1919                $this->assertEquals( 0, count( $result ) );
    2020        }
    function test_capable_user() { 
    2323                $this->make_user_by_role( 'editor' );
    2424
    2525                $result = $this->myxmlrpcserver->wp_getPostTypes( array( 1, 'editor', 'editor' ) );
    26                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     26                $this->assertNotIXRError( $result );
    2727                $this->assertInternalType( 'array', $result );
    2828                $this->assertGreaterThan( 0, count( $result ) );
    2929        }
    function test_simple_filter() { 
    3232                $this->make_user_by_role( 'editor' );
    3333
    3434                $result = $this->myxmlrpcserver->wp_getPostTypes( array( 1, 'editor', 'editor', array( 'hierarchical' => true ) ) );
    35                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     35                $this->assertNotIXRError( $result );
    3636                $this->assertInternalType( 'array', $result );
    3737
    3838                // verify that pages is in the result, and post is not
  • tests/phpunit/tests/xmlrpc/wp/getPosts.php

    diff --git a/tests/phpunit/tests/xmlrpc/wp/getPosts.php b/tests/phpunit/tests/xmlrpc/wp/getPosts.php
    index 3119fea..28d3c4b 100644
    a b class Tests_XMLRPC_wp_getPosts extends WP_XMLRPC_UnitTestCase { 
    77
    88        function test_invalid_username_password() {
    99                $result = $this->myxmlrpcserver->wp_getPosts( array( 1, 'username', 'password' ) );
    10                 $this->assertInstanceOf( 'IXR_Error', $result );
     10                $this->assertIXRError( $result );
    1111                $this->assertEquals( 403, $result->code );
    1212        }
    1313
    function test_incapable_user() { 
    1818                $this->make_user_by_role( 'subscriber' );
    1919
    2020                $result = $this->myxmlrpcserver->wp_getPosts( array( 1, 'subscriber', 'subscriber' ) );
    21                 $this->assertInstanceOf( 'IXR_Error', $result );
     21                $this->assertIXRError( $result );
    2222                $this->assertEquals( 401, $result->code );
    2323
    2424                $filter = array( 'post_type' => 'page' );
    2525                $result = $this->myxmlrpcserver->wp_getPosts( array( 1, 'subscriber', 'subscriber', $filter ) );
    26                 $this->assertInstanceOf( 'IXR_Error', $result );
     26                $this->assertIXRError( $result );
    2727                $this->assertEquals( 401, $result->code );
    2828        }
    2929
    function test_capable_user() { 
    3131                $this->make_user_by_role( 'editor' );
    3232
    3333                $result = $this->myxmlrpcserver->wp_getPosts( array( 1, 'editor', 'editor' ) );
    34                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     34                $this->assertNotIXRError( $result );
    3535        }
    3636
    3737        function test_invalid_post_type() {
    function test_invalid_post_type() { 
    3939
    4040                $filter = array( 'post_type' => 'invalid_post_type_name' );
    4141                $result = $this->myxmlrpcserver->wp_getPosts( array( 1, 'editor', 'editor', $filter ) );
    42                 $this->assertInstanceOf( 'IXR_Error', $result );
     42                $this->assertIXRError( $result );
    4343        }
    4444
    4545        function test_filters() {
    function test_filters() { 
    6262                // get them all
    6363                $filter = array( 'post_type' => $cpt_name, 'number' => $num_posts + 10 );
    6464                $results = $this->myxmlrpcserver->wp_getPosts( array( 1, 'editor', 'editor', $filter ) );
    65                 $this->assertNotInstanceOf( 'IXR_Error', $results );
     65                $this->assertNotIXRError( $results );
    6666                $this->assertEquals( $num_posts, count( $results ) );
    6767
    6868                // page through results
    function test_filters() { 
    8686                // get results ordered by comment count
    8787                $filter2 = array( 'post_type' => $cpt_name, 'number' => $num_posts, 'orderby' => 'comment_count', 'order' => 'DESC' );
    8888                $results2 = $this->myxmlrpcserver->wp_getPosts( array( 1, 'editor', 'editor', $filter2 ) );
    89                 $this->assertNotInstanceOf( 'IXR_Error', $results2 );
     89                $this->assertNotIXRError( $results2 );
    9090                $last_comment_count = 100;
    9191                foreach ( $results2 as $post ) {
    9292                        $comment_count = intval( get_comments_number( $post['post_id'] ) );
    function test_filters() { 
    100100                wp_update_post( $post );
    101101                $filter3 = array( 'post_type' => $cpt_name, 'post_status' => 'draft' );
    102102                $results3 = $this->myxmlrpcserver->wp_getPosts( array( 1, 'editor', 'editor', $filter3 ) );
    103                 $this->assertNotInstanceOf( 'IXR_Error', $results3 );
     103                $this->assertNotIXRError( $results3 );
    104104                $this->assertEquals( 1, count( $results3 ) );
    105105                $this->assertEquals( $post->ID, $results3[0]['post_id'] );
    106106
    function test_fields() { 
    113113
    114114                // check default fields
    115115                $results = $this->myxmlrpcserver->wp_getPosts( array( 1, 'editor', 'editor' ) );
    116                 $this->assertNotInstanceOf( 'IXR_Error', $results );
     116                $this->assertNotIXRError( $results );
    117117                $expected_fields = array( 'post_id', 'post_title', 'terms', 'custom_fields', 'link' ); // subset of expected fields
    118118                foreach( $expected_fields as $field ) {
    119119                        $this->assertArrayHasKey( $field, $results[0] );
    function test_fields() { 
    123123                $filter = array();
    124124                $fields = array( 'post_name', 'post_author', 'enclosure' );
    125125                $results2 = $this->myxmlrpcserver->wp_getPosts( array( 1, 'editor', 'editor', $filter, $fields ) );
    126                 $this->assertNotInstanceOf( 'IXR_Error', $results2 );
     126                $this->assertNotIXRError( $results2 );
    127127                $expected_fields = array_merge( $fields, array( 'post_id' ) );
    128128                foreach ( array_keys( $results2[0] ) as $field ) {
    129129                        $this->assertContains( $field, $expected_fields );
    function test_search() { 
    142142                // Search for none of them
    143143                $filter = array( 's' => 'Third' );
    144144                $results = $this->myxmlrpcserver->wp_getPosts( array( 1, 'editor', 'editor', $filter ) );
    145                 $this->assertNotInstanceOf( 'IXR_Error', $results );
     145                $this->assertNotIXRError( $results );
    146146                $this->assertEquals( 0, count( $results ) );
    147147
    148148                // Search for one of them
    149149                $filter = array( 's' => 'First:' );
    150150                $results = $this->myxmlrpcserver->wp_getPosts( array( 1, 'editor', 'editor', $filter ) );
    151                 $this->assertNotInstanceOf( 'IXR_Error', $results );
     151                $this->assertNotIXRError( $results );
    152152                $this->assertEquals( 1, count( $results ) );
    153153        }
    154154
  • tests/phpunit/tests/xmlrpc/wp/getProfile.php

    diff --git a/tests/phpunit/tests/xmlrpc/wp/getProfile.php b/tests/phpunit/tests/xmlrpc/wp/getProfile.php
    index cc2da3e..86fd821 100644
    a b class Tests_XMLRPC_wp_getProfile extends WP_XMLRPC_UnitTestCase { 
    88
    99        function test_invalid_username_password() {
    1010                $result = $this->myxmlrpcserver->wp_getProfile( array( 1, 'username', 'password' ) );
    11                 $this->assertInstanceOf( 'IXR_Error', $result );
     11                $this->assertIXRError( $result );
    1212                $this->assertEquals( 403, $result->code );
    1313        }
    1414
    function test_subscriber() { 
    1616                $subscriber_id = $this->make_user_by_role( 'subscriber' );
    1717
    1818                $result = $this->myxmlrpcserver->wp_getProfile( array( 1, 'subscriber', 'subscriber' ) );
    19                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     19                $this->assertNotIXRError( $result );
    2020                $this->assertEquals( $subscriber_id, $result['user_id'] );
    2121                $this->assertContains( 'subscriber', $result['roles'] );
    2222        }
    function test_administrator() { 
    2525                $administrator_id = $this->make_user_by_role( 'administrator' );
    2626
    2727                $result = $this->myxmlrpcserver->wp_getProfile( array( 1, 'administrator', 'administrator' ) );
    28                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     28                $this->assertNotIXRError( $result );
    2929                $this->assertEquals( $administrator_id, $result['user_id'] );
    3030                $this->assertContains( 'administrator', $result['roles'] );
    3131        }
    function test_arbitrary_fields() { 
    3636                $fields = array( 'email', 'bio', 'user_contacts' );
    3737
    3838                $result = $this->myxmlrpcserver->wp_getProfile( array( 1, 'editor', 'editor', $fields ) );
    39                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     39                $this->assertNotIXRError( $result );
    4040                $this->assertEquals( $editor_id, $result['user_id'] );
    4141
    4242                $expected_fields = array( 'user_id', 'email', 'bio' );
  • tests/phpunit/tests/xmlrpc/wp/getRevisions.php

    diff --git a/tests/phpunit/tests/xmlrpc/wp/getRevisions.php b/tests/phpunit/tests/xmlrpc/wp/getRevisions.php
    index a407c65..d1aad1e 100644
    a b class Tests_XMLRPC_wp_getRevisions extends WP_XMLRPC_UnitTestCase { 
    77
    88        function test_invalid_username_password() {
    99                $result = $this->myxmlrpcserver->wp_getRevisions( array( 1, 'username', 'password', 0 ) );
    10                 $this->assertInstanceOf( 'IXR_Error', $result );
     10                $this->assertIXRError( $result );
    1111                $this->assertEquals( 403, $result->code );
    1212        }
    1313
    function test_incapable_user() { 
    1717                $post_id = self::factory()->post->create();
    1818
    1919                $result = $this->myxmlrpcserver->wp_getRevisions( array( 1, 'subscriber', 'subscriber', $post_id ) );
    20                 $this->assertInstanceOf( 'IXR_Error', $result );
     20                $this->assertIXRError( $result );
    2121                $this->assertEquals( 401, $result->code );
    2222        }
    2323
    function test_capable_user() { 
    2626
    2727                $post_id = self::factory()->post->create();
    2828                $result = $this->myxmlrpcserver->wp_getRevisions( array( 1, 'editor', 'editor', $post_id ) );
    29                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     29                $this->assertNotIXRError( $result );
    3030        }
    3131
    3232        function test_revision_count() {
  • tests/phpunit/tests/xmlrpc/wp/getTaxonomies.php

    diff --git a/tests/phpunit/tests/xmlrpc/wp/getTaxonomies.php b/tests/phpunit/tests/xmlrpc/wp/getTaxonomies.php
    index cd2c86e..97bd9cf 100644
    a b class Tests_XMLRPC_wp_getTaxonomies extends WP_XMLRPC_UnitTestCase { 
    77
    88        function test_invalid_username_password() {
    99                $result = $this->myxmlrpcserver->wp_getTaxonomies( array( 1, 'username', 'password' ) );
    10                 $this->assertInstanceOf( 'IXR_Error', $result );
     10                $this->assertIXRError( $result );
    1111                $this->assertEquals( 403, $result->code );
    1212        }
    1313
    function test_taxonomy_validated() { 
    1515                $this->make_user_by_role( 'editor' );
    1616
    1717                $result = $this->myxmlrpcserver->wp_getTaxonomies( array( 1, 'editor', 'editor' ) );
    18                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     18                $this->assertNotIXRError( $result );
    1919        }
    2020}
     21 No newline at end of file
  • tests/phpunit/tests/xmlrpc/wp/getTaxonomy.php

    diff --git a/tests/phpunit/tests/xmlrpc/wp/getTaxonomy.php b/tests/phpunit/tests/xmlrpc/wp/getTaxonomy.php
    index f8446bc..5ffff80 100644
    a b class Tests_XMLRPC_wp_getTaxonomy extends WP_XMLRPC_UnitTestCase { 
    77
    88        function test_invalid_username_password() {
    99                $result = $this->myxmlrpcserver->wp_getTaxonomy( array( 1, 'username', 'password', 'category' ) );
    10                 $this->assertInstanceOf( 'IXR_Error', $result );
     10                $this->assertIXRError( $result );
    1111                $this->assertEquals( 403, $result->code );
    1212        }
    1313
    function test_empty_taxonomy() { 
    1515                $this->make_user_by_role( 'editor' );
    1616
    1717                $result = $this->myxmlrpcserver->wp_getTaxonomy( array( 1, 'editor', 'editor', '' ) );
    18                 $this->assertInstanceOf( 'IXR_Error', $result );
     18                $this->assertIXRError( $result );
    1919                $this->assertEquals( 403, $result->code );
    2020                $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message );
    2121        }
    function test_invalid_taxonomy() { 
    2424                $this->make_user_by_role( 'editor' );
    2525
    2626                $result = $this->myxmlrpcserver->wp_getTaxonomy( array( 1, 'editor', 'editor', 'not_existing' ) );
    27                 $this->assertInstanceOf( 'IXR_Error', $result );
     27                $this->assertIXRError( $result );
    2828                $this->assertEquals( 403, $result->code );
    2929                $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message );
    3030        }
    function test_incapable_user() { 
    3333                $this->make_user_by_role( 'subscriber' );
    3434
    3535                $result = $this->myxmlrpcserver->wp_getTaxonomy( array( 1, 'subscriber', 'subscriber', 'category' ) );
    36                 $this->assertInstanceOf( 'IXR_Error', $result );
     36                $this->assertIXRError( $result );
    3737                $this->assertEquals( 401, $result->code );
    3838                $this->assertEquals( __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ), $result->message );
    3939        }
    function test_taxonomy_validated() { 
    4242                $this->make_user_by_role( 'editor' );
    4343
    4444                $result = $this->myxmlrpcserver->wp_getTaxonomy( array( 1, 'editor', 'editor', 'category' ) );
    45                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     45                $this->assertNotIXRError( $result );
    4646        }
    4747
    4848        function test_prepare_taxonomy() {
    4949                $this->make_user_by_role( 'editor' );
    5050
    5151                $result = $this->myxmlrpcserver->wp_getTaxonomy( array( 1, 'editor', 'editor', 'category' ) );
    52                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     52                $this->assertNotIXRError( $result );
    5353                $taxonomy = get_taxonomy( 'category' );
    5454                $this->assertEquals( 'category', $result['name'], 'name' );
    5555                $this->assertEquals( true, $result['_builtin'], '_builtin' );
  • tests/phpunit/tests/xmlrpc/wp/getTerm.php

    diff --git a/tests/phpunit/tests/xmlrpc/wp/getTerm.php b/tests/phpunit/tests/xmlrpc/wp/getTerm.php
    index 2edbaeb..fca71a7 100644
    a b public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) { 
    1515
    1616        function test_invalid_username_password() {
    1717                $result = $this->myxmlrpcserver->wp_getTerm( array( 1, 'username', 'password', 'category', 1 ) );
    18                 $this->assertInstanceOf( 'IXR_Error', $result );
     18                $this->assertIXRError( $result );
    1919                $this->assertEquals( 403, $result->code );
    2020        }
    2121
    function test_empty_taxonomy() { 
    2323                $this->make_user_by_role( 'editor' );
    2424
    2525                $result = $this->myxmlrpcserver->wp_getTerm( array( 1, 'editor', 'editor', '', 0 ) );
    26                 $this->assertInstanceOf( 'IXR_Error', $result );
     26                $this->assertIXRError( $result );
    2727                $this->assertEquals( 403, $result->code );
    2828                $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message );
    2929        }
    function test_invalid_taxonomy() { 
    3232                $this->make_user_by_role( 'editor' );
    3333
    3434                $result = $this->myxmlrpcserver->wp_getTerm( array( 1, 'editor', 'editor', 'not_existing', 0 ) );
    35                 $this->assertInstanceOf( 'IXR_Error', $result );
     35                $this->assertIXRError( $result );
    3636                $this->assertEquals( 403, $result->code );
    3737                $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message );
    3838        }
    function test_incapable_user() { 
    4141                $this->make_user_by_role( 'subscriber' );
    4242
    4343                $result = $this->myxmlrpcserver->wp_getTerm( array( 1, 'subscriber', 'subscriber', 'category', self::$term_id ) );
    44                 $this->assertInstanceOf( 'IXR_Error', $result );
     44                $this->assertIXRError( $result );
    4545                $this->assertEquals( 401, $result->code );
    4646                $this->assertEquals( __( 'Sorry, you are not allowed to assign this term.' ), $result->message );
    4747        }
    function test_empty_term() { 
    5151                $this->make_user_by_role( 'editor' );
    5252
    5353                $result = $this->myxmlrpcserver->wp_getTerm( array( 1, 'editor', 'editor', 'category', '' ) );
    54                 $this->assertInstanceOf( 'IXR_Error', $result );
     54                $this->assertIXRError( $result );
    5555                $this->assertEquals( 500, $result->code );
    5656                $this->assertEquals( __('Empty Term'), $result->message );
    5757        }
    function test_invalid_term() { 
    6060                $this->make_user_by_role( 'editor' );
    6161
    6262                $result = $this->myxmlrpcserver->wp_getTerm( array( 1, 'editor', 'editor', 'category', 9999 ) );
    63                 $this->assertInstanceOf( 'IXR_Error', $result );
     63                $this->assertIXRError( $result );
    6464                $this->assertEquals( 404, $result->code );
    6565                $this->assertEquals( __( 'Invalid term ID.' ), $result->message );
    6666        }
    function test_valid_term() { 
    7272
    7373                $result = $this->myxmlrpcserver->wp_getTerm( array( 1, 'editor', 'editor', 'category', self::$term_id ) );
    7474
    75                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     75                $this->assertNotIXRError( $result );
    7676                $this->assertEquals( $result, $term );
    7777
    7878                // Check DataTypes
  • tests/phpunit/tests/xmlrpc/wp/getTerms.php

    diff --git a/tests/phpunit/tests/xmlrpc/wp/getTerms.php b/tests/phpunit/tests/xmlrpc/wp/getTerms.php
    index 1673975..b67cbde 100644
    a b class Tests_XMLRPC_wp_getTerms extends WP_XMLRPC_UnitTestCase { 
    77
    88        function test_invalid_username_password() {
    99                $result = $this->myxmlrpcserver->wp_getTerms( array( 1, 'username', 'password', 'category' ) );
    10                 $this->assertInstanceOf( 'IXR_Error', $result );
     10                $this->assertIXRError( $result );
    1111                $this->assertEquals( 403, $result->code );
    1212        }
    1313
    function test_empty_taxonomy() { 
    1515                $this->make_user_by_role( 'editor' );
    1616
    1717                $result = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', '' ) );
    18                 $this->assertInstanceOf( 'IXR_Error', $result );
     18                $this->assertIXRError( $result );
    1919                $this->assertEquals( 403, $result->code );
    2020                $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message );
    2121        }
    function test_invalid_taxonomy() { 
    2424                $this->make_user_by_role( 'editor' );
    2525
    2626                $result = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', 'not_existing' ) );
    27                 $this->assertInstanceOf( 'IXR_Error', $result );
     27                $this->assertIXRError( $result );
    2828                $this->assertEquals( 403, $result->code );
    2929                $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message );
    3030        }
    function test_incapable_user() { 
    3333                $this->make_user_by_role( 'subscriber' );
    3434
    3535                $result = $this->myxmlrpcserver->wp_getTerms( array( 1, 'subscriber', 'subscriber', 'category' ) );
    36                 $this->assertInstanceOf( 'IXR_Error', $result );
     36                $this->assertIXRError( $result );
    3737                $this->assertEquals( 401, $result->code );
    3838                $this->assertEquals( __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ), $result->message );
    3939        }
    function test_valid_terms() { 
    4545                $cat = wp_insert_term( 'term_' . __FUNCTION__ , 'category' );
    4646
    4747                $results = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', 'category' ) );
    48                 $this->assertNotInstanceOf( 'IXR_Error', $results );
     48                $this->assertNotIXRError( $results );
    4949
    5050                foreach( $results as $term ) {
    5151                        $this->assertInternalType( 'int', $term['count'] );
    function test_custom_taxonomy() { 
    7171
    7272                // test fetching all terms
    7373                $results = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', $tax_name ) );
    74                 $this->assertNotInstanceOf( 'IXR_Error', $results );
     74                $this->assertNotIXRError( $results );
    7575
    7676                $this->assertEquals( $num_terms, count( $results ) );
    7777                foreach ( $results as $term ) {
    function test_custom_taxonomy() { 
    8181                // test paged results
    8282                $filter = array( 'number' => 5 );
    8383                $results2 = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', $tax_name, $filter ) );
    84                 $this->assertNotInstanceOf( 'IXR_Error', $results );
     84                $this->assertNotIXRError( $results );
    8585                $this->assertEquals( 5, count( $results2 ) );
    8686                $this->assertEquals( $results[1]['term_id'], $results2[1]['term_id'] ); // check one of the terms
    8787
    8888                $filter['offset'] = 10;
    8989                $results3 = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', $tax_name, $filter ) );
    90                 $this->assertNotInstanceOf( 'IXR_Error', $results3 );
     90                $this->assertNotIXRError( $results3 );
    9191                $this->assertEquals( $num_terms - 10, count( $results3 ) );
    9292                $this->assertEquals( $results[11]['term_id'], $results3[1]['term_id'] );
    9393
    9494                // test hide_empty (since none have been attached to posts yet, all should be hidden
    9595                $filter = array( 'hide_empty' => true );
    9696                $results4 = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', $tax_name, $filter ) );
    97                 $this->assertNotInstanceOf( 'IXR_Error', $results4 );
     97                $this->assertNotIXRError( $results4 );
    9898                $this->assertEquals( 0, count( $results4 ) );
    9999
    100100                unset($GLOBALS['wp_taxonomies'][$tax_name]);
    function test_term_ordering() { 
    111111
    112112                $filter = array( 'orderby' => 'count', 'order' => 'DESC' );
    113113                $results = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', 'category', $filter ) );
    114                 $this->assertNotInstanceOf( 'IXR_Error', $results );
     114                $this->assertNotIXRError( $results );
    115115                $this->assertNotEquals( 0, count( $results ) );
    116116
    117117                foreach( $results as $term ) {
    function test_terms_search() { 
    133133                // search by full name
    134134                $filter = array( 'search' => $name );
    135135                $results = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', 'category', $filter ) );
    136                 $this->assertNotInstanceOf( 'IXR_Error', $results );
     136                $this->assertNotIXRError( $results );
    137137                $this->assertEquals( 1, count( $results ) );
    138138                $this->assertEquals( $name, $results[0]['name'] );
    139139                $this->assertEquals( $name_id, $results[0]['term_id'] );
    function test_terms_search() { 
    141141                // search by partial name
    142142                $filter = array( 'search' => substr( $name, 0, 10 ) );
    143143                $results2 = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', 'category', $filter ) );
    144                 $this->assertNotInstanceOf( 'IXR_Error', $results2 );
     144                $this->assertNotIXRError( $results2 );
    145145                $this->assertEquals( 1, count( $results2 ) );
    146146                $this->assertEquals( $name, $results2[0]['name'] );
    147147                $this->assertEquals( $name_id, $results2[0]['term_id'] );
  • tests/phpunit/tests/xmlrpc/wp/getUser.php

    diff --git a/tests/phpunit/tests/xmlrpc/wp/getUser.php b/tests/phpunit/tests/xmlrpc/wp/getUser.php
    index acef3c6..beda930 100644
    a b function tearDown() { 
    2525
    2626        function test_invalid_username_password() {
    2727                $result = $this->myxmlrpcserver->wp_getUser( array( 1, 'username', 'password', 1 ) );
    28                 $this->assertInstanceOf( 'IXR_Error', $result );
     28                $this->assertIXRError( $result );
    2929                $this->assertEquals( 403, $result->code );
    3030        }
    3131
    3232        function test_invalid_user() {
    3333                $result = $this->myxmlrpcserver->wp_getUser( array( 1, 'administrator', 'administrator', 34902348908234 ) );
    34                 $this->assertInstanceOf( 'IXR_Error', $result );
     34                $this->assertIXRError( $result );
    3535                $this->assertEquals( 404, $result->code );
    3636        }
    3737
    function test_incapable_user() { 
    4040                $editor_id = $this->make_user_by_role( 'editor' );
    4141
    4242                $result = $this->myxmlrpcserver->wp_getUser( array( 1, 'subscriber', 'subscriber', $editor_id ) );
    43                 $this->assertInstanceOf( 'IXR_Error', $result );
     43                $this->assertIXRError( $result );
    4444                $this->assertEquals( 401, $result->code );
    4545        }
    4646
    function test_subscriber_self() { 
    4848                $subscriber_id = $this->make_user_by_role( 'subscriber' );
    4949
    5050                $result = $this->myxmlrpcserver->wp_getUser( array( 1, 'subscriber', 'subscriber', $subscriber_id ) );
    51                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     51                $this->assertNotIXRError( $result );
    5252                $this->assertEquals( $subscriber_id, $result['user_id'] );
    5353        }
    5454
    function test_valid_user() { 
    7272                $user_id = wp_insert_user( $user_data );
    7373
    7474                $result = $this->myxmlrpcserver->wp_getUser( array( 1, 'administrator', 'administrator', $user_id ) );
    75                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     75                $this->assertNotIXRError( $result );
    7676
    7777                // check data types
    7878                $this->assertInternalType( 'string', $result['user_id'] );
    function test_no_fields() { 
    111111                $editor_id = $this->make_user_by_role( 'editor' );
    112112
    113113                $result = $this->myxmlrpcserver->wp_getUser( array( 1, 'administrator', 'administrator', $editor_id, array() ) );
    114                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     114                $this->assertNotIXRError( $result );
    115115                $this->assertEquals( $editor_id, $result['user_id'] );
    116116
    117117                $expected_fields = array( 'user_id' );
    function test_basic_fields() { 
    122122                $editor_id = $this->make_user_by_role( 'editor' );
    123123
    124124                $result = $this->myxmlrpcserver->wp_getUser( array( 1, 'administrator', 'administrator', $editor_id, array( 'basic' ) ) );
    125                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     125                $this->assertNotIXRError( $result );
    126126                $this->assertEquals( $editor_id, $result['user_id'] );
    127127
    128128                $expected_fields = array( 'user_id', 'username', 'email', 'registered', 'display_name', 'nicename' );
    function test_arbitrary_fields() { 
    138138                $fields = array( 'email', 'bio', 'user_contacts' );
    139139
    140140                $result = $this->myxmlrpcserver->wp_getUser( array( 1, 'administrator', 'administrator', $editor_id, $fields ) );
    141                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     141                $this->assertNotIXRError( $result );
    142142                $this->assertEquals( $editor_id, $result['user_id'] );
    143143
    144144                $expected_fields = array( 'user_id', 'email', 'bio' );
  • tests/phpunit/tests/xmlrpc/wp/getUsers.php

    diff --git a/tests/phpunit/tests/xmlrpc/wp/getUsers.php b/tests/phpunit/tests/xmlrpc/wp/getUsers.php
    index 1860fd1..62169e0 100644
    a b class Tests_XMLRPC_wp_getUsers extends WP_XMLRPC_UnitTestCase { 
    88
    99        function test_invalid_username_password() {
    1010                $results = $this->myxmlrpcserver->wp_getUsers( array( 1, 'username', 'password' ) );
    11                 $this->assertInstanceOf( 'IXR_Error', $results );
     11                $this->assertIXRError( $results );
    1212                $this->assertEquals( 403, $results->code );
    1313        }
    1414
    function test_incapable_user() { 
    1616                $this->make_user_by_role( 'subscriber' );
    1717
    1818                $results = $this->myxmlrpcserver->wp_getUsers( array( 1, 'subscriber', 'subscriber' ) );
    19                 $this->assertInstanceOf( 'IXR_Error', $results );
     19                $this->assertIXRError( $results );
    2020                $this->assertEquals( 401, $results->code );
    2121        }
    2222
    function test_capable_user() { 
    2424                $this->make_user_by_role( 'administrator' );
    2525
    2626                $result = $this->myxmlrpcserver->wp_getUsers( array( 1, 'administrator', 'administrator' ) );
    27                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     27                $this->assertNotIXRError( $result );
    2828
    2929                // check data types
    3030                $this->assertInternalType( 'string', $result[0]['user_id'] );
    function test_invalid_role() { 
    4949
    5050                $filter = array( 'role' => 'invalidrole' );
    5151                $results = $this->myxmlrpcserver->wp_getUsers( array( 1, 'administrator', 'administrator', $filter ) );
    52                 $this->assertInstanceOf( 'IXR_Error', $results );
     52                $this->assertIXRError( $results );
    5353                $this->assertEquals( 403, $results->code );
    5454        }
    5555
    function test_role_filter() { 
    6363                // test a single role ('editor')
    6464                $filter = array( 'role' => 'editor' );
    6565                $results = $this->myxmlrpcserver->wp_getUsers( array( 1, 'administrator', 'administrator', $filter ) );
    66                 $this->assertNotInstanceOf( 'IXR_Error', $results );
     66                $this->assertNotIXRError( $results );
    6767                $this->assertCount( 1, $results );
    6868                $this->assertEquals( $editor_id, $results[0]['user_id'] );
    6969
    7070                // test 'authors', which should return all non-subscribers
    7171                $filter2 = array( 'who' => 'authors' );
    7272                $results2 = $this->myxmlrpcserver->wp_getUsers( array( 1, 'administrator', 'administrator', $filter2 ) );
    73                 $this->assertNotInstanceOf( 'IXR_Error', $results2 );
     73                $this->assertNotIXRError( $results2 );
    7474                $this->assertCount( 3, array_intersect( array( $author_id, $editor_id, $administrator_id ), wp_list_pluck( $results2, 'user_id' ) ) );
    7575        }
    7676
    function test_order_filters() { 
    104104
    105105                $filter = array( 'orderby' => 'email', 'order' => 'ASC' );
    106106                $results = $this->myxmlrpcserver->wp_getUsers( array( 1, 'administrator', 'administrator', $filter ) );
    107                 $this->assertNotInstanceOf( 'IXR_Error', $results );
     107                $this->assertNotIXRError( $results );
    108108
    109109                $last_email = '';
    110110                foreach ( $results as $user ) {
  • tests/phpunit/tests/xmlrpc/wp/newComment.php

    diff --git a/tests/phpunit/tests/xmlrpc/wp/newComment.php b/tests/phpunit/tests/xmlrpc/wp/newComment.php
    index 80e70ef..148c6ac 100644
    a b function test_valid_comment() { 
    1313                        'content' => rand_str( 100 )
    1414                ) ) );
    1515 
    16                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     16                $this->assertNotIXRError( $result );
    1717        }
    1818 
    1919        function test_empty_comment() {
    function test_empty_comment() { 
    2424                        'content' => ''
    2525                ) ) );
    2626 
    27                 $this->assertInstanceOf( 'IXR_Error', $result );
     27                $this->assertIXRError( $result );
    2828                $this->assertEquals( 403, $result->code );
    2929        }
    3030
    function test_new_comment_post_closed() { 
    4040                        'content' => rand_str( 100 ),
    4141                ) ) );
    4242
    43                 $this->assertInstanceOf( 'IXR_Error', $result );
     43                $this->assertIXRError( $result );
    4444                $this->assertEquals( 403, $result->code );
    4545        }
    4646
    function test_new_comment_duplicated() { 
    5454
    5555                // First time it's a valid comment
    5656                $result = $this->myxmlrpcserver->wp_newComment( $comment_args  );
    57                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     57                $this->assertNotIXRError( $result );
    5858
    5959                // Run second time for duplication error
    6060                $result = $this->myxmlrpcserver->wp_newComment( $comment_args );
    6161
    62                 $this->assertInstanceOf( 'IXR_Error', $result );
     62                $this->assertIXRError( $result );
    6363                $this->assertEquals( 403, $result->code );
    6464        }
    6565
  • tests/phpunit/tests/xmlrpc/wp/newPost.php

    diff --git a/tests/phpunit/tests/xmlrpc/wp/newPost.php b/tests/phpunit/tests/xmlrpc/wp/newPost.php
    index 3092aef..1b718bc 100644
    a b class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { 
    77
    88        function test_invalid_username_password() {
    99                $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'username', 'password', array() ) );
    10                 $this->assertInstanceOf( 'IXR_Error', $result );
     10                $this->assertIXRError( $result );
    1111                $this->assertEquals( 403, $result->code );
    1212        }
    1313
    function test_incapable_user() { 
    1515                $this->make_user_by_role( 'subscriber' );
    1616
    1717                $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'subscriber', 'subscriber', array() ) );
    18                 $this->assertInstanceOf( 'IXR_Error', $result );
     18                $this->assertIXRError( $result );
    1919                $this->assertEquals( 401, $result->code );
    2020        }
    2121
    function test_no_content() { 
    2323                $this->make_user_by_role( 'author' );
    2424
    2525                $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'author', 'author', array() ) );
    26                 $this->assertInstanceOf( 'IXR_Error', $result );
     26                $this->assertIXRError( $result );
    2727                $this->assertEquals( 500, $result->code );
    2828                $this->assertEquals( 'Content, title, and excerpt are empty.', $result->message );
    2929        }
    function test_basic_content() { 
    3333
    3434                $post = array( 'post_title' => 'Test' );
    3535                $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'author', 'author', $post ) );
    36                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     36                $this->assertNotIXRError( $result );
    3737                $this->assertStringMatchesFormat( '%d', $result );
    3838        }
    3939
    function test_ignore_id() { 
    4242
    4343                $post = array( 'post_title' => 'Test', 'ID' => 103948 );
    4444                $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'author', 'author', $post ) );
    45                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     45                $this->assertNotIXRError( $result );
    4646                $this->assertNotEquals( '103948', $result );
    4747        }
    4848
    function test_capable_publish() { 
    5151
    5252                $post = array( 'post_title' => 'Test', 'post_status' => 'publish' );
    5353                $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'author', 'author', $post ) );
    54                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     54                $this->assertNotIXRError( $result );
    5555        }
    5656
    5757        function test_incapable_publish() {
    function test_incapable_publish() { 
    5959
    6060                $post = array( 'post_title' => 'Test', 'post_status' => 'publish' );
    6161                $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'contributor', 'contributor', $post ) );
    62                 $this->assertInstanceOf( 'IXR_Error', $result );
     62                $this->assertIXRError( $result );
    6363                $this->assertEquals( 401, $result->code );
    6464        }
    6565
    function test_capable_private() { 
    6868
    6969                $post = array( 'post_title' => 'Test', 'post_status' => 'private' );
    7070                $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post ) );
    71                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     71                $this->assertNotIXRError( $result );
    7272        }
    7373
    7474        function test_incapable_private() {
    function test_incapable_private() { 
    7676
    7777                $post = array( 'post_title' => 'Test', 'post_status' => 'private' );
    7878                $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'contributor', 'contributor', $post ) );
    79                 $this->assertInstanceOf( 'IXR_Error', $result );
     79                $this->assertIXRError( $result );
    8080                $this->assertEquals( 401, $result->code );
    8181        }
    8282
    function test_capable_other_author() { 
    8686
    8787                $post = array( 'post_title' => 'Test', 'post_author' => $other_author_id );
    8888                $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post ) );
    89                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     89                $this->assertNotIXRError( $result );
    9090        }
    9191
    9292        function test_incapable_other_author() {
    function test_incapable_other_author() { 
    9595
    9696                $post = array( 'post_title' => 'Test', 'post_author' => $other_author_id );
    9797                $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'contributor', 'contributor', $post ) );
    98                 $this->assertInstanceOf( 'IXR_Error', $result );
     98                $this->assertIXRError( $result );
    9999                $this->assertEquals( 401, $result->code );
    100100        }
    101101
    function test_invalid_author() { 
    104104
    105105                $post = array( 'post_title' => 'Test', 'post_author' => 99999999 );
    106106                $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post ) );
    107                 $this->assertInstanceOf( 'IXR_Error', $result );
     107                $this->assertIXRError( $result );
    108108                $this->assertEquals( 404, $result->code );
    109109        }
    110110
    function test_empty_author() { 
    113113
    114114                $post = array( 'post_title' => 'Test' );
    115115                $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'author', 'author', $post ) );
    116                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     116                $this->assertNotIXRError( $result );
    117117                $this->assertStringMatchesFormat( '%d', $result );
    118118
    119119                $out = get_post( $result );
    function test_post_thumbnail() { 
    132132
    133133                $post = array( 'post_title' => 'Post Thumbnail Test', 'post_thumbnail' => $attachment_id );
    134134                $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'author', 'author', $post ) );
    135                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     135                $this->assertNotIXRError( $result );
    136136                $this->assertEquals( $attachment_id, get_post_meta( $result, '_thumbnail_id', true ) );
    137137
    138138                remove_theme_support( 'post-thumbnails' );
    function test_invalid_post_status() { 
    143143
    144144                $post = array( 'post_title' => 'Test', 'post_status' => 'foobar_status' );
    145145                $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'author', 'author', $post ) );
    146                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     146                $this->assertNotIXRError( $result );
    147147                $this->assertEquals( 'draft', get_post_status( $result ) );
    148148        }
    149149
    function test_incapable_sticky() { 
    152152
    153153                $post = array( 'post_title' => 'Test', 'sticky' => true );
    154154                $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'contributor', 'contributor', $post ) );
    155                 $this->assertInstanceOf( 'IXR_Error', $result );
     155                $this->assertIXRError( $result );
    156156                $this->assertEquals( 401, $result->code );
    157157        }
    158158
    function test_capable_sticky() { 
    161161
    162162                $post = array( 'post_title' => 'Test', 'sticky' => true );
    163163                $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post ) );
    164                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     164                $this->assertNotIXRError( $result );
    165165                $this->assertTrue( is_sticky( $result ) );
    166166        }
    167167
    function test_private_sticky() { 
    170170
    171171                $post = array( 'post_title' => 'Test', 'post_status' => 'private', 'sticky' => true );
    172172                $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post ) );
    173                 $this->assertInstanceOf( 'IXR_Error', $result );
     173                $this->assertIXRError( $result );
    174174                $this->assertEquals( 401, $result->code );
    175175        }
    176176
    function test_post_format() { 
    179179
    180180                $post = array( 'post_title' => 'Test', 'post_format' => 'quote' );
    181181                $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post ) );
    182                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     182                $this->assertNotIXRError( $result );
    183183                $this->assertEquals( 'quote', get_post_format( $result ) );
    184184        }
    185185
    function test_invalid_post_format() { 
    188188
    189189                $post = array( 'post_title' => 'Test', 'post_format' => 'tumblr' );
    190190                $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post ) );
    191                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     191                $this->assertNotIXRError( $result );
    192192                $this->assertEquals( '', get_post_format( $result ) );
    193193        }
    194194
    function test_invalid_taxonomy() { 
    202202                        )
    203203                );
    204204                $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post ) );
    205                 $this->assertInstanceOf( 'IXR_Error', $result );
     205                $this->assertIXRError( $result );
    206206                $this->assertEquals( 401, $result->code );
    207207
    208208                $post2 = array(
    function test_invalid_taxonomy() { 
    212212                        )
    213213                );
    214214                $result2 = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post2 ) );
    215                 $this->assertInstanceOf( 'IXR_Error', $result2 );
     215                $this->assertIXRError( $result2 );
    216216                $this->assertEquals( 401, $result2->code );
    217217        }
    218218
    function test_invalid_term_id() { 
    226226                        )
    227227                );
    228228                $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post ) );
    229                 $this->assertInstanceOf( 'IXR_Error', $result );
     229                $this->assertIXRError( $result );
    230230                $this->assertEquals( 403, $result->code );
    231231        }
    232232
    function test_terms() { 
    247247                        )
    248248                );
    249249                $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post ) );
    250                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     250                $this->assertNotIXRError( $result );
    251251
    252252                $post_tags = wp_get_object_terms( $result, 'post_tag', array( 'fields' => 'ids' ) );
    253253                $this->assertNotContains( $tag1['term_id'], $post_tags );
    function test_terms_names() { 
    274274                        )
    275275                );
    276276                $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post ) );
    277                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     277                $this->assertNotIXRError( $result );
    278278                // verify that cat2 was created
    279279                $cat2 = get_term_by( 'name', $cat2_name, 'category' );
    280280                $this->assertNotEmpty( $cat2 );
    function test_terms_names() { 
    291291                        )
    292292                );
    293293                $result2 = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post2 ) );
    294                 $this->assertInstanceOf( 'IXR_Error', $result2 );
     294                $this->assertIXRError( $result2 );
    295295                $this->assertEquals( 401, $result2->code );
    296296        }
    297297
  • tests/phpunit/tests/xmlrpc/wp/newTerm.php

    diff --git a/tests/phpunit/tests/xmlrpc/wp/newTerm.php b/tests/phpunit/tests/xmlrpc/wp/newTerm.php
    index 860e5c8..f5f012f 100644
    a b public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) { 
    1515
    1616        function test_invalid_username_password() {
    1717                $result = $this->myxmlrpcserver->wp_newTerm( array( 1, 'username', 'password', array() ) );
    18                 $this->assertInstanceOf( 'IXR_Error', $result );
     18                $this->assertIXRError( $result );
    1919                $this->assertEquals( 403, $result->code );
    2020        }
    2121
    function test_empty_taxonomy() { 
    2323                $this->make_user_by_role( 'editor' );
    2424
    2525                $result = $this->myxmlrpcserver->wp_newTerm( array( 1, 'editor', 'editor', array( 'taxonomy' => '' ) ) );
    26                 $this->assertInstanceOf( 'IXR_Error', $result );
     26                $this->assertIXRError( $result );
    2727                $this->assertEquals( 403, $result->code );
    2828                $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message );
    2929        }
    function test_invalid_taxonomy() { 
    3232                $this->make_user_by_role( 'editor' );
    3333
    3434                $result = $this->myxmlrpcserver->wp_newTerm( array( 1, 'editor', 'editor', array( 'taxonomy' => 'not_existing' ) ) );
    35                 $this->assertInstanceOf( 'IXR_Error', $result );
     35                $this->assertIXRError( $result );
    3636                $this->assertEquals( 403, $result->code );
    3737                $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message );
    3838        }
    function test_incapable_user() { 
    4141                $this->make_user_by_role( 'subscriber' );
    4242
    4343                $result = $this->myxmlrpcserver->wp_newTerm( array( 1, 'subscriber', 'subscriber', array( 'taxonomy' => 'category' ) ) );
    44                 $this->assertInstanceOf( 'IXR_Error', $result );
     44                $this->assertIXRError( $result );
    4545                $this->assertEquals( 401, $result->code );
    4646                $this->assertEquals( __( 'Sorry, you are not allowed to create terms in this taxonomy.' ), $result->message );
    4747        }
    function test_empty_term() { 
    5050                $this->make_user_by_role( 'editor' );
    5151
    5252                $result = $this->myxmlrpcserver->wp_newTerm( array( 1, 'editor', 'editor', array( 'taxonomy' => 'category', 'name' => '' ) ) );
    53                 $this->assertInstanceOf( 'IXR_Error', $result );
     53                $this->assertIXRError( $result );
    5454                $this->assertEquals( 403, $result->code );
    5555                $this->assertEquals( __( 'The term name cannot be empty.' ), $result->message );
    5656        }
    function test_parent_for_nonhierarchical() { 
    5959                $this->make_user_by_role( 'editor' );
    6060
    6161                $result = $this->myxmlrpcserver->wp_newTerm( array( 1, 'editor', 'editor', array( 'taxonomy' => 'post_tag', 'parent' => self::$parent_term_id, 'name' => 'test' ) ) );
    62                 $this->assertInstanceOf( 'IXR_Error', $result );
     62                $this->assertIXRError( $result );
    6363                $this->assertEquals( 403, $result->code );
    6464                $this->assertEquals( __( 'This taxonomy is not hierarchical.' ), $result->message );
    6565        }
    function test_parent_invalid() { 
    6868                $this->make_user_by_role( 'editor' );
    6969
    7070                $result = $this->myxmlrpcserver->wp_newTerm( array( 1, 'editor', 'editor', array( 'taxonomy' => 'category', 'parent' => 'dasda', 'name' => 'test' ) ) );
    71                 $this->assertInstanceOf( 'IXR_Error', $result );
     71                $this->assertIXRError( $result );
    7272                $this->assertEquals( 500, $result->code );
    7373        }
    7474
    function test_parent_not_existing() { 
    7676                $this->make_user_by_role( 'editor' );
    7777
    7878                $result = $this->myxmlrpcserver->wp_newTerm( array( 1, 'editor', 'editor', array( 'taxonomy' => 'category', 'parent' => 9999, 'name' => 'test' ) ) );
    79                 $this->assertInstanceOf( 'IXR_Error', $result );
     79                $this->assertIXRError( $result );
    8080                $this->assertEquals( 403, $result->code );
    8181                $this->assertEquals( __( 'Parent term does not exist.' ), $result->message );
    8282        }
    function test_add_term() { 
    8686                $this->make_user_by_role( 'editor' );
    8787
    8888                $result = $this->myxmlrpcserver->wp_newTerm( array( 1, 'editor', 'editor', array( 'taxonomy' => 'category', 'name' => 'test' ) ) );
    89                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     89                $this->assertNotIXRError( $result );
    9090                $this->assertStringMatchesFormat( '%d', $result );
    9191        }
    9292
    function test_add_term_with_parent() { 
    9494                $this->make_user_by_role( 'editor' );
    9595
    9696                $result  = $this->myxmlrpcserver->wp_newTerm( array( 1, 'editor', 'editor', array( 'taxonomy' => 'category', 'parent' => self::$parent_term_id, 'name' => 'test' ) ) );
    97                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     97                $this->assertNotIXRError( $result );
    9898                $this->assertStringMatchesFormat( '%d', $result );
    9999        }
    100100
    function test_add_term_with_all() { 
    103103
    104104                $taxonomy = array( 'taxonomy' => 'category', 'parent' => self::$parent_term_id, 'name' => 'test_all', 'description' => 'Test all', 'slug' => 'test_all' );
    105105                $result  = $this->myxmlrpcserver->wp_newTerm( array( 1, 'editor', 'editor', $taxonomy ) );
    106                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     106                $this->assertNotIXRError( $result );
    107107                $this->assertStringMatchesFormat( '%d', $result );
    108108        }
    109109}
  • tests/phpunit/tests/xmlrpc/wp/restoreRevision.php

    diff --git a/tests/phpunit/tests/xmlrpc/wp/restoreRevision.php b/tests/phpunit/tests/xmlrpc/wp/restoreRevision.php
    index 75f5d74..be9d191 100644
    a b function setUp() { 
    2323
    2424        function test_invalid_username_password() {
    2525                $result = $this->myxmlrpcserver->wp_restoreRevision( array( 1, 'username', 'password', $this->revision_id ) );
    26                 $this->assertInstanceOf( 'IXR_Error', $result );
     26                $this->assertIXRError( $result );
    2727                $this->assertEquals( 403, $result->code );
    2828        }
    2929
    function test_incapable_user() { 
    3131                $this->make_user_by_role( 'subscriber' );
    3232
    3333                $result = $this->myxmlrpcserver->wp_restoreRevision( array( 1, 'subscriber', 'subscriber', $this->revision_id ) );
    34                 $this->assertInstanceOf( 'IXR_Error', $result );
     34                $this->assertIXRError( $result );
    3535                $this->assertEquals( 401, $result->code );
    3636        }
    3737
    function test_capable_user() { 
    3939                $this->make_user_by_role( 'editor' );
    4040
    4141                $result = $this->myxmlrpcserver->wp_restoreRevision( array( 1, 'editor', 'editor', $this->revision_id ) );
    42                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     42                $this->assertNotIXRError( $result );
    4343        }
    4444
    4545        function test_revision_restored() {
  • tests/phpunit/tests/xmlrpc/wp/uploadFile.php

    diff --git a/tests/phpunit/tests/xmlrpc/wp/uploadFile.php b/tests/phpunit/tests/xmlrpc/wp/uploadFile.php
    index 8baa3f6..e15f85d 100644
    a b function test_valid_attachment() { 
    2525
    2626
    2727                $result = $this->myxmlrpcserver->mw_newMediaObject( array( 0, 'editor', 'editor', $data ) );
    28                 $this->assertNotInstanceOf( 'IXR_Error', $result );
     28                $this->assertNotIXRError( $result );
    2929
    3030                // check data types
    3131                $this->assertInternalType( 'string', $result['id'] );