8000 Add rollback button when only one theme is installed by DevinWalker · Pull Request #57 · DevinWalker/wp-rollback · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add rollback button when only one theme is installed #57

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Sep 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions assets/css/wp-rollback.css
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
}

.wpr-versions-wrap {
padding-left: 20px;
margin-bottom:30px;
margin: 0 0 30px;
padding: 0 0 0 4px;
}

.wpr-versions-wrap .wpr-error {
Expand Down Expand Up @@ -76,7 +76,7 @@

.wpr-version-li {
clear: left;
padding: 8px 0;
padding: 8px;
overflow: hidden;
width: 800px;
}
Expand Down
16 changes: 11 additions & 5 deletions assets/js/themes-wp-rollback.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jQuery.noConflict();
(function( $ ) {

/**
* Content Change DOM Event Listenter
* Content Change DOM Event Listener
*
* @see: http://stackoverflow.com/questions/3233991/jquery-watch-div/3234646#3234646
* @param callback
Expand All @@ -31,7 +31,7 @@ jQuery.noConflict();
setInterval( function() {
if ( window.watchContentChange ) {
for ( i in window.watchContentChange ) {
if ( window.watchContentChange[ i ].element.data( 'lastContents' ) != window.watchContentChange[ i ].element.html() ) {
if ( window.watchContentChange[ i ].element.data( 'lastContents' ) !== window.watchContentChange[ i ].element.html() ) {
window.watchContentChange[ i ].callback.apply( window.watchContentChange[ i ].element );
window.watchContentChange[ i ].element.data( 'lastContents', window.watchContentChange[ i ].element.html() );
}
Expand All @@ -47,6 +47,12 @@ jQuery.noConflict();
themes = wp.themes = wp.themes || {};
themes.data = typeof _wpThemeSettings !== 'undefined' ? _wpThemeSettings : '';

// Is only one theme active?
if( themes.data.themes.length === 1 ) {
// Show the rollback button.
wpr_theme_rollback(themes.data.themes[0].id);
}

// On clicking a theme template
$( '.theme-overlay' ).contentChange( function( e ) {

Expand Down Expand Up @@ -81,7 +87,9 @@ jQuery.noConflict();
/**
* Is Theme WordPress.org?
*
* @description Rollback only supports WordPress.org themes
* Rollback only supports WordPress.org themes.
*
* @param theme
*/
function wpr_theme_rollback( theme ) {

Expand Down Expand Up @@ -163,9 +171,7 @@ jQuery.noConflict();
* Send them over to rollback.
*/
$( 'body' ).on( 'click', '.wpr-theme-rollback', function( e ) {

window.location = $( this ).attr( 'href' );

} );

} );
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ We provide no (zero) assurances, guarantees, or warranties that the plugin, them

= Translation Ready =

Do you speak another language? Want to contribute in a meaninful way to WP Rollback? There's no better way than to help us translate the plugin. This plugin is translation ready. Simply use the wp-rollback.pot file and your favorite translation tool. Once finished, please reach out to us on the WordPress.org forums or better yet, submit a pull request on the [Github Repo](https://github.com/impress-org/wp-rollback/).
Do you speak another language? Want to contribute in a meaningful way to WP Rollback? There's no better way than to help us translate the plugin. This plugin is translation ready. Simply header over to the WP Rollback [translation project](https://translate.wordpress.org/projects/wp-plugins/wp-rollback/) that's powered by WordPress.org volunteer translators. There you can contribute to the translation of the plugin into your language.

= Support and Documentation =

We answer all support requests [on the WordPress.org support forum](https://wordpress.org/support/plugin/wp-rollback).

WP Rollback was created to be as intuitive to the natural WordPress experience as possible. There are is no dedicated setting page or option panels. We believe that once you activate WP Rollback, you'll quickly discover exactly how it works without question.
WP Rollback was created to be as intuitive to the natural WordPress experience as possible. There are is no dedicated settings page or options panel. We believe that once you activate WP Rollback, you'll quickly discover exactly how it works without question.

**BUT!!**

Expand Down Expand Up @@ -108,8 +108,9 @@ This is the first version of this plugin. It is a tool for your convenience. Rol
== Changelog ==

= 1.7.2 =
* Fix: The Rollback button now appears as expected when only one theme is installed.
* Fix: Ensure that the "Rollback" button displays properly when a WordPress site only has a single theme installed. Thanks [@eldertech](https://wordpress.org/support/users/eldertech/) for your help uncovering this bug.
* Fix: Minor CSS fixes for the Rollback page.
* Tweak: Update the WordPress.org readme.txt file to have better instructions for translating the plugin. We also fixed a few typos.

= 1.7.1 =
* Fix: Prevent PHP notice when rolling back a plugin or theme on PHP 7.4.
Expand Down
4 changes: 2 additions & 2 deletions wp-rollback.php
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ private function set_plugin_slug() {
/**
* Admin Menu
*
* @description: Adds a 'hidden' menu item that is activated when the user elects to rollback
* Adds a 'hidden' menu item that is activated when the user elects to rollback
*/
public function admin_menu() {

Expand Down Expand Up @@ -864,7 +864,7 @@ function wpr_prepare_themes_js( $prepared_themes ) {
$rollbacks = array();
$wp_themes = get_site_transient( 'rollback_themes' );

// Double check our transient is present.
// Double-check our transient is present.
if ( empty( $wp_themes ) || ! is_object( $wp_themes ) ) {
$this->wpr_theme_updates_list();
$wp_themes = get_site_transient( 'rollback_themes' );
Expand Down
0