wp/wp-admin/includes/class-wp-plugins-list-table.php
changeset 18 be944660c56a
parent 16 a86126ab1dd4
child 19 3d72ae0968f4
equal deleted inserted replaced
17:34716fd837a4 18:be944660c56a
   227 				'banners_rtl'   => array(),
   227 				'banners_rtl'   => array(),
   228 				'tested'        => '',
   228 				'tested'        => '',
   229 				'requires_php'  => '',
   229 				'requires_php'  => '',
   230 				'compatibility' => new stdClass(),
   230 				'compatibility' => new stdClass(),
   231 			);
   231 			);
   232 			$filter_payload = (object) array_merge( $filter_payload, array_intersect_key( $plugin_data, $filter_payload ) );
   232 
   233 
   233 			$filter_payload = (object) wp_parse_args( $plugin_data, $filter_payload );
   234 			$type = 'plugin';
   234 
   235 			/** This filter is documented in wp-admin/includes/class-wp-automatic-updater.php */
   235 			$auto_update_forced = wp_is_auto_update_forced_for_item( 'plugin', null, $filter_payload );
   236 			$auto_update_forced = apply_filters( "auto_update_{$type}", null, $filter_payload );
       
   237 
   236 
   238 			if ( ! is_null( $auto_update_forced ) ) {
   237 			if ( ! is_null( $auto_update_forced ) ) {
   239 				$plugin_data['auto-update-forced'] = $auto_update_forced;
   238 				$plugin_data['auto-update-forced'] = $auto_update_forced;
   240 			}
   239 			}
   241 
   240 
   316 
   315 
   317 		$total_this_page = $totals[ $status ];
   316 		$total_this_page = $totals[ $status ];
   318 
   317 
   319 		$js_plugins = array();
   318 		$js_plugins = array();
   320 		foreach ( $plugins as $key => $list ) {
   319 		foreach ( $plugins as $key => $list ) {
   321 			$js_plugins[ $key ] = array_keys( (array) $list );
   320 			$js_plugins[ $key ] = array_keys( $list );
   322 		}
   321 		}
   323 
   322 
   324 		wp_localize_script(
   323 		wp_localize_script(
   325 			'updates',
   324 			'updates',
   326 			'_wpUpdatesItemCounts',
   325 			'_wpUpdatesItemCounts',
   385 		global $orderby, $order;
   384 		global $orderby, $order;
   386 
   385 
   387 		$a = $plugin_a[ $orderby ];
   386 		$a = $plugin_a[ $orderby ];
   388 		$b = $plugin_b[ $orderby ];
   387 		$b = $plugin_b[ $orderby ];
   389 
   388 
   390 		if ( $a == $b ) {
   389 		if ( $a === $b ) {
   391 			return 0;
   390 			return 0;
   392 		}
   391 		}
   393 
   392 
   394 		if ( 'DESC' === $order ) {
   393 		if ( 'DESC' === $order ) {
   395 			return strcasecmp( $b, $a );
   394 			return strcasecmp( $b, $a );
   406 
   405 
   407 		if ( ! empty( $_REQUEST['s'] ) ) {
   406 		if ( ! empty( $_REQUEST['s'] ) ) {
   408 			$s = esc_html( wp_unslash( $_REQUEST['s'] ) );
   407 			$s = esc_html( wp_unslash( $_REQUEST['s'] ) );
   409 
   408 
   410 			/* translators: %s: Plugin search term. */
   409 			/* translators: %s: Plugin search term. */
   411 			printf( __( 'No plugins found for “%s”.' ), $s );
   410 			printf( __( 'No plugins found for: %s.' ), '<strong>' . $s . '</strong>' );
   412 
   411 
   413 			// We assume that somebody who can install plugins in multisite is experienced enough to not need this helper link.
   412 			// We assume that somebody who can install plugins in multisite is experienced enough to not need this helper link.
   414 			if ( ! is_multisite() && current_user_can( 'install_plugins' ) ) {
   413 			if ( ! is_multisite() && current_user_can( 'install_plugins' ) ) {
   415 				echo ' <a href="' . esc_url( admin_url( 'plugin-install.php?tab=search&s=' . urlencode( $s ) ) ) . '">' . __( 'Search for plugins in the WordPress Plugin Directory.' ) . '</a>';
   414 				echo ' <a href="' . esc_url( admin_url( 'plugin-install.php?tab=search&s=' . urlencode( $s ) ) ) . '">' . __( 'Search for plugins in the WordPress Plugin Directory.' ) . '</a>';
   416 			}
   415 			}
   443 			echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />';
   442 			echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />';
   444 		}
   443 		}
   445 		?>
   444 		?>
   446 		<p class="search-box">
   445 		<p class="search-box">
   447 			<label class="screen-reader-text" for="<?php echo esc_attr( $input_id ); ?>"><?php echo $text; ?>:</label>
   446 			<label class="screen-reader-text" for="<?php echo esc_attr( $input_id ); ?>"><?php echo $text; ?>:</label>
   448 			<input type="search" id="<?php echo esc_attr( $input_id ); ?>" class="wp-filter-search" name="s" value="<?php _admin_search_query(); ?>" placeholder="<?php esc_attr_e( 'Search installed plugins...' ); ?>"/>
   447 			<input type="search" id="<?php echo esc_attr( $input_id ); ?>" class="wp-filter-search" name="s" value="<?php _admin_search_query(); ?>" placeholder="<?php esc_attr_e( 'Search installed plugins...' ); ?>" />
   449 			<?php submit_button( $text, 'hide-if-js', '', false, array( 'id' => 'search-submit' ) ); ?>
   448 			<?php submit_button( $text, 'hide-if-js', '', false, array( 'id' => 'search-submit' ) ); ?>
   450 		</p>
   449 		</p>
   451 		<?php
   450 		<?php
   452 	}
   451 	}
   453 
   452 
   743 		if ( 'mustuse' === $context ) {
   742 		if ( 'mustuse' === $context ) {
   744 			$is_active = true;
   743 			$is_active = true;
   745 		} elseif ( 'dropins' === $context ) {
   744 		} elseif ( 'dropins' === $context ) {
   746 			$dropins     = _get_dropins();
   745 			$dropins     = _get_dropins();
   747 			$plugin_name = $plugin_file;
   746 			$plugin_name = $plugin_file;
   748 			if ( $plugin_file != $plugin_data['Name'] ) {
   747 
       
   748 			if ( $plugin_file !== $plugin_data['Name'] ) {
   749 				$plugin_name .= '<br/>' . $plugin_data['Name'];
   749 				$plugin_name .= '<br/>' . $plugin_data['Name'];
   750 			}
   750 			}
       
   751 
   751 			if ( true === ( $dropins[ $plugin_file ][1] ) ) { // Doesn't require a constant.
   752 			if ( true === ( $dropins[ $plugin_file ][1] ) ) { // Doesn't require a constant.
   752 				$is_active   = true;
   753 				$is_active   = true;
   753 				$description = '<p><strong>' . $dropins[ $plugin_file ][0] . '</strong></p>';
   754 				$description = '<p><strong>' . $dropins[ $plugin_file ][0] . '</strong></p>';
   754 			} elseif ( defined( $dropins[ $plugin_file ][1] ) && constant( $dropins[ $plugin_file ][1] ) ) { // Constant is true.
   755 			} elseif ( defined( $dropins[ $plugin_file ][1] ) && constant( $dropins[ $plugin_file ][1] ) ) { // Constant is true.
   755 				$is_active   = true;
   756 				$is_active   = true;
   762 						__( 'Requires %1$s in %2$s file.' ),
   763 						__( 'Requires %1$s in %2$s file.' ),
   763 						"<code>define('" . $dropins[ $plugin_file ][1] . "', true);</code>",
   764 						"<code>define('" . $dropins[ $plugin_file ][1] . "', true);</code>",
   764 						'<code>wp-config.php</code>'
   765 						'<code>wp-config.php</code>'
   765 					) . '</p>';
   766 					) . '</p>';
   766 			}
   767 			}
       
   768 
   767 			if ( $plugin_data['Description'] ) {
   769 			if ( $plugin_data['Description'] ) {
   768 				$description .= '<p>' . $plugin_data['Description'] . '</p>';
   770 				$description .= '<p>' . $plugin_data['Description'] . '</p>';
   769 			}
   771 			}
   770 		} else {
   772 		} else {
   771 			if ( $screen->in_admin( 'network' ) ) {
   773 			if ( $screen->in_admin( 'network' ) ) {
   944 		}
   946 		}
   945 
   947 
   946 		$requires_php   = isset( $plugin_data['requires_php'] ) ? $plugin_data['requires_php'] : null;
   948 		$requires_php   = isset( $plugin_data['requires_php'] ) ? $plugin_data['requires_php'] : null;
   947 		$compatible_php = is_php_version_compatible( $requires_php );
   949 		$compatible_php = is_php_version_compatible( $requires_php );
   948 		$class          = $is_active ? 'active' : 'inactive';
   950 		$class          = $is_active ? 'active' : 'inactive';
   949 		$checkbox_id    = 'checkbox_' . md5( $plugin_data['Name'] );
   951 		$checkbox_id    = 'checkbox_' . md5( $plugin_file );
       
   952 
   950 		if ( $restrict_network_active || $restrict_network_only || in_array( $status, array( 'mustuse', 'dropins' ), true ) || ! $compatible_php ) {
   953 		if ( $restrict_network_active || $restrict_network_only || in_array( $status, array( 'mustuse', 'dropins' ), true ) || ! $compatible_php ) {
   951 			$checkbox = '';
   954 			$checkbox = '';
   952 		} else {
   955 		} else {
   953 			$checkbox = sprintf(
   956 			$checkbox = sprintf(
   954 				'<label class="screen-reader-text" for="%1$s">%2$s</label>' .
   957 				'<label class="screen-reader-text" for="%1$s">%2$s</label>' .
   957 				/* translators: %s: Plugin name. */
   960 				/* translators: %s: Plugin name. */
   958 				sprintf( __( 'Select %s' ), $plugin_data['Name'] ),
   961 				sprintf( __( 'Select %s' ), $plugin_data['Name'] ),
   959 				esc_attr( $plugin_file )
   962 				esc_attr( $plugin_file )
   960 			);
   963 			);
   961 		}
   964 		}
       
   965 
   962 		if ( 'dropins' !== $context ) {
   966 		if ( 'dropins' !== $context ) {
   963 			$description = '<p>' . ( $plugin_data['Description'] ? $plugin_data['Description'] : '&nbsp;' ) . '</p>';
   967 			$description = '<p>' . ( $plugin_data['Description'] ? $plugin_data['Description'] : '&nbsp;' ) . '</p>';
   964 			$plugin_name = $plugin_data['Name'];
   968 			$plugin_name = $plugin_data['Name'];
   965 		}
   969 		}
   966 
   970 
  1122 						'plugin_status' => $status,
  1126 						'plugin_status' => $status,
  1123 					);
  1127 					);
  1124 
  1128 
  1125 					$url = add_query_arg( $query_args, 'plugins.php' );
  1129 					$url = add_query_arg( $query_args, 'plugins.php' );
  1126 
  1130 
  1127 					if ( 'unavailable' == $action ) {
  1131 					if ( 'unavailable' === $action ) {
  1128 						$html[] = '<span class="label">' . $text . '</span>';
  1132 						$html[] = '<span class="label">' . $text . '</span>';
  1129 					} else {
  1133 					} else {
  1130 						$html[] = sprintf(
  1134 						$html[] = sprintf(
  1131 							'<a href="%s" class="toggle-auto-update aria-button-if-js" data-wp-action="%s">',
  1135 							'<a href="%s" class="toggle-auto-update aria-button-if-js" data-wp-action="%s">',
  1132 							wp_nonce_url( $url, 'updates' ),
  1136 							wp_nonce_url( $url, 'updates' ),