~canonical-sysadmins/wordpress/4.8.3

« back to all changes in this revision

Viewing changes to wp-includes/script-loader.php

  • Committer: Barry Price
  • Date: 2017-06-09 02:09:58 UTC
  • mfrom: (1.1.26 upstream)
  • Revision ID: barry.price@canonical.com-20170609020958-838whhwt2196f2vk
Merge WP4.8 from upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
77
77
 
78
78
        $scripts->add( 'common', "/wp-admin/js/common$suffix.js", array('jquery', 'hoverIntent', 'utils'), false, 1 );
79
79
        did_action( 'init' ) && $scripts->localize( 'common', 'commonL10n', array(
80
 
                'warnDelete'   => __( "You are about to permanently delete these items.\n  'Cancel' to stop, 'OK' to delete." ),
 
80
                'warnDelete'   => __( "You are about to permanently delete these items from your site.\nThis action cannot be undone.\n 'Cancel' to stop, 'OK' to delete." ),
81
81
                'dismiss'      => __( 'Dismiss this notice.' ),
82
82
                'collapseMenu' => __( 'Collapse Main menu' ),
83
83
                'expandMenu'   => __( 'Expand Main menu' ),
280
280
                'queue_limit_exceeded' => __('You have attempted to queue too many files.'),
281
281
                'file_exceeds_size_limit' => __('%s exceeds the maximum upload size for this site.'),
282
282
                'zero_byte_file' => __('This file is empty. Please try another.'),
283
 
                'invalid_filetype' => __('This file type is not allowed. Please try another.'),
 
283
                'invalid_filetype' => __('Sorry, this file type is not permitted for security reasons.'),
284
284
                'not_an_image' => __('This file is not an image. Please try another.'),
285
285
                'image_memory_exceeded' => __('Memory exceeded. Please try another smaller file.'),
286
286
                'image_dimensions_exceeded' => __('This is larger than the maximum size. Please try another.'),
357
357
                        'Play'                    => __( 'Play' ),
358
358
                        'Pause'                   => __( 'Pause' ),
359
359
                        'Captions/Subtitles'      => __( 'Captions/Subtitles' ),
360
 
                        'None'                    => __( 'None', 'no captions/subtitles' ),
 
360
                        'None'                    => _x( 'None', 'no captions/subtitles' ),
361
361
                        'Time Slider'             => __( 'Time Slider' ),
362
362
                        /* translators: %1: number of seconds (30 by default) */
363
363
                        'Skip back %1 seconds'    => __( 'Skip back %1 seconds' ),
602
602
                $scripts->add( 'admin-gallery', "/wp-admin/js/gallery$suffix.js", array( 'jquery-ui-sortable' ) );
603
603
 
604
604
                $scripts->add( 'admin-widgets', "/wp-admin/js/widgets$suffix.js", array( 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-droppable' ), false, 1 );
 
605
                $scripts->add( 'media-widgets', "/wp-admin/js/widgets/media-widgets$suffix.js", array( 'jquery', 'media-models', 'media-views' ) );
 
606
                $scripts->add_inline_script( 'media-widgets', 'wp.mediaWidgets.init();', 'after' );
 
607
 
 
608
                $scripts->add( 'media-audio-widget', "/wp-admin/js/widgets/media-audio-widget$suffix.js", array( 'media-widgets', 'media-audiovideo' ) );
 
609
                $scripts->add( 'media-image-widget', "/wp-admin/js/widgets/media-image-widget$suffix.js", array( 'media-widgets' ) );
 
610
                $scripts->add( 'media-video-widget', "/wp-admin/js/widgets/media-video-widget$suffix.js", array( 'media-widgets', 'media-audiovideo' ) );
 
611
                $scripts->add( 'text-widgets', "/wp-admin/js/widgets/text-widgets$suffix.js", array( 'jquery', 'backbone', 'editor', 'wp-util' ) );
 
612
                $scripts->add_inline_script( 'text-widgets', 'wp.textWidgets.init();', 'after' );
605
613
 
606
614
                $scripts->add( 'theme', "/wp-admin/js/theme$suffix.js", array( 'wp-backbone', 'wp-a11y' ), false, 1 );
607
615
 
637
645
                                'noPlugins'                  => __( 'You do not appear to have any plugins available at this time.' ),
638
646
                                'noItemsSelected'            => __( 'Please select at least one item to perform this action on.' ),
639
647
                                'updating'                   => __( 'Updating...' ), // No ellipsis.
640
 
                                'updated'                    => __( 'Updated!' ),
 
648
                                'pluginUpdated'              => _x( 'Updated!', 'plugin' ),
 
649
                                'themeUpdated'               => _x( 'Updated!', 'theme' ),
641
650
                                'update'                     => __( 'Update' ),
642
651
                                'updateNow'                  => __( 'Update Now' ),
643
652
                                /* translators: %s: Plugin name and version */
644
 
                                'updateNowLabel'             => __( 'Update %s now' ),
 
653
                                'pluginUpdateNowLabel'       => _x( 'Update %s now', 'plugin' ),
645
654
                                'updateFailedShort'          => __( 'Update Failed!' ),
646
655
                                /* translators: %s: Error string for a failed update */
647
656
                                'updateFailed'               => __( 'Update Failed: %s' ),
648
657
                                /* translators: %s: Plugin name and version */
649
 
                                'updatingLabel'              => __( 'Updating %s...' ), // No ellipsis.
650
 
                                /* translators: %s: Plugin name and version */
651
 
                                'updatedLabel'               => __( '%s updated!' ),
652
 
                                /* translators: %s: Plugin name and version */
653
 
                                'updateFailedLabel'          => __( '%s update failed' ),
654
 
                                /* translators: JavaScript accessible string */
 
658
                                'pluginUpdatingLabel'        => _x( 'Updating %s...', 'plugin' ), // No ellipsis.
 
659
                                /* translators: %s: Plugin name and version */
 
660
                                'pluginUpdatedLabel'         => _x( '%s updated!', 'plugin' ),
 
661
                                /* translators: %s: Plugin name and version */
 
662
                                'pluginUpdateFailedLabel'    => _x( '%s update failed', 'plugin' ),
 
663
                                /* translators: Accessibility text */
655
664
                                'updatingMsg'                => __( 'Updating... please wait.' ), // No ellipsis.
656
 
                                /* translators: JavaScript accessible string */
 
665
                                /* translators: Accessibility text */
657
666
                                'updatedMsg'                 => __( 'Update completed successfully.' ),
658
 
                                /* translators: JavaScript accessible string */
 
667
                                /* translators: Accessibility text */
659
668
                                'updateCancel'               => __( 'Update canceled.' ),
660
669
                                'beforeunload'               => __( 'Updates may not complete if you navigate away from this page.' ),
661
670
                                'installNow'                 => __( 'Install Now' ),
662
671
                                /* translators: %s: Plugin name */
663
 
                                'installNowLabel'            => __( 'Install %s now' ),
 
672
                                'pluginInstallNowLabel'      => _x( 'Install %s now', 'plugin' ),
664
673
                                'installing'                 => __( 'Installing...' ),
665
 
                                'installed'                  => __( 'Installed!' ),
 
674
                                'pluginInstalled'            => _x( 'Installed!', 'plugin' ),
 
675
                                'themeInstalled'             => _x( 'Installed!', 'theme' ),
666
676
                                'installFailedShort'         => __( 'Install Failed!' ),
667
677
                                /* translators: %s: Error string for a failed installation */
668
678
                                'installFailed'              => __( 'Installation failed: %s' ),
691
701
                                'deleting'                   => __( 'Deleting...' ),
692
702
                                /* translators: %s: Error string for a failed deletion */
693
703
                                'deleteFailed'               => __( 'Deletion failed: %s' ),
694
 
                                'deleted'                    => __( 'Deleted!' ),
 
704
                                'pluginDeleted'              => _x( 'Deleted!', 'plugin' ),
 
705
                                'themeDeleted'               => _x( 'Deleted!', 'theme' ),
695
706
                                'livePreview'                => __( 'Live Preview' ),
696
707
                                'activatePlugin'             => is_network_admin() ? __( 'Network Activate' ) : __( 'Activate' ),
697
708
                                'activateTheme'              => is_network_admin() ? __( 'Network Enable' ) : __( 'Activate' ),
721
732
                        'current' => __( 'Current Color' ),
722
733
                ) );
723
734
 
724
 
                $scripts->add( 'dashboard', "/wp-admin/js/dashboard$suffix.js", array( 'jquery', 'admin-comments', 'postbox' ), false, 1 );
 
735
                $scripts->add( 'dashboard', "/wp-admin/js/dashboard$suffix.js", array( 'jquery', 'admin-comments', 'postbox', 'wp-util', 'wp-a11y' ), false, 1 );
725
736
 
726
737
                $scripts->add( 'list-revisions', "/wp-includes/js/wp-list-revisions$suffix.js" );
727
738
 
990
1001
}
991
1002
 
992
1003
/**
 
1004
 * Localizes community events data that needs to be passed to dashboard.js.
 
1005
 *
 
1006
 * @since 4.8.0
 
1007
 */
 
1008
function wp_localize_community_events() {
 
1009
        if ( ! wp_script_is( 'dashboard' ) ) {
 
1010
                return;
 
1011
        }
 
1012
 
 
1013
        require_once( ABSPATH . 'wp-admin/includes/class-wp-community-events.php' );
 
1014
 
 
1015
        $user_id            = get_current_user_id();
 
1016
        $saved_location     = get_user_option( 'community-events-location', $user_id );
 
1017
        $saved_ip_address   = isset( $saved_location['ip'] ) ? $saved_location['ip'] : false;
 
1018
        $current_ip_address = WP_Community_Events::get_unsafe_client_ip();
 
1019
 
 
1020
        /*
 
1021
         * If the user's location is based on their IP address, then update their
 
1022
         * location when their IP address changes. This allows them to see events
 
1023
         * in their current city when travelling. Otherwise, they would always be
 
1024
         * shown events in the city where they were when they first loaded the
 
1025
         * Dashboard, which could have been months or years ago.
 
1026
         */
 
1027
        if ( $saved_ip_address && $current_ip_address && $current_ip_address !== $saved_ip_address ) {
 
1028
                $saved_location['ip'] = $current_ip_address;
 
1029
                update_user_option( $user_id, 'community-events-location', $saved_location, true );
 
1030
        }
 
1031
 
 
1032
        $events_client = new WP_Community_Events( $user_id, $saved_location );
 
1033
 
 
1034
        wp_localize_script( 'dashboard', 'communityEventsData', array(
 
1035
                'nonce' => wp_create_nonce( 'community_events' ),
 
1036
                'cache' => $events_client->get_cached_events(),
 
1037
 
 
1038
                'l10n' => array(
 
1039
                        'enter_closest_city' => __( 'Enter your closest city to find nearby events.' ),
 
1040
                        'error_occurred_please_try_again' => __( 'An error occurred. Please try again.' ),
 
1041
                        'attend_event_near_generic' => __( 'Attend an upcoming event near you.' ),
 
1042
 
 
1043
                        /*
 
1044
                         * These specific examples were chosen to highlight the fact that a
 
1045
                         * state is not needed, even for cities whose name is not unique.
 
1046
                         * It would be too cumbersome to include that in the instructions
 
1047
                         * to the user, so it's left as an implication.
 
1048
                         */
 
1049
                        /* translators: %s is the name of the city we couldn't locate.
 
1050
                         * Replace the examples with cities related to your locale. Test that
 
1051
                         * they match the expected location and have upcoming events before
 
1052
                         * including them. If no cities related to your locale have events,
 
1053
                         * then use cities related to your locale that would be recognizable
 
1054
                         * to most users. Use only the city name itself, without any region
 
1055
                         * or country. Use the endonym (native locale name) instead of the
 
1056
                         * English name if possible.
 
1057
                         */
 
1058
                        'could_not_locate_city' => __( 'We couldn’t locate %s. Please try another nearby city. For example: Kansas City; Springfield; Portland.' ),
 
1059
 
 
1060
                        // This one is only used with wp.a11y.speak(), so it can/should be more brief.
 
1061
                        /* translators: %s is the name of a city. */
 
1062
                        'city_updated' => __( 'City updated. Listing events near %s.' ),
 
1063
                )
 
1064
        ) );
 
1065
}
 
1066
 
 
1067
/**
993
1068
 * Administration Screen CSS for changing the styles.
994
1069
 *
995
1070
 * If installing the 'wp-admin/' directory will be replaced with './'.