mirror of
https://gh.wpcy.net/https://github.com/aspirepress/aspireupdate.git
synced 2026-07-17 09:56:36 +08:00
* Prevent Recursion on certain Host name patterns (#69) --------- Signed-off-by: Namith Jawahar <48271037+namithj@users.noreply.github.com> * Playground ready updating into main (#71) * Update blueprint.json Switching to default theme of 2022 to support minimum WP Playground support for WordPress version as 5.9.9 Signed-off-by: Namith Jawahar <48271037+namithj@users.noreply.github.com> * Switching blueprint.json to 2022 theme Signed-off-by: Alex Sirota <alex@newpathconsulting.com> --------- Signed-off-by: Alex Sirota <alex@newpathconsulting.com> Signed-off-by: Namith Jawahar <48271037+namithj@users.noreply.github.com> * `Add New Plugin`: Remove 'Featured' and 'Favorites' tabs when API rewrite is enabled. (#80) * Add class for overriding plugins screens. * Remove unused tabs when API rewrite is enabled. * `Add New Theme`: Remove 'Favorites' filter tab when API rewrite is enabled. (#82) * Add class for overriding themes screens. * Hide unsupported filters. * Redirect unsupported filters to `theme-install.php`. --------- Signed-off-by: Alex Sirota <alex@newpathconsulting.com> Co-authored-by: Alex Sirota <alex@newpathconsulting.com> * Add PHPUnit. (#87) * Add PHPUnit scaffolding. * Add Composer files for dependencies and test script. * Add `.gitignore`. * Add sample test for `Admin_Settings::get_setting()`. * Add PHP 8.3 to the test matrix. * Add `.cache/*` to `.gitignore`. * Limit testing to PHP 7.4 (minimum) and 8.3 (latest). * `Plugins Screens`: Initialize in `Controller::__construct()`. (#89) * `Workflows`: Fix PHP version and add more workflow triggers. (#92) * Fix PHP version. * Add `push` and `workflow_dispatch` workflow triggers. * `Tests`: Ensure options are not set when tests run. (#95) * Introduce a test constant. * Don't initialize when the tests are running. * Use a new object for testing `Admin_Settings::get_setting()`. * Warning when debug-aspire-update.log doesnt exist (#109) * `Tests`: Add default coverage settings. (#97) * Improve I18N Issues Based on version 0.5 (#104) * Fixes Settings not getting saved when rewrites were turned off (#108) * Add French Translation (#105) * I18n fr fr (#113) * Translations loading fix112 (#114) * Add French translations. * load any available translations with code in the plugin * #110 (#116) Fixes #110 * Add nonce verification and sanitize `$_REQUEST/$_GET` values. (#115) Signed-off-by: Colin Stewart <79332690+costdev@users.noreply.github.com> * Added German Translation (#111) * added German translation * added gitignore for .DS_Store Signed-off-by: Harikrishnan R <harikrishnanr994@gmail.com> * Voltron has landed. (#117) The Voltron has landed. See if you can find where. * `Admin Settings`: Delete all settings when the plugin is uninstalled. (#118) * `Admin Settings`: Add multisite-safe deletion of all settings. * Delete all settings when the plugin is uninstalled. * add multisite support (#102) * accidentally deleted (#124) Fixed typo in code deleted when addressing #102 * Add `.editorconfig`. (#123) * create zip with each new tagged release (#121) * create zip with each new tagged release * update .gitattributes * Cleanup after `.editorconfig` was added to the repository. (#126) * Add coding standard. (#127) * Add Coding Standard. * Add PHPCS cache directory. * Coding Standards: Apply PHPCBF to codebase. * Coding Standards: Add GitHub workflow. --------- Signed-off-by: Alex Sirota <alex@newpathconsulting.com> Co-authored-by: Alex Sirota <alex@newpathconsulting.com> --------- Signed-off-by: Namith Jawahar <48271037+namithj@users.noreply.github.com> Signed-off-by: Alex Sirota <alex@newpathconsulting.com> Signed-off-by: Colin Stewart <79332690+costdev@users.noreply.github.com> Signed-off-by: Harikrishnan R <harikrishnanr994@gmail.com> Co-authored-by: Namith Jawahar <48271037+namithj@users.noreply.github.com> Co-authored-by: Colin Stewart <79332690+costdev@users.noreply.github.com> Co-authored-by: Alex Lion <learnwithalex@gmail.com> Co-authored-by: Sébastien SERRE <sebastien@thivinfo.com> Co-authored-by: Harikrishnan R <harikrishnanr994@gmail.com> Co-authored-by: Andy Fragen <andy@thefragens.com>
111 lines
2.4 KiB
PHP
111 lines
2.4 KiB
PHP
<?php
|
|
/**
|
|
* The Class for overriding the default themes screens.
|
|
*
|
|
* @package aspire-update
|
|
*/
|
|
|
|
namespace AspireUpdate;
|
|
|
|
/**
|
|
* The Class for overriding the default themes screens.
|
|
*/
|
|
class Themes_Screens {
|
|
/**
|
|
* Hold a single instance of the class.
|
|
*
|
|
* @var object
|
|
*/
|
|
private static $instance = null;
|
|
|
|
/**
|
|
* Hold an array of unsupported filters.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $unsupported_filters = [
|
|
'favorites',
|
|
];
|
|
|
|
/**
|
|
* The Constructor.
|
|
*/
|
|
public function __construct() {
|
|
$admin_settings = Admin_Settings::get_instance();
|
|
if ( $admin_settings->get_setting( 'enable', false ) ) {
|
|
add_action( 'admin_enqueue_scripts', [ $this, 'admin_enqueue_scripts' ] );
|
|
add_action( 'load-theme-install.php', [ $this, 'redirect_to_theme_install' ] );
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Initialize Class.
|
|
*
|
|
* @return object
|
|
*/
|
|
public static function get_instance() {
|
|
if ( null === self::$instance ) {
|
|
self::$instance = new self();
|
|
}
|
|
return self::$instance;
|
|
}
|
|
|
|
/**
|
|
* Enqueue the styles.
|
|
*
|
|
* @param string $hook The page identifier.
|
|
* @return void
|
|
*/
|
|
public function admin_enqueue_scripts( $hook ) {
|
|
if ( 'theme-install.php' !== $hook ) {
|
|
return;
|
|
}
|
|
|
|
if ( ! empty( $this->unsupported_filters ) ) {
|
|
wp_register_style(
|
|
'aspire_update_themes_screens_css',
|
|
false,
|
|
[],
|
|
AP_VERSION
|
|
);
|
|
|
|
wp_enqueue_style( 'aspire_update_themes_screens_css' );
|
|
|
|
$css_selectors = [];
|
|
foreach ( $this->unsupported_filters as $filter ) {
|
|
$css_selectors[] = '.wp-filter .filter-links a[data-sort="' . $filter . '"]';
|
|
}
|
|
|
|
wp_add_inline_style(
|
|
'aspire_update_themes_screens_css',
|
|
implode( ', ', $css_selectors ) . '{ display: none; }'
|
|
);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Redirect unsupported filters to theme-install.php.
|
|
*
|
|
* @param string $hook The page identifier.
|
|
* @return void
|
|
*/
|
|
public function redirect_to_theme_install() {
|
|
|
|
$nonce = isset( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ) : false;
|
|
if ( $nonce && ! wp_verify_nonce( $nonce, 'query-themes' ) ) {
|
|
return;
|
|
}
|
|
|
|
$browse = isset( $_GET['browse'] ) ? sanitize_text_field( wp_unslash( $_GET['browse'] ) ) : '';
|
|
|
|
if ( ! in_array( $browse, $this->unsupported_filters, true ) ) {
|
|
return;
|
|
}
|
|
|
|
$admin_settings = Admin_Settings::get_instance();
|
|
if ( $admin_settings->get_setting( 'enable', false ) ) {
|
|
wp_safe_redirect( admin_url( 'theme-install.php' ) );
|
|
exit;
|
|
}
|
|
}
|
|
}
|