Skip to content

Commit

Permalink
Merge pull request #30 from wp-media/branch-1.4.5
Browse files Browse the repository at this point in the history
Rename Admin Page + Add Imagify Banner
  • Loading branch information
remyperona authored Dec 19, 2017
2 parents 123cf35 + 3a1949b commit 7f48a11
Show file tree
Hide file tree
Showing 8 changed files with 251 additions and 8 deletions.
49 changes: 49 additions & 0 deletions admin/actions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php
defined( 'ABSPATH' ) || die( 'Cheatin\' uh?' );

/**
* Manage the dismissed boxes
*
* @since 2.4 Add a delete_transient on function name (box name)
* @since 1.3.0 $args can replace $_GET when called internaly
* @since 1.1.10
*
* @param array $args An array of query args.
*/
function rocket_lazyload_dismiss_boxes( $args ) {
$args = empty( $args ) ? $_GET : $args;

if ( isset( $args['box'], $args['_wpnonce'] ) ) {

if ( ! wp_verify_nonce( $args['_wpnonce'], $args['action'] . '_' . $args['box'] ) ) {
if ( defined( 'DOING_AJAX' ) ) {
wp_send_json( array( 'error' => 1 ) );
} else {
wp_nonce_ays( '' );
}
}

if ( '__rocket_lazyload_imagify_notice' === $args['box'] ) {
update_option( 'rocket_lazyload_dismiss_imagify_notice', 0 );
}

global $current_user;
$actual = get_user_meta( $current_user->ID, 'rocket_lazyload_boxes', true );
$actual = array_merge( (array) $actual, array( $args['box'] ) );
$actual = array_filter( $actual );
$actual = array_unique( $actual );
update_user_meta( $current_user->ID, 'rocket_lazyload_boxes', $actual );
delete_transient( $args['box'] );

if ( 'admin-post.php' === $GLOBALS['pagenow'] ) {
if ( defined( 'DOING_AJAX' ) ) {
wp_send_json( array( 'error' => 0 ) );
} else {
wp_safe_redirect( wp_get_referer() );
die();
}
}
}
}
add_action( 'wp_ajax_rocket_lazyload_ignore', 'rocket_lazyload_dismiss_boxes' );
add_action( 'admin_post_rocket_lazyload_ignore', 'rocket_lazyload_dismiss_boxes' );
3 changes: 2 additions & 1 deletion admin/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @return void
*/
function rocket_lazyload_add_menu() {
add_options_page( __( 'Rocket LazyLoad', 'rocket-lazy-load' ), __( 'Rocket LazyLoad', 'rocket-lazy-load' ), 'manage_options', 'rocket-lazyload', 'rocket_lazyload_options_output' );
add_options_page( __( 'LazyLoad by WP Rocket', 'rocket-lazy-load' ), __( 'LazyLoad', 'rocket-lazy-load' ), 'manage_options', 'rocket-lazyload', 'rocket_lazyload_options_output' );
}
add_action( 'admin_menu', 'rocket_lazyload_add_menu' );

Expand Down Expand Up @@ -70,6 +70,7 @@ function rocket_lazyload_options_output() {

?>
<div class="wrap rocket-lazyload-settings">

<?php $heading_tag = version_compare( $wp_version, '4.3' ) >= 0 ? 'h1' : 'h2'; ?>
<<?php echo $heading_tag; ?> class="screen-reader-text"><?php echo esc_html( get_admin_page_title() ); ?></<?php echo $heading_tag; ?>>
<div class="rocket-lazyload-header">
Expand Down
79 changes: 79 additions & 0 deletions admin/notices.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?php
defined( 'ABSPATH' ) || die( 'Cheatin\' uh?' );

/**
* Add a message about Imagify on the Rocket LazyLoad options page.
*
* @author Geoffrey Crofte
* @return void
* @since 1.4.5
*/
function rocket_lazyload_imagify_notice() {
$current_screen = get_current_screen();

// Add the notice only on the "WP Rocket" settings, "Media Library" & "Upload New Media" screens.
if ( 'admin_notices' === current_filter() && ( isset( $current_screen ) && 'settings_page_rocket-lazyload' !== $current_screen->base ) ) {
return;
}

$boxes = get_user_meta( $GLOBALS['current_user']->ID, 'rocket_lazyload_boxes', true );

if ( defined( 'IMAGIFY_VERSION' ) || in_array( __FUNCTION__, (array) $boxes, true ) || 1 === get_option( 'rocket_lazyload_dismiss_imagify_notice' ) || ! current_user_can( 'manage_options' ) ) {
return;
}

$action_url = wp_nonce_url( add_query_arg(
array(
'action' => 'install-plugin',
'plugin' => 'imagify',
),
admin_url( 'update.php' )
), 'install-plugin_imagify' );

$classes = ' install-now';
$cta_txt = esc_html__( 'Install Imagify for Free', 'rocket-lazyload' );

$dismiss_url = wp_nonce_url(
admin_url( 'admin-post.php?action=rocket_lazyload_ignore&box=' . __FUNCTION__ ),
'rocket_lazyload_ignore_' . __FUNCTION__
);
?>

<div id="plugin-filter" class="updated plugin-card plugin-card-imagify rktll-imagify-notice">
<a href="<?php echo $dismiss_url; ?>" class="rktll-cross"><span class="dashicons dashicons-no"></span></a>

<p class="rktll-imagify-logo">
<img src="<?php echo ROCKET_LL_ASSETS_URL ?>img/logo-imagify.png" srcset="<?php echo ROCKET_LL_ASSETS_URL ?>img/logo-imagify.svg 2x" alt="Imagify" width="150" height="18">
</p>
<p class="rktll-imagify-msg">
<?php _e( 'Speed up your website and boost your SEO by reducing image file sizes without losing quality with Imagify.', 'rocket-lazyload' ); ?>
</p>
<p class="rktll-imagify-cta">
<a data-slug="imagify" href="<?php echo $action_url; ?>" class="button button-primary<?php echo $classes; ?>"><?php echo $cta_txt; ?></a>
</p>
</div>

<?php
}
add_action( 'admin_notices', 'rocket_lazyload_imagify_notice' );

/**
* Add Script to remove Notice thanks to JS.
* @since 1.4.5
* @author Geoffrey Crofte
* @return void
*/
function rocket_lazyload_notice_script() {
echo <<<HTML
<script>
jQuery( document ).ready( function( $ ){
$( '.rktll-cross' ).on( 'click', function( e ) {
e.preventDefault();
var url = $( this ).attr( 'href' ).replace( 'admin-post', 'admin-ajax' );
$.get( url ).done( $( this ).parent().hide( 'slow' ) );
});
} );
</script>
HTML;
}
add_action( 'admin_footer', 'rocket_lazyload_notice_script' );
113 changes: 110 additions & 3 deletions assets/css/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
flex-wrap: wrap;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
align-items: center;
-webkit-box-pack: justify;
-ms-flex-pack: justify;
justify-content: space-between;
Expand Down Expand Up @@ -202,7 +202,7 @@
display: flex;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
align-items: center;
margin: -10px 20px 20px 20px;
padding: 26px;
background: #F6F6F6;
Expand All @@ -214,9 +214,11 @@
flex-basis: 250px;
padding-right: 38px;
}

.rocket-lazyload-cta-block {
margin-top: 1.75em;
}

.rocket-lazyload-cta-promo {
display: block;
padding: 15px;
Expand All @@ -227,21 +229,25 @@
font-weight: bold;
color: #F56640;
}

.rocket-lazyload-cta-promo strong {
color: #0E1B23;
}

.rocket-lazyload-cta-block.rocket-lazyload-cta-block .button-primary {
width: 100%;
text-align: center;
font-size: 13px;
}

.rll-upgrade-item {
position: relative;
margin: 1.5em auto;
padding-left: 35px;
font-size: 13px;
color: #71787D;
}

.rll-upgrade-item:before {
content: "✓";
position: absolute;
Expand All @@ -251,24 +257,29 @@
color: #39CE9A;
font-weight: normal;
}

.rll-upgrade-item strong {
color: #39CE9A;
font-weight: bold;
}

.rocket-lazyload-upgrade p {
margin: 0;
}

.rocket-lazyload-upgrade .rocket-lazyload-subtitle {
margin-bottom: 8px;
font-size: 14px;
letter-spacing: 1px;
color: #F56640;
}

.rocket-lazyload-bigtext {
font-size: 28px;
font-weight: bold;
color: #0E1B23;
}

.rocket-lazyload-rocket-logo {
display: block;
margin-top: 12px;
Expand Down Expand Up @@ -297,6 +308,7 @@
font-weight: bold;
text-shadow: none;
}

.rocket-lazyload-form .button-primary:hover,
.rocket-lazyload-form .button-primary:focus {
text-shadow: none;
Expand All @@ -308,14 +320,109 @@
margin-left: 8px;
}

.rktll-imagify-notice.rktll-imagify-notice {
position: relative;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-align: center;
-webkit-align-items: center;
-ms-flex-align: center;
-ms-grid-row-align: center;
align-items: center;
float: none;
width: auto;
padding: 5px 45px 5px 0;
border: 0 none;
box-shadow: none;
color: #FFF;
background: #2e3243;
}

.rktll-imagify-notice .rktll-cross {
position: absolute;
right: 8px;
top: 50%;
width: 22px;
height: 22px;
padding: 0;
margin-top: -11px;
background: #FFF;
color: #2e3243;
border-radius: 50%;
transition: all .275s;
}
.rktll-imagify-notice .rktll-cross:hover,
.rktll-imagify-notice .rktll-cross:focus {
opacity: .5;
color: #2e3243;
text-decoration: none;
border-bottom: 0 none;
}

.rktll-cross .dashicons,
.rktll-cross .dashicons * {
display: inline;
text-decoration: none;
vertical-align: text-bottom;
}

.rktll-imagify-notice .rktll-cross .dashicons {
position: relative;
top: 2px;
left: 1px;
transition: all .275s;
}

.rktll-imagify-notice .rktll-imagify-logo,
.rktll-imagify-notice .rktll-imagify-cta {
-webkit-flex-shrink: 0;
-ms-flex-negative: 0;
flex-shrink: 0;
}

.rktll-imagify-notice .rktll-imagify-logo {
width: 160px !important;
text-align: right;
padding: 0 15px;
line-height: 0.8;
}

.rktll-imagify-notice .rktll-imagify-msg {
width: 100% !important;
padding: 0 15px;
}

.rktll-imagify-notice .rktll-imagify-cta {
-webkit-box-flex: 1;
-webkit-flex-grow: 1;
-ms-flex-positive: 1;
flex-grow: 1;
-webkit-flex-basis: 200px;
-ms-flex-preferred-size: 200px;
flex-basis: 200px;
padding-top: 7px;
}

.rktll-imagify-notice .button.button {
height: auto;
font-weight: 600;
font-size: 14px;
box-shadow: 0 3px 0 rgba(0,0,0,.15);
border: 0 none;
padding: 4px 18px;
background: #40B1D0;
text-shadow: 1px 1px 1px rgba(0,0,0,.2);
}

@media (max-width: 820px) {
.rocket-lazyload-header .rocket-lazyload-rate-us {
margin: 1.5em 0 0;
text-align: left;
}
}


@media (max-width: 650px) {
.rocket-lazyload-upgrade {
-ms-flex-wrap: wrap;
Expand Down
Binary file added assets/img/logo-imagify.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/img/logo-imagify.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: creativejuiz, tabrisrp, wp_media
Tags: lazyload, lazy load, images, iframes, thumbnail, thumbnails, smiley, smilies, avatar, gravatar
Requires at least: 3.0
Tested up to: 4.8
Stable tag: 1.4.4
Stable tag: 1.4.5

The tiny Lazy Load script for WordPress without jQuery, works for images and iframes.

Expand Down Expand Up @@ -64,6 +64,10 @@ Some plugins are not compatible without lazy loading. Please open a support thre

== Changelog ==

= 1.4.5 =
* Rename Setting Page Name in WP Menu
* New Product Banner in Settings Page

= 1.4.4 =
* Admin Redesign

Expand Down
Loading

0 comments on commit 7f48a11

Please sign in to comment.