~canonical-sysadmins/wordpress/4.8.1

« back to all changes in this revision

Viewing changes to wp-includes/class-wp-theme.php

  • Committer: Barry Price
  • Date: 2016-08-17 04:50:12 UTC
  • mfrom: (1.1.18 upstream)
  • Revision ID: barry.price@canonical.com-20160817045012-qfui81zhqnqv2ba9
Merge WP4.6 from upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
170
170
        /**
171
171
         * Flag for whether the themes cache bucket should be persistently cached.
172
172
         *
173
 
         * Default is false. Can be set with the wp_cache_themes_persistently filter.
 
173
         * Default is false. Can be set with the {@see 'wp_cache_themes_persistently'} filter.
174
174
         *
175
175
         * @static
176
176
         * @access private
437
437
         * translated data. We are doing so now as it is safe to do. However, as
438
438
         * Name and Title could have been used as the key for get_themes(), both remain
439
439
         * untranslated for back compatibility. This means that ['Name'] is not ideal,
440
 
         * and care should be taken to use $theme->display('Name') to get a properly
 
440
         * and care should be taken to use `$theme::display( 'Name' )` to get a properly
441
441
         * translated header.
442
442
         *
443
443
         * @param mixed $offset
447
447
                switch ( $offset ) {
448
448
                        case 'Name' :
449
449
                        case 'Title' :
450
 
                                // See note above about using translated data. get() is not ideal.
451
 
                                // It is only for backwards compatibility. Use display().
 
450
                                /*
 
451
                                 * See note above about using translated data. get() is not ideal.
 
452
                                 * It is only for backward compatibility. Use display().
 
453
                                 */
452
454
                                return $this->get('Name');
453
455
                        case 'Author' :
454
456
                                return $this->display( 'Author');
769
771
                                $this->name_translated = translate( $value, $this->get('TextDomain' ) );
770
772
                                return $this->name_translated;
771
773
                        case 'Tags' :
772
 
                                if ( empty( $value ) || ! function_exists( 'get_theme_feature_list' ) )
 
774
                                if ( empty( $value ) || ! function_exists( 'get_theme_feature_list' ) ) {
773
775
                                        return $value;
 
776
                                }
774
777
 
775
778
                                static $tags_list;
776
779
                                if ( ! isset( $tags_list ) ) {
777
 
                                        $tags_list = array();
 
780
                                        $tags_list = array(
 
781
                                                // As of 4.6, deprecated tags which are only used to provide translation for older themes.
 
782
                                                'black' => __( 'Black' ), 'blue' => __( 'Blue' ), 'brown'  => __( 'Brown' ),
 
783
                                                'gray' => __( 'Gray' ), 'green'  => __( 'Green' ), 'orange' => __( 'Orange' ),
 
784
                                                'pink' => __( 'Pink' ), 'purple' => __( 'Purple' ), 'red' => __( 'Red' ),
 
785
                                                'silver' => __( 'Silver' ), 'tan' => __( 'Tan' ), 'white' => __( 'White' ),
 
786
                                                'yellow' => __( 'Yellow' ), 'dark' => __( 'Dark' ), 'light' => __( 'Light' ),
 
787
                                                'fixed-layout' => __( 'Fixed Layout' ), 'fluid-layout' => __( 'Fluid Layout' ),
 
788
                                                'responsive-layout' => __( 'Responsive Layout' ), 'blavatar' => __( 'Blavatar' ),
 
789
                                                'photoblogging' => __( 'Photoblogging' ), 'seasonal' => __( 'Seasonal' ),
 
790
                                        );
 
791
 
778
792
                                        $feature_list = get_theme_feature_list( false ); // No API
779
 
                                        foreach ( $feature_list as $tags )
 
793
                                        foreach ( $feature_list as $tags ) {
780
794
                                                $tags_list += $tags;
 
795
                                        }
781
796
                                }
782
797
 
783
798
                                foreach ( $value as &$tag ) {
918
933
         *
919
934
         * This is typically the absolute URL to wp-content/themes. This forms the basis
920
935
         * for all other URLs returned by WP_Theme, so we pass it to the public function
921
 
         * get_theme_root_uri() and allow it to run the theme_root_uri filter.
 
936
         * get_theme_root_uri() and allow it to run the {@see 'theme_root_uri'} filter.
922
937
         *
923
938
         * @since 3.4.0
924
939
         * @access public
1029
1044
                        $page_templates += $this->parent()->get_page_templates( $post );
1030
1045
 
1031
1046
                /**
1032
 
                 * Filter list of page templates for a theme.
 
1047
                 * Filters list of page templates for a theme.
1033
1048
                 *
1034
1049
                 * @since 3.9.0
1035
1050
                 * @since 4.4.0 Converted to allow complete control over the `$page_templates` array.
1190
1205
         */
1191
1206
        public static function get_allowed( $blog_id = null ) {
1192
1207
                /**
1193
 
                 * Filter the array of themes allowed on the network.
 
1208
                 * Filters the array of themes allowed on the network.
1194
1209
                 *
1195
1210
                 * Site is provided as context so that a list of network allowed themes can
1196
1211
                 * be filtered further.
1223
1238
                }
1224
1239
 
1225
1240
                /**
1226
 
                 * Filter the array of themes allowed on the network.
 
1241
                 * Filters the array of themes allowed on the network.
1227
1242
                 *
1228
1243
                 * @since MU
1229
1244
                 *
1255
1270
 
1256
1271
                if ( isset( $allowed_themes[ $blog_id ] ) ) {
1257
1272
                        /**
1258
 
                         * Filter the array of themes allowed on the site.
 
1273
                         * Filters the array of themes allowed on the site.
1259
1274
                         *
1260
1275
                         * @since 4.5.0
1261
1276
                         *
1316
1331
        }
1317
1332
 
1318
1333
        /**
 
1334
         * Enables a theme for all sites on the current network.
 
1335
         *
 
1336
         * @since 4.6.0
 
1337
         * @access public
 
1338
         * @static
 
1339
         *
 
1340
         * @param string|array $stylesheets Stylesheet name or array of stylesheet names.
 
1341
         */
 
1342
        public static function network_enable_theme( $stylesheets ) {
 
1343
                if ( ! is_multisite() ) {
 
1344
                        return;
 
1345
                }
 
1346
 
 
1347
                if ( ! is_array( $stylesheets ) ) {
 
1348
                        $stylesheets = array( $stylesheets );
 
1349
                }
 
1350
 
 
1351
                $allowed_themes = get_site_option( 'allowedthemes' );
 
1352
                foreach ( $stylesheets as $stylesheet ) {
 
1353
                        $allowed_themes[ $stylesheet ] = true;
 
1354
                }
 
1355
 
 
1356
                update_site_option( 'allowedthemes', $allowed_themes );
 
1357
        }
 
1358
 
 
1359
        /**
 
1360
         * Disables a theme for all sites on the current network.
 
1361
         *
 
1362
         * @since 4.6.0
 
1363
         * @access public
 
1364
         * @static
 
1365
         *
 
1366
         * @param string|array $stylesheets Stylesheet name or array of stylesheet names.
 
1367
         */
 
1368
        public static function network_disable_theme( $stylesheets ) {
 
1369
                if ( ! is_multisite() ) {
 
1370
                        return;
 
1371
                }
 
1372
 
 
1373
                if ( ! is_array( $stylesheets ) ) {
 
1374
                        $stylesheets = array( $stylesheets );
 
1375
                }
 
1376
 
 
1377
                $allowed_themes = get_site_option( 'allowedthemes' );
 
1378
                foreach ( $stylesheets as $stylesheet ) {
 
1379
                        if ( isset( $allowed_themes[ $stylesheet ] ) ) {
 
1380
                                unset( $allowed_themes[ $stylesheet ] );
 
1381
                        }
 
1382
                }
 
1383
 
 
1384
                update_site_option( 'allowedthemes', $allowed_themes );
 
1385
        }
 
1386
 
 
1387
        /**
1319
1388
         * Sorts themes by name.
1320
1389
         *
1321
1390
         * @since 3.4.0