Posts

Showing posts from 2016

PHP BUILT-IN FUNCTIONS

strtolower() - converts a string to lowercase. lcfirst() - converts the first character of a string to lowercase. ucfirst() - converts the first character of a string to uppercase. ucwords() - converts the first character of each word in a string to uppercase.

Bootstrap browse button

  a) For Multiple file upload..........     <label class="btn btn-primary btn-file">         <i class="fa fa-picture-o"></i> Browse         <input type="file" name="file[]" style="display:none;" multiple>     </label>   b) For Single file upload........     <label class="btn btn-primary btn-file">         <i class="fa fa-picture-o"></i> Browse         <input type="file" name="file" style="display:none;">     </label>

INCREASING SQL UPLOADING FILE SIZE

1> Go to php.ini file 2> Find : post_max_size = 8M upload_max_filesize = 2M max_execution_time = 30 max_input_time = 60 memory_limit = 8M 3> Replace : post_max_size = 35M upload_max_filesize = 35M max_execution_time = 5000 max_input_time = 5000 memory_limit = 1000M

LARAVEL STYLE and SCRIPT LINKING

CSS LINKING : {!!Html::style('assets/css/bootstrap.css')!!} JAVASCRIPT LINKING : {!!Html::script('assets/js/bootstrap.min.js')!!}

UBUNTU>TERMINAL>MYSQL>DATABASE>TABLE

How to Install MySQL sudo apt-get install mysql-server How to Access the MySQL shell mysql -u root -p How to Create and Delete a MySQL Database mysql> SHOW DATABASES; mysql> CREATE DATABASE db_name; mysql> DROP DATABASE db_name ; mysql> USE db_name; mysql> SHOW tables; How to Create a MySQL Table CREATE TABLE tbl_name (id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, name VARCHAR(20), food VARCHAR(30), confirmed CHAR(1), signup_date DATE); mysql> SHOW TABLES; mysql> DESCRIBE tbl_name; How to Add Information to a MySQL Table INSERT INTO `tbl_name` (`id`,`name`,`food`,`confirmed`,`signup_date`) VALUES (NULL, "John", "Casserole","Y", '2012-04-11'); mysql> SELECT * FROM tbl_name; How to Update Information in the Table UPDATE `tbl_name` SET `confirmed` = 'Y' WHERE `tbl_name`.`name`='Sandy'; How to Add and Delete a Column ALTER TABLE tbl_name ADD email VARCHAR(40); ALTER TABLE tbl_name ADD email VARCHAR(40)

LARAVEL FORM AND INPUT BOX WITH VALIDATION FORMAT

{{ Form::open(array('url'=>'action_route','method'=>'post')) }}   <div class="form-group {{$errors->has('first_name')?'has-error':''}}">     {!!Form::label('first_name','First Name : ')!!}    {!!Form::text('first_name',$info->first_name,array('class'=>'form-control'))!!}    {!!$errors->first('first_name','<span class="help-block">:message</span>')!!}   </div> {{ Form::close() }}

ul->li active class in laravel

{!! Request::segment(1)== 'contact' ? ' class="active" ' : '' !!}

DIFFERENT BETWEEN {{ }} and {!! !!} in LARAVEL

{{ }} $first = "<b>Hasib Kamal</b>" ; {{ $first }} Output : <b>Hasib Kamal </b> {!! !!} $first = "<b>Hasib Kamal</b>" ; {!! $first !!} Output : Hasib Kamal

LARAVEL(SAVE,VIEW,DELETE)

VIEW :     public function index(){         $info_list = infoModel::all();         return view('list',compact('info_list'));     } SAVE :     public function storeInfo(Request $request){         $first_name = $request->get('first_name');         $last_name = $request->get('last_name');         $email_address = $request->get('email_address');         $phone_number = $request->get('phone_number');         $info = new infoModel();         $info->first_name = $first_name;         $info->last_name = $last_name;         $info->email_address = $email_address;         $info->phone_number = $phone_number;         $info->save();         return redirect('/');     } DELETE :     public function delete($id){         infoModel::where('id',$id)->delete();         return redirect('/');     }

APACHE SERVER (START || STOP || RESTART)

START> sudo service apache2 start STOP> sudo service apache2 stop RESTART> sudo service apache2 restart

PhpStrom INSTALLATION ON UBUNTU

->Install Oracle Java 8 on Ubuntu 15.10/16.04 sudo apt-get remove openjdk* sudo add-apt-repository ppa:webupd8team/java  sudo apt-get update sudo apt-get install java-common oracle-java8-installer sudo apt-get install oracle-java8-set-default source /etc/profile ->Install phpstorm on Ubuntu 15.10/16.04 wget https://download-cf.jetbrains.com/webide/PhpStorm-2016.1.2.tar.gz tar xvf PhpStorm-2016.1.2.tar.gz sudo mv PhpStorm-145.1616.3/ /opt/phpstorm/ sudo ln -s /opt/phpstorm/bin/phpstorm.sh /usr/local/bin/phpstorm phpstorm https://www.linuxbabe.com/desktop-linux/install-phpstorm-ubuntu-15-10

SOME IMPORTANT UBUNTU INSTALLATION

TRASH COMMAND INSTALLATION ->sudo apt install trash-cli ANY LINUX SUPPORTED SOFTWARE INSTALLATION ->sudo dpkg -i software-name-details CAT -> cat>text {Enter} -> echo "Hasib Kamal Chowdhury" {Enter} -> ctrl+d {Enter} -> chmod +x text -> sh text

LARAVEL DOWNLOAD BY COMPOSER

DOWNLOAD THE CURRENT PROJECT -> composer create-project laravel/laravel project-name DOWNLOAD THE PROJECT VERSION WISE -> composer create-project --prefer-dist laravel/laravel project-name 5.1

SNIPPING TOOL FOR UBUNTU

> sudo apt-get install shutter

INSTALL COMPOSER ON UBUNTU

Procedures are Given Below : sudo updates-alternatives --install "/usr/bin/php" "php" "/opt/lampp/bin/php" 1 php -v su sudo apt-get install curl curl -V sudo apt-get install git git curl -sS https://getcomposer.org/installer | php php composer.phar sudo mv composer.phar /usr/local/bin/composer sudo apt-get install composer

TO SEE PHP VERSION ON UBUNTU

1st step : sudo update-alternatives --install "/usr/bin/php" "php" "/opt/lampp/bin/php" 1 2nd step : Enter User Password 3rd step : php -v

LAMPP SERVER (START && STOP) ON UBUNTU

Start Procedure sudo /opt/lampp/lampp start Stop Procedure sudo /opt/lampp/lampp stop

apt-get command on ubuntu

APT is stands for ' Advanced Packaging Tool '. The apt-get command is a powerful command-line tool, which works with Ubuntu's Advanced Packaging Tool (APT) performing such functions as installation of new software packages, upgrade of existing software packages, updating of the package list index, and even upgrading the entire Ubuntu system. Some examples of popular uses for the apt-get utility: Install a Package : sudo apt-get install nmap Remove a Package : sudo apt-get remove nmap Update the Package Index : sudo apt-get update Upgrade Packages : sudo apt-get upgrade  Further Information : apt-get help

INSTALL SUBLIME TEXT-3 ON UBUNTU

Sublime Text-3 Installation Procedural step by step on ubuntu Run terminal as root user sudo add-apt-repository ppa:webupd8team/sublime-text-3 Enter sudo apt-get update sudo apt-get install sublime-text-installer 

HOW TO CHECK LINUX SYSTEM EITHER 32-BIT OR 64-BIT

THROUGH TERMINAL uname -a uname -m arch file/sbin/init THROUGH GUI UBUNTU ON TOP RIGHT -> SETTINGS -> SYSTEM SETTINGS -> Details -> Overview

CREATE ROOT USER IN UBUNTU

1st step : Open Terminal 2nd step : sudo passwd root 3rd step : give current password 4th step : set new password for root user 5th step : confirm new password for root user 6th step : su 7th step : give root user password Done :) You are now using terminal as root user

LARAVEL SETUP

1st Step : Download Composer From : https://getcomposer.org/ 2ns Step : Install Composer and locate this given below path at the installation time ->xampp/php/php.exe 3rd Step : Git Bash in the htdocs directory 4th Step : composer create-project laravel/laravel project_folder 5th Step : After completing download laravel files cd project_folder 6th Step : Now Run the project with this given bellow command php artisan serve

DATA VIEW FROM MYSQL DATABASE THROUGH PDO PROCESS

//LOGICAL TEMPLATE (CLASS || student.php) class Student{ protected $db_connect; public function __construct(){ $host_name = 'localhost'; $user_name = 'root'; $password = ''; $db_name = 'db_test'; try{ $this->db_connect = new PDO("mysql:host={$host_name}; dbname={$db_name}",$user_name,$password); }catch(PDOException $e){ echo $e->getMessage(); } } public function select_all_student_info(){ try{ $student_info = $this->db_connect->prepare("SELECT * FROM tbl_student"); $student_info->execute(); return $student_info; }catch(PDOException $e){ echo $e->getMessage(); } } } //VIEW PAGE <?php require_once('student.php'); $obj_student = new Student(); $student_info = $obj_student->select_all_student_info(); ?>   <fieldset>   <legend>View Student Form</legend>   <table border="1" cellpad

DATA INSERT INTO MYSQL DATABASE THROUGH PDO PROCESS

<?php class Student{ protected $db_connect; public function __construct(){ $host_name = 'localhost'; $user_name = 'root'; $password = ''; $db_name = 'db_test'; try{ $this->db_connect = new PDO("mysql:host={$host_name}; dbname={$db_name}",$user_name,$password); }catch(PDOException $e){ echo $e->getMessage(); } } public function save_student_info($data){ $student_info = $this->db_connect->prepare("INSERT INTO tbl_student(student_name,phone_number,email_address) VALUES(:a,:b,:c)"); $student_info->bindParam(':a',$data['student_name']); $student_info->bindParam(':b',$data['phone_number']); $student_info->bindParam(':c',$data['email_address']); $student_info->execute(); } }

Basic AJAX Codes

<script type="text/javascript">           if (window.XMLHttpRequest) {                 // code for IE7+, Firefox, Chrome, Opera, Safari                 xmlhttp = new XMLHttpRequest();             } else {                 // code for IE6, IE5                 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");                          }                       function makerequest(given_text,objID){ //alert(given_text);         //var obj = document.getElementById(objID);         serverPage='text.php?text='+given_text; xmlhttp.open("GET", serverPage); xmlhttp.onreadystatechange = function(){ //alert(xmlhttp.readyState); //alert(xmlhttp.status); if (xmlhttp.readyState == 4 && xmlhttp.status == 200){ //alert(xmlhttp.responseText);                         document.getElementById(objID).innerHTML = xmlhttp.responseText; //document.getElementById(objcw).innerHTML = xmlhttp.responseText; } } xmlhttp.send(n

Best Example of Inheritance

<?php class DB_Connection{ private $host = 'localhost'; private $user = 'root'; private $pass = ''; private $db_name = 'test'; protected $db_connect; public function __construct(){ $this->db_connect = mysqli_connect($this->host,$this->user,$this->pass,$this->db_name); if(!$this->db_connect){ die('Connection Problem : '.mysqli_error($this->db_connect)); } } } class Student extends DB_Connection{ public function __construct(){ parent::__construct(); } } ?>

To use font-awesome icons in redux framworks

function my_font_awesome(){         wp_register_style('font-awesome',get_template_directory_uri().'/css/font-awesome.min.css');         wp_enqueue_style('font-awesome');     }     add_action('admin_enqueue_scripts','my_font_awesome');

How to add a program to startup

-> Create a shortcut of your program (.exe file) from root directory -> Go to run command -> Write (%appdata%) and run -> Now to to this directory from the (AppData->Roaming) window -> Directory : (Microsoft\Windows\Start Menu\Programs\Startup) -> Cut and Paste your created shortcut file in this directory -> Restart You PC -> Is it Done Successfully ???

CSS3 @keyframes Concept

@keyframes color_change{      from{color:red;}      to{color:blue;} } OR @keyframes color_change{     0%{color:red;}     100%{color:blue;} } This is the process to define a @keyframes now the job is to call the @keyframes in a CLASS or ID. .text{     animation-name : color_change;    // To Call the @keyframes by it's name     animation-iteration-count : 1;        // How many times the process will be reprocess     animation-duration : 1s;                // How long the process will run in a single execution }

WP Customizer API

index.php <img src="<?php echo get_theme_mod('logo_img'); ?>" alt="Logo"> <?php if(true=== get_theme_mod('copyright_visibility')) : ?> <h1>Copyright : <?php echo get_theme_mod('copyright_text'); ?></h1> <?php endif; ?> <h1 class="fruit">Fruit : <?php echo get_theme_mod('select_fruit'); ?></h1> functions.php /* Customizer API*/ function customize_api($custom_val){        //Section Name : general_section  {A New Section Start} $custom_val->add_section('general_section',array( 'title' => 'General Options', 'priority' => 20 )); //For Logo Upload (general_section) $custom_val->add_setting('logo_img',array( 'default' => '', 'transport' => 'refresh' )); $custom_val->add_control( new WP_Customize_Image_Contr

customizer-scripts.js

index.php <h1>Copyright : <?php echo get_theme_mod('copyright_text'); ?></h1> functions.php function customize_api($custom_val){ $custom_val->add_section('general_section',array( 'title' => 'General Options', 'priority' => 20 )); //For Copyright Text $custom_val->add_setting('copyright_text',array( 'default' => 'Copyright Text', 'transport' => 'postMessage' )); $custom_val->add_control('copyright_text',array( 'section' => 'general_section', 'label' => 'Copyright Text', 'type' => 'text' )); } add_action('customize_register','customize_api'); function scripts_for_customizer(){ wp_enqueue_script('customizer-scripts',get_template_directory_uri().'/js/customizer-scripts.js',array('jquery','customize-preview'

WP customize_register for Logo Upload

/* Customizer API*/ functions.php function customize_api($custom_val){ $custom_val->add_section('general_section',array( 'title' => 'General Options', 'priority' => 20 )); $custom_val->add_setting('logo_img',array( 'default' => '', 'transport' => 'refresh' )); $custom_val->add_control( new WP_Customize_Image_Control($custom_val,'logo_img',array( 'section' => 'general_section', 'label' => 'Logo Uploader', 'settings' => 'logo_img' )) ); } add_action('customize_register','customize_api'); index.php <img src="<?php echo get_theme_mod('logo_img'); ?>" alt="Logo">

WP customize_register for Title OR Text

/* Customizer API*/ functions.php function customize_api($custom_val){ $custom_val->add_section('general_section',array( 'title' => 'General Options', 'priority' => 20 )); $custom_val->add_setting('copyright_text',array( 'default' => 'HKC', 'transport' => 'refresh' )); $custom_val->add_control('copyright_text',array( 'section' => 'general_section', 'label' => 'Copyright Text', 'type' => 'text' )); } add_action('customize_register','customize_api'); index.php <h1>Copyright : <?php echo get_theme_mod('copyright_text'); ?></h1>

Ternary Operator PHP

() ? : ; (Condition) ? TRUE : FALSE ;

class two extends one {}

In object oriented php programming concept if I extends class one into class two and make an object named as $second = new two(); then what will happen actually ?? Then I can access all property of class one by using the object "$second->first_string;" cause I've extended all property of class one from class two. Note : One protected and public property is possible to access from other class.

Process to view repository project on live in github

-> Create a repository name as your wish -> Upload all files to the repository from your project folder -> Go to the branches and add a branch name gh-pages for this repository -> Your job has done -> Now go through the link such as http://username.github.io/repositoryname

The process of hosting a site in github with (https://username.github.io) URL

Step by step is written below, -> Create a repository name as username.github.io -> git clone https://github.com/username/username.github.io -> cd username.github.io -> Copy your project files into the username.github.io folder -> git status -> git add --a -> git commit -m "Uploading Files" -> git push -u origin master

Drop-down Menu in WP

functions.php      <?php         function theme_basic_tools(){        register_nav_menu('site-menu','Site Menu');          }         add_action('after_setup_theme','theme_basic_tools');         require_once('navwalker.php');         function default_site_menu(){       echo '<ul class="nav navbar-nav">';       echo '<li><a href="'.esc_url(home_url()).'">Home</a></li>';       echo '</ul>';         }       ?> index.php           <?php                     wp_nav_menu(array(                    'theme_location' => 'site-menu',                     'menu_class' => 'nav navbar-nav',                     'fallback_cb' => 'default_site_menu',                     'walker' => new wp_bootstrap_navwalker()                 ));             ?>

The process to link js files and css files from functions.php

function porject_styles_scripts(){ wp_register_style('bootstrap',esc_url(get_template_directory_uri()).'/css/bootstrap.min.css'); wp_register_style('awesome',esc_url(get_template_directory_uri()).'/font-awesome/css/font-awesome.min.css'); wp_register_style ('animate',esc_url(get_template_directory_uri()).'/css/animate.css'); wp_register_style('style',esc_url(get_template_directory_uri()).'/css/style.css'); wp_register_style('default',esc_url(get_template_directory_uri()).'/color/default.css'); wp_register_script ('bootstrap',esc_url(get_template_directory_uri()).'/js/bootstrap.min.js', array('jquery')); wp_register_script('easing',esc_url(get_template_directory_uri()).'/js/jquery.easing.min.js',array('jquery')); wp_register_script('scroll',esc_url(get_template_directory_uri()).'/js/jquery.scrollTo.js',array('jquery'));

CMB2 Meta Box Code

function cmb_meta_box(array $mitul){ $prefix = '_xx_'; $mitul[] = array( 'id' => 'second-section', 'title' => 'This is Second section', 'object_types' => array('post'), 'fields' => array( array( 'name' => 'Enter Your Name', 'type' => 'text', 'id' => $prefix.'hkname' ) ) ); return $mitul; } add_filter('cmb2_meta_boxes','cmb_meta_box');

Raw Code Meta Box

//functions.php function favourite_food(){ add_meta_box( 'fav_food_meta', 'What is your Favourite Food ???', 'meta_box_op', 'page', 'normal' ); } add_action('add_meta_boxes','favourite_food'); function meta_box_op($post){ ?> <label for="food">Type your favourite food</label> <p><input type="text" id="food" name="zboom_food" class="widefat" value="<?php echo get_post_meta($post->ID,'zboom_food',true); ?>" /></p> <?php } function food_send_to_database($post_id){ update_post_meta($post_id,'zboom_food',$_POST['zboom_food']); } add_action('save_post','food_send_to_database'); //page.php <?php echo get_post_meta($post->ID,'zboom_food',true); ?>

What is callback function ?

A callback function also known as a higher-order function is, a function that is passed to another function as a parameter, and the callback function is called inside the other function.

WP read_more($limit);

WordPress read_more($limit); function with limitation. Code and explanation is given below. //functions.php function read_more($limit){ $content = explode(' ', get_the_content()); $less_content = array_slice($content, 0, $limit); echo implode(" ", $less_content); } //page.php read_more(10); Function's explanation : First we make a function with a parameter which through we will pass the limit of contents. Then we take a variable named $content which containing explode (php) function. What explode function do actually ?? explode(); convert contents in to array basis on which you define. It can be space or any character. explode(); function has two parameter. First one is for the exact context which divide the content into two array. We have define here space ' '. So according to our statement where it will get space it will built array. And using space in first parameter we have made each word in an array. Second parameter is for

WP function : get_post_meta();

get_post_meta(); function has three parameter. First parameter is for define page or post id. We can statically define the first parameter or dynamically. If we want to dynamically define the first parameter then we have use another function which is get_the_ID(). In the second parameter we will choose a unique id and the third parameter is Boolean (true/false). We will write true in the Boolean parameter.   

Three important thing in HTML

Image
1. Tag 2. Element 3. Attribute Tag is a specific thing. Element is a complete thing. Attribute define in the opening tag and modify the elements till the closing tag which in it. Example : <p align="center">This is Element Content</p> Attribute Visual Example :  Element Visual Example : 

To easily generate favicon

http://www.favicon-generator.org/ 

WP Admin Menu Position

2. Dashboard 4. Separator 5. Posts 10. Media 15. Links 20. Pages 25. Comments 59. Separator 60. Appearance 65. Plugins 70. Users 75. Tools 80. Settings 99. Separator

Create WP User

functions.php $newser = new WP_User(wp_create_user('kamal','123','hkc@gmail.com')); $newser->set_role('administrator');

WP Slider

functions.php register_post_type('zboom',array( 'labels' => array( 'name' => 'zBoomSlider', 'add_new_item' => 'Slider Addition' ), 'public' => true, 'supports' => array( 'title','thumbnail' ) )); index.php <?php $slider_itm = new WP_Query(array( 'post_type' => 'zboom' )); ?> <?php while($slider_itm->have_posts()) : $slider_itm->the_post();?> <li><?php the_post_thumbnail(); ?></li> <?php endwhile; ?>

comments_popup_link();

comments_popup_link("","","","",""); 1. " "    "No Comments" {If there is not comments will show the message} 2. " "    "Single Comment" {If there is single comment will show the message} 3. " "    "% Comments" {% will show how many comments} 4. " "    "class" {Add Class to change design} 5. " "    "Comments Disable" {For disable comments}

WP read more

index.php <?php read_more(10); ?>.... <a href="<?php the_permalink(); ?>">read more</a> functions.php function read_more($limit){ $contents = explode(' ', get_the_content()); $less_contents = array_slice($contents, 0, $limit); echo implode(" ", $less_contents); }

Some WP Functions

comments_popup_link(); the_time(); the_title(); the_content(); dynamic_sidebar(); add_action();

WP time function

<?php the_time('d F, Y | g : i a'); ?>

Code for WP Sidebar

functions.php <?php function newx(){ register_sidebar(array( 'name' => 'left sidebar', 'description' => 'You can add widget here', 'id' => 'leftsidebar', 'before_title' => '<h3>', 'after-title' => '</h3>', 'before_widget' => '', 'after_widget' => '' )); register_sidebar(array( 'name' => 'Right sidebar', 'description' => 'You can add right widget here', 'id' => 'rightsidebar' )); } add_action('widgets_init','newx'); ?> index.php <?php dynamic_sidebar('leftsidebar'); ?>

https://getcomposer.org/

installation directory xampp/php/php.exe install ctrl+shift right button php -S localhost:8000

HTML Code Format

http://www.freeformatter.com/html-formatter.html

the_post_thumbnail

functions.php           <?php               add_theme_support('post-thumbnails');           ?> index.php           <?php               the_post_thumbnail();           ?>

WP Menu

functions.php         <?php load_theme_textdomain('wp_dev', get_template_directory_uri().'/languages'); register_nav_menus(array( 'primarymenu' => __('Main Menu','wp_dev'), 'footermenu' => __('Footer Menu','wp_dev') ));         ?> header.php        <?php             wp_nav_menu(array(                 'theme_location' => 'primarymenu'                 ));         ?>

important !!!!!!!

#bar ul li:hover a, #bar ul .current-menu-item a{ background: linear-gradient(#4D0017,#8B002A); }

How to make dynamic WordPress Content

    <?php while(have_posts()) : the_post(); ?>         <div class="articleTitle"><?php the_title(); ?></div>         <div class="articleContent">               <p><?php the_content(); ?></p>     </div>     <?php endwhile; ?>

AJAX code to pass values by POST Method in Javascript.

        function datainsert(){             var xmlhr = new XMLHttpRequest();             var url = 'gethint.php';             var fname = document.getElementById('fname').value;             var lname = document.getElementById('lname').value;             var vars = "firstname="+fname+"&lastname="+lname;             xmlhr.open("POST",url,true);             xmlhr.setRequestHeader("content-type","application/x-www-form-urlencoded");             xmlhr.send(vars);         }

print_r($_FILES);

name, type, tmp_name, error, size