From 49083e62c5980c297902a745571f97539b9644bc Mon Sep 17 00:00:00 2001 From: Git I Hate You Date: Fri, 29 Jun 2018 23:15:26 +0200 Subject: [PATCH 01/21] Introduced class Imagify_WP_Time_Capsule --- inc/3rd-party/3rd-party.php | 1 + .../classes/class-imagify-wp-time-capsule.php | 303 ++++++++++++++++++ .../wp-time-capsule/wp-time-capsule.php | 8 + inc/functions/common.php | 1 + 4 files changed, 313 insertions(+) create mode 100644 inc/3rd-party/wp-time-capsule/inc/classes/class-imagify-wp-time-capsule.php create mode 100644 inc/3rd-party/wp-time-capsule/wp-time-capsule.php diff --git a/inc/3rd-party/3rd-party.php b/inc/3rd-party/3rd-party.php index 77e240cd1..58fffa402 100755 --- a/inc/3rd-party/3rd-party.php +++ b/inc/3rd-party/3rd-party.php @@ -10,6 +10,7 @@ require( IMAGIFY_3RD_PARTY_PATH . 'nextgen-gallery/nextgen-gallery.php' ); require( IMAGIFY_3RD_PARTY_PATH . 'regenerate-thumbnails/regenerate-thumbnails.php' ); require( IMAGIFY_3RD_PARTY_PATH . 'wp-retina-2x/wp-retina-2x.php' ); +require( IMAGIFY_3RD_PARTY_PATH . 'wp-time-capsule/wp-time-capsule.php' ); require( IMAGIFY_3RD_PARTY_PATH . 'screets-lc.php' ); require( IMAGIFY_3RD_PARTY_PATH . 'wp-real-media-library.php' ); require( IMAGIFY_3RD_PARTY_PATH . 'wp-rocket.php' ); diff --git a/inc/3rd-party/wp-time-capsule/inc/classes/class-imagify-wp-time-capsule.php b/inc/3rd-party/wp-time-capsule/inc/classes/class-imagify-wp-time-capsule.php new file mode 100644 index 000000000..f9b938b0d --- /dev/null +++ b/inc/3rd-party/wp-time-capsule/inc/classes/class-imagify-wp-time-capsule.php @@ -0,0 +1,303 @@ +package ) || ! current_user_can( 'update_plugins' ) ) { + return; + } + + $link = ''; + $zelda = ''; + + echo ' '; + /* translators: 1 is a link opening, 2 is a "new window" icon, 3 is the link closing. */ + printf( __( 'You can also %1$sbackup and update %2$s%3$s.', 'imagify' ), $link, $zelda, '' ); + } + + /** + * Print some CSS in the Core Update page for the link into the Imagify row. + * + * @since 1.8.1 + * @access public + * @author Grégory Viguier + */ + public function add_style_to_core_update() { + $action = filter_input( INPUT_GET, 'action', FILTER_SANITIZE_STRING ); + + if ( $action && 'upgrade-core' !== $action ) { + return; + } + + echo "\n"; + } + + /** + * Print some JS in the Core Update page to add a link into the Imagify row. + * + * @since 1.8.1 + * @access public + * @author Grégory Viguier + */ + public function add_script_to_core_update() { + $action = filter_input( INPUT_GET, 'action', FILTER_SANITIZE_STRING ); + + if ( $action && 'upgrade-core' !== $action ) { + return; + } + + $link = __( 'Backup and Update', 'imagify' ) . ' '; + $link = ' ' . __( 'Backup and Update', 'imagify' ) . ' '; + + $output = html_entity_decode( $link, ENT_QUOTES, 'UTF-8' ); + $output = wp_json_encode( $output ); + $output = 'jQuery( "#update-plugins-table .plugin-title p [href*=\"&plugin=imagify&\"]").after( ' . $output . ' );'; + + echo "\n"; + } + + /** + * Maybe launch the hooks that will add a button in the plugin information modal. + * + * @since 1.8.1 + * @access public + * @author Grégory Viguier + * + * @param false|object|array $result The result object or array. Default false. + * @param string $action The type of information being requested from the Plugin Installation API. + * @param object $args Plugin API arguments. + * @return false|object|array + */ + public function maybe_print_link_in_iframe_init( $result, $action, $args ) { + if ( 'plugin_information' !== $action ) { + return $result; + } + if ( empty( $args->slug ) || 'imagify' !== $args->slug ) { + return $result; + } + + $res = (object) $result; + + if ( empty( $res->slug ) || 'imagify' !== $res->slug ) { + return $result; + } + + if ( empty( $res->download_link ) || ( ! current_user_can( 'install_plugins' ) && ! current_user_can( 'update_plugins' ) ) ) { + return $result; + } + + $status = install_plugin_install_status( $res ); + + if ( 'update_available' !== $status['status'] ) { + return $result; + } + + // OK, it's us. + $this->add_iframe_button = true; + + add_action( 'admin_head-plugin-install.php', array( $this, 'print_link_in_iframe_init' ), IMAGIFY_INT_MAX ); + + return $result; + } + + /** + * Launch a ob_start() at the beginning of the plugin information modal. + * + * @since 1.8.1 + * @access public + * @author Grégory Viguier + */ + function print_link_in_iframe_init() { + if ( ! $this->add_iframe_button ) { + return; + } + + ob_start(); + + add_action( 'admin_footer', array( $this, 'print_link_in_iframe' ), 5 ); + } + + /** + * Add a button in the plugin information modal. + * + * @since 1.8.1 + * @access public + * @author Grégory Viguier + */ + function print_link_in_iframe() { + global $tab; + + if ( ! $this->add_iframe_button ) { + return; + } + + $this->add_iframe_button = false; + + $footer = preg_quote( "

- +

From 1ee984cd3c10972a180451d6a758262c7086ac80 Mon Sep 17 00:00:00 2001 From: Git I Hate You Date: Tue, 4 Sep 2018 14:06:31 +0200 Subject: [PATCH 10/21] Hotfix: prevent displaying unnecessary white space in title attributes --- views/part-settings-files-tree-row.php | 38 ++++++++++++-------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/views/part-settings-files-tree-row.php b/views/part-settings-files-tree-row.php index 8807a909a..2c676ac0c 100755 --- a/views/part-settings-files-tree-row.php +++ b/views/part-settings-files-tree-row.php @@ -8,16 +8,15 @@ > - @@ -28,16 +27,15 @@ /> -