~canonical-sysadmins/wordpress/upstream-4.1

« back to all changes in this revision

Viewing changes to wp-admin/plugin-install.php

  • Committer: Jacek Nykis
  • Date: 2015-01-05 16:17:05 UTC
  • Revision ID: jacek.nykis@canonical.com-20150105161705-w544l1h5mcg7u4w9
Initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
/**
 
3
 * Install plugin administration panel.
 
4
 *
 
5
 * @package WordPress
 
6
 * @subpackage Administration
 
7
 */
 
8
// TODO route this pages via a specific iframe handler instead of the do_action below
 
9
if ( !defined( 'IFRAME_REQUEST' ) && isset( $_GET['tab'] ) && ( 'plugin-information' == $_GET['tab'] ) )
 
10
        define( 'IFRAME_REQUEST', true );
 
11
 
 
12
/**
 
13
 * WordPress Administration Bootstrap.
 
14
 */
 
15
require_once( dirname( __FILE__ ) . '/admin.php' );
 
16
 
 
17
if ( ! current_user_can('install_plugins') )
 
18
        wp_die(__('You do not have sufficient permissions to install plugins on this site.'));
 
19
 
 
20
if ( is_multisite() && ! is_network_admin() ) {
 
21
        wp_redirect( network_admin_url( 'plugin-install.php' ) );
 
22
        exit();
 
23
}
 
24
 
 
25
$wp_list_table = _get_list_table('WP_Plugin_Install_List_Table');
 
26
$pagenum = $wp_list_table->get_pagenum();
 
27
 
 
28
if ( ! empty( $_REQUEST['_wp_http_referer'] ) ) {
 
29
        $location = remove_query_arg( '_wp_http_referer', wp_unslash( $_SERVER['REQUEST_URI'] ) );
 
30
 
 
31
        if ( ! empty( $_REQUEST['paged'] ) ) {
 
32
                $location = add_query_arg( 'paged', (int) $_REQUEST['paged'], $location );
 
33
        }
 
34
 
 
35
        wp_redirect( $location );
 
36
        exit;
 
37
}
 
38
 
 
39
$wp_list_table->prepare_items();
 
40
 
 
41
$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
 
42
 
 
43
if ( $pagenum > $total_pages && $total_pages > 0 ) {
 
44
        wp_redirect( add_query_arg( 'paged', $total_pages ) );
 
45
        exit;
 
46
}
 
47
 
 
48
$title = __( 'Add Plugins' );
 
49
$parent_file = 'plugins.php';
 
50
 
 
51
wp_enqueue_script( 'plugin-install' );
 
52
if ( 'plugin-information' != $tab )
 
53
        add_thickbox();
 
54
 
 
55
$body_id = $tab;
 
56
 
 
57
/**
 
58
 * Fires before each tab on the Install Plugins screen is loaded.
 
59
 *
 
60
 * The dynamic portion of the action hook, $tab, allows for targeting
 
61
 * individual tabs, for instance 'install_plugins_pre_plugin-information'.
 
62
 *
 
63
 * @since 2.7.0
 
64
 */
 
65
do_action( "install_plugins_pre_$tab" );
 
66
 
 
67
get_current_screen()->add_help_tab( array(
 
68
'id'            => 'overview',
 
69
'title'         => __('Overview'),
 
70
'content'       =>
 
71
        '<p>' . sprintf(__('Plugins hook into WordPress to extend its functionality with custom features. Plugins are developed independently from the core WordPress application by thousands of developers all over the world. All plugins in the official <a href="%s" target="_blank">WordPress.org Plugin Directory</a> are compatible with the license WordPress uses. You can find new plugins to install by searching or browsing the Directory right here in your own Plugins section.'), 'https://wordpress.org/plugins/') . '</p>'
 
72
) );
 
73
get_current_screen()->add_help_tab( array(
 
74
'id'            => 'adding-plugins',
 
75
'title'         => __('Adding Plugins'),
 
76
'content'       =>
 
77
        '<p>' . __('If you know what you&#8217;re looking for, Search is your best bet. The Search screen has options to search the WordPress.org Plugin Directory for a particular Term, Author, or Tag. You can also search the directory by selecting popular tags. Tags in larger type mean more plugins have been labeled with that tag.') . '</p>' .
 
78
        '<p>' . __('If you just want to get an idea of what&#8217;s available, you can browse Featured and Popular plugins by using the links in the upper left of the screen. These sections rotate regularly.') . '</p>' .
 
79
        '<p>' . __('You can also browse a user&#8217;s favorite plugins, by using the Favorites link in the upper left of the screen and entering their WordPress.org username.') . '</p>' .
 
80
        '<p>' . __('If you want to install a plugin that you&#8217;ve downloaded elsewhere, click the Upload link in the upper left. You will be prompted to upload the .zip package, and once uploaded, you can activate the new plugin.') . '</p>'
 
81
) );
 
82
 
 
83
get_current_screen()->set_help_sidebar(
 
84
        '<p><strong>' . __('For more information:') . '</strong></p>' .
 
85
        '<p>' . __('<a href="http://codex.wordpress.org/Plugins_Add_New_Screen" target="_blank">Documentation on Installing Plugins</a>') . '</p>' .
 
86
        '<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
 
87
);
 
88
 
 
89
/**
 
90
 * WordPress Administration Template Header.
 
91
 */
 
92
include(ABSPATH . 'wp-admin/admin-header.php');
 
93
?>
 
94
<div class="wrap">
 
95
<h2>
 
96
        <?php
 
97
        echo esc_html( $title );
 
98
        if ( ! empty( $tabs['upload'] ) && current_user_can( 'upload_plugins' ) ) {
 
99
                if ( $tab === 'upload' ) {
 
100
                        $href = self_admin_url( 'plugin-install.php' );
 
101
                        $text = _x( 'Browse', 'plugins' );
 
102
                } else {
 
103
                        $href = self_admin_url( 'plugin-install.php?tab=upload' );
 
104
                        $text = __( 'Upload Plugin' );
 
105
                }
 
106
                echo ' <a href="' . $href . '" class="upload add-new-h2">' . $text . '</a>';
 
107
        }
 
108
        ?>
 
109
</h2>
 
110
 
 
111
<?php
 
112
if ( $tab !== 'upload' ) {
 
113
        $wp_list_table->views();
 
114
        echo '<br class="clear" />';
 
115
}
 
116
 
 
117
/**
 
118
 * Fires after the plugins list table in each tab of the Install Plugins screen.
 
119
 *
 
120
 * The dynamic portion of the action hook, $tab, allows for targeting
 
121
 * individual tabs, for instance 'install_plugins_plugin-information'.
 
122
 *
 
123
 * @since 2.7.0
 
124
 *
 
125
 * @param int $paged The current page number of the plugins list table.
 
126
 */
 
127
?>
 
128
<?php do_action( "install_plugins_$tab", $paged ); ?>
 
129
</div>
 
130
<?php
 
131
/**
 
132
 * WordPress Administration Template Footer.
 
133
 */
 
134
include(ABSPATH . 'wp-admin/admin-footer.php');