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

Minimum and maximum number with - and + 500 in Mysql and Sql query and Find out table scheema of our database in Mysql and sql query and Find out all table name of our database in Mysql and sql query and Find out current date and time in mysql and sql help of sql query

Minimum and maximum number with - and + 500 in Mysql and Sql query:- syntax:-  SELECT MIN(Used)-500 , max(Used)+500 FROM audit Find out current date and time in mysql and sql help of sql query:- syntax:- SELECT now() Find out database name in Mysql and sql query:- syntax:-  SELECT DATABASE(); Find out all table name of our database in Mysql and sql query:- syntax:- SHOW TABLES; Find out   table scheema   of our database in Mysql and sql query:- syntax:- DESCRIBE <table name>;
Form validation html and javascript <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <style> .main { height:auto;//100px; width:300px; //border:1px solid #FF0000; } .msg { height:20px; width:200px; //border:1px solid black; color:red; display:none; } </style> <script language="javascript" type="text/javascript"> function hide() { document.getElementById('m').style.display="none"; document.getElementById('m1').style.display="none"; } function check() { var f=document.getElementById('fn').value; var l=document.getElementById('ln').value; if...

PHP STRING FUNCTION WITH OUTPUT AND EXAMPLE

PHP STRING FUNCTION  WITH OUTPUT AND EXAMPLE  <?php   $var="my name is saddam hussain saifi ";   print_r(explode("a",$var)); //output:Array ( [0] => my n [1] => me is s [2] => dd [3] => m huss [4] => in s [5] => ifi )       echo crypt($varws);//output:-$1$m5/.1//.$KRawtTgnzzScShDJN3aHa.     echo crc32($var);//output:-1732983884  echo count_chars($var ,4);//output;-!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`bcgjklopqrtvwxz{|}~€ ‚ƒ„…†‡ˆ‰Š‹Œ Ž ’“”•–—˜™š›œ žŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ    echo convert_uuencode($var);//output:-@;7D@;F%M92!I      echo convert_uudecode($var);// output:d4P L@M     echo convert_cyr_string($var,'m','a');       echo chunk_split($var,2,"(sam)");//output:-my(sam) n(sam)am(sam)e (sam)is(sam) s(sam)ad(sam)da(sam)m (sam)hu(sam)ss(sam)ai(sam)n (sam)s...