- Timestamp:
- 02/06/2024 11:44:09 PM (9 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-wp-plugins-list-table.php
r56824 r57545 755 755 $compatible_wp = is_wp_version_compatible( $requires_wp ); 756 756 757 $has_dependents = WP_Plugin_Dependencies::has_dependents( $plugin_file ); 758 $has_active_dependents = WP_Plugin_Dependencies::has_active_dependents( $plugin_file ); 759 $has_unmet_dependencies = WP_Plugin_Dependencies::has_unmet_dependencies( $plugin_file ); 760 $has_circular_dependency = WP_Plugin_Dependencies::has_circular_dependency( $plugin_file ); 761 757 762 if ( 'mustuse' === $context ) { 758 763 $is_active = true; … … 797 802 if ( $is_active ) { 798 803 if ( current_user_can( 'manage_network_plugins' ) ) { 799 $actions['deactivate'] = sprintf( 800 '<a href="%s" id="deactivate-%s" aria-label="%s">%s</a>', 801 wp_nonce_url( 'plugins.php?action=deactivate&plugin=' . urlencode( $plugin_file ) . '&plugin_status=' . $context . '&paged=' . $page . '&s=' . $s, 'deactivate-plugin_' . $plugin_file ), 802 esc_attr( $plugin_id_attr ), 803 /* translators: %s: Plugin name. */ 804 esc_attr( sprintf( _x( 'Network Deactivate %s', 'plugin' ), $plugin_data['Name'] ) ), 805 __( 'Network Deactivate' ) 806 ); 804 if ( $has_active_dependents ) { 805 $actions['deactivate'] = __( 'Deactivate' ) . 806 '<span class="screen-reader-text">' . 807 __( 'You cannot deactivate this plugin as other plugins require it.' ) . 808 '</span>'; 809 810 } else { 811 $deactivate_url = 'plugins.php?action=deactivate' . 812 '&plugin=' . urlencode( $plugin_file ) . 813 '&plugin_status=' . $context . 814 '&paged=' . $page . 815 '&s=' . $s; 816 817 $actions['deactivate'] = sprintf( 818 '<a href="%s" id="deactivate-%s" aria-label="%s">%s</a>', 819 wp_nonce_url( $deactivate_url, 'deactivate-plugin_' . $plugin_file ), 820 esc_attr( $plugin_id_attr ), 821 /* translators: %s: Plugin name. */ 822 esc_attr( sprintf( _x( 'Network Deactivate %s', 'plugin' ), $plugin_data['Name'] ) ), 823 __( 'Network Deactivate' ) 824 ); 825 } 807 826 } 808 827 } else { 809 828 if ( current_user_can( 'manage_network_plugins' ) ) { 810 829 if ( $compatible_php && $compatible_wp ) { 811 $actions['activate'] = sprintf( 812 '<a href="%s" id="activate-%s" class="edit" aria-label="%s">%s</a>', 813 wp_nonce_url( 'plugins.php?action=activate&plugin=' . urlencode( $plugin_file ) . '&plugin_status=' . $context . '&paged=' . $page . '&s=' . $s, 'activate-plugin_' . $plugin_file ), 814 esc_attr( $plugin_id_attr ), 815 /* translators: %s: Plugin name. */ 816 esc_attr( sprintf( _x( 'Network Activate %s', 'plugin' ), $plugin_data['Name'] ) ), 817 __( 'Network Activate' ) 818 ); 830 if ( $has_unmet_dependencies ) { 831 $actions['activate'] = __( 'Network Activate' ) . 832 '<span class="screen-reader-text">' . 833 __( 'You cannot activate this plugin as it has unmet requirements.' ) . 834 '</span>'; 835 } else { 836 $activate_url = 'plugins.php?action=activate' . 837 '&plugin=' . urlencode( $plugin_file ) . 838 '&plugin_status=' . $context . 839 '&paged=' . $page . 840 '&s=' . $s; 841 842 $actions['activate'] = sprintf( 843 '<a href="%s" id="activate-%s" class="edit" aria-label="%s">%s</a>', 844 wp_nonce_url( $activate_url, 'activate-plugin_' . $plugin_file ), 845 esc_attr( $plugin_id_attr ), 846 /* translators: %s: Plugin name. */ 847 esc_attr( sprintf( _x( 'Network Activate %s', 'plugin' ), $plugin_data['Name'] ) ), 848 __( 'Network Activate' ) 849 ); 850 } 819 851 } else { 820 852 $actions['activate'] = sprintf( … … 826 858 827 859 if ( current_user_can( 'delete_plugins' ) && ! is_plugin_active( $plugin_file ) ) { 828 $actions['delete'] = sprintf( 829 '<a href="%s" id="delete-%s" class="delete" aria-label="%s">%s</a>', 830 wp_nonce_url( 'plugins.php?action=delete-selected&checked[]=' . urlencode( $plugin_file ) . '&plugin_status=' . $context . '&paged=' . $page . '&s=' . $s, 'bulk-plugins' ), 831 esc_attr( $plugin_id_attr ), 832 /* translators: %s: Plugin name. */ 833 esc_attr( sprintf( _x( 'Delete %s', 'plugin' ), $plugin_data['Name'] ) ), 834 __( 'Delete' ) 835 ); 860 if ( $has_dependents && ! $has_circular_dependency ) { 861 $actions['delete'] = __( 'Delete' ) . 862 '<span class="screen-reader-text">' . 863 __( 'You cannot delete this plugin as other plugins require it.' ) . 864 '</span>'; 865 } else { 866 $delete_url = 'plugins.php?action=delete-selected' . 867 '&checked[]=' . urlencode( $plugin_file ) . 868 '&plugin_status=' . $context . 869 '&paged=' . $page . 870 '&s=' . $s; 871 872 $actions['delete'] = sprintf( 873 '<a href="%s" id="delete-%s" class="delete" aria-label="%s">%s</a>', 874 wp_nonce_url( $delete_url, 'bulk-plugins' ), 875 esc_attr( $plugin_id_attr ), 876 /* translators: %s: Plugin name. */ 877 esc_attr( sprintf( _x( 'Delete %s', 'plugin' ), $plugin_data['Name'] ) ), 878 __( 'Delete' ) 879 ); 880 } 836 881 } 837 882 } … … 847 892 } elseif ( $is_active ) { 848 893 if ( current_user_can( 'deactivate_plugin', $plugin_file ) ) { 849 $actions['deactivate'] = sprintf( 850 '<a href="%s" id="deactivate-%s" aria-label="%s">%s</a>', 851 wp_nonce_url( 'plugins.php?action=deactivate&plugin=' . urlencode( $plugin_file ) . '&plugin_status=' . $context . '&paged=' . $page . '&s=' . $s, 'deactivate-plugin_' . $plugin_file ), 852 esc_attr( $plugin_id_attr ), 853 /* translators: %s: Plugin name. */ 854 esc_attr( sprintf( _x( 'Deactivate %s', 'plugin' ), $plugin_data['Name'] ) ), 855 __( 'Deactivate' ) 856 ); 894 if ( $has_active_dependents ) { 895 $actions['deactivate'] = __( 'Deactivate' ) . 896 '<span class="screen-reader-text">' . 897 __( 'You cannot deactivate this plugin as other plugins depend on it.' ) . 898 '</span>'; 899 } else { 900 $deactivate_url = 'plugins.php?action=deactivate' . 901 '&plugin=' . urlencode( $plugin_file ) . 902 '&plugin_status=' . $context . 903 '&paged=' . $page . 904 '&s=' . $s; 905 906 $actions['deactivate'] = sprintf( 907 '<a href="%s" id="deactivate-%s" aria-label="%s">%s</a>', 908 wp_nonce_url( $deactivate_url, 'deactivate-plugin_' . $plugin_file ), 909 esc_attr( $plugin_id_attr ), 910 /* translators: %s: Plugin name. */ 911 esc_attr( sprintf( _x( 'Deactivate %s', 'plugin' ), $plugin_data['Name'] ) ), 912 __( 'Deactivate' ) 913 ); 914 } 857 915 } 858 916 859 917 if ( current_user_can( 'resume_plugin', $plugin_file ) && is_plugin_paused( $plugin_file ) ) { 918 $resume_url = 'plugins.php?action=resume' . 919 '&plugin=' . urlencode( $plugin_file ) . 920 '&plugin_status=' . $context . 921 '&paged=' . $page . 922 '&s=' . $s; 923 860 924 $actions['resume'] = sprintf( 861 925 '<a href="%s" id="resume-%s" class="resume-link" aria-label="%s">%s</a>', 862 wp_nonce_url( 'plugins.php?action=resume&plugin=' . urlencode( $plugin_file ) . '&plugin_status=' . $context . '&paged=' . $page . '&s=' . $s, 'resume-plugin_' . $plugin_file ),926 wp_nonce_url( $resume_url, 'resume-plugin_' . $plugin_file ), 863 927 esc_attr( $plugin_id_attr ), 864 928 /* translators: %s: Plugin name. */ … … 870 934 if ( current_user_can( 'activate_plugin', $plugin_file ) ) { 871 935 if ( $compatible_php && $compatible_wp ) { 872 $actions['activate'] = sprintf( 873 '<a href="%s" id="activate-%s" class="edit" aria-label="%s">%s</a>', 874 wp_nonce_url( 'plugins.php?action=activate&plugin=' . urlencode( $plugin_file ) . '&plugin_status=' . $context . '&paged=' . $page . '&s=' . $s, 'activate-plugin_' . $plugin_file ), 875 esc_attr( $plugin_id_attr ), 876 /* translators: %s: Plugin name. */ 877 esc_attr( sprintf( _x( 'Activate %s', 'plugin' ), $plugin_data['Name'] ) ), 878 __( 'Activate' ) 879 ); 936 if ( $has_unmet_dependencies ) { 937 $actions['activate'] = __( 'Activate' ) . 938 '<span class="screen-reader-text">' . 939 __( 'You cannot activate this plugin as it has unmet requirements.' ) . 940 '</span>'; 941 } else { 942 $activate_url = 'plugins.php?action=activate' . 943 '&plugin=' . urlencode( $plugin_file ) . 944 '&plugin_status=' . $context . 945 '&paged=' . $page . 946 '&s=' . $s; 947 948 $actions['activate'] = sprintf( 949 '<a href="%s" id="activate-%s" class="edit" aria-label="%s">%s</a>', 950 wp_nonce_url( $activate_url, 'activate-plugin_' . $plugin_file ), 951 esc_attr( $plugin_id_attr ), 952 /* translators: %s: Plugin name. */ 953 esc_attr( sprintf( _x( 'Activate %s', 'plugin' ), $plugin_data['Name'] ) ), 954 __( 'Activate' ) 955 ); 956 } 880 957 } else { 881 958 $actions['activate'] = sprintf( … … 887 964 888 965 if ( ! is_multisite() && current_user_can( 'delete_plugins' ) ) { 889 $actions['delete'] = sprintf( 890 '<a href="%s" id="delete-%s" class="delete" aria-label="%s">%s</a>', 891 wp_nonce_url( 'plugins.php?action=delete-selected&checked[]=' . urlencode( $plugin_file ) . '&plugin_status=' . $context . '&paged=' . $page . '&s=' . $s, 'bulk-plugins' ), 892 esc_attr( $plugin_id_attr ), 893 /* translators: %s: Plugin name. */ 894 esc_attr( sprintf( _x( 'Delete %s', 'plugin' ), $plugin_data['Name'] ) ), 895 __( 'Delete' ) 896 ); 966 if ( $has_dependents && ! $has_circular_dependency ) { 967 $actions['delete'] = __( 'Delete' ) . 968 '<span class="screen-reader-text">' . 969 __( 'You cannot delete this plugin as other plugins require it.' ) . 970 '</span>'; 971 } else { 972 $delete_url = 'plugins.php?action=delete-selected' . 973 '&checked[]=' . urlencode( $plugin_file ) . 974 '&plugin_status=' . $context . 975 '&paged=' . $page . 976 '&s=' . $s; 977 978 $actions['delete'] = sprintf( 979 '<a href="%s" id="delete-%s" class="delete" aria-label="%s">%s</a>', 980 wp_nonce_url( $delete_url, 'bulk-plugins' ), 981 esc_attr( $plugin_id_attr ), 982 /* translators: %s: Plugin name. */ 983 esc_attr( sprintf( _x( 'Delete %s', 'plugin' ), $plugin_data['Name'] ) ), 984 __( 'Delete' ) 985 ); 986 } 897 987 } 898 988 } // End if $is_active. … … 989 1079 $class = $is_active ? 'active' : 'inactive'; 990 1080 $checkbox_id = 'checkbox_' . md5( $plugin_file ); 991 992 if ( $restrict_network_active || $restrict_network_only || in_array( $status, array( 'mustuse', 'dropins' ), true ) || ! $compatible_php ) { 1081 $disabled = ''; 1082 1083 if ( $has_active_dependents || $has_unmet_dependencies ) { 1084 $disabled = 'disabled'; 1085 } 1086 1087 if ( 1088 $restrict_network_active || 1089 $restrict_network_only || 1090 in_array( $status, array( 'mustuse', 'dropins' ), true ) || 1091 ! $compatible_php 1092 ) { 993 1093 $checkbox = ''; 994 1094 } else { 995 1095 $checkbox = sprintf( 996 '< input type="checkbox" name="checked[]" value="%1$s" id="%2$s" />' .997 '< label for="%2$s"><span class="screen-reader-text">%3$s</span></label>',998 esc_attr( $plugin_file ),1096 '<label class="label-covers-full-cell" for="%1$s">' . 1097 '<span class="screen-reader-text">%2$s</span></label>' . 1098 '<input type="checkbox" name="checked[]" value="%3$s" id="%1$s" ' . $disabled . '/>', 999 1099 $checkbox_id, 1000 1100 /* translators: Hidden accessibility text. %s: Plugin name. */ 1001 sprintf( __( 'Select %s' ), $plugin_data['Name'] ) 1101 sprintf( __( 'Select %s' ), $plugin_data['Name'] ), 1102 esc_attr( $plugin_file ) 1002 1103 ); 1003 1104 } … … 1008 1109 } 1009 1110 1010 if ( ! empty( $totals['upgrade'] ) && ! empty( $plugin_data['update'] ) 1011 || ! $compatible_php || ! $compatible_wp 1111 if ( 1112 ! empty( $totals['upgrade'] ) && 1113 ! empty( $plugin_data['update'] ) || 1114 ! $compatible_php || 1115 ! $compatible_wp 1012 1116 ) { 1013 1117 $class .= ' update'; … … 1058 1162 1059 1163 $plugin_meta = array(); 1164 1060 1165 if ( ! empty( $plugin_data['Version'] ) ) { 1061 1166 /* translators: %s: Plugin version number. */ 1062 1167 $plugin_meta[] = sprintf( __( 'Version %s' ), $plugin_data['Version'] ); 1063 1168 } 1169 1064 1170 if ( ! empty( $plugin_data['Author'] ) ) { 1065 1171 $author = $plugin_data['Author']; 1172 1066 1173 if ( ! empty( $plugin_data['AuthorURI'] ) ) { 1067 1174 $author = '<a href="' . $plugin_data['AuthorURI'] . '">' . $plugin_data['Author'] . '</a>'; 1068 1175 } 1176 1069 1177 /* translators: %s: Plugin author name. */ 1070 1178 $plugin_meta[] = sprintf( __( 'By %s' ), $author ); … … 1150 1258 echo '</div>'; 1151 1259 1260 if ( $has_dependents ) { 1261 $this->add_dependents_to_dependency_plugin_row( $plugin_file ); 1262 } 1263 1264 if ( WP_Plugin_Dependencies::has_dependencies( $plugin_file ) ) { 1265 $this->add_dependencies_to_dependent_plugin_row( $plugin_file ); 1266 } 1267 1268 /** 1269 * Fires after plugin row meta. 1270 * 1271 * @since 6.5.0 1272 * 1273 * @param string $plugin_file Refer to {@see 'plugin_row_meta'} filter. 1274 * @param array $plugin_data Refer to {@see 'plugin_row_meta'} filter. 1275 */ 1276 do_action( 'after_plugin_row_meta', $plugin_file, $plugin_data ); 1277 1152 1278 if ( $paused ) { 1153 1279 $notice_text = __( 'This plugin failed to load properly and is paused during recovery mode.' ); … … 1392 1518 return 'name'; 1393 1519 } 1520 1521 /** 1522 * Prints a list of other plugins that depend on the plugin. 1523 * 1524 * @since 6.5.0 1525 * 1526 * @param string $dependency The dependency's filepath, relative to the plugins directory. 1527 */ 1528 protected function add_dependents_to_dependency_plugin_row( $dependency ) { 1529 $dependent_names = WP_Plugin_Dependencies::get_dependent_names( $dependency ); 1530 1531 if ( empty( $dependent_names ) ) { 1532 return; 1533 } 1534 1535 $dependency_note = __( 'Note: this plugin cannot be deactivated or deleted until the plugins that require it are deactivated or deleted.' ); 1536 printf( 1537 '<div class="required-by"><p><strong>%1$s</strong> %2$s</p><p>%3$s</p></div>', 1538 __( 'Required by:' ), 1539 esc_html( implode( ' | ', $dependent_names ) ), 1540 $dependency_note 1541 ); 1542 } 1543 1544 /** 1545 * Prints a list of other plugins that the plugin depends on. 1546 * 1547 * @since 6.5.0 1548 * 1549 * @param string $dependent The dependent plugin's filepath, relative to the plugins directory. 1550 */ 1551 protected function add_dependencies_to_dependent_plugin_row( $dependent ) { 1552 $dependency_names = WP_Plugin_Dependencies::get_dependency_names( $dependent ); 1553 1554 if ( array() === $dependency_names ) { 1555 return; 1556 } 1557 1558 $links = array(); 1559 foreach ( $dependency_names as $slug => $name ) { 1560 $links[] = $this->get_dependency_view_details_link( $name, $slug ); 1561 } 1562 1563 $dependency_note = __( 'Note: this plugin cannot be activated until the plugins that are required by it are activated.' ); 1564 1565 printf( 1566 '<div class="requires"><p><strong>%1$s</strong> %2$s</p><p>%3$s</p></div>', 1567 __( 'Requires:' ), 1568 implode( ' | ', $links ), 1569 $dependency_note 1570 ); 1571 } 1572 1573 /** 1574 * Returns a 'View details' like link for a dependency. 1575 * 1576 * @since 6.5.0 1577 * 1578 * @param string $name The dependency's name. 1579 * @param string $slug The dependency's slug. 1580 * @return string A 'View details' link for the dependency. 1581 */ 1582 protected function get_dependency_view_details_link( $name, $slug ) { 1583 $dependency_data = WP_Plugin_Dependencies::get_dependency_data( $slug ); 1584 1585 if ( false === $dependency_data 1586 || $name === $slug 1587 || $name !== $dependency_data['name'] 1588 || empty( $dependency_data['version'] ) 1589 ) { 1590 return $name; 1591 } 1592 1593 return $this->get_view_details_link( $name, $slug ); 1594 } 1595 1596 /** 1597 * Returns a 'View details' link for the plugin. 1598 * 1599 * @since 6.5.0 1600 * 1601 * @param string $name The plugin's name. 1602 * @param string $slug The plugin's slug. 1603 * @return string A 'View details' link for the plugin. 1604 */ 1605 protected function get_view_details_link( $name, $slug ) { 1606 $url = add_query_arg( 1607 array( 1608 'tab' => 'plugin-information', 1609 'plugin' => $slug, 1610 'TB_iframe' => 'true', 1611 'width' => '600', 1612 'height' => '550', 1613 ), 1614 network_admin_url( 'plugin-install.php' ) 1615 ); 1616 1617 $name_attr = esc_attr( $name ); 1618 return sprintf( 1619 "<a href='%s' class='thickbox open-plugin-details-modal' aria-label='%s' data-title='%s'>%s</a>", 1620 esc_url( $url ), 1621 /* translators: %s: Plugin name. */ 1622 sprintf( __( 'More information about %s' ), $name_attr ), 1623 $name_attr, 1624 esc_html( $name ) 1625 ); 1626 } 1394 1627 }
Note: See TracChangeset
for help on using the changeset viewer.