| @@ -5,11 +5,8 @@ | ||
| 5 | 5 | |
| 6 | 6 | class FrmFormMigratorsHelper { |
| 7 | 7 | |
| 8 | 8 | /** |
| 9 | - * @param array $form | |
| 10 | - * @param array|null $dismissed | |
| 11 | - * | |
| 12 | 9 | * @return bool |
| 13 | 10 | */ |
| 14 | 11 | private static function is_dismissed( $form, $dismissed = null ) { |
| 15 | 12 | if ( $dismissed === null ) { |
| @@ -14,10 +11,14 @@ | ||
| 14 | 11 | private static function is_dismissed( $form, $dismissed = null ) { |
| 15 | 12 | if ( $dismissed === null ) { |
| 16 | 13 | $dismissed = get_option( 'frm_dismissed' ); |
| 17 | 14 | } |
| 18 | - // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict | |
| 19 | - return $dismissed && in_array( $form['class'], $dismissed ); | |
| 15 | + | |
| 16 | + if ( ! empty( $dismissed ) && in_array( $form['class'], $dismissed ) ) { | |
| 17 | + return true; | |
| 18 | + } | |
| 19 | + | |
| 20 | + return false; | |
| 20 | 21 | } |
| 21 | 22 | |
| 22 | 23 | /** |
| 23 | 24 | * @return void |
| @@ -23,9 +24,8 @@ | ||
| 23 | 24 | * @return void |
| 24 | 25 | */ |
| 25 | 26 | public static function maybe_show_download_link() { |
| 26 | 27 | $forms = self::import_links(); |
| 27 | - | |
| 28 | 28 | foreach ( $forms as $form ) { |
| 29 | 29 | if ( ! self::is_dismissed( $form ) ) { |
| 30 | 30 | self::install_banner( $form ); |
| 31 | 31 | } else { |
| @@ -42,15 +42,13 @@ | ||
| 42 | 42 | * @return void |
| 43 | 43 | */ |
| 44 | 44 | public static function maybe_add_to_inbox() { |
| 45 | 45 | $forms = self::import_links(); |
| 46 | - | |
| 47 | 46 | if ( ! $forms ) { |
| 48 | 47 | return; |
| 49 | 48 | } |
| 50 | 49 | |
| 51 | 50 | $inbox = new FrmInbox(); |
| 52 | - | |
| 53 | 51 | foreach ( $forms as $form ) { |
| 54 | 52 | $inbox->add_message( |
| 55 | 53 | array( |
| 56 | 54 | 'key' => $form['class'], |
| @@ -55,9 +53,9 @@ | ||
| 55 | 53 | array( |
| 56 | 54 | 'key' => $form['class'], |
| 57 | 55 | 'subject' => 'You have new importable forms', |
| 58 | 56 | 'message' => 'Did you know you can import your forms created in ' . esc_html( $form['name'] ) . '?', |
| 59 | - 'cta' => '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-import' ) ) . '" class="button-primary frm-button-primary">' . esc_html__( 'Learn More', 'formidable' ) . '</a>', // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong | |
| 57 | + 'cta' => '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-import' ) ) . '" class="button-primary frm-button-primary">' . esc_html__( 'Learn More', 'formidable' ) . '</a>', | |
| 60 | 58 | 'icon' => 'frm_cloud_upload_solid_icon', |
| 61 | 59 | 'type' => 'news', |
| 62 | 60 | ) |
| 63 | 61 | ); |
| @@ -72,9 +70,8 @@ | ||
| 72 | 70 | return array(); |
| 73 | 71 | } |
| 74 | 72 | |
| 75 | 73 | $forms = array(); |
| 76 | - | |
| 77 | 74 | foreach ( self::importable_forms() as $form ) { |
| 78 | 75 | if ( class_exists( $form['class'] ) || ! is_plugin_active( $form['plugin'] ) ) { |
| 79 | 76 | // Either the importer is installed or the source plugin isn't. |
| 80 | 77 | continue; |
| @@ -85,9 +82,8 @@ | ||
| 85 | 82 | $form['link'] = $installer->get_activate_link(); |
| 86 | 83 | |
| 87 | 84 | $forms[] = $form; |
| 88 | 85 | } |
| 89 | - | |
| 90 | 86 | return $forms; |
| 91 | 87 | } |
| 92 | 88 | |
| 93 | 89 | /** |
| @@ -111,19 +107,13 @@ | ||
| 111 | 107 | ), |
| 112 | 108 | ); |
| 113 | 109 | } |
| 114 | 110 | |
| 115 | - /** | |
| 116 | - * @param array $install | |
| 117 | - * | |
| 118 | - * @return string|null | |
| 119 | - */ | |
| 120 | 111 | private static function install_banner( $install ) { |
| 121 | 112 | if ( empty( $install['link'] ) ) { |
| 122 | 113 | return ''; |
| 123 | 114 | } |
| 124 | 115 | |
| 125 | - // phpcs:disable Generic.WhiteSpace.ScopeIndent | |
| 126 | 116 | ?> |
| 127 | 117 | <div class="frm-feature-banner"> |
| 128 | 118 | <a href="#" class="dismiss alignright" id="<?php echo esc_attr( $install['class'] ); ?>" title="<?php esc_attr_e( 'Dismiss this message', 'formidable' ); ?>"> |
| 129 | 119 | <?php FrmAppHelper::icon_by_class( 'frmfont frm_close_icon', array( 'aria-label' => 'Dismiss' ) ); ?> |
| @@ -134,10 +124,8 @@ | ||
| 134 | 124 | <p>Did you know you can import your forms created in <?php echo esc_html( $install['name'] ); ?>?</p> |
| 135 | 125 | <?php self::install_button( $install ); ?> |
| 136 | 126 | </div> |
| 137 | 127 | <?php |
| 138 | - // phpcs:enable Generic.WhiteSpace.ScopeIndent | |
| 139 | - return null; | |
| 140 | 128 | } |
| 141 | 129 | |
| 142 | 130 | /** |
| 143 | 131 | * @param array $install |
| @@ -147,17 +135,16 @@ | ||
| 147 | 135 | */ |
| 148 | 136 | private static function install_button( $install, $label = '' ) { |
| 149 | 137 | $primary = 'button-secondary frm-button-secondary '; |
| 150 | 138 | |
| 151 | - if ( ! $label ) { | |
| 139 | + if ( empty( $label ) ) { | |
| 152 | 140 | $label = __( 'Get Started', 'formidable' ); |
| 153 | 141 | $primary = 'button-primary frm-button-primary '; |
| 154 | 142 | } |
| 155 | 143 | |
| 156 | - // phpcs:disable Generic.WhiteSpace.ScopeIndent | |
| 157 | 144 | if ( $install['installed'] ) { |
| 158 | 145 | ?> |
| 159 | - <a rel="<?php echo esc_attr( $install['importer'] ); ?>" class="button frm-activate-addon <?php echo esc_attr( $primary . ( empty( $install['link'] ) ? 'frm_hidden' : '' ) ); ?>"><?php // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong ?> | |
| 146 | + <a rel="<?php echo esc_attr( $install['importer'] ); ?>" class="button frm-activate-addon <?php echo esc_attr( $primary . ( empty( $install['link'] ) ? 'frm_hidden' : '' ) ); ?>"> | |
| 160 | 147 | <?php |
| 161 | 148 | if ( $label === 'auto' ) { |
| 162 | 149 | /* translators: %s: Name of the plugin */ |
| 163 | 150 | $label = sprintf( __( 'Activate %s', 'formidable' ), $install['name'] ); |
| @@ -163,9 +150,9 @@ | ||
| 163 | 150 | $label = sprintf( __( 'Activate %s', 'formidable' ), $install['name'] ); |
| 164 | 151 | } |
| 165 | 152 | } else { |
| 166 | 153 | ?> |
| 167 | - <a rel="<?php echo esc_attr( $install['package'] ); ?>" class="frm-install-addon button <?php echo esc_attr( $primary ); ?>" aria-label="<?php esc_attr_e( 'Install', 'formidable' ); ?>"><?php // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong ?> | |
| 154 | + <a rel="<?php echo esc_attr( $install['package'] ); ?>" class="frm-install-addon button <?php echo esc_attr( $primary ); ?>" aria-label="<?php esc_attr_e( 'Install', 'formidable' ); ?>"> | |
| 168 | 155 | <?php |
| 169 | 156 | if ( $label === 'auto' ) { |
| 170 | 157 | /* translators: %s: Name of the plugin */ |
| 171 | 158 | $label = sprintf( __( 'Install %s Importer', 'formidable' ), $install['name'] ); |
| @@ -174,9 +161,8 @@ | ||
| 174 | 161 | ?> |
| 175 | 162 | <?php echo esc_html( $label ); ?> |
| 176 | 163 | </a> |
| 177 | 164 | <?php |
| 178 | - // phpcs:enable Generic.WhiteSpace.ScopeIndent | |
| 179 | 165 | } |
| 180 | 166 | |
| 181 | 167 | /** |
| 182 | 168 | * @return void |
| @@ -183,14 +169,12 @@ | ||
| 183 | 169 | */ |
| 184 | 170 | public static function dismiss_migrator() { |
| 185 | 171 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 186 | 172 | $dismissed = get_option( 'frm_dismissed' ); |
| 187 | - | |
| 188 | - if ( ! $dismissed ) { | |
| 173 | + if ( empty( $dismissed ) ) { | |
| 189 | 174 | $dismissed = array(); |
| 190 | 175 | } |
| 191 | - | |
| 192 | 176 | $dismissed[] = FrmAppHelper::get_param( 'plugin', '', 'post', 'sanitize_text_field' ); |
| 193 | - update_option( 'frm_dismissed', array_filter( $dismissed ), false ); | |
| 177 | + update_option( 'frm_dismissed', array_filter( $dismissed ), 'no' ); | |
| 194 | 178 | wp_die(); |
| 195 | 179 | } |
| 196 | 180 | } |