← All changes
|
vendor/team-updraft/lib-central/central/modules/updates.php
+86
-3
3.7.0
→
4.7.0
View file →
| @@ -682,9 +682,23 @@ | ||
| 682 | 682 | // Check for WP Compatibility based from the update information |
| 683 | 683 | if (!empty($info['update']['requires'])) { |
| 684 | 684 | if (version_compare($wp_version, $info['update']['requires'], '<')) { |
| 685 | 685 | $is_compatible = false; |
| 686 | - $message = esc_attr(sprintf(__('The latest update for this %s is not compatible with the WordPress version installed on the remote site.', 'updraftplus').' '.__('The minimum WordPress version supported by this %s is %s.', 'updraftplus'), $type, $type, $info['update']['requires'])); | |
| 686 | + | |
| 687 | + /* translators: %s: Plugin/theme type */ | |
| 688 | + $message1 = sprintf( | |
| 689 | + __('The latest update for this %s is not compatible with the WordPress version installed on the remote site.', 'updraftplus'), | |
| 690 | + $type | |
| 691 | + ); | |
| 692 | + | |
| 693 | + /* translators: 1: Plugin/theme type, 2: Required WordPress version */ | |
| 694 | + $message2 = sprintf( | |
| 695 | + __('The minimum WordPress version supported by this %1$s is %2$s.', 'updraftplus'), | |
| 696 | + $type, | |
| 697 | + $info['update']['requires'] | |
| 698 | + ); | |
| 699 | + | |
| 700 | + $message = esc_attr($message1 . ' ' . $message2); | |
| 687 | 701 | } else { |
| 688 | 702 | $is_compatible = true; |
| 689 | 703 | } |
| 690 | 704 | } |
| @@ -692,9 +706,23 @@ | ||
| 692 | 706 | // Check for PHP Compatibility based from the update information |
| 693 | 707 | if (!empty($info['update']['requires_php'])) { |
| 694 | 708 | if (version_compare(PHP_VERSION, $info['update']['requires_php'], '<')) { |
| 695 | 709 | $is_compatible = false; |
| 696 | - $message = esc_attr(sprintf(__('The latest update for this %s is not compatible with the PHP version installed on the remote site.', 'updraftplus').' '.__('The minimum PHP version supported by this %s is %s.', 'updraftplus'), $type, $type, $info['update']['requires_php'])); | |
| 710 | + | |
| 711 | + /* translators: %s: Plugin/theme type */ | |
| 712 | + $message1 = sprintf( | |
| 713 | + __('The latest update for this %s is not compatible with the PHP version installed on the remote site.', 'updraftplus'), | |
| 714 | + $type | |
| 715 | + ); | |
| 716 | + | |
| 717 | + /* translators: 1: Plugin/theme type, 2: Required PHP version */ | |
| 718 | + $message2 = sprintf( | |
| 719 | + __('The minimum PHP version supported by this %1$s is %2$s.', 'updraftplus'), | |
| 720 | + $type, | |
| 721 | + $info['update']['requires_php'] | |
| 722 | + ); | |
| 723 | + | |
| 724 | + $message = esc_attr($message1 . ' ' . $message2); | |
| 697 | 725 | } else { |
| 698 | 726 | $is_compatible = true; |
| 699 | 727 | } |
| 700 | 728 | } |
| @@ -702,8 +730,9 @@ | ||
| 702 | 730 | // Check whether Plugin/Theme has been tested based from the update information |
| 703 | 731 | if (!empty($info['update']['tested'])) { |
| 704 | 732 | if (version_compare($wp_version, $info['update']['tested'], '>')) { |
| 705 | 733 | $is_compatible = false; |
| 734 | + // translators: %s: Plugin/theme type | |
| 706 | 735 | $message = esc_attr(sprintf(__('The latest update for this %s has not been tested with the WordPress version installed on the remote site and may have compatibility issues when used.', 'updraftplus'), $type)); |
| 707 | 736 | } else { |
| 708 | 737 | $is_compatible = true; |
| 709 | 738 | } |
| @@ -720,8 +749,60 @@ | ||
| 720 | 749 | 'compatible_message' => $message, |
| 721 | 750 | ); |
| 722 | 751 | } |
| 723 | 752 | |
| 753 | + /** | |
| 754 | + * Retrieve icons for plugin and screenshot for theme | |
| 755 | + * | |
| 756 | + * @param string $type The type of the entity to process (e.g. 'plugin' or 'theme') | |
| 757 | + * @param string $slug The entity slug | |
| 758 | + * @return string | |
| 759 | + */ | |
| 760 | + private function get_icons_screenshot($type, $slug) { | |
| 761 | + if (!in_array($type, array('plugin', 'theme'))) return ''; | |
| 762 | + | |
| 763 | + if ('plugin' == $type) { | |
| 764 | + if (!function_exists('plugins_api') && file_exists(ABSPATH.'wp-admin/includes/plugin-install.php')) { | |
| 765 | + include_once(ABSPATH.'wp-admin/includes/plugin-install.php'); | |
| 766 | + } | |
| 767 | + | |
| 768 | + // We make sure that the function now exists before we use it because | |
| 769 | + // the definition of this function maybe located in other places given | |
| 770 | + // the varying versions and changes to the WordPress platform. | |
| 771 | + if (function_exists('plugins_api')) { | |
| 772 | + $api = plugins_api('plugin_information', array( | |
| 773 | + 'slug' => $slug, | |
| 774 | + 'fields' => array('icons' => true), | |
| 775 | + )); | |
| 776 | + | |
| 777 | + if (!is_wp_error($api) && property_exists($api, 'icons')) { | |
| 778 | + return $api->icons; | |
| 779 | + } | |
| 780 | + } | |
| 781 | + | |
| 782 | + } elseif ('theme' == $type) { | |
| 783 | + if (!function_exists('themes_api') && file_exists(ABSPATH.'wp-admin/includes/theme.php')) { | |
| 784 | + include_once(ABSPATH.'wp-admin/includes/theme.php'); | |
| 785 | + } | |
| 786 | + | |
| 787 | + // We make sure that the function now exists before we use it because | |
| 788 | + // the definition of this function maybe located in other places given | |
| 789 | + // the varying versions and changes to the WordPress platform. | |
| 790 | + if (function_exists('themes_api')) { | |
| 791 | + $api = themes_api('theme_information', array( | |
| 792 | + 'slug' => $slug, | |
| 793 | + 'fields' => array('screenshot_url' => true), | |
| 794 | + )); | |
| 795 | + | |
| 796 | + if (!is_wp_error($api) && property_exists($api, 'screenshot_url')) { | |
| 797 | + return $api->screenshot_url; | |
| 798 | + } | |
| 799 | + } | |
| 800 | + } | |
| 801 | + | |
| 802 | + return ''; | |
| 803 | + } | |
| 804 | + | |
| 724 | 805 | public function get_updates($options) { |
| 725 | 806 | |
| 726 | 807 | // Forcing Elegant Themes (Divi) updates component to load if it exist. |
| 727 | 808 | if (function_exists('et_register_updates_component')) et_register_updates_component(); |
| @@ -772,8 +853,9 @@ | ||
| 772 | 853 | 'compatibility' => isset($update->update->compatibility) ? (array) $update->update->compatibility : null, |
| 773 | 854 | 'sections' => isset($update->update->sections) ? (array) $update->update->sections : null, |
| 774 | 855 | 'requires' => isset($update->update->requires) ? $update->update->requires : null, |
| 775 | 856 | 'requires_php' => isset($update->update->requires_php) ? $update->update->requires_php : null, |
| 857 | + 'icons' => isset($update->update->icons) ? $update->update->icons : $this->get_icons_screenshot('plugin', $update->update->slug), | |
| 776 | 858 | ), |
| 777 | 859 | ); |
| 778 | 860 | |
| 779 | 861 | // Check for compatibility and merge result into info |
| @@ -817,8 +899,9 @@ | ||
| 817 | 899 | 'url' => $update->update['url'], |
| 818 | 900 | 'tested' => isset($update->update['tested']) ? $update->update['tested'] : null, |
| 819 | 901 | 'requires' => $update->update['requires'], |
| 820 | 902 | 'requires_php' => $update->update['requires_php'], |
| 903 | + 'screenshot_url' => isset($update->update['screenshot_url']) ? $update->update['screenshot_url'] : $this->get_icons_screenshot('theme', $update->update['theme']), | |
| 821 | 904 | ), |
| 822 | 905 | ); |
| 823 | 906 | |
| 824 | 907 | // Check for compatibility and merge result into info |
| @@ -927,9 +1010,9 @@ | ||
| 927 | 1010 | ob_end_clean(); |
| 928 | 1011 | $request_filesystem_credentials[$entity] = ('direct' != $filesystem_method && !$filesystem_credentials_are_stored); |
| 929 | 1012 | } |
| 930 | 1013 | |
| 931 | - $automatic_backups = (class_exists('UpdraftPlus_Options') && class_exists('UpdraftPlus_Addon_Autobackup') && UpdraftPlus_Options::get_updraft_option('updraft_autobackup_default', true)) ? true : false; | |
| 1014 | + $automatic_backups = (class_exists('UpdraftPlus_Options') && class_exists('UpdraftPlus_Addon_Autobackup') && UpdraftPlus_Options::get_updraft_option('updraft_autobackup_default')) ? true : false; | |
| 932 | 1015 | |
| 933 | 1016 | return $this->_response(array( |
| 934 | 1017 | 'plugins' => $plugin_updates, |
| 935 | 1018 | 'themes' => $theme_updates, |