| @@ -1,52 +1,52 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -namespace PXLBSAdminify\Inc\Admin\Options; | |
| 3 | +namespace WPAdminify\Inc\Admin\Options; | |
| 4 | 4 | |
| 5 | -use PXLBSAdminify\Inc\Utils; | |
| 6 | -use PXLBSAdminify\Inc\Classes\Helper; | |
| 7 | -use PXLBSAdminify\Inc\Classes\Adminify_Rollback; | |
| 5 | +use WPAdminify\Inc\Utils; | |
| 6 | +use WPAdminify\Inc\Classes\Adminify_Rollback; | |
| 8 | 7 | |
| 9 | -if ( ! defined( 'ABSPATH' ) ) { | |
| 10 | - die; | |
| 8 | +if (!defined('ABSPATH')) { | |
| 9 | + die; | |
| 11 | 10 | } // Cannot access directly. |
| 12 | 11 | |
| 13 | -class RollbackVersion { | |
| 12 | +class RollbackVersion | |
| 13 | +{ | |
| 14 | + private $prefix; | |
| 15 | + public function __construct() | |
| 16 | + { | |
| 17 | + $this->prefix = '_adminify_rollback'; | |
| 18 | + $this->jltwp_adminify_rollback_options(); | |
| 14 | 19 | |
| 15 | - private $prefix; | |
| 16 | - public function __construct() { | |
| 17 | - if ( is_multisite() && ! is_network_admin() ) { | |
| 18 | - return; // only display to network admin if multisite is enbaled | |
| 19 | - } | |
| 20 | + if (is_admin()) { | |
| 21 | + add_action('admin_enqueue_scripts', [$this, 'jltwp_adminify_rollback_enqueue_scripts']); | |
| 22 | + } | |
| 23 | + } | |
| 20 | 24 | |
| 21 | - $this->prefix = '_adminify_rollback'; | |
| 22 | - $this->pxlbsadminify_rollback_options(); | |
| 25 | + public function get_defaults() | |
| 26 | + { | |
| 27 | + return [ | |
| 28 | + 'adminify_rollback' => '' | |
| 29 | + ]; | |
| 30 | + } | |
| 23 | 31 | |
| 24 | - add_action( 'admin_enqueue_scripts', [ $this, 'pxlbsadminify_rollback_enqueue_scripts' ] ); | |
| 25 | - } | |
| 32 | + /** | |
| 33 | + * Scripts/Styles | |
| 34 | + */ | |
| 35 | + public function jltwp_adminify_rollback_enqueue_scripts() | |
| 36 | + { | |
| 37 | + global $pagenow; | |
| 26 | 38 | |
| 27 | - public function get_defaults() { | |
| 28 | - return [ | |
| 29 | - 'adminify_rollback' => '', | |
| 30 | - ]; | |
| 31 | - } | |
| 39 | + // Load Scripts/Styles only WP Adminify Custom CSS/JS Page | |
| 40 | + if (('admin.php' === $pagenow) && ('adminify-rollback-version' === $_GET['page'])) { | |
| 41 | + $this->version_rollback_admin_script(); | |
| 42 | + } | |
| 43 | + } | |
| 32 | 44 | |
| 33 | - /** | |
| 34 | - * Scripts/Styles | |
| 35 | - */ | |
| 36 | - public function pxlbsadminify_rollback_enqueue_scripts() { | |
| 37 | - global $pagenow; | |
| 38 | 45 | |
| 39 | - // Load Scripts/Styles only WP Adminify Custom CSS/JS Page | |
| 40 | - // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read-only check, no state change. | |
| 41 | - if ( ! empty( $_GET['page'] ) && ( 'admin.php' === $pagenow ) && ( 'adminify-rollback-version' === sanitize_key( wp_unslash( $_GET['page'] ) ) ) ) { | |
| 42 | - $this->version_rollback_admin_script(); | |
| 43 | - } | |
| 44 | - } | |
| 45 | - | |
| 46 | - | |
| 47 | - public function version_rollback_admin_script() { | |
| 48 | - $rollback_custom_admin_styles = '.adminify-rollback-version .adminify-container{ max-width:60%; margin:0 auto;} .adminify-rollback-version .adminify-header{display:none ;} | |
| 46 | + public function version_rollback_admin_script() | |
| 47 | + { | |
| 48 | + echo '<style>.adminify-rollback-version .adminify-container{ max-width:60%; margin:0 auto;} .adminify-rollback-version .adminify-header{display:none ;} | |
| 49 | 49 | .adminify-rollback-version .adminify-header-inner{padding:0;}.adminify-rollback-version .adminify-field-subheading{font-size:20px; padding-left:0;} .adminify-rollback-version .adminify-nav,.adminify-rollback-version .adminify-search,.adminify-rollback-version .adminify-footer,.adminify-rollback-version .adminify-reset-all,.adminify-rollback-version .adminify-expand-all,.adminify-rollback-version .adminify-header-left,.adminify-rollback-version .adminify-reset-section,.adminify-rollback-version .adminify-nav-background{display: none !important;}.adminify-rollback-version .adminify-nav-normal + .adminify-content{margin-left: 0;} |
| 50 | 50 | /* If needed for white top-bar */ |
| 51 | 51 | .adminify-rollback-version .adminify-header-inner { |
| 52 | 52 | background-color: #fafafa !important; |
| @@ -51,176 +51,170 @@ | ||
| 51 | 51 | .adminify-rollback-version .adminify-header-inner { |
| 52 | 52 | background-color: #fafafa !important; |
| 53 | 53 | border-bottom: 1px solid #f5f5f5; |
| 54 | 54 | } |
| 55 | - .adminify-rollback-version .adminify-field-callback a.dashicons{ width: inherit; }'; | |
| 55 | + .adminify-rollback-version .adminify-field-callback a.dashicons{ width: inherit; } | |
| 56 | + </style>'; | |
| 57 | + } | |
| 56 | 58 | |
| 57 | - echo '<style>' . esc_html( wp_strip_all_tags( $rollback_custom_admin_styles ) ) . '</style>'; | |
| 58 | - } | |
| 59 | 59 | |
| 60 | + public static function jltwp_adminify_rollback_contents() | |
| 61 | + { ?> | |
| 60 | 62 | |
| 61 | - public static function pxlbsadminify_rollback_contents() { ?> | |
| 63 | + <div class="border border-muted"> | |
| 62 | 64 | |
| 63 | - <div class="border border-muted"> | |
| 65 | + <h3><?php echo __('Rollback Version', WP_ADMINIFY_TD); ?></h3> | |
| 64 | 66 | |
| 65 | - <h3><?php echo esc_html__( 'Rollback Version', 'adminify' ); ?></h3> | |
| 66 | 67 | |
| 68 | + <?php | |
| 69 | + $rollback_html = '<select class="wp-adminify-rollback-select">'; | |
| 70 | + $ger_versions = Adminify_Rollback::get_instance(); | |
| 67 | 71 | |
| 68 | - <?php | |
| 69 | - $rollback_html = '<select class="wp-adminify-rollback-select">'; | |
| 70 | - $ger_versions = Adminify_Rollback::get_instance(); | |
| 72 | + foreach ($ger_versions->get_rollback_versions() as $version) { | |
| 73 | + $rollback_html .= "<option value='{$version}'>$version</option>"; | |
| 74 | + } | |
| 75 | + $rollback_html .= '</select>'; | |
| 76 | + echo $rollback_html; | |
| 71 | 77 | |
| 72 | - foreach ( $ger_versions->get_rollback_versions() as $version ) { | |
| 73 | - $rollback_html .= "<option value='{$version}'>$version</option>"; | |
| 74 | - } | |
| 75 | - $rollback_html .= '</select>'; | |
| 76 | - echo Utils::kses_custom( $rollback_html ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- kses_custom() is a wp_kses() wrapper; output already escaped. | |
| 78 | + echo sprintf('<a data-placeholder-text="' . esc_html__('Reinstall', WP_ADMINIFY_VER) . ' v{VERSION}" href="#" data-placeholder-url="%s" class="button button-primary wp-adminify-btn wp-adminify-rollback-button dashicons dashicons-update-alt ml-2">%s</a>', wp_nonce_url(admin_url('admin-post.php?action=wp_adminify_rollback_version&version=VERSION'), 'wp_adminify_rollback_version'), __('Reinstall', WP_ADMINIFY_VER)); | |
| 79 | + ?> | |
| 80 | + <p class="wp-adminify-roll-desc pt-2 has-text-danger"> | |
| 81 | + <?php echo __('Warning: Please backup your database before making the rollback.', WP_ADMINIFY_TD); ?> | |
| 82 | + </p> | |
| 83 | + </div> | |
| 77 | 84 | |
| 78 | - echo sprintf( | |
| 79 | - wp_kses_post( '<a data-placeholder-text="%1$s" href="#" data-placeholder-url="%2$s" class="button button-primary wp-adminify-btn wp-adminify-rollback-button dashicons dashicons-update-alt ml-2">%3$s</a>' ), | |
| 80 | - esc_html__( 'Reinstall', 'adminify' ) . ' v' . esc_html( PXLBSADMINIFY_VER ), | |
| 81 | - esc_url( wp_nonce_url( admin_url( 'admin-post.php?action=pxlbsadminify_rollback_version&version=VERSION' ), 'pxlbsadminify_rollback_version' ) ), | |
| 82 | - esc_html__( 'Reinstall', 'adminify' ) | |
| 83 | - ); | |
| 84 | - ?> | |
| 85 | - <p class="wp-adminify-roll-desc pt-2 has-text-danger"> | |
| 86 | - <?php echo esc_html__( 'Warning: Please backup your database before making the rollback.', 'adminify' ); ?> | |
| 87 | - </p> | |
| 88 | - </div> | |
| 89 | 85 | |
| 86 | + <div class="wp-adminify--popup-area is-flex is-align-items-center is-justify-content-center"> | |
| 87 | + <div class="wp-adminify--popup-container has-text-centered"> | |
| 88 | + <div class="wp-adminify--popup-container_inner pt-6 pb-6"> | |
| 89 | + <div class="wp-adminify-popup-header"> | |
| 90 | + <?php echo __('Rollback to Previous Version', WP_ADMINIFY_TD); ?> | |
| 91 | + </div> | |
| 92 | + <div class="wp-adminify-dialog-message wp-adminify-dialog-confirm-message slow"> | |
| 93 | + <?php echo __('Are you sure you want to reinstall previous version?', WP_ADMINIFY_TD); ?> | |
| 94 | + </div> | |
| 95 | + <div class="wp-adminify-dialog-buttons-wrapper wp-adminify-dialog-confirm-buttons-wrapper mt-5"> | |
| 96 | + <button class="wp-adminify-dialog-button button-secondary wp-adminify-dialog-cancel wp-adminify-dialog-confirm-cancel"> | |
| 97 | + <?php echo __('Cancel', WP_ADMINIFY_TD); ?> | |
| 98 | + </button> | |
| 99 | + <button class="wp-adminify-dialog-button button-primary wp-adminify-dialog-ok wp-adminify-dialog-confirm-ok"> | |
| 100 | + <?php echo __('Continue', WP_ADMINIFY_TD); ?> | |
| 101 | + </button> | |
| 102 | + </div> | |
| 103 | + </div> | |
| 104 | + </div> | |
| 105 | + </div> | |
| 90 | 106 | |
| 91 | - <div class="wp-adminify--popup-area is-flex is-align-items-center is-justify-content-center"> | |
| 92 | - <div class="wp-adminify--popup-container has-text-centered"> | |
| 93 | - <div class="wp-adminify--popup-container_inner pt-6 pb-6"> | |
| 94 | - <div class="wp-adminify-popup-header"> | |
| 95 | - <?php echo esc_html__( 'Rollback to Previous Version', 'adminify' ); ?> | |
| 96 | - </div> | |
| 97 | - <div class="wp-adminify-dialog-message wp-adminify-dialog-confirm-message slow"> | |
| 98 | - <?php echo esc_html__( 'Are you sure you want to reinstall previous version?', 'adminify' ); ?> | |
| 99 | - </div> | |
| 100 | - <div class="wp-adminify-dialog-buttons-wrapper wp-adminify-dialog-confirm-buttons-wrapper mt-5"> | |
| 101 | - <button class="wp-adminify-dialog-button button-secondary wp-adminify-dialog-cancel wp-adminify-dialog-confirm-cancel"> | |
| 102 | - <?php echo esc_html__( 'Cancel', 'adminify' ); ?> | |
| 103 | - </button> | |
| 104 | - <button class="wp-adminify-dialog-button button-primary wp-adminify-dialog-ok wp-adminify-dialog-confirm-ok"> | |
| 105 | - <?php echo esc_html__( 'Continue', 'adminify' ); ?> | |
| 106 | - </button> | |
| 107 | - </div> | |
| 108 | - </div> | |
| 109 | - </div> | |
| 110 | - </div> | |
| 111 | 107 | |
| 112 | 108 | |
| 113 | 109 | |
| 110 | +<?php } | |
| 114 | 111 | |
| 115 | - <?php | |
| 116 | - } | |
| 117 | 112 | |
| 113 | + public function jltwp_adminify_rollback_fields(&$fields) | |
| 114 | + { | |
| 115 | + $fields[] = array( | |
| 116 | + 'type' => 'subheading', | |
| 117 | + 'content' => Utils::adminfiy_help_urls( | |
| 118 | + __('Rollback to Previous Version', WP_ADMINIFY_TD), | |
| 119 | + 'https://wpadminify.com/kb/version-rollback/', | |
| 120 | + 'https://www.youtube.com/playlist?list=PLqpMw0NsHXV-EKj9Xm1DMGa6FGniHHly8', | |
| 121 | + 'https://www.facebook.com/groups/jeweltheme', | |
| 122 | + 'https://wpadminify.com/support/' | |
| 123 | + ) | |
| 124 | + ); | |
| 118 | 125 | |
| 119 | - public function pxlbsadminify_rollback_fields( &$fields ) { | |
| 120 | - $fields[] = [ | |
| 121 | - 'type' => 'subheading', | |
| 122 | - 'content' => Utils::help_urls( | |
| 123 | - __( 'Rollback to Previous Version', 'adminify' ), | |
| 124 | - 'https://wpadminify.com/kb/version-rollback/', | |
| 125 | - 'https://www.youtube.com/playlist?list=PLqpMw0NsHXV-EKj9Xm1DMGa6FGniHHly8', | |
| 126 | - 'https://www.facebook.com/groups/jeweltheme', | |
| 127 | - \PXLBSAdminify\Inc\Admin\AdminSettings::support_url() | |
| 128 | - ), | |
| 129 | - ]; | |
| 126 | + $fields[] = array( | |
| 127 | + 'type' => 'submessage', | |
| 128 | + 'style' => 'info', | |
| 129 | + 'content' => sprintf(__('<strong>Experiencing an issue with %1$s <em>v%2$s</em>? Rollback to a previous version before the issue appeared.</strong>', WP_ADMINIFY_TD), WP_ADMINIFY, WP_ADMINIFY_VER), | |
| 130 | + ); | |
| 130 | 131 | |
| 131 | - $fields[] = [ | |
| 132 | - 'type' => 'submessage', | |
| 133 | - 'style' => 'info', | |
| 134 | - /* translators: %1$s: plugin name, %2$s: plugin version */ | |
| 135 | - 'content' => '<strong>' . sprintf( __( 'Experiencing an issue with %1$s <em>v%2$s</em>? Rollback to a previous version before the issue appeared.', 'adminify' ), esc_html( PXLBSADMINIFY ), esc_html( PXLBSADMINIFY_VER ) ) . '</strong>', | |
| 136 | - ]; | |
| 132 | + $fields[] = array( | |
| 133 | + 'id' => 'adminify_rollback', | |
| 134 | + 'type' => 'callback', | |
| 135 | + 'function' => '\WPAdminify\Inc\Admin\Options\RollbackVersion::jltwp_adminify_rollback_contents', | |
| 136 | + ); | |
| 137 | + } | |
| 137 | 138 | |
| 138 | - $fields[] = [ | |
| 139 | - 'id' => 'adminify_rollback', | |
| 140 | - 'type' => 'callback', | |
| 141 | - 'function' => '\PXLBSAdminify\Inc\Admin\Options\RollbackVersion::pxlbsadminify_rollback_contents', | |
| 142 | - ]; | |
| 143 | - } | |
| 139 | + public function jltwp_adminify_rollback_options() | |
| 140 | + { | |
| 141 | + if (!class_exists('ADMINIFY')) { | |
| 142 | + return; | |
| 143 | + } | |
| 144 | 144 | |
| 145 | - public function pxlbsadminify_rollback_options() { | |
| 146 | - if ( ! class_exists( 'ADMINIFY' ) ) { | |
| 147 | - return; | |
| 148 | - } | |
| 145 | + // WP Adminify Custom Header & Footer Options | |
| 146 | + \ADMINIFY::createOptions($this->prefix, array( | |
| 149 | 147 | |
| 150 | - // WP Adminify Custom Header & Footer Options | |
| 151 | - \ADMINIFY::createOptions( | |
| 152 | - $this->prefix, | |
| 153 | - [ | |
| 148 | + // Framework Title | |
| 149 | + 'framework_title' => 'Rollback Version <small>for WP Adminify</small>', | |
| 150 | + 'framework_class' => 'adminify-rollback-version', | |
| 154 | 151 | |
| 155 | - // Framework Title | |
| 156 | - 'framework_title' => __( 'Rollback Version <small>for Adminify</small>', 'adminify' ), | |
| 157 | - 'framework_class' => 'adminify-rollback-version', | |
| 152 | + // menu settings | |
| 153 | + 'menu_title' => 'Rollback Version', | |
| 154 | + 'menu_slug' => 'adminify-rollback-version', | |
| 155 | + 'menu_type' => 'submenu', // menu, submenu, options, theme, etc. | |
| 156 | + 'menu_capability' => 'manage_options', | |
| 157 | + 'menu_icon' => '', | |
| 158 | + 'menu_position' => 54, | |
| 159 | + 'menu_hidden' => false, | |
| 160 | + 'menu_parent' => 'wp-adminify-settings', | |
| 158 | 161 | |
| 159 | - // menu settings | |
| 160 | - 'menu_title' => __( 'Rollback Version', 'adminify' ), | |
| 161 | - 'menu_slug' => 'adminify-rollback-version', | |
| 162 | - 'menu_type' => 'submenu', // menu, submenu, options, theme, etc. | |
| 163 | - 'menu_capability' => 'manage_options', | |
| 164 | - 'menu_icon' => '', | |
| 165 | - 'menu_position' => 54, | |
| 166 | - 'menu_hidden' => false, | |
| 167 | - 'menu_parent' => 'wp-adminify-settings', | |
| 162 | + // footer | |
| 163 | + 'footer_text' => ' ', | |
| 164 | + 'footer_after' => ' ', | |
| 165 | + 'footer_credit' => ' ', | |
| 168 | 166 | |
| 169 | - // footer | |
| 170 | - 'footer_text' => ' ', | |
| 171 | - 'footer_after' => ' ', | |
| 172 | - 'footer_credit' => ' ', | |
| 167 | + // menu extras | |
| 168 | + 'show_bar_menu' => false, | |
| 169 | + 'show_sub_menu' => false, | |
| 170 | + 'show_in_network' => false, | |
| 171 | + 'show_in_customizer' => false, | |
| 173 | 172 | |
| 174 | - // menu extras | |
| 175 | - 'show_bar_menu' => false, | |
| 176 | - 'show_sub_menu' => false, | |
| 177 | - 'show_in_network' => true, | |
| 178 | - 'show_in_customizer' => false, | |
| 173 | + 'show_search' => false, | |
| 174 | + 'show_reset_all' => false, | |
| 175 | + 'show_reset_section' => false, | |
| 176 | + 'show_header' => false, | |
| 177 | + 'show_footer' => false, | |
| 178 | + 'show_all_options' => false, | |
| 179 | + 'show_form_warning' => false, | |
| 180 | + 'sticky_header' => false, | |
| 181 | + 'save_defaults' => false, | |
| 182 | + 'ajax_save' => false, | |
| 179 | 183 | |
| 180 | - 'show_search' => false, | |
| 181 | - 'show_reset_all' => false, | |
| 182 | - 'show_reset_section' => false, | |
| 183 | - 'show_header' => false, | |
| 184 | - 'show_footer' => false, | |
| 185 | - 'show_all_options' => false, | |
| 186 | - 'show_form_warning' => false, | |
| 187 | - 'sticky_header' => false, | |
| 188 | - 'save_defaults' => false, | |
| 189 | - 'ajax_save' => false, | |
| 184 | + // admin bar menu settings | |
| 185 | + 'admin_bar_menu_icon' => '', | |
| 186 | + 'admin_bar_menu_priority' => 45, | |
| 190 | 187 | |
| 191 | - // admin bar menu settings | |
| 192 | - 'admin_bar_menu_icon' => '', | |
| 193 | - 'admin_bar_menu_priority' => 45, | |
| 194 | 188 | |
| 195 | - // database model | |
| 196 | - 'database' => 'network', // options, transient, theme_mod, network(multisite support) | |
| 197 | - 'transient_time' => 0, | |
| 189 | + // database model | |
| 190 | + 'database' => 'network', // options, transient, theme_mod, network(multisite support) | |
| 191 | + 'transient_time' => 0, | |
| 198 | 192 | |
| 199 | - // typography options | |
| 200 | - 'enqueue_webfont' => false, | |
| 201 | - 'async_webfont' => false, | |
| 202 | 193 | |
| 203 | - // others | |
| 204 | - 'output_css' => false, | |
| 194 | + // typography options | |
| 195 | + 'enqueue_webfont' => false, | |
| 196 | + 'async_webfont' => false, | |
| 205 | 197 | |
| 206 | - // theme and wrapper classname | |
| 207 | - 'nav' => 'normal', | |
| 208 | - 'theme' => 'dark', | |
| 209 | - 'class' => 'wp-adminify-rollback', | |
| 210 | - ] | |
| 211 | - ); | |
| 198 | + // others | |
| 199 | + 'output_css' => false, | |
| 212 | 200 | |
| 213 | - $fields = []; | |
| 214 | - $this->pxlbsadminify_rollback_fields( $fields ); | |
| 201 | + // theme and wrapper classname | |
| 202 | + 'nav' => 'normal', | |
| 203 | + 'theme' => 'dark', | |
| 204 | + 'class' => 'wp-adminify-rollback', | |
| 205 | + )); | |
| 215 | 206 | |
| 216 | - // Rollback Section | |
| 217 | - \ADMINIFY::createSection( | |
| 218 | - $this->prefix, | |
| 219 | - [ | |
| 220 | - 'title' => __( 'Rollback Version', 'adminify' ), | |
| 221 | - 'icon' => 'fas fa-layer-group', | |
| 222 | - 'fields' => $fields, | |
| 223 | - ] | |
| 224 | - ); | |
| 225 | - } | |
| 207 | + | |
| 208 | + | |
| 209 | + $fields = []; | |
| 210 | + $this->jltwp_adminify_rollback_fields($fields); | |
| 211 | + | |
| 212 | + | |
| 213 | + // Rollback Section | |
| 214 | + \ADMINIFY::createSection($this->prefix, array( | |
| 215 | + 'title' => __('Rollback Version', WP_ADMINIFY_TD), | |
| 216 | + 'icon' => 'fas fa-layer-group', | |
| 217 | + 'fields' => $fields | |
| 218 | + )); | |
| 219 | + } | |
| 226 | 220 | } |