one-click-accessibility/modules/legacy/components/admin.php
Rami Yushuvaev 8bd77f003b
WordPress 7.0 design compatibility (#536)
* WordPress 7.0 design compatibility

* WordPress 7.0 design compatibility
2026-03-18 04:19:04 -07:00

143 lines
5.3 KiB
PHP

<?php
namespace EA11y\Modules\Legacy\Components;
use EA11y\Classes\Utils;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
/**
* Class Admin
*/
class Admin {
const SETTINGS_SLUG = 'toplevel_page_accessibility-settings';
const TOOLBAR_SLUG = 'accessibility_page_accessibility-toolbar';
public function ajax_a11y_install_elementor_set_admin_notice_viewed() {
update_user_meta( get_current_user_id(), '_a11y_elementor_install_notice', 'true' );
}
public function admin_notices() {
if ( ! current_user_can( 'install_plugins' ) || Utils::is_elementor_installed() ) {
return;
}
if ( 'true' === get_user_meta( get_current_user_id(), '_a11y_elementor_install_notice', true ) ) {
return;
}
if ( ! in_array( get_current_screen()->id, array( self::SETTINGS_SLUG, self::TOOLBAR_SLUG, 'dashboard', 'plugins', 'plugins-network' ) ) ) {
return;
}
add_action( 'admin_footer', array( &$this, 'print_js' ) );
$install_url = self_admin_url( 'plugin-install.php?tab=search&s=elementor' );
?>
<style>
.notice.a11y-notice {
display: flex;
justify-content: flex-start;
box-sizing: border-box;
width: 100%;
padding: 0;
box-shadow: 0 1px 4px #00000026;
border: 1px solid #ccd0d4;
border-inline-start:4px solid #92003B;
}
.notice.a11y-notice .a11y-notice-icon {
background-color: rgb(82 76 255 / 0.04);
width: 50px;
text-align: center;
padding-block-start: 15px;
flex-shrink: 0;
}
.notice.a11y-notice .a11y-notice-icon svg {
color: #92003B;
font-size: 50px;
width: 24px;
height: 24px;
}
.notice.a11y-notice .a11y-notice-content {
display: flex;
flex-direction: column;
gap: 10px;
padding: 20px;
}
.notice.a11y-notice .a11y-notice-content h3,
.notice.a11y-notice .a11y-notice-content p {
padding: 0;
margin: 0;
}
.notice.a11y-notice .a11y-install-now .a11y-install-button {
background-color: #92003B;
color: #fff;
border-color: #92003B;
box-shadow: 0 1px 0 #92003B;
}
.notice.a11y-notice .a11y-install-now .a11y-install-button i {
padding-inline-end: 5px;
}
.notice.a11y-notice .a11y-install-now .a11y-install-button:hover,
.notice.a11y-notice .a11y-install-now .a11y-install-button:focus {
background-color: #c60055;
border-color: #c60055;
box-shadow: 0 1px 0 #c60055;
}
</style>
<div role="region" aria-label="<?php esc_attr_e( 'Notice', 'pojo-accessibility' ); ?>" class="notice is-dismissible a11y-notice a11y-install-elementor">
<div class="a11y-notice-icon">
<svg width="24" height="24" viewBox="0 0 28 28" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M14.0035 3.98515e-07C8.34084 -0.00134594 3.23499 3.40874 1.06704 8.64C-1.10092 13.8713 0.0960255 19.8934 4.09968 23.898C8.10333 27.9026 14.1252 29.1009 19.3569 26.9342C24.5887 24.7675 28 19.6625 28 13.9998C28 6.26922 21.7341 0.00183839 14.0035 3.98515e-07Z" fill="#92003B"/>
<rect x="8.1687" y="8.16504" width="2.3333" height="11.6665" fill="white"/>
<rect x="12.8352" y="17.498" width="6.9999" height="2.3333" fill="white"/>
<rect x="12.8352" y="12.8315" width="6.9999" height="2.3333" fill="white"/>
<rect x="12.8352" y="8.16504" width="6.9999" height="2.3333" fill="white"/>
</svg>
</div>
<div class="a11y-notice-content">
<h3><?php esc_html_e( 'Do You Like One Click Accessibility? You\'ll Love Elementor!', 'pojo-accessibility' ); ?></h3>
<p><?php esc_html_e( 'Create high-end, pixel perfect websites at record speeds. Any theme, any page, any design. The most advanced frontend drag & drop page builder.', 'pojo-accessibility' ); ?>
<a href="https://elementor.com/?utm_source=accessibility&utm_medium=wp-dash&utm_campaign=notice" target="_blank"><?php esc_html_e( 'Learn more about Elementor', 'pojo-accessibility' ); ?></a>.</p>
<div class="a11y-install-now">
<a class="button a11y-install-button" href="<?php echo $install_url; ?>"><?php esc_html_e( 'Install Now For Free!', 'pojo-accessibility' ); ?></a>
</div>
</div>
</div>
<?php
}
public function print_js() {
?>
<script>jQuery( function( $ ) {
$( 'div.notice.a11y-install-elementor' ).on( 'click', 'button.notice-dismiss', function( event ) {
event.preventDefault();
$.post( ajaxurl, {
action: 'a11y_install_elementor_set_admin_notice_viewed'
} );
} );
} );</script>
<?php
}
public function admin_footer_text( $footer_text ) {
$current_screen = get_current_screen();
if ( in_array( $current_screen->id, array( self::SETTINGS_SLUG, self::TOOLBAR_SLUG ) ) ) {
$footer_text = sprintf(
/* translators: 1: One Click Accessibility, 2: Link to plugin review */
__( 'Enjoyed %1$s? Please leave us a %2$s rating. We really appreciate your support!', 'pojo-accessibility' ),
'<strong>' . __( 'One Click Accessibility', 'pojo-accessibility' ) . '</strong>',
'<a href="https://wordpress.org/support/plugin/pojo-accessibility/reviews/?filter=5#new-post" target="_blank">&#9733;&#9733;&#9733;&#9733;&#9733;</a>'
);
}
return $footer_text;
}
public function __construct() {
add_action( 'admin_notices', array( &$this, 'admin_notices' ) );
add_action( 'wp_ajax_a11y_install_elementor_set_admin_notice_viewed', array( &$this, 'ajax_a11y_install_elementor_set_admin_notice_viewed' ) );
add_filter( 'admin_footer_text', [ $this, 'admin_footer_text' ] );
}
}