Skip to content

Commit

Permalink
Merge pull request #2 from zarei-dev/main
Browse files Browse the repository at this point in the history
fix: Style and script loading issues
  • Loading branch information
parsafatehi authored Mar 31, 2022
2 parents a0eeac8 + 31fdb5a commit 504b93d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions backend/Settings_Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public function change_admin_font() {
$field_name = ( $this->get_locale == 'fa_IR' ? 'admin-font-fa': 'admin-font' );
$admin_font = $_POST[ $field_name ] ?? $this->customizing_option[ $field_name ] ?? false;

if ( isset( $admin_font ) && $admin_font != 'wp-default' ) {
if ( isset( $admin_font ) && !empty($editor_font) && $admin_font != 'wp-default' ) {
if ( $this->get_locale == 'fa_IR' ) {
add_action( 'wp_enqueue_scripts', array( $this, 'remove_google_fonts' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'remove_google_fonts' ) );
Expand All @@ -182,7 +182,7 @@ public function change_editor_font() {
$field_name = ( $this->get_locale == 'fa_IR' ? 'editor-font-fa': 'editor-font' );
$editor_font = $this->customizing_option[ $field_name ] ?? false;

if ( isset( $editor_font ) && $editor_font != 'wp-default' ) {
if ( isset( $editor_font ) && !empty($editor_font) && $editor_font != 'wp-default' ) {
if ( $this->get_locale == 'fa_IR' ) {
add_action( 'wp_enqueue_scripts', array( $this, 'remove_google_fonts' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'remove_google_fonts' ) );
Expand Down
8 changes: 5 additions & 3 deletions frontend/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ public function initialize() {
add_action( 'init', array( $this, 'disable_xmlrpc' ) );
add_action( 'init', array( $this, 'hide_admin_bar' ), 9999 );
add_action( 'wp_head', array( $this, 'change_adminbar_font' ), 30 );
add_action( 'wp_before_admin_bar_render', array( $this, 'adminbar_logo' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'adminbar_logo' ) );
add_action( 'wp_enqueue_scripts', array( $this, 'adminbar_logo' ) );
add_action( 'login_head', array( $this, 'change_login_font' ), 999 );
add_action( 'after_setup_theme', array( $this, 'remove_shortlink' ) );
add_filter( 'after_setup_theme', array( $this, 'remove_wp_version_from_head' ) );
Expand Down Expand Up @@ -239,8 +240,8 @@ public function adminbar_logo() {
if ( ( isset( $this->customizing_option['custom_logo'] ) && !isset( $_POST['custom_logo'] ) ) || ( isset( $_POST['custom_logo'] ) && !empty( $_POST['custom_logo'] ) ) ) {
$custom_logo = isset( $_POST['custom_logo'] ) ? sanitize_text_field( $_POST['custom_logo'] ) : $this->customizing_option['custom_logo'];

wp_register_style( EZPZ_TWEAKS_TEXTDOMAIN . '-adminbar-logo', '' );
wp_enqueue_style( EZPZ_TWEAKS_TEXTDOMAIN . '-adminbar-logo' );
wp_register_style( EZPZ_TWEAKS_TEXTDOMAIN . '-adminbar-logo', false );

wp_add_inline_style( EZPZ_TWEAKS_TEXTDOMAIN . '-adminbar-logo',
'#wpadminbar #wp-admin-bar-wp-logo>.ab-item {
padding: 0 7px;
Expand All @@ -255,6 +256,7 @@ public function adminbar_logo() {
top: 2px;
}'
);
wp_enqueue_style( EZPZ_TWEAKS_TEXTDOMAIN . '-adminbar-logo' );
}
}

Expand Down

0 comments on commit 504b93d

Please sign in to comment.