Skip to main content

Wordpress card pluging (best practice)

<?php
/*
Plugin Name: My form

*/
$my_option= get_option('myformSetting');
function my_admin_theme_style() {
    wp_enqueue_style('my-admin-theme', plugins_url('wp-admin.css', __FILE__));
}
add_action('admin_enqueue_scripts', 'my_admin_theme_style');
add_action('login_enqueue_scripts', 'my_admin_theme_style');

add_action('admin_menu', 'my_menu_pages');
function my_menu_pages(){
    add_menu_page('My Page Title', 'My Menu Title', 'manage_options', 'my-menu', 'my_menu_output' );
    add_submenu_page('my-menu', 'Submenu Page Title', 'Whatever You Want', 'manage_options', 'my_menu','my_menu' );
    add_submenu_page('my-menu', 'Submenu Page Title2', 'Whatever You Want2', 'manage_options', 'my_menu2','my_menu2' );
}

function register_mysettings() { // whitelist options
 register_setting('myform','name');
 register_setting('myform','email');
}
add_action( 'admin_init', 'register_mysettings' );
 function my_menu_output()
{
?>
<div class='wrap'>
<?php if (get_option('name')) {
         
          ?>
        <div class="alert alert-success" role="alert">
        <strong>Well done!</strong> Your form submitted <?php get_option('name');?> or <?php get_option('some_other_option');?> </a>.
        </div>
        <?php }   ?>
<form action="options.php" method="post" class="col-md-6">
   <?php settings_fields( 'myform' ); ?>
            <?php do_settings_sections( 'myform' ); ?>
<fieldset class="form-group">
<label for="formGroupExampleInput">Example label</label>
<input type="text" class="form-control"  name='name' value="<?php echo esc_attr( get_option('name') ); ?>">
</fieldset>
<fieldset class="form-group">
<label for="formGroupExampleInput2">Another label</label>
<input type="text" class="form-control" name='email'  value="<?php echo esc_attr( get_option('email') ); ?>" >
</fieldset>
<fieldset class="form-group">
<?php submit_button(); ?>
</fieldset>
</form>
</div>
<?php

}


function my_menu( )
{
    echo '<div class="card col-md-4"  >
     <div class="card-block">
    <h4 class="card-title">'. get_option('name') .'</h4>
    <h4 class="card-title">'. get_option('email') .'</h4>
    <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card\'s content.</p>
    <a href="#" class="btn btn-primary">[card-wight]</a>
  </div>
</div>
<div class="card col-md-4 bg-primary"  >
     <div class="card-block">
    <h4 class="card-title" style="color:#fff">'. get_option('name') .'</h4>
    <h4 class="card-title" style="color:#fff">'. get_option('email') .'</h4>
    <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card\'s content.</p>
    <a href="#" class="btn" style="background:#fff"  >[card-blue]</a>
  </div>
</div>
<div class="card col-md-4 bg-success"  >
     <div class="card-block">
    <h4 class="card-title"  >'. get_option('name') .'</h4>
    <h4 class="card-title"  >'. get_option('email') .'</h4>
    <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card\'s content.</p>
    <a href="#" class="btn btn-warning"   >[card-green]</a>
  </div>
</div>
<div class="card col-md-4 bg-warning"  >
     <div class="card-block">
    <h4 class="card-title"  >'. get_option('name') .'</h4>
    <h4 class="card-title"  >'. get_option('email') .'</h4>
    <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card\'s content.</p>
    <a href="#" class="btn btn-danger"     >[card-yellow]</a>
  </div>
</div>
<div class="card col-md-4 bg-danger"  >
     <div class="card-block">
    <h4 class="card-title"  >'. get_option('name') .'</h4>
    <h4 class="card-title"  >'. get_option('email') .'</h4>
    <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card\'s content.</p>
    <a href="#" class="btn btn-primary"    >[card-red]</a>
  </div>
</div>';

}
function card_wight() {
return '<div class="card col-md-4"  >
     <div class="card-block">
    <h4 class="card-title">'. get_option('name') .'</h4>
    <h4 class="card-title">'. get_option('email') .'</h4>
    <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card\'s content.</p>
  </div>
</div>';
}
add_shortcode('card-wight', 'card_wight');
function card_blue() {
return '<div class="card col-md-4 bg-primary"  >
     <div class="card-block">
    <h4 class="card-title" style="color:#fff">'. get_option('name') .'</h4>
    <h4 class="card-title" style="color:#fff">'. get_option('email') .'</h4>
    <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card\'s content.</p>
  </div>
</div>';
}
add_shortcode('card-blue', 'card_blue');
function card_gree()
{
return '<div class="card col-md-4 bg-success"  >
     <div class="card-block">
    <h4 class="card-title"  >'. get_option('name') .'</h4>
    <h4 class="card-title"  >'. get_option('email') .'</h4>
    <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card\'s content.</p>
  </div>
</div>';
}
add_shortcode('card-green','card_green');
function card_warning()
{
return '<div class="card col-md-4 bg-warning"  >
     <div class="card-block">
    <h4 class="card-title"  >'. get_option('name') .'</h4>
    <h4 class="card-title"  >'. get_option('email') .'</h4>
    <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card\'s content.</p>
  </div>
</div>';
}
add_shortcode('card-yellow','card_warning');
function card_red()
{
return'<div class="card col-md-4 bg-danger"  >
     <div class="card-block">
    <h4 class="card-title"  >'. get_option('name') .'</h4>
    <h4 class="card-title"  >'. get_option('email') .'</h4>
    <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card\'s content.</p>
  </div>
</div>';
}
add_shortcode('card-red','card_red');
function my_menu2(){
echo "dam too";
}


Comments

Popular posts from this blog

how send mail using Swift mailer | switmailer send mail tutorial

how send mail using Swift mailer | switmailer send mail tutorial  <?php /* step 1 include Swift mailer file ;  */ include("vendor/swiftmailer/swiftmailer/lib/swift_required.php"); /* step 2 create your user details */ $senderEmail="saddam1234321@gmail.com"; $senderPassword="****Your password****"; $senderName="Saddam huassin"; /* step 3 set SMTP host  for sending mail  */ $user = Swift_SmtpTransport::newInstance('smtp.gmail.com','587','tls'); /* step 4 set your user details  */ $user->setUsername($senderEmail); $user->setPassword($senderPassword); /* step 5 create swift  mailer instance with a variable */ $mailer = Swift_Mailer::newInstance($user); /* step 6 Create a message */ $message = Swift_Message::newInstance('Wonderful Subject')   ->setFrom(array($senderEmail => $senderName))   ->setTo(array($senderEmail))   ->setBody('Here is the message itsel...

how install Swift mailer in localhost | swift mailer installation | composer install swift mailer

how install Swift mailer in localhost | swift mailer installation | composer install swift mailer Step 1:- open cmd  Step 2;- copy this command " composer required swiftmailer/swiftmailer @stable " . Step 3;- paste in cmd and press enter. Step 4;- after few second swift mailer ready to use .................................