Skip to content

Commit

Permalink
startup optimization
Browse files Browse the repository at this point in the history
close #104
  • Loading branch information
erikyo committed Jan 26, 2024
1 parent 5c0dec3 commit 5bae44b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
15 changes: 5 additions & 10 deletions cf7-antispam.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,11 @@ function cf7_antispam_register_service() {
}
add_action( 'wpcf7_init', 'cf7_antispam_register_service', 1, 0 );


/**
* Executes CF7-AntiSpam
*/
function run_cf7a() {
$options = get_option( 'cf7a_options' );

if ( ! empty( $options['cf7a_enable'] ) ) {
$cf7a = new \CF7_AntiSpam\Core\CF7_AntiSpam();
$cf7a->run();
} else {
/* Must call style enqueue to apply styles in integration page even if the plugin is deactivated */
wp_enqueue_style( CF7ANTISPAM_NAME, CF7ANTISPAM_PLUGIN_URL . '/build/admin-scripts.css', array(), CF7ANTISPAM_VERSION );
}
$cf7a = new \CF7_AntiSpam\Core\CF7_AntiSpam();
$cf7a->run();
}
add_action( 'init', 'run_cf7a', 11, 0 );
2 changes: 2 additions & 0 deletions core/CF7_Antispam_Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ public function icon() {
),
);
echo '<div class="integration-icon">' . wp_kses( file_get_contents( CF7ANTISPAM_PLUGIN_DIR . '/assets/icon.svg' ), $allowed_html ) . '</div>';
// inline css isn't the best idea generally speaking, but in this case will avoid to enqueue the css before to know if the plugin is enabled
echo '<style>#cf7-antispam input { margin: 0 5px 0 0; } #cf7-antispam .integration-icon { display: inline-block; padding-block: inherit; margin: 0 0 0 0.7em; width: 30px; }</style>';
}

/**
Expand Down

0 comments on commit 5bae44b

Please sign in to comment.