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>;

Create Json code from MySQL database with php

Create Json code  from MySQL database with php   -- -- Database: `test` -- -- -------------------------------------------------------- -- -- Table structure for table `page` -- CREATE TABLE IF NOT EXISTS `page` (   `page_id` int(11) NOT NULL,   `page_title` text NOT NULL,   `page_url` text NOT NULL ) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=latin1; -- -- Dumping data for table `page` -- INSERT INTO `page` (`page_id`, `page_title`, `page_url`) VALUES (1, 'JSON - Dynamic Dependent Dropdown List using Jquery and Ajax', 'json-dynamic-dependent-dropdown-list-using-jquery-and-ajax'), (2, 'Live Table Data Edit Delete using Tabledit Plugin in PHP', 'live-table-data-edit-delete-using-tabledit-plugin-in-php'), (3, 'Create Treeview with Bootstrap Treeview Ajax JQuery in PHP\r\n', 'create-treeview-with-bootstrap-treeview-ajax-jquery-in-php'), (4, 'Bootstrap Multiselect Dropdown with Checkboxes using Jquery in PH...

Php prime number program with use of class

Php prime number  program with use of class <?php class find_p_number { # Function to check single number is Prime or not static function isPrime ( $ number ) { # Start temporary number from 2 (1 is not a prime number) $ i = 2 ; # 1 is not a prime number if ( $ number == 1 ) return false ; # 2 is the only even prime number if ( $ number == 2 ) return true ; # Check numbers other than 1 and 2 while ( $ i <= sqrt ( $ number ) ) { if ( $ number % $ i == 0 ) return false ;   $ i ++ ; } # If the execution has come to this point, means it is a prime Number :) return true ; } # Function to check Prime Numbers between two given numbers static function betweenTwoNumbers ( $ num1 , $ num2 ) { $ prime_numbers = array ( ) ; # Check Prime Numbers between two given numbers for ( $ num1 ; $ num1 < $ num2 ; $ num1 +...