| @@ -9,8 +9,13 @@ | ||
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | 11 | namespace MainWP\Dashboard; |
| 12 | 12 | |
| 13 | +// Exit if accessed directly. | |
| 14 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 15 | + exit; | |
| 16 | +} | |
| 17 | + | |
| 13 | 18 | // Exit if access directly. |
| 14 | 19 | if ( ! defined( 'WP_CLI' ) ) { |
| 15 | 20 | return; // NOSONAR - skip CLI. |
| 16 | 21 | } |
| @@ -775,11 +780,18 @@ | ||
| 775 | 780 | * @param array $assoc_args Arguments. |
| 776 | 781 | * @param object $website Object containing child site data. |
| 777 | 782 | */ |
| 778 | 783 | public static function callback_site_site_available_updates( $args = array(), $assoc_args = array(), $website = false ) { // phpcs:ignore -- NOSONAR - complex. |
| 779 | - $wp_upgrades = MainWP_DB::instance()->get_website_option( $website, 'wp_upgrades' ); | |
| 780 | - $wp_upgrades = ! empty( $wp_upgrades ) ? json_decode( $wp_upgrades, true ) : array(); | |
| 784 | + $site_options = MainWP_DB::instance()->get_website_options_array( $website, array( 'wp_upgrades', 'ignored_trans_updates' ) ); | |
| 785 | + $wp_upgrades = isset( $site_options['wp_upgrades'] ) ? json_decode( $site_options['wp_upgrades'], true ) : array(); | |
| 786 | + $ignored_core_upgrades = isset( $site_options['ignored_wp_upgrades'] ) ? json_decode( $site_options['ignored_wp_upgrades'], true ) : array(); | |
| 781 | 787 | |
| 788 | + if ( $website->is_ignoreCoreUpdates || MainWP_Common_Functions::instance()->is_ignored_updates( $wp_upgrades, $ignored_core_upgrades, 'core' ) ) { | |
| 789 | + $wp_upgrades = array(); | |
| 790 | + } | |
| 791 | + | |
| 792 | + $ignored_trans_updates = isset( $site_options['ignored_trans_updates'] ) ? (int) $site_options['ignored_trans_updates'] : false; | |
| 793 | + | |
| 782 | 794 | $plugin_upgrades = json_decode( $website->plugin_upgrades, true ); |
| 783 | 795 | $theme_upgrades = json_decode( $website->theme_upgrades, true ); |
| 784 | 796 | $translation_upgrades = json_decode( $website->translation_upgrades, true ); |
| 785 | 797 | |
| @@ -789,17 +801,23 @@ | ||
| 789 | 801 | if ( $website->is_ignoreThemeUpdates ) { |
| 790 | 802 | $theme_upgrades = array(); |
| 791 | 803 | } |
| 792 | 804 | |
| 805 | + if ( $ignored_trans_updates ) { | |
| 806 | + $translation_upgrades = array(); | |
| 807 | + } | |
| 808 | + | |
| 793 | 809 | $userExtension = MainWP_DB_Common::instance()->get_user_extension(); |
| 794 | 810 | if ( is_array( $plugin_upgrades ) && ! empty( $plugin_upgrades ) ) { |
| 795 | 811 | $ignored_plugins = json_decode( $website->ignored_plugins, true ); |
| 796 | 812 | if ( is_array( $ignored_plugins ) ) { |
| 797 | - $plugin_upgrades = array_diff_key( $plugin_upgrades, $ignored_plugins ); | |
| 813 | + $plugin_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $plugin_upgrades, $ignored_plugins ); | |
| 814 | + | |
| 798 | 815 | } |
| 799 | 816 | $ignored_plugins = json_decode( $userExtension->ignored_plugins, true ); |
| 800 | 817 | if ( is_array( $ignored_plugins ) ) { |
| 801 | - $plugin_upgrades = array_diff_key( $plugin_upgrades, $ignored_plugins ); | |
| 818 | + $plugin_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $plugin_upgrades, $ignored_plugins ); | |
| 819 | + | |
| 802 | 820 | } |
| 803 | 821 | } |
| 804 | 822 | |
| 805 | 823 | if ( is_array( $theme_upgrades ) && ! empty( $theme_upgrades ) ) { |
| @@ -804,14 +822,14 @@ | ||
| 804 | 822 | |
| 805 | 823 | if ( is_array( $theme_upgrades ) && ! empty( $theme_upgrades ) ) { |
| 806 | 824 | $ignored_themes = json_decode( $website->ignored_themes, true ); |
| 807 | 825 | if ( is_array( $ignored_themes ) ) { |
| 808 | - $theme_upgrades = array_diff_key( $theme_upgrades, $ignored_themes ); | |
| 826 | + $theme_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $theme_upgrades, $ignored_themes ); | |
| 809 | 827 | } |
| 810 | 828 | |
| 811 | 829 | $ignored_themes = json_decode( $userExtension->ignored_themes, true ); |
| 812 | 830 | if ( is_array( $ignored_themes ) ) { |
| 813 | - $theme_upgrades = array_diff_key( $theme_upgrades, $ignored_themes ); | |
| 831 | + $theme_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $theme_upgrades, $ignored_themes ); | |
| 814 | 832 | } |
| 815 | 833 | } |
| 816 | 834 | |
| 817 | 835 | \WP_CLI::line( '' ); |
| @@ -893,13 +911,15 @@ | ||
| 893 | 911 | $userExtension = MainWP_DB_Common::instance()->get_user_extension(); |
| 894 | 912 | if ( is_array( $plugin_upgrades ) && ! empty( $plugin_upgrades ) ) { |
| 895 | 913 | $ignored_plugins = json_decode( $website->ignored_plugins, true ); |
| 896 | 914 | if ( is_array( $ignored_plugins ) ) { |
| 897 | - $plugin_upgrades = array_diff_key( $plugin_upgrades, $ignored_plugins ); | |
| 915 | + $plugin_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $plugin_upgrades, $ignored_plugins ); | |
| 916 | + | |
| 898 | 917 | } |
| 899 | 918 | $ignored_plugins = json_decode( $userExtension->ignored_plugins, true ); |
| 900 | 919 | if ( is_array( $ignored_plugins ) ) { |
| 901 | - $plugin_upgrades = array_diff_key( $plugin_upgrades, $ignored_plugins ); | |
| 920 | + $plugin_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $plugin_upgrades, $ignored_plugins ); | |
| 921 | + | |
| 902 | 922 | } |
| 903 | 923 | } |
| 904 | 924 | |
| 905 | 925 | if ( is_array( $theme_upgrades ) && ! empty( $theme_upgrades ) ) { |
| @@ -904,14 +924,14 @@ | ||
| 904 | 924 | |
| 905 | 925 | if ( is_array( $theme_upgrades ) && ! empty( $theme_upgrades ) ) { |
| 906 | 926 | $ignored_themes = json_decode( $website->ignored_themes, true ); |
| 907 | 927 | if ( is_array( $ignored_themes ) ) { |
| 908 | - $theme_upgrades = array_diff_key( $theme_upgrades, $ignored_themes ); | |
| 928 | + $theme_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $theme_upgrades, $ignored_themes ); | |
| 909 | 929 | } |
| 910 | 930 | |
| 911 | 931 | $ignored_themes = json_decode( $userExtension->ignored_themes, true ); |
| 912 | 932 | if ( is_array( $ignored_themes ) ) { |
| 913 | - $theme_upgrades = array_diff_key( $theme_upgrades, $ignored_themes ); | |
| 933 | + $theme_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $theme_upgrades, $ignored_themes ); | |
| 914 | 934 | } |
| 915 | 935 | } |
| 916 | 936 | |
| 917 | 937 | $translations = json_decode( $website->translation_upgrades, true ); |
| @@ -1085,21 +1105,13 @@ | ||
| 1085 | 1105 | public static function callback_site_site_security_issues( $args = array(), $assoc_args = array(), $website = false ) { |
| 1086 | 1106 | $data = MainWP_Connect::fetch_url_authed( $website, 'security' ); |
| 1087 | 1107 | |
| 1088 | 1108 | \WP_CLI::line( '' ); |
| 1089 | - \WP_CLI::line( \WP_CLI::colorize( '%9' . $website->name . ' ' . esc_html__( 'Security Issues', 'mainwp' ) . '%n' ) ); | |
| 1109 | + \WP_CLI::line( \WP_CLI::colorize( '%9' . $website->name . ' ' . esc_html__( 'Potential Secuirty Issues', 'mainwp' ) . '%n' ) ); | |
| 1090 | 1110 | \WP_CLI::line( '' ); |
| 1091 | 1111 | |
| 1092 | - \WP_CLI::line( \WP_CLI::colorize( '%g' . esc_html__( 'Directories listing prevented:', 'mainwp' ) . '%n ' ) . ( 'N' === $data['listing'] ? 'NO' : 'YES' ) ); | |
| 1093 | - \WP_CLI::line( \WP_CLI::colorize( '%g' . esc_html__( 'WordPress version hidden:', 'mainwp' ) . '%n ' ) . ( 'N' === $data['wp_version'] ? 'NO' : 'YES' ) ); | |
| 1094 | - \WP_CLI::line( \WP_CLI::colorize( '%g' . esc_html__( 'Really Simple Discovery meta tag removed:', 'mainwp' ) . '%n ' ) . ( 'N' === $data['rsd'] ? 'NO' : 'YES' ) ); | |
| 1095 | - \WP_CLI::line( \WP_CLI::colorize( '%g' . esc_html__( 'Windows Live Writer meta tag removed:', 'mainwp' ) . '%n ' ) . ( 'N' === $data['wlw'] ? 'NO' : 'YES' ) ); | |
| 1096 | 1112 | \WP_CLI::line( \WP_CLI::colorize( '%g' . esc_html__( 'Database error reporting disabled:', 'mainwp' ) . '%n ' ) . ( 'N' === $data['db_reporting'] ? 'NO' : 'YES' ) ); |
| 1097 | 1113 | \WP_CLI::line( \WP_CLI::colorize( '%g' . esc_html__( 'PHP error reporting disabled:', 'mainwp' ) . '%n ' ) . ( 'N' === $data['php_reporting'] ? 'NO' : 'YES' ) ); |
| 1098 | - \WP_CLI::line( \WP_CLI::colorize( '%g' . esc_html__( 'Version information removed from URLs:', 'mainwp' ) . '%n ' ) . ( 'N' === $data['versions'] ? 'NO' : 'YES' ) ); | |
| 1099 | - \WP_CLI::line( \WP_CLI::colorize( '%g' . esc_html__( 'Registered version information removed from URLs:', 'mainwp' ) . '%n ' ) . ( 'N' === $data['registered_versions'] ? 'NO' : 'YES' ) ); | |
| 1100 | - \WP_CLI::line( \WP_CLI::colorize( '%g' . esc_html__( 'readme.html removed from WordPress root:', 'mainwp' ) . '%n ' ) . ( 'N' === $data['readme'] ? 'NO' : 'YES' ) ); | |
| 1101 | - \WP_CLI::line( \WP_CLI::colorize( '%g' . esc_html__( 'Administrator username is not "admin":', 'mainwp' ) . '%n ' ) . ( 'N' === $data['admin'] ? 'NO' : 'YES' ) ); | |
| 1102 | 1114 | \WP_CLI::line( \WP_CLI::colorize( '%g' . esc_html__( 'WordPress is not up to date:', 'mainwp' ) . '%n ' ) . ( 'N' === $data['wp_uptodate'] ? 'NO' : 'YES' ) ); |
| 1103 | 1115 | \WP_CLI::line( \WP_CLI::colorize( '%g' . esc_html__( 'PHP version does not match the WordPress requirement:', 'mainwp' ) . '%n ' ) . ( 'N' === $data['phpversion_matched'] ? 'NO' : 'YES' ) ); |
| 1104 | 1116 | \WP_CLI::line( \WP_CLI::colorize( '%g' . esc_html__( 'SSL protocol is not in place:', 'mainwp' ) . '%n ' ) . ( 'N' === $data['sslprotocol'] ? 'NO' : 'YES' ) ); |
| 1105 | 1117 | \WP_CLI::line( \WP_CLI::colorize( '%g' . esc_html__( 'WP Config debugging is enabled:', 'mainwp' ) . '%n ' ) . ( 'N' === $data['debug_disabled'] ? 'NO' : 'YES' ) ); |
| @@ -1278,13 +1290,15 @@ | ||
| 1278 | 1290 | $userExtension = MainWP_DB_Common::instance()->get_user_extension(); |
| 1279 | 1291 | if ( is_array( $plugin_upgrades ) && ! empty( $plugin_upgrades ) ) { |
| 1280 | 1292 | $ignored_plugins = json_decode( $website->ignored_plugins, true ); |
| 1281 | 1293 | if ( is_array( $ignored_plugins ) ) { |
| 1282 | - $plugin_upgrades = array_diff_key( $plugin_upgrades, $ignored_plugins ); | |
| 1294 | + $plugin_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $plugin_upgrades, $ignored_plugins ); | |
| 1295 | + | |
| 1283 | 1296 | } |
| 1284 | 1297 | $ignored_plugins = json_decode( $userExtension->ignored_plugins, true ); |
| 1285 | 1298 | if ( is_array( $ignored_plugins ) ) { |
| 1286 | - $plugin_upgrades = array_diff_key( $plugin_upgrades, $ignored_plugins ); | |
| 1299 | + $plugin_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $plugin_upgrades, $ignored_plugins ); | |
| 1300 | + | |
| 1287 | 1301 | } |
| 1288 | 1302 | } |
| 1289 | 1303 | |
| 1290 | 1304 | $slugs = array(); |
| @@ -1515,8 +1529,19 @@ | ||
| 1515 | 1529 | \WP_CLI::line( '' ); |
| 1516 | 1530 | |
| 1517 | 1531 | $websites = MainWP_DB::instance()->query( MainWP_DB::instance()->get_sql_websites_for_current_user() ); |
| 1518 | 1532 | while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) { |
| 1533 | + | |
| 1534 | + $site_options = MainWP_DB::instance()->get_website_options_array( $website, array( 'wp_upgrades', 'ignored_trans_updates' ) ); | |
| 1535 | + $wp_upgrades = isset( $site_options['wp_upgrades'] ) ? json_decode( $site_options['wp_upgrades'], true ) : array(); | |
| 1536 | + $ignored_core_upgrades = isset( $site_options['ignored_wp_upgrades'] ) ? json_decode( $site_options['ignored_wp_upgrades'], true ) : array(); | |
| 1537 | + | |
| 1538 | + if ( $website->is_ignoreCoreUpdates || MainWP_Common_Functions::instance()->is_ignored_updates( $wp_upgrades, $ignored_core_upgrades, 'core' ) ) { | |
| 1539 | + $wp_upgrades = array(); | |
| 1540 | + } | |
| 1541 | + | |
| 1542 | + $ignored_trans_updates = isset( $site_options['ignored_trans_updates'] ) ? (int) $site_options['ignored_trans_updates'] : false; | |
| 1543 | + | |
| 1519 | 1544 | $wp_upgrades = MainWP_DB::instance()->get_website_option( $website, 'wp_upgrades' ); |
| 1520 | 1545 | $wp_upgrades = ! empty( $wp_upgrades ) ? json_decode( $wp_upgrades, true ) : array(); |
| 1521 | 1546 | |
| 1522 | 1547 | $plugin_upgrades = json_decode( $website->plugin_upgrades, true ); |
| @@ -1529,17 +1554,23 @@ | ||
| 1529 | 1554 | if ( $website->is_ignoreThemeUpdates ) { |
| 1530 | 1555 | $theme_upgrades = array(); |
| 1531 | 1556 | } |
| 1532 | 1557 | |
| 1558 | + if ( $ignored_trans_updates ) { | |
| 1559 | + $translation_upgrades = array(); | |
| 1560 | + } | |
| 1561 | + | |
| 1533 | 1562 | $userExtension = MainWP_DB_Common::instance()->get_user_extension(); |
| 1534 | 1563 | if ( is_array( $plugin_upgrades ) && ! empty( $plugin_upgrades ) ) { |
| 1535 | 1564 | $ignored_plugins = json_decode( $website->ignored_plugins, true ); |
| 1536 | 1565 | if ( is_array( $ignored_plugins ) ) { |
| 1537 | - $plugin_upgrades = array_diff_key( $plugin_upgrades, $ignored_plugins ); | |
| 1566 | + $plugin_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $plugin_upgrades, $ignored_plugins ); | |
| 1567 | + | |
| 1538 | 1568 | } |
| 1539 | 1569 | $ignored_plugins = json_decode( $userExtension->ignored_plugins, true ); |
| 1540 | 1570 | if ( is_array( $ignored_plugins ) ) { |
| 1541 | - $plugin_upgrades = array_diff_key( $plugin_upgrades, $ignored_plugins ); | |
| 1571 | + $plugin_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $plugin_upgrades, $ignored_plugins ); | |
| 1572 | + | |
| 1542 | 1573 | } |
| 1543 | 1574 | } |
| 1544 | 1575 | |
| 1545 | 1576 | if ( is_array( $theme_upgrades ) && ! empty( $theme_upgrades ) ) { |
| @@ -1544,14 +1575,14 @@ | ||
| 1544 | 1575 | |
| 1545 | 1576 | if ( is_array( $theme_upgrades ) && ! empty( $theme_upgrades ) ) { |
| 1546 | 1577 | $ignored_themes = json_decode( $website->ignored_themes, true ); |
| 1547 | 1578 | if ( is_array( $ignored_themes ) ) { |
| 1548 | - $theme_upgrades = array_diff_key( $theme_upgrades, $ignored_themes ); | |
| 1579 | + $theme_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $theme_upgrades, $ignored_themes ); | |
| 1549 | 1580 | } |
| 1550 | 1581 | |
| 1551 | 1582 | $ignored_themes = json_decode( $userExtension->ignored_themes, true ); |
| 1552 | 1583 | if ( is_array( $ignored_themes ) ) { |
| 1553 | - $theme_upgrades = array_diff_key( $theme_upgrades, $ignored_themes ); | |
| 1584 | + $theme_upgrades = MainWP_Common_Functions::instance()->get_not_ignored_updates_themesplugins( $theme_upgrades, $ignored_themes ); | |
| 1554 | 1585 | } |
| 1555 | 1586 | } |
| 1556 | 1587 | |
| 1557 | 1588 | \WP_CLI::line( \WP_CLI::colorize( '%B' . $website->name . ' (' . $website->url . ')%n' ) ); |
| @@ -1614,9 +1645,9 @@ | ||
| 1614 | 1645 | * @param array $args Arguments. |
| 1615 | 1646 | * @param array $assoc_args Arguments. |
| 1616 | 1647 | * @param object|bool $website Website object. |
| 1617 | 1648 | */ |
| 1618 | - public static function callback_updates_ignored_plugins_updates( $args = array(), $assoc_args = array(), $website = false ) { | |
| 1649 | + public static function callback_updates_ignored_plugins_updates( $args = array(), $assoc_args = array(), $website = false ) { //phpcs:ignore -- NOSONAR - complex. | |
| 1619 | 1650 | $ignored_all = false; |
| 1620 | 1651 | if ( $website ) { |
| 1621 | 1652 | \WP_CLI::line( '' ); |
| 1622 | 1653 | \WP_CLI::line( \WP_CLI::colorize( '%9' . $website->name . ' ' . esc_html__( 'Ignored Updates', 'mainwp' ) . '%n' ) ); |
| @@ -1631,14 +1662,19 @@ | ||
| 1631 | 1662 | if ( ! $ignored_all ) { |
| 1632 | 1663 | $userExtension = MainWP_DB_Common::instance()->get_user_extension(); |
| 1633 | 1664 | $data = json_decode( $userExtension->ignored_plugins, true ); |
| 1634 | 1665 | foreach ( $data as $value ) { |
| 1635 | - \WP_CLI::line( \WP_CLI::colorize( '%gName:%n ' ) . $value ); | |
| 1666 | + $name = is_array( $value ) && ! empty( $value['Name'] ) ? $value['Name'] : ''; | |
| 1667 | + $name = empty( $name ) && is_string( $value ) ? $value : $name; | |
| 1668 | + | |
| 1669 | + \WP_CLI::line( \WP_CLI::colorize( '%gName:%n ' ) . $name ); | |
| 1636 | 1670 | } |
| 1637 | 1671 | if ( $website ) { |
| 1638 | 1672 | $ignored_plugins = json_decode( $website->ignored_plugins, true ); |
| 1639 | 1673 | if ( is_array( $ignored_plugins ) ) { |
| 1640 | - foreach ( $ignored_plugins as $name ) { | |
| 1674 | + foreach ( $ignored_plugins as $value ) { | |
| 1675 | + $name = is_array( $value ) && ! empty( $value['Name'] ) ? $value['Name'] : ''; | |
| 1676 | + $name = empty( $name ) && is_string( $value ) ? $value : $name; | |
| 1641 | 1677 | \WP_CLI::line( \WP_CLI::colorize( '%gName:%n ' ) . $name ); |
| 1642 | 1678 | } |
| 1643 | 1679 | } |
| 1644 | 1680 | } |
| @@ -1663,9 +1699,11 @@ | ||
| 1663 | 1699 | \WP_CLI::line( \WP_CLI::colorize( '%9' . $website->name . ' ' . esc_html__( 'Ignored Updates', 'mainwp' ) . '%n' ) ); |
| 1664 | 1700 | \WP_CLI::line( '' ); |
| 1665 | 1701 | |
| 1666 | 1702 | foreach ( $data as $value ) { |
| 1667 | - \WP_CLI::line( \WP_CLI::colorize( '%gName:%n ' ) . $value ); | |
| 1703 | + $name = is_array( $value ) && ! empty( $value['Name'] ) ? $value['Name'] : ''; | |
| 1704 | + $name = empty( $name ) && is_string( $value ) ? $value : $name; | |
| 1705 | + \WP_CLI::line( \WP_CLI::colorize( '%gName:%n ' ) . $name ); | |
| 1668 | 1706 | } |
| 1669 | 1707 | |
| 1670 | 1708 | \WP_CLI::line( '' ); |
| 1671 | 1709 | } |
| @@ -1799,9 +1837,9 @@ | ||
| 1799 | 1837 | $params = static::get_cli_params( $args, $assoc_args, array( 'type', 'slug' ) ); |
| 1800 | 1838 | $type = $params['type']; |
| 1801 | 1839 | $slug = $params['slug']; |
| 1802 | 1840 | |
| 1803 | - MainWP_Updates_Handler::unignore_plugins_themes( $type, $slug ); | |
| 1841 | + MainWP_Updates_Handler::unignore_global_plugins_themes( $type, $slug ); | |
| 1804 | 1842 | |
| 1805 | 1843 | \WP_CLI::line( '' ); |
| 1806 | 1844 | \WP_CLI::line( \WP_CLI::colorize( '%g' . $slug . esc_html__( ' unignorred successfully.', 'mainwp' ) . '%n' ) ); |
| 1807 | 1845 | \WP_CLI::line( '' ); |