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