help calling a function

Hi i want call a function called “my_custom_login_stylesheet” inside a if ( $test_option == ‘yes’ ), i have done it, but doesn’t work, here is my code:

<?php
/*
Plugin Name: My Plugin
Description: My plugin
Author: Marco
Version: 1.0
*/

function my_custom_login_stylesheet() {?>
<style type=”text/css”>

body.login div#login p#backtoblog {
display: none;
}

</style>
<?php

}

defined( ‘ABSPATH’ ) || exit;

if ( ! class_exists( ‘MP_Test_Plugin’ ) ) :

class MP_Test_Plugin {

public function __construct() {

add_action( ‘admin_menu’, array( $this, ‘setup_menu’ ) );
add_action( ‘admin_init’, array( $this, ‘register_options’ ) );

}

public function setup_menu() {
add_menu_page( ‘Test Plugin Page’, ‘Test Plugin’, ‘manage_options’, ‘test-plugin’, array( $this, ‘test_menu_page’ ), ‘dashicons-smiley’ );
}

public function test_menu_page() {

if ( isset( $_POST[‘option_page’] ) && $_POST[‘option_page’] == ‘mp_settings_group’ ) {
if ( isset( $_POST[‘test_init’] ) ) {
update_option( ‘test_init’, ‘yes’ );
} else {
update_option( ‘test_init’, ‘no’ );
}
}

$test_option = get_option( ‘test_init’, ‘no’ );
?>
<div class=”wrap”>
<h1>Plugin</h1>
<form method=”post”>
<?php settings_fields( ‘mp_settings_group’ ); ?>
<?php do_settings_sections( ‘mp_settings_group’ ); ?>
<input type=”checkbox” name=”test_init” value=”<?php echo $test_option; ?>” <?php checked( $test_option, ‘yes’ ); ?> id=”test_init” /><label for=”test_init”> We’re good?</label>
<?php submit_button(); ?>
</form>
</div>

<?php

if ( $test_option == ‘yes’ ) {
echo ‘We’re good.’;

add_action(‘login_enqueue_scripts’, ‘my_custom_login_stylesheet’ );

}

else {
echo ‘Don’t leave me hanging’;
}

}

public function register_options() {
register_setting( ‘mp_settings_group’, ‘test_init’ );
}
}

endif;

if ( is_admin() ) {
new MP_Test_Plugin();
}

thanks in advance

Read more here:: help calling a function

Leave a Reply

Your email address will not be published. Required fields are marked *