diff --git a/README.md b/README.md index b87b068..ce1a708 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,12 @@ This plugin is required by other plugins, which uses its libraries and its setti ## Changelog ## +### 0.3.5 - 2016-03-07 ### +* Improvement: Support for `DBI_` prefixed constants to avoid conflicts with other plugins +* Improvement: Redesign of the Addons page +* Improvement: Compatibility with WP Offload S3 Lite 1.0 +* Improvement: Compatibility with WP Offload S3 1.1 + ### 0.3.4 - 2015-11-02 ### * Improvement: Compatibility with WP Offload S3 Pro 1.0.3 diff --git a/amazon-web-services.php b/amazon-web-services.php index cf03314..f48ed18 100644 --- a/amazon-web-services.php +++ b/amazon-web-services.php @@ -4,7 +4,7 @@ Plugin URI: http://wordpress.org/extend/plugins/amazon-web-services/ Description: Includes the Amazon Web Services PHP libraries, stores access keys, and allows other plugins to hook into it. Author: Delicious Brains -Version: 0.3.4 +Version: 0.3.5 Author URI: http://deliciousbrains.com/ Network: True Text Domain: amazon-web-services @@ -22,10 +22,11 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. // ********************************************************************** -$GLOBALS['aws_meta']['amazon-web-services']['version'] = '0.3.4'; +$GLOBALS['aws_meta']['amazon-web-services']['version'] = '0.3.5'; $GLOBALS['aws_meta']['amazon-web-services']['supported_addon_versions'] = array( - 'amazon-s3-and-cloudfront' => '0.9', + 'amazon-s3-and-cloudfront' => '0.9', + 'amazon-s3-and-cloudfront-pro' => '1.0b1', ); require dirname( __FILE__ ) . '/classes/aws-compatibility-check.php'; diff --git a/assets/css/styles.css b/assets/css/styles.css index a5acad1..0bd503f 100644 --- a/assets/css/styles.css +++ b/assets/css/styles.css @@ -1 +1 @@ -.aws-content,.aws-updated,.aws-compatibility-notice{box-sizing:border-box;max-width:650px}.toplevel_page_amazon-web-services .error,.toplevel_page_amazon-web-services .notice,.toplevel_page_amazon-web-services .updated{box-sizing:border-box;max-width:650px}.aws-addons,.aws-main[data-view="addons"] .aws-compatibility-notice{max-width:772px}.aws-settings h3{font-size:20px}.aws-settings .need-help{background-color:#fff;padding:20px 20px 20px 50px;line-height:1;font-size:16px;font-weight:bold;position:relative}.aws-settings .need-help:before{font-family:"dashicons";content:"\f348";font-size:24px;line-height:1;width:24px;height:24px;position:absolute;top:16px;left:16px}.aws-settings .need-help a{text-decoration:none}.aws-settings p{font-size:14px}body.toplevel_page_amazon-web-services .wrap h1{color:#fff;font-weight:600;font-size:26px;line-height:1;margin:20px 0 15px 0;width:650px;padding:100px 0 0 25px;height:150px;background:#f7a80d url(../img/aws-logo.svg) right 40px center no-repeat;background-size:100px 79px;box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box}.aws-addons .addons-list{margin:20px 0 200px;padding-top:5px;border-top:1px solid #ddd;font-size:14px}.aws-addons .addons-list li:last-child{margin-bottom:0}.aws-addons .addons-list article{margin-top:10px;width:100%;height:250px;position:relative;font-weight:300;line-height:1;overflow:hidden}.aws-addons .addons-list article .info{position:absolute;bottom:20px;left:20px}.aws-addons .addons-list article .info ul{margin:16px 0 0;color:rgba(255,255,255,0.7)}.aws-addons .addons-list article .info ul li{display:inline-block;margin:0 30px 0 0}.aws-addons .addons-list article .info ul li:last-child{margin-right:0}.aws-addons .addons-list article .info a{color:#fff;text-decoration:none}.aws-addons .addons-list article .info a:hover{text-decoration:underline}.aws-addons .addons-list article h1,.aws-addons .addons-list article h2{padding:0;color:#fff;line-height:1;font-weight:600}.aws-addons .addons-list article h1{margin:0;font-size:26px}.aws-addons .addons-list article h2{margin:4px 0 0;font-size:18px}.aws-addons .addons-list article .label{position:absolute;top:10px;right:10px;font-style:italic;color:#fff}.aws-addons .addons-list ul{margin:0 120px 0 80px}.aws-addons .addons-list ul article{height:100px}.aws-addons .addons-list ul article .info{position:static;padding:25px 20px 25px 110px}.aws-addons .addons-list ul article .info ul{margin:12px 0 0}.aws-addons .addons-list ul article h1{font-size:22px}.aws-addons .addons-list ul ul{margin-right:0}.aws-addons .addons-list ul ul article{height:80px}.aws-addons .addons-list ul ul article .info{padding:19px 10px 19px 90px}.aws-addons .addons-list ul ul article .info ul{margin:8px 0 0}.aws-addons .addons-list ul ul article h1{font-size:20px;font-weight:300}.aws-addons .addons-list .amazon-s3-and-cloudfront article{background-image:url(../img/as3cf-banner.jpg);background-size:772px 250px;background-repeat:no-repeat}@media (min--moz-device-pixel-ratio: 1.3), (-o-min-device-pixel-ratio: 2.6 / 2), (-webkit-min-device-pixel-ratio: 1.3), (min-device-pixel-ratio: 1.3), (min-resolution: 1.3dppx){.aws-addons .addons-list .amazon-s3-and-cloudfront article{background-image:url(../img/as3cf-banner@2x.jpg)}}.aws-addons .addons-list .amazon-s3-and-cloudfront-pro article{background:#d4a637 url(../img/icon-pro.svg) no-repeat 15px center;background-size:70px 70px}.aws-addons .addons-list .amazon-s3-and-cloudfront-woocommerce article{background:#a46497 url(../img/icon-woocommerce.svg) no-repeat 15px center;background-size:50px 50px}.aws-addons .addons-list .amazon-s3-and-cloudfront-edd article{background:#1d2428 url(../img/icon-edd.svg) no-repeat 15px center;background-size:50px 50px}.aws-addons .addons-list .amazon-s3-and-cloudfront-assets article{background:#0769ad url(../img/icon-assets.svg) no-repeat 15px center;background-size:50px 50px}.aws-addons .addons-list .amazon-s3-and-cloudfront-wpml article{background:#277f91 url(../img/icon-wpml.svg) no-repeat 15px center;background-size:50px 50px}.aws-addons .addons-list .amazon-s3-and-cloudfront-meta-slider article{background:#03b0d8 url(../img/icon-meta-slider.svg) no-repeat 15px center;background-size:50px 50px}.aws-addons .addons-list .amazon-s3-and-cloudfront-enable-media-replace article{background:#3c6 url(../img/icon-enable-media-replace.svg) no-repeat 15px center;background-size:50px 50px}.aws-addons .addons-list li li.addon{position:relative}.aws-addons .addons-list li li.addon:before,.aws-addons .addons-list li li.addon:after{content:'';position:absolute;display:block;background:#ddd}.aws-addons .addons-list li li.addon:before{top:0;left:-45px;width:10px;height:65px}.aws-addons .addons-list li li.addon:after{top:55px;left:-45px;width:35px;height:10px}.aws-addons .addons-list li li.addon li:before{height:45px}.aws-addons .addons-list li li.addon li:after{top:35px}.aws-addons .addons-list li li.addon:not(:first-child):before{top:-45px;height:80px}.aws-addons .addons-list li li.addon .info span.type{position:absolute;top:10px;right:15px;font-style:italic;color:#fff} +.aws-content,.aws-updated,.aws-compatibility-notice{-webkit-box-sizing:border-box;box-sizing:border-box;max-width:650px}.toplevel_page_amazon-web-services .error,.toplevel_page_amazon-web-services .notice,.toplevel_page_amazon-web-services .updated{-webkit-box-sizing:border-box;box-sizing:border-box;max-width:650px}.aws-addons,.aws-main[data-view="addons"] .aws-compatibility-notice{max-width:772px}.aws-settings h3{font-size:20px}.aws-settings .need-help{background-color:#fff;padding:20px 20px 20px 50px;line-height:1;font-size:16px;font-weight:bold;position:relative}.aws-settings .need-help:before{font-family:"dashicons";content:"\f348";font-size:24px;line-height:1;width:24px;height:24px;position:absolute;top:16px;left:16px}.aws-settings .need-help a{text-decoration:none}.aws-settings p{font-size:14px}body.toplevel_page_amazon-web-services .wrap h1{color:#fff;font-weight:600;font-size:26px;line-height:1;margin:20px 0 15px 0;width:650px;padding:100px 0 0 25px;height:150px;background:#f7a80d url(../img/aws-logo.svg) right 40px center no-repeat;background-size:100px 79px;box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box}.aws-addons .addons-list{margin:20px 0 200px;padding-top:5px;border-top:1px solid #ddd;font-size:14px}.aws-addons .addons-list li:last-child{margin-bottom:0}.aws-addons .addons-list article{margin-top:10px;width:100%;height:250px;position:relative;font-weight:300;line-height:1;overflow:hidden}.aws-addons .addons-list article .info{position:absolute;bottom:20px;left:20px}.aws-addons .addons-list article .info ul{margin:16px 0 0;color:rgba(255,255,255,0.7)}.aws-addons .addons-list article .info ul li{display:inline-block;margin:0 30px 0 0}.aws-addons .addons-list article .info ul li:last-child{margin-right:0}.aws-addons .addons-list article .info a{color:#fff;text-decoration:none}.aws-addons .addons-list article .info a:hover{text-decoration:underline}.aws-addons .addons-list article h1,.aws-addons .addons-list article h2{padding:0;color:#fff;line-height:1;font-weight:600}.aws-addons .addons-list article h1{margin:0;font-size:26px}.aws-addons .addons-list article h2{margin:4px 0 0;font-size:18px}.aws-addons .addons-list article .label{position:absolute;top:10px;right:10px;font-style:italic;color:#fff}.aws-addons .addons-list>li>ul{background-color:#fff;border-top:0;padding:10px;overflow:hidden}.aws-addons .addons-list>li>ul article{width:244px;float:left;margin-right:10px}.aws-addons .addons-list>li>ul article img{width:80px;height:80px}.aws-addons .addons-list>li>ul article h1{font-size:22px;line-height:1.2}.aws-addons .addons-list>li>ul article .info{left:0;right:0;margin:0 auto;width:210px;text-align:center}.aws-addons .addons-list>li>ul article .info ul li{margin-right:10px;font-size:13px;line-height:1.6}.aws-addons .addons-list>li>ul li{margin-bottom:0}.aws-addons .addons-list .amazon-s3-and-cloudfront>article{background-image:url(../img/as3cf-banner-bw.jpg);background-size:772px 150px;background-repeat:no-repeat;height:150px}@media (min--moz-device-pixel-ratio: 1.3), (-webkit-min-device-pixel-ratio: 1.3), (min-device-pixel-ratio: 1.3), (min-resolution: 1.3dppx){.aws-addons .addons-list .amazon-s3-and-cloudfront>article{background-image:url(../img/as3cf-banner-bw@2x.jpg)}}.aws-addons .addons-list .amazon-s3-and-cloudfront-pro>article{background-image:url(../img/as3cf-banner.jpg);background-size:772px 250px;background-repeat:no-repeat}@media (min--moz-device-pixel-ratio: 1.3), (-webkit-min-device-pixel-ratio: 1.3), (min-device-pixel-ratio: 1.3), (min-resolution: 1.3dppx){.aws-addons .addons-list .amazon-s3-and-cloudfront-pro>article{background-image:url(../img/as3cf-banner@2x.jpg)}}.aws-addons .addons-list .amazon-s3-and-cloudfront-woocommerce>article{background-color:#a46497;margin:0}.aws-addons .addons-list .amazon-s3-and-cloudfront-edd>article{background-color:#1d2428;background-position:center 50px}.aws-addons .addons-list .amazon-s3-and-cloudfront-assets>article{background-color:#0769ad;width:498px;margin-top:0}.aws-addons .addons-list .amazon-s3-and-cloudfront-assets>article img{width:100px;height:100px}.aws-addons .addons-list .amazon-s3-and-cloudfront-assets>article h1{font-size:30px}.aws-addons .addons-list .amazon-s3-and-cloudfront-wpml>article{background-color:#277f91}.aws-addons .addons-list .amazon-s3-and-cloudfront-meta-slider>article{background-color:#03b0d8;margin-right:0}.aws-addons .addons-list .amazon-s3-and-cloudfront-enable-media-replace>article{background-color:#33cc66}.aws-addons .addons-list .amazon-s3-and-cloudfront-enable-media-replace>article img{width:70px;height:70px;margin-bottom:10px}.aws-addons .addons-list .amazon-s3-and-cloudfront-acf-image-crop>article{background-color:#f55e4f} diff --git a/assets/img/as3cf-banner-bw.jpg b/assets/img/as3cf-banner-bw.jpg new file mode 100644 index 0000000..8ee652b Binary files /dev/null and b/assets/img/as3cf-banner-bw.jpg differ diff --git a/assets/img/as3cf-banner-bw@2x.jpg b/assets/img/as3cf-banner-bw@2x.jpg new file mode 100644 index 0000000..f91757a Binary files /dev/null and b/assets/img/as3cf-banner-bw@2x.jpg differ diff --git a/assets/img/icon-acf-image-crop.svg b/assets/img/icon-acf-image-crop.svg new file mode 100644 index 0000000..f4edcf2 --- /dev/null +++ b/assets/img/icon-acf-image-crop.svg @@ -0,0 +1,10 @@ + + + + Untitled 5 + Created with Sketch. + + + + + \ No newline at end of file diff --git a/assets/img/icon-pro.svg b/assets/img/icon-pro.svg deleted file mode 100644 index 04173ac..0000000 --- a/assets/img/icon-pro.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - - Untitled - Created with Sketch. - - - - - \ No newline at end of file diff --git a/assets/js/script.js b/assets/js/script.js index 7e8ef00..9e0916b 100644 --- a/assets/js/script.js +++ b/assets/js/script.js @@ -1,4 +1,4 @@ -(function($) { +(function( $ ) { $( document ).ready( function() { @@ -9,8 +9,7 @@ var $form = $( 'form', $container ); if ( 'block' === $form.css( 'display' ) ) { $form.hide(); - } - else { + } else { $form.show(); } return false; @@ -23,4 +22,4 @@ } ); -})(jQuery); \ No newline at end of file +})( jQuery ); diff --git a/assets/sass/styles.scss b/assets/sass/styles.scss index e4fd50e..51a5f63 100644 --- a/assets/sass/styles.scss +++ b/assets/sass/styles.scss @@ -153,51 +153,66 @@ body.toplevel_page_amazon-web-services .wrap { } } - // Second depth - ul { - margin: 0 120px 0 80px; + // Addons + > li > ul { + background-color: #fff; + border-top: 0; + padding: 10px; + overflow: hidden; article { - height: 100px; - - .info { - position: static; - padding: 25px 20px 25px 110px; + width: 244px; + float: left; + margin-right: 10px; - ul { - margin: 12px 0 0; - } + img { + width: 80px; + height: 80px; } h1 { font-size: 22px; + line-height: 1.2; } - } - - // Third depth - ul { - margin-right: 0; - - article { - height: 80px; - .info { - padding: 19px 10px 19px 90px; + .info { + left: 0; + right: 0; + margin: 0 auto; + width: 210px; + text-align: center; - ul { - margin: 8px 0 0; + ul { + li { + margin-right: 10px; + font-size: 13px; + line-height: 1.6; } } - - h1 { - font-size: 20px; - font-weight: 300; - } } } + + li { + margin-bottom: 0; + } + } + + .amazon-s3-and-cloudfront > article { + background-image: url(../img/as3cf-banner-bw.jpg); + background-size: 772px 150px; + background-repeat: no-repeat; + height: 150px; + + @media (min--moz-device-pixel-ratio: 1.3), + (-o-min-device-pixel-ratio: 2.6/2), + (-webkit-min-device-pixel-ratio: 1.3), + (min-device-pixel-ratio: 1.3), + (min-resolution: 1.3dppx) { + background-image: url(../img/as3cf-banner-bw@2x.jpg); + } } - .amazon-s3-and-cloudfront article { + .amazon-s3-and-cloudfront-pro > article { background-image: url(../img/as3cf-banner.jpg); background-size: 772px 250px; background-repeat: no-repeat; @@ -211,93 +226,52 @@ body.toplevel_page_amazon-web-services .wrap { } } - .amazon-s3-and-cloudfront-pro article { - background: #d4a637 url(../img/icon-pro.svg) no-repeat 15px center; - background-size: 70px 70px; + .amazon-s3-and-cloudfront-woocommerce > article { + background-color: #a46497; + margin: 0; } - .amazon-s3-and-cloudfront-woocommerce article { - background: #a46497 url(../img/icon-woocommerce.svg) no-repeat 15px center; - background-size: 50px 50px; + .amazon-s3-and-cloudfront-edd > article { + background-color: #1d2428; + background-position: center 50px; } - .amazon-s3-and-cloudfront-edd article { - background: #1d2428 url(../img/icon-edd.svg) no-repeat 15px center; - background-size: 50px 50px; - } + .amazon-s3-and-cloudfront-assets > article { + background-color: #0769ad; + width: 498px; + margin-top: 0; - .amazon-s3-and-cloudfront-assets article { - background: #0769ad url(../img/icon-assets.svg) no-repeat 15px center; - background-size: 50px 50px; - } + img { + width: 100px; + height: 100px; + } - .amazon-s3-and-cloudfront-wpml article { - background: #277f91 url(../img/icon-wpml.svg) no-repeat 15px center; - background-size: 50px 50px; + h1 { + font-size: 30px; + } } - .amazon-s3-and-cloudfront-meta-slider article { - background: #03b0d8 url(../img/icon-meta-slider.svg) no-repeat 15px center; - background-size: 50px 50px; + .amazon-s3-and-cloudfront-wpml > article { + background-color: #277f91; } - .amazon-s3-and-cloudfront-enable-media-replace article { - background: #33cc66 url(../img/icon-enable-media-replace.svg) no-repeat 15px center; - background-size: 50px 50px; + .amazon-s3-and-cloudfront-meta-slider > article { + background-color: #03b0d8; + margin-right: 0; } - // Tree hierarchy - li li.addon { - position: relative; - - &:before, - &:after { - content: ''; - position: absolute; - display: block; - background: #ddd; - } - - &:before { - top: 0; - left: -45px; - width: 10px; - height: 65px; - } - - &:after { - top: 55px; - left: -45px; - width: 35px; - height: 10px; - } - - // Second depth - li:before { - height: 45px; - } + .amazon-s3-and-cloudfront-enable-media-replace > article { + background-color: #33cc66; - li:after { - top: 35px; - } - - // Adjust height for all but first child - &:not(:first-child) { - &:before { - top: -45px; - height: 80px; - } + img { + width: 70px; + height: 70px; + margin-bottom: 10px; } + } - .info { - span.type { - position: absolute; - top: 10px; - right: 15px; - font-style: italic; - color: #fff; - } - } + .amazon-s3-and-cloudfront-acf-image-crop > article { + background-color: #f55e4f; } } } \ No newline at end of file diff --git a/classes/amazon-web-services.php b/classes/amazon-web-services.php index b47b466..6ff6596 100644 --- a/classes/amazon-web-services.php +++ b/classes/amazon-web-services.php @@ -24,6 +24,7 @@ class Amazon_Web_Services extends AWS_Plugin_Base { private $client; const SETTINGS_KEY = 'aws_settings'; + const SETTINGS_CONSTANT = 'AWS_SETTINGS'; /** * @param string $plugin_file_path @@ -112,22 +113,20 @@ function add_page( $page_title, $menu_title, $capability, $menu_slug, $function * Load styles for the AWS menu item */ function enqueue_menu_styles() { - $version = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? time() : $this->plugin_version; - $src = plugins_url( 'assets/css/global.css', $this->plugin_file_path ); - wp_enqueue_style( 'aws-global-styles', $src, array(), $version ); + $src = plugins_url( 'assets/css/global.css', $this->plugin_file_path ); + wp_enqueue_style( 'aws-global-styles', $src, array(), $this->get_asset_version() ); } /** * Plugin loading enqueue scripts and styles */ function plugin_load() { - $version = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? time() : $this->plugin_version; + $version = $this->get_asset_version(); + $suffix = $this->get_asset_suffix(); $src = plugins_url( 'assets/css/styles.css', $this->plugin_file_path ); wp_enqueue_style( 'aws-styles', $src, array(), $version ); - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; - $src = plugins_url( 'assets/js/script' . $suffix . '.js', $this->plugin_file_path ); wp_enqueue_script( 'aws-script', $src, array( 'jquery' ), $version, true ); @@ -224,6 +223,15 @@ function are_key_constants_set() { return defined( 'AWS_ACCESS_KEY_ID' ) && defined( 'AWS_SECRET_ACCESS_KEY' ); } + /** + * Check if we are using the prefixed constants for the AWS access credentials + * + * @return bool + */ + function are_prefixed_key_constants_set() { + return defined( 'DBI_AWS_ACCESS_KEY_ID' ) && defined( 'DBI_AWS_SECRET_ACCESS_KEY' ); + } + /** * Check if access keys are defined either by constants or database * @@ -239,8 +247,10 @@ function are_access_keys_set() { * @return string */ function get_access_key_id() { - if ( $this->are_key_constants_set() ) { - return AWS_ACCESS_KEY_ID; + if ( defined( 'DBI_AWS_ACCESS_KEY_ID' ) ) { + return DBI_AWS_ACCESS_KEY_ID; + } elseif ( defined( 'AWS_ACCESS_KEY_ID' ) ) { + return AWS_ACCESS_KEY_ID; // Deprecated } return $this->get_setting( 'access_key_id' ); @@ -252,8 +262,10 @@ function get_access_key_id() { * @return string */ function get_secret_access_key() { - if ( $this->are_key_constants_set() ) { - return AWS_SECRET_ACCESS_KEY; + if ( defined( 'DBI_AWS_SECRET_ACCESS_KEY' ) ) { + return DBI_AWS_SECRET_ACCESS_KEY; + } elseif ( defined( 'AWS_SECRET_ACCESS_KEY' ) ) { + return AWS_SECRET_ACCESS_KEY; // Deprecated } return $this->get_setting( 'secret_access_key' ); @@ -347,50 +359,61 @@ function get_plugin_action_settings_text() { function get_addons( $unfiltered = false ) { $addons = array( 'amazon-s3-and-cloudfront' => array( - 'title' => __( 'WP Offload S3', 'amazon-web-services' ), + 'title' => __( 'WP Offload S3 Lite', 'amazon-web-services' ), 'url' => 'https://wordpress.org/plugins/amazon-s3-and-cloudfront/', 'install' => true, - 'addons' => array( - 'amazon-s3-and-cloudfront-pro' => array( - 'title' => __( 'Pro Upgrade', 'amazon-web-services' ), - 'url' => 'https://deliciousbrains.com/wp-offload-s3/', - 'addons' => array( - 'amazon-s3-and-cloudfront-assets' => array( - 'title' => __( 'Assets', 'amazon-web-services' ), - 'url' => 'https://deliciousbrains.com/wp-offload-s3/doc/assets-addon/', - 'label' => __( 'Addon', 'amazon-web-services' ), - ), - 'amazon-s3-and-cloudfront-woocommerce' => array( - 'title' => __( 'WooCommerce', 'amazon-web-services' ), - 'url' => 'https://deliciousbrains.com/wp-offload-s3/doc/woocommerce-addon/', - 'label' => __( 'Addon', 'amazon-web-services' ), - 'parent_plugin_basename' => 'woocommerce/woocommerce.php', - ), - 'amazon-s3-and-cloudfront-edd' => array( - 'title' => __( 'Easy Digital Downloads', 'amazon-web-services' ), - 'url' => 'https://deliciousbrains.com/wp-offload-s3/doc/edd-addon/', - 'label' => __( 'Addon', 'amazon-web-services' ), - 'parent_plugin_basename' => 'easy-digital-downloads/easy-digital-downloads.php', - ), - 'amazon-s3-and-cloudfront-wpml' => array( - 'title' => __( 'WPML', 'amazon-web-services' ), - 'url' => 'https://deliciousbrains.com/wp-offload-s3/doc/wpml-addon/', - 'label' => __( 'Addon', 'amazon-web-services' ), - 'parent_plugin_basename' => 'wpml-media/plugin.php', - ), - 'amazon-s3-and-cloudfront-meta-slider' => array( - 'title' => __( 'Meta Slider', 'amazon-web-services' ), - 'url' => 'https://deliciousbrains.com/wp-offload-s3/doc/meta-slider-addon/', - 'label' => __( 'Addon', 'amazon-web-services' ), - 'parent_plugin_basename' => 'ml-slider/ml-slider.php', - ), - 'amazon-s3-and-cloudfront-enable-media-replace' => array( - 'title' => __( 'Enable Media Replace', 'amazon-web-services' ), - 'url' => 'https://deliciousbrains.com/wp-offload-s3/doc/enable-media-replace-addon/', - 'label' => __( 'Addon', 'amazon-web-services' ), - 'parent_plugin_basename' => 'enable-media-replace/enable-media-replace.php', - ), - ), + ), + 'amazon-s3-and-cloudfront-pro' => array( + 'title' => __( 'WP Offload S3', 'amazon-web-services' ), + 'url' => 'https://deliciousbrains.com/wp-offload-s3/', + 'addons' => array( + 'amazon-s3-and-cloudfront-assets' => array( + 'title' => __( 'Assets', 'amazon-web-services' ), + 'url' => 'https://deliciousbrains.com/wp-offload-s3/doc/assets-addon/', + 'label' => __( 'Feature', 'amazon-web-services' ), + 'icon' => true, + ), + 'amazon-s3-and-cloudfront-woocommerce' => array( + 'title' => __( 'WooCommerce', 'amazon-web-services' ), + 'url' => 'https://deliciousbrains.com/wp-offload-s3/doc/woocommerce-addon/', + 'label' => __( 'Integration', 'amazon-web-services' ), + 'parent_plugin_basename' => 'woocommerce/woocommerce.php', + 'icon' => true, + ), + 'amazon-s3-and-cloudfront-edd' => array( + 'title' => __( 'Easy Digital Downloads', 'amazon-web-services' ), + 'url' => 'https://deliciousbrains.com/wp-offload-s3/doc/edd-addon/', + 'label' => __( 'Integration', 'amazon-web-services' ), + 'parent_plugin_basename' => 'easy-digital-downloads/easy-digital-downloads.php', + 'icon' => true, + ), + 'amazon-s3-and-cloudfront-wpml' => array( + 'title' => __( 'WPML', 'amazon-web-services' ), + 'url' => 'https://deliciousbrains.com/wp-offload-s3/doc/wpml-addon/', + 'label' => __( 'Integration', 'amazon-web-services' ), + 'parent_plugin_basename' => 'wpml-media/plugin.php', + 'icon' => true, + ), + 'amazon-s3-and-cloudfront-meta-slider' => array( + 'title' => __( 'Meta Slider', 'amazon-web-services' ), + 'url' => 'https://deliciousbrains.com/wp-offload-s3/doc/meta-slider-addon/', + 'label' => __( 'Integration', 'amazon-web-services' ), + 'parent_plugin_basename' => 'ml-slider/ml-slider.php', + 'icon' => true, + ), + 'amazon-s3-and-cloudfront-enable-media-replace' => array( + 'title' => __( 'Enable Media Replace', 'amazon-web-services' ), + 'url' => 'https://deliciousbrains.com/wp-offload-s3/doc/enable-media-replace-addon/', + 'label' => __( 'Integration', 'amazon-web-services' ), + 'parent_plugin_basename' => 'enable-media-replace/enable-media-replace.php', + 'icon' => true, + ), + 'amazon-s3-and-cloudfront-acf-image-crop' => array( + 'title' => __( 'ACF Image Crop', 'amazon-web-services' ), + 'url' => 'https://deliciousbrains.com/wp-offload-s3/doc/acf-image-crop-addon/', + 'label' => __( 'Integration', 'amazon-web-services' ), + 'parent_plugin_basename' => 'acf-image-crop-add-on/acf-image-crop.php', + 'icon' => true, ), ), ), @@ -415,6 +438,10 @@ function render_addons( $addons = null ) { $addons = $this->get_addons(); } + if ( class_exists( 'Amazon_S3_And_CloudFront_Pro' ) ) { + unset( $addons['amazon-s3-and-cloudfront'] ); + } + foreach ( $addons as $slug => $addon ) { $this->render_view( 'addon', array( 'slug' => $slug, 'addon' => $addon ) ); } @@ -452,6 +479,19 @@ function get_addon_install_link( $slug, $addon ) { } } + /** + * Get the URL of the addon's icon + * + * @param string $slug + * + * @return string + */ + function get_addon_icon_url( $slug ) { + $filename = str_replace( 'amazon-s3-and-cloudfront-', '', $slug ); + $filename = 'icon-' . $filename . '.svg'; + echo plugins_url( 'assets/img/' . $filename, $this->plugin_file_path ); + } + /** * Add details link to AWS addon page * diff --git a/classes/aws-plugin-base.php b/classes/aws-plugin-base.php index 2acb9b9..23c47dd 100644 --- a/classes/aws-plugin-base.php +++ b/classes/aws-plugin-base.php @@ -13,6 +13,11 @@ class AWS_Plugin_Base { */ private $settings; + /** + * @var array + */ + private $defined_settings; + function __construct( $plugin_file_path ) { $this->plugin_file_path = $plugin_file_path; $this->plugin_dir_path = rtrim( plugin_dir_path( $plugin_file_path ), '/' ); @@ -74,12 +79,88 @@ public function get_plugin_dir_path() { */ function get_settings( $force = false ) { if ( is_null( $this->settings ) || $force ) { - $this->settings = get_site_option( static::SETTINGS_KEY ); + $this->settings = $this->filter_settings( get_site_option( static::SETTINGS_KEY ) ); } return $this->settings; } + /** + * Get all settings that have been defined via constant for the plugin + * + * @param bool $force + * + * @return array + */ + function get_defined_settings( $force = false ) { + if ( is_null( $this->defined_settings ) || $force ) { + $this->defined_settings = array(); + $unserialized = array(); + $class = get_class( $this ); + + if ( defined( "$class::SETTINGS_CONSTANT" ) ) { + $constant = static::SETTINGS_CONSTANT; + if ( defined( $constant ) ) { + $unserialized = maybe_unserialize( constant( $constant ) ); + } + } + + $unserialized = is_array( $unserialized ) ? $unserialized : array(); + + foreach ( $unserialized as $key => $value ) { + if ( ! in_array( $key, $this->get_settings_whitelist() ) ) { + continue; + } + + if ( is_bool( $value ) || is_null( $value ) ) { + $value = (int) $value; + } + + if ( is_numeric( $value ) ) { + $value = strval( $value ); + } else { + $value = sanitize_text_field( $value ); + } + + $this->defined_settings[ $key ] = $value; + } + } + + return $this->defined_settings; + } + + /** + * Filter the plugin settings array + * + * @param array $settings + * + * @return array $settings + */ + function filter_settings( $settings ) { + $defined_settings = $this->get_defined_settings(); + + // Bail early if there are no defined settings + if ( empty( $defined_settings ) ) { + return $settings; + } + + foreach ( $defined_settings as $key => $value ) { + $settings[ $key ] = $value; + } + + return $settings; + } + + /** + * Get the whitelisted settings for the plugin. + * Meant to be overridden in child classes. + * + * @return array + */ + function get_settings_whitelist() { + return array(); + } + /** * Get a specific setting * @@ -92,10 +173,27 @@ function get_setting( $key, $default = '' ) { $this->get_settings(); if ( isset( $this->settings[ $key ] ) ) { - return $this->settings[ $key ]; + $setting = $this->settings[ $key ]; + } else { + $setting = $default; } - return $default; + return apply_filters( 'aws_get_setting', $setting, $key ); + } + + /** + * Gets a single setting that has been defined in the plugin settings constant + * + * @param string $key + * @param mixed $default + * + * @return mixed + */ + function get_defined_setting( $key, $default = '' ) { + $defined_settings = $this->get_defined_settings(); + $setting = isset( $defined_settings[ $key ] ) ? $defined_settings[ $key ] : $default; + + return $setting; } /** @@ -111,6 +209,21 @@ function remove_setting( $key ) { } } + /** + * Removes a defined setting from the defined_settings array. + * + * Does not unset the actual constant. + * + * @param $key + */ + function remove_defined_setting( $key ) { + $this->get_defined_settings(); + + if ( isset( $this->defined_settings[ $key ] ) ) { + unset( $this->defined_settings[ $key ] ); + } + } + /** * Render a view template file * @@ -188,4 +301,22 @@ function plugin_actions_settings_link( $links, $file ) { return $links; } + + /** + * Get the version used for script enqueuing + * + * @return mixed + */ + public function get_asset_version() { + return defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? time() : $this->plugin_version; + } + + /** + * Get the filename suffix used for script enqueuing + * + * @return mixed + */ + public function get_asset_suffix() { + return defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; + } } \ No newline at end of file diff --git a/classes/wp-aws-compatibility-check.php b/classes/wp-aws-compatibility-check.php index 61ab3cd..15ec5d7 100644 --- a/classes/wp-aws-compatibility-check.php +++ b/classes/wp-aws-compatibility-check.php @@ -30,7 +30,7 @@ class WP_AWS_Compatibility_Check { protected $plugin_slug; /** - * @var string The name of the plugin, e.g. WP Offload S3 - Pro Upgrade + * @var string The name of the plugin, e.g. WP Offload S3 */ protected $plugin_name; @@ -123,6 +123,19 @@ function is_compatible() { return $compatible; } + /** + * Is a plugin active + * + * @param string $plugin_base + * + * @return bool + */ + function is_plugin_active( $plugin_base ) { + include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); + + return is_plugin_active( $plugin_base ); + } + /** * Get the basename for the plugin * diff --git a/classes/wp-aws-uninstall.php b/classes/wp-aws-uninstall.php index b24a097..e9414a3 100644 --- a/classes/wp-aws-uninstall.php +++ b/classes/wp-aws-uninstall.php @@ -53,6 +53,11 @@ class WP_AWS_Uninstall { */ protected $transients; + /** + * @var array|string User meta to be deleted + */ + protected $usermeta; + /** * @var array Blog(s) in site */ @@ -65,17 +70,20 @@ class WP_AWS_Uninstall { * @param array|string $postmeta * @param array|string $crons * @param array|string $transients + * @param array|string $usermeta */ public function __construct( $options = array(), $postmeta = array(), $crons = array(), - $transients = array() + $transients = array(), + $usermeta = array() ) { $this->options = $this->maybe_convert_to_array( $options ); $this->postmeta = $this->maybe_convert_to_array( $postmeta ); $this->crons = $this->maybe_convert_to_array( $crons ); $this->transients = $this->maybe_convert_to_array( $transients ); + $this->usermeta = $this->maybe_convert_to_array( $usermeta ); $this->set_blog_ids(); @@ -83,6 +91,7 @@ public function __construct( $this->delete_postmeta(); $this->clear_crons(); $this->delete_transients(); + $this->delete_usermeta(); } /** @@ -201,17 +210,52 @@ public function delete_transients() { $subsite_transients = $this->maybe_convert_to_array( $this->transients['subsite'] ); foreach ( $this->blog_ids as $blog_id ) { - if ( is_multisite() && ! $this->is_current_blog( $blog_id ) ) { + if ( is_multisite() && $blog_id !== get_current_blog_id() ) { switch_to_blog( $blog_id ); } foreach ( $subsite_transients as $transient ) { delete_transient( $transient ); } + + if ( is_multisite() ) { + restore_current_blog(); + } } + } + } + + /** + * Delete user meta. + */ + public function delete_usermeta() { + global $wpdb; + + if ( empty( $this->usermeta ) ) { + return; + } + + // Loop through our user meta keys to create our WHERE clauses. + $where_array = array(); + foreach ( $this->usermeta as $usermeta ) { + $where_array[] = $wpdb->prepare( "meta_key = '%s'", $usermeta ); + } + + // Merge all WHERE clauses into an OR comparison. + $where_sql = implode( ' OR ', $where_array ); + + // Get any user ids that have keys to be deleted. + $user_ids = $wpdb->get_col( "SELECT DISTINCT user_id FROM {$wpdb->usermeta} WHERE {$where_sql}" ); + + // Bail if no user has keys to be deleted. + if ( empty( $user_ids ) ) { + return; + } - if ( is_multisite() && ! $this->is_current_blog( $blog_id ) ) { - restore_current_blog(); + // Loop through the list of users and delete our user meta. + foreach ( $user_ids as $user_id ) { + foreach ( $this->usermeta as $usermeta ) { + delete_user_meta( $user_id, $usermeta ); } } } diff --git a/languages/amazon-web-services-en.pot b/languages/amazon-web-services-en.pot index 2739740..4fa8b16 100644 --- a/languages/amazon-web-services-en.pot +++ b/languages/amazon-web-services-en.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: amazon-web-services\n" "Report-Msgid-Bugs-To: nom@deliciousbrains.com\n" -"POT-Creation-Date: 2015-11-02 14:25+0000\n" +"POT-Creation-Date: 2016-03-07 16:39+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,105 +17,113 @@ msgstr "" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" -#: classes/amazon-web-services.php:50 -#: classes/amazon-web-services.php:196 +#: classes/amazon-web-services.php:51 +#: classes/amazon-web-services.php:195 msgid "Amazon Web Services" msgstr "" -#: classes/amazon-web-services.php:51 +#: classes/amazon-web-services.php:52 msgid "AWS" msgstr "" -#: classes/amazon-web-services.php:74 +#: classes/amazon-web-services.php:75 msgid "Addons" msgstr "" -#: classes/amazon-web-services.php:82 -#: classes/amazon-web-services.php:337 +#: classes/amazon-web-services.php:83 +#: classes/amazon-web-services.php:349 #: view/settings.php:14 msgid "Access Keys" msgstr "" -#: classes/amazon-web-services.php:154 +#: classes/amazon-web-services.php:153 msgid "Cheatin' eh?" msgstr "" -#: classes/amazon-web-services.php:205 +#: classes/amazon-web-services.php:204 msgid "Amazon Web Services: Addons" msgstr "" -#: classes/amazon-web-services.php:285 +#: classes/amazon-web-services.php:297 #, php-format msgid "" "You must first set your AWS access keys to use this addon." msgstr "" -#: classes/amazon-web-services.php:350 -msgid "WP Offload S3" +#: classes/amazon-web-services.php:362 +msgid "WP Offload S3 Lite" msgstr "" -#: classes/amazon-web-services.php:355 -msgid "Pro Upgrade" +#: classes/amazon-web-services.php:367 +msgid "WP Offload S3" msgstr "" -#: classes/amazon-web-services.php:359 +#: classes/amazon-web-services.php:371 msgid "Assets" msgstr "" -#: classes/amazon-web-services.php:361 -#: classes/amazon-web-services.php:366 -#: classes/amazon-web-services.php:372 -#: classes/amazon-web-services.php:378 -#: classes/amazon-web-services.php:384 -#: classes/amazon-web-services.php:390 -msgid "Addon" +#: classes/amazon-web-services.php:373 +msgid "Feature" msgstr "" -#: classes/amazon-web-services.php:364 +#: classes/amazon-web-services.php:377 msgid "WooCommerce" msgstr "" -#: classes/amazon-web-services.php:370 +#: classes/amazon-web-services.php:379 +#: classes/amazon-web-services.php:386 +#: classes/amazon-web-services.php:393 +#: classes/amazon-web-services.php:400 +#: classes/amazon-web-services.php:407 +#: classes/amazon-web-services.php:414 +msgid "Integration" +msgstr "" + +#: classes/amazon-web-services.php:384 msgid "Easy Digital Downloads" msgstr "" -#: classes/amazon-web-services.php:376 +#: classes/amazon-web-services.php:391 msgid "WPML" msgstr "" -#: classes/amazon-web-services.php:382 +#: classes/amazon-web-services.php:398 msgid "Meta Slider" msgstr "" -#: classes/amazon-web-services.php:388 +#: classes/amazon-web-services.php:405 msgid "Enable Media Replace" msgstr "" -#: classes/amazon-web-services.php:434 +#: classes/amazon-web-services.php:412 +msgid "ACF Image Crop" +msgstr "" + +#: classes/amazon-web-services.php:461 msgctxt "Plugin already installed and activated" msgid "Installed & Activated" msgstr "" -#: classes/amazon-web-services.php:436 +#: classes/amazon-web-services.php:463 msgctxt "Plugin already installed" msgid "Installed" msgstr "" -#: classes/amazon-web-services.php:437 +#: classes/amazon-web-services.php:464 msgctxt "Activate plugin now" msgid "Activate Now" msgstr "" -#: classes/amazon-web-services.php:440 +#: classes/amazon-web-services.php:467 msgctxt "Install plugin now" msgid "Install Now" msgstr "" -#: classes/amazon-web-services.php:463 +#: classes/amazon-web-services.php:503 msgid "Visit Site" msgstr "" -#: classes/amazon-web-services.php:466 +#: classes/amazon-web-services.php:506 msgctxt "View plugin details" msgid "View Details" msgstr "" @@ -142,83 +150,83 @@ msgid "" "7.16.2+ compiled with OpenSSL and zlib. Your server currently has" msgstr "" -#: classes/aws-plugin-base.php:166 +#: classes/aws-plugin-base.php:279 msgid "Settings" msgstr "" -#: classes/wp-aws-compatibility-check.php:310 +#: classes/wp-aws-compatibility-check.php:323 msgid "deactivate" msgstr "" -#: classes/wp-aws-compatibility-check.php:311 +#: classes/wp-aws-compatibility-check.php:324 #, php-format msgid "You can %s the %s plugin to get rid of this notice." msgstr "" -#: classes/wp-aws-compatibility-check.php:314 +#: classes/wp-aws-compatibility-check.php:327 #, php-format msgid "%s has been disabled as it requires the %s plugin." msgstr "" -#: classes/wp-aws-compatibility-check.php:318 +#: classes/wp-aws-compatibility-check.php:331 msgid "which is currently disabled." msgstr "" -#: classes/wp-aws-compatibility-check.php:320 +#: classes/wp-aws-compatibility-check.php:333 msgid "It appears to be installed already." msgstr "" -#: classes/wp-aws-compatibility-check.php:322 +#: classes/wp-aws-compatibility-check.php:335 msgctxt "Activate plugin" msgid "Activate it now." msgstr "" -#: classes/wp-aws-compatibility-check.php:329 +#: classes/wp-aws-compatibility-check.php:342 #, php-format msgid "Install and activate it." msgstr "" -#: classes/wp-aws-compatibility-check.php:340 +#: classes/wp-aws-compatibility-check.php:353 #, php-format msgid "" "%s has been disabled as it requires version %s or later of the %s plugin." msgstr "" -#: classes/wp-aws-compatibility-check.php:343 +#: classes/wp-aws-compatibility-check.php:356 #, php-format msgid "You currently have version %s installed." msgstr "" -#: classes/wp-aws-compatibility-check.php:350 -#: classes/wp-aws-compatibility-check.php:388 +#: classes/wp-aws-compatibility-check.php:363 +#: classes/wp-aws-compatibility-check.php:401 #, php-format msgid "A valid license for %s is required to update." msgstr "" -#: classes/wp-aws-compatibility-check.php:358 +#: classes/wp-aws-compatibility-check.php:371 msgid "Update to the latest version" msgstr "" -#: classes/wp-aws-compatibility-check.php:370 +#: classes/wp-aws-compatibility-check.php:383 #, php-format msgid "" "%1$s has been disabled because it is not a supported addon of the %2$s " "plugin." msgstr "" -#: classes/wp-aws-compatibility-check.php:379 +#: classes/wp-aws-compatibility-check.php:392 #, php-format msgid "" "%1$s has been disabled because it will not work with the version of the %2$s " "plugin installed. %1$s %3$s or later is required." msgstr "" -#: classes/wp-aws-compatibility-check.php:382 +#: classes/wp-aws-compatibility-check.php:395 #, php-format msgid "Update %s to the latest version" msgstr "" -#: classes/wp-aws-compatibility-check.php:451 +#: classes/wp-aws-compatibility-check.php:464 #, php-format msgid "The %s plugin has been deactivated." msgstr "" diff --git a/languages/amazon-web-services-pt-br.mo b/languages/amazon-web-services-pt-br.mo deleted file mode 100644 index 8a0ba74..0000000 Binary files a/languages/amazon-web-services-pt-br.mo and /dev/null differ diff --git a/readme.txt b/readme.txt index cc3dbd5..dcbf579 100644 --- a/readme.txt +++ b/readme.txt @@ -31,6 +31,12 @@ This plugin is required by other plugins, which uses its libraries and its setti == Changelog == += 0.3.5 - 2016-03-07 = +* Improvement: Support for `DBI_` prefixed constants to avoid conflicts with other plugins +* Improvement: Redesign of the Addons page +* Improvement: Compatibility with WP Offload S3 Lite 1.0 +* Improvement: Compatibility with WP Offload S3 1.1 + = 0.3.4 - 2015-11-02 = * Improvement: Compatibility with WP Offload S3 Pro 1.0.3 diff --git a/view/addon.php b/view/addon.php index 852471a..3c73be8 100644 --- a/view/addon.php +++ b/view/addon.php @@ -1,6 +1,9 @@
  • + + +

    diff --git a/view/settings.php b/view/settings.php index 26a98d5..31cb519 100644 --- a/view/settings.php +++ b/view/settings.php @@ -19,7 +19,7 @@

    - are_key_constants_set() && ! $use_ec2_iam_roles ) : ?> + are_prefixed_key_constants_set() || $this->are_key_constants_set() ) ) : ?>

    @@ -31,8 +31,8 @@

    -
    define( 'AWS_ACCESS_KEY_ID', '********************' );
    -define( 'AWS_SECRET_ACCESS_KEY', '****************************************' );
    +
    define( 'DBI_AWS_ACCESS_KEY_ID', '********************' );
    +define( 'DBI_AWS_SECRET_ACCESS_KEY', '****************************************' );

    click here to reveal a form.', 'amazon-web-services' ); ?>