Skip to content

Commit

Permalink
Add gravity styles and scripts compatibility, fixed lint errors #919
Browse files Browse the repository at this point in the history
  • Loading branch information
Khadreal committed Dec 17, 2024
1 parent c7d4999 commit c01a235
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 3 deletions.
1 change: 1 addition & 0 deletions inc/3rd-party/3rd-party.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
require IMAGIFY_PATH . 'inc/3rd-party/wp-rocket/wp-rocket.php';
require IMAGIFY_PATH . 'inc/3rd-party/yoast-seo.php';
require IMAGIFY_PATH . 'inc/3rd-party/WooCommerce/class-woocommerce.php';
require IMAGIFY_PATH . 'inc/3rd-party/gravity-forms.php';

/**
* Hosting.
Expand Down
48 changes: 48 additions & 0 deletions inc/3rd-party/gravity-forms.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php
defined( 'ABSPATH' ) || die( 'Cheatin’ uh?' );

/**
* Check if gravity form is active and no-conflict mode is enabled,
* and you're in gravity form page.
*/
if ( is_plugin_active( 'gravityforms/gravityforms.php' )
&& class_exists( 'GFCommon' )
&& get_option( 'gform_enable_noconflict', false )
&& GFForms::is_gravity_page()
) {
add_filter( 'gform_noconflict_styles', 'imagify_gf_noconflict_styles' );
add_filter( 'gform_noconflict_scripts', 'imagify_gf_noconflict_scripts' );
}

/**
* Register imagify styles to gravity forms conflict styles
*
* @param array $styles Array fo registered styles
*
* @return array
*/
function imagify_gf_noconflict_styles( $styles ) {
$styles[] = 'imagify-admin-bar';
$styles[] = 'imagify-admin';
$styles[] = 'imagify-notices';
$styles[] = 'imagify-pricing-modal';

return $styles;
}

/**
* Register Imagify scripts to gravity forms conflict scripts
*
* @param array $scripts Array fo registered scripts
*
* @return array
*/
function imagify_gf_noconflict_scripts( $scripts ) {
$scripts[] = 'imagify-admin-bar';
$scripts[] = 'imagify-sweetalert';
$scripts[] = 'imagify-admin';
$scripts[] = 'imagify-notices';
$scripts[] = 'imagify-pricing-modal';

return $scripts;
}
6 changes: 3 additions & 3 deletions inc/classes/class-imagify-views.php
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ private function admin_menu_is_present(): bool {
* Get imagify user info
*
* @return bool
*/
*/
private function get_user_info(): bool {
$user = new User();
$unconsumed_quota = $user->get_percent_unconsumed_quota();
Expand All @@ -674,7 +674,7 @@ private function get_user_info(): bool {
public function maybe_print_modal_payment() {
if ( $this->get_user_info() ) {
global $wp_admin_bar;
$this->admin_menu_is_present = $wp_admin_bar && $wp_admin_bar->get_node( 'imagify' );
$this->admin_menu_is_present = $wp_admin_bar && $wp_admin_bar->get_node( 'imagify' );

return;
}
Expand All @@ -687,7 +687,7 @@ public function maybe_print_modal_payment() {
*
* @return void
*/
public function print_modal_payment( ) {
public function print_modal_payment() {
if ( is_admin_bar_showing() && $this->admin_menu_is_present ) {
$this->print_template(
'modal-payment',
Expand Down

0 comments on commit c01a235

Please sign in to comment.