Showing posts with label wordpress. Show all posts
Showing posts with label wordpress. Show all posts

Monday, March 30, 2020

Implementing cron job in WordPress

function myplugin_activate()
{

    if (!wp_next_scheduled('pt_my_task_hook')) {
        //wp_schedule_event(time(), 'hourly', 'pt_my_task_hook');
        //wp_schedule_event(time(), 'every_three_minutes', 'pt_my_task_hook');
        wp_schedule_event(strtotime('22:00:00'), 'daily', 'pt_my_task_hook');
    }
}

register_activation_hook(__FILE__, 'myplugin_activate');

/* Deactivate Hook */
register_deactivation_hook(__FILE__, 'my_deactivation');
function my_deactivation()
{
    wp_clear_scheduled_hook('pt_my_task_hook');
}

add_action('pt_my_task_hook2', 'user_email_task_function');
function user_email_task_function()
{
    // code to implement
}

Sunday, March 29, 2020

Creating custom post type in wordpress

// Our custom post type function
function create_posttype() {

    register_post_type( 'mycpt',
    // CPT Options
        array(
            'labels' => array(
                'name' => __( 'My Cpts' ),
                'singular_name' => __( 'My Cpt' )
            ),
            'public' => true,
            'has_archive' => true,
            'rewrite' => array('slug' => 'mycpt'),
            'show_in_rest' => true,

        )
    );
}
// Hooking up our function to theme setup
add_action( 'init', 'create_posttype' );


------------------------------------
Advance fields
-------------------------------------

/*
* Creating a function to create our CPT
*/

function custom_post_type() {

// Set UI labels for Custom Post Type
    $labels = array(
        'name'                => _x( 'Movies', 'Post Type General Name', 'twentytwenty' ),
        'singular_name'       => _x( 'Movie', 'Post Type Singular Name', 'twentytwenty' ),
        'menu_name'           => __( 'Movies', 'twentytwenty' ),
        'parent_item_colon'   => __( 'Parent Movie', 'twentytwenty' ),
        'all_items'           => __( 'All Movies', 'twentytwenty' ),
        'view_item'           => __( 'View Movie', 'twentytwenty' ),
        'add_new_item'        => __( 'Add New Movie', 'twentytwenty' ),
        'add_new'             => __( 'Add New', 'twentytwenty' ),
        'edit_item'           => __( 'Edit Movie', 'twentytwenty' ),
        'update_item'         => __( 'Update Movie', 'twentytwenty' ),
        'search_items'        => __( 'Search Movie', 'twentytwenty' ),
        'not_found'           => __( 'Not Found', 'twentytwenty' ),
        'not_found_in_trash'  => __( 'Not found in Trash', 'twentytwenty' ),
    );
   
// Set other options for Custom Post Type
   
    $args = array(
        'label'               => __( 'movies', 'twentytwenty' ),
        'description'         => __( 'Movie news and reviews', 'twentytwenty' ),
        'labels'              => $labels,
        // Features this CPT supports in Post Editor
        'supports'            => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'revisions', 'custom-fields', ),
        // You can associate this CPT with a taxonomy or custom taxonomy.
        'taxonomies'          => array( 'genres' ),
        /* A hierarchical CPT is like Pages and can have
        * Parent and child items. A non-hierarchical CPT
        * is like Posts.
        */
        'hierarchical'        => false,
        'public'              => true,
        'show_ui'             => true,
        'show_in_menu'        => true,
        'show_in_nav_menus'   => true,
        'show_in_admin_bar'   => true,
        'menu_position'       => 5,
        'can_export'          => true,
        'has_archive'         => true,
        'exclude_from_search' => false,
        'publicly_queryable'  => true,
        'capability_type'     => 'post',
        'show_in_rest' => true,

    );
   
    // Registering your Custom Post Type
    register_post_type( 'movies', $args );

}

/* Hook into the 'init' action so that the function
* Containing our post type registration is not 

Tuesday, December 31, 2019

Add JavaScript(JS), JQuery, and CSS to WordPress Site without wp_enqueue...




In this video will learn how we can add JavaScript(JS), JQuery, and CSS to WordPress Site without enqueuing it using Simple Custom CSS and JS. Add JavaScript(JS), JQuery, and CSS from Wp-admin in WordPress and select a particular side you want to implement it. Customize your WordPress site’s appearance by easily adding custom CSS and JS code without even having to modify your theme or plugin files. This is perfect for adding custom CSS tweaks to your site. Plugin url: https://wordpress.org/plugins/custom-css-js/

Sunday, December 1, 2019

How to take Automatic Backup of WordPress Site and Database and Store on server using updraft




Automatic Backup of WordPress Site and Database and Store on Google Drive with UpdraftPlus. Do it without connecting FTP or hosting anything Automatically take Backup into the cloud directly to Dropbox, Google Drive, Amazon S3 (or compatible), UpdraftVault, Rackspace Cloud, FTP, DreamObjects, Openstack Swift, and email. The paid version also backs up to Microsoft OneDrive, Microsoft Azure, Google Cloud Storage, Backblaze B2, SFTP, SCP, and WebDAV. DON’T RISK YOUR BACKUPS ON ANYTHING LESS Your WordPress Automatic backups are worth the entire investment you’ve made in your website. The day may come when you get hacked, when something goes wrong with an update, your server crashes or your hosting company goes bust – without good backups, you lose everything. #wordpress #backup #updraft

Sunday, November 3, 2019

Automatically Send Email on Publish of New Product in WooCommerce to all...






In this video you will learn how automatically send to users or subscribers as soon as the new Product is published in WordPress Woocommerce using mailpoet3.
 The mails will be sent automatically as soon as the new Product is added.

#wordpress
#mailpoet3
#productemails

Saturday, October 26, 2019

Sunday, October 20, 2019

Automatically Sending Welcome Email to new user or subscriber in WordPress | MailPoet3






In this video you will learn how automatically send welcome emails to new users or subscribers in WordPress using mailpoet3. The mails will be sent automatically as soon as the subscriber is added. #wordpress #mailpoet3 #welcomeemails

Saturday, October 19, 2019

Create A Blogging Website without Code from Scratch in 15 mins in Hindi



In this video, you will learn how to setup a blog without coding using WordPress hosting. Firstly, we will buy hosting using Godaddy then will set up WordPress and login into the dashboard and then set up the title of the site and set up the theme To learn Blogging check my video tutorial: https://www.youtube.com/watch?v=Poirc... #SetUp #Blogs #WithoutCoding

Thursday, October 17, 2019

Create a eCommerce site without coding in 15 mins in hindi




In this video, you will learn how to setup E-commerce or Shopping Sites without coding using WordPress hosting. Firstly, we will buy hosting using Godaddy then will set up WordPress and login into the dashboard and then set up the title of the site and set up the Woocommcerce To learn Woocommerce check my video tutorial: https://www.youtube.com/watch?v=O0ZZ-... #SetUp #EcommerceSite #WithoutCoding

Sunday, October 6, 2019

WP SEO Structure Data Schema in Wordpress


In this video, we will learn how to begin with SEO structured data in Wordpress wooCommerce in Hindi. We will learn to configure Wp SEO Structured data plugin and how we can add the keyword, description and SEO title in Wordpress post, page and products yoast seo video: https://youtu.be/hIl6dneOfAE All in one SEO: https://youtu.be/skGvng_88h0 #SEO #WordPress #StructuredData

 In an SEO context, "structured data" usually refers to implementing some type of markup on a webpage, in order to provide additional detail around the page’s content. This markup improves the search engines’ understanding of that content, which can help with relevancy signals and also enables a site to benefit from enhanced results in SERPs (rich snippets, rich cards, carousels, knowledge boxes, etc). Because this type of markup needs to be parsed and understood consistently by search engines as well as by people, there are standardized implementations (known as formats and/or syntaxes) and classifications of concepts, relationships, and terms (known as vocabularies) which should be used.

Saturday, September 21, 2019

Create a Custom CRUD Operation Plugin With Tables created on Plugin Acti...





Learn how to create a Custom CRUD operation (Insert, Update, Delete, View) Plugin in Wordpress From Scratch with Tables created on plugin activation hook of WordPress.


Github:
https://github.com/sahilgulati007/crud-plugin-wordpress

plugin Basic Video:
https://youtu.be/i5Up4mJB7fw


File to create plugin and add menu to wordpress backend

Crud-plugin.php

<?php
/**
 * Plugin Name:       CRUD Plugin
 * Plugin URI:        https://example.com/plugins/the-basics/
 * Description:       Custom Plugin to exceute crud opreation in Wordpress.
 * Version:           1.00
 * Requires at least: 5.0
 * Requires PHP:      7.0
 * Author:            Sahil Gulati
 * Author URI:        https://facebook.com/sahilgulati007
 * License:           GPL v2 or later
 * License URI:       https://www.gnu.org/licenses/gpl-2.0.html
 * Text Domain:       crud-plugin
 */

//creating database on plugin activation
global $jal_db_version;
$jal_db_version = '1.0';
function jal_install() {
    global $wpdb;
    global $jal_db_version;
    $table_name = $wpdb->prefix . 'employee_list';
    $charset_collate = $wpdb->get_charset_collate();
    $sql = "CREATE TABLE $table_name (
id mediumint(9) NOT NULL AUTO_INCREMENT,
name tinytext NOT NULL,
address text NOT NULL,
role text NOT NULL,
contact bigint(12), 
PRIMARY KEY  (id)
) $charset_collate;";
    require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
    dbDelta( $sql );
    add_option( 'jal_db_version', $jal_db_version );
}
register_activation_hook( __FILE__, 'jal_install' );

//adding in menu
add_action('admin_menu', 'at_try_menu');
function at_try_menu() {
    //adding plugin in menu
    add_menu_page('employee_list', //page title
        'Employee Listing', //menu title
        'manage_options', //capabilities
        'Employee_Listing', //menu slug
        employee_list //function
    );
    //adding submenu to a menu
    add_submenu_page('Employee_Listing',//parent page slug
        'employee_insert',//page title
        'Employee Insert',//menu titel
        'manage_options',//manage optios
        'Employee_Insert',//slug
        'employee_insert'//function
    );
    add_submenu_page( null,//parent page slug
        'employee_update',//$page_title
        'Employee Update',// $menu_title
        'manage_options',// $capability
        'Employee_Update',// $menu_slug,
        'employee_update'// $function
    );
    add_submenu_page( null,//parent page slug
        'employee_delete',//$page_title
        'Employee Delete',// $menu_title
        'manage_options',// $capability
        'Employee_Delete',// $menu_slug,
        'employee_delete'// $function
    );
}

// returns the root directory path of particular plugin
define('ROOTDIR', plugin_dir_path(__FILE__));
require_once(ROOTDIR . 'employee_list.php');
require_once (ROOTDIR.'employee_insert.php');
require_once (ROOTDIR.'employee_update.php');
require_once (ROOTDIR.'employee_delete.php');
?>

Employee_list.php

<?php
function employee_list() {
    ?>
    <style>
        table {
            border-collapse: collapse;
        }
        table, td, th {
            border: 1px solid black;
            padding: 20px;
            text-align: center;
        }
    </style>
    <div class="wrap">
        <table>
            <thead>
            <tr>
                <th>No</th>
                <th>Name</th>
                <th>Address</th>
                <th>Role</th>
                <th>Contact</th>
                <th>Update</th>
                <th>Delete</th>
            </tr>
            </thead>
            <tbody>
            <?php
            global $wpdb;
            $table_name = $wpdb->prefix . 'employee_list';
            $employees = $wpdb->get_results("SELECT id,name,address,contact,role from $table_name");
            foreach ($employees as $employee) {
                ?>
                <tr>
                    <td><?= $employee->id; ?></td>
                    <td><?= $employee->name; ?></td>
                    <td><?= $employee->address; ?></td>
                    <td><?= $employee->role; ?></td>
                    <td><?= $employee->contact; ?></td>
                    <td><a href="<?php echo admin_url('admin.php?page=Employee_Update&id=' . $employee->id); ?>">Update</a> </td>
                    <td><a href="<?php echo admin_url('admin.php?page=Employee_Delete&id=' . $employee->id); ?>"> Delete</a></td>
                </tr>
            <?php } ?>

            </tbody>
            <!--<tbody>
            <tr>
                <td>1</td>
                <td>Hardik K. Vyas</td>
                <td>Php Developer</td>
                <td>+91 940894578</td>
            </tr>
            <tr>
                <td>2</td>
                <td>Mark M. Knight</td>
                <td>Blog Writer</td>
                <td>630-531-9601</td>
            </tr>
            <tr>
                <td>3</td>
                <td>Annie D. Naccarato</td>
                <td>Project Leader</td>
                <td>144-54-XXXX</td>
            </tr>
            <tr>
                <td>4</td>
                <td>Jayesh P. Patel</td>
                <td>Web Designer</td>
                <td>+91 98562315</td>
            </tr>
            <tr>
                <td>5</td>
                <td>Alvin B. Reddick</td>
                <td>ifone Developer</td>
                <td>619-11-XXXX</td>
            </tr>
            </tbody>-->
        </table>
    </div>
    <?php
}
add_shortcode('short_employee_list', 'employee_list');
?>

Employee_insert.php

<?php

function employee_insert()
{
    //echo "insert page";
    ?>
<table>
    <thead>
    <tr>
        <th></th>
        <th></th>
    </tr>
    </thead>
    <tbody>
    <form name="frm" action="#" method="post">
    <tr>
        <td>Name:</td>
        <td><input type="text" name="nm"></td>
    </tr>
    <tr>
        <td>Address:</td>
        <td><input type="text" name="adrs"></td>
    </tr>
    <tr>
        <td>Desigination:</td>
        <td><select name="des">
                <option value="developer">Developer</option>
                <option value="designer">Designer</option>
            </select>
        </td>
    </tr>
    <tr>
        <td>Mob no:</td>
        <td><input type="number" name="mob"></td>
    </tr>
    <tr>
        <td></td>
        <td><input type="submit" value="Insert" name="ins"></td>
    </tr>
    </form>
    </tbody>
</table>
<?php
    if(isset($_POST['ins'])){
        global $wpdb;
        $nm=$_POST['nm'];
        $ad=$_POST['adrs'];
        $d=$_POST['des'];
        $m=$_POST['mob'];
        $table_name = $wpdb->prefix . 'employee_list';
        $wpdb->insert(
            $table_name,
            array(
                'name' => $nm,
                'address' => $ad,
                'role' => $d,
                'contact'=>$m
            )
        );
        echo "inserted";
       // wp_redirect( admin_url('admin.php?page=page=Employee_List'),301 );
        //header("location:http://localhost/wordpressmyplugin/wordpress/wp-admin/admin.php?page=Employee_Listing");
      //  header("http://google.com");
        ?>
        <meta http-equiv="refresh" content="1; url=http://localhost/wordpressmyplugin/wordpress/wp-admin/admin.php?page=Employee_Listing" />
        <?php
        exit;
    }
}
?>

Employee_update.php

<?php
//echo "update page";
function employee_update(){
    //echo "update page in";
    $i=$_GET['id'];
    global $wpdb;
    $table_name = $wpdb->prefix . 'employee_list';
    $employees = $wpdb->get_results("SELECT id,name,address,contact,role from $table_name where id=$i");
    echo $employees[0]->id;
    ?>
    <table>
        <thead>
        <tr>
            <th></th>
            <th></th>
        </tr>
        </thead>
        <tbody>
        <form name="frm" action="#" method="post">
            <input type="hidden" name="id" value="<?= $employees[0]->id; ?>">
            <tr>
                <td>Name:</td>
                <td><input type="text" name="nm" value="<?= $employees[0]->name; ?>"></td>
            </tr>
            <tr>
                <td>Address:</td>
                <td><input type="text" name="adrs" value="<?= $employees[0]->address; ?>"></td>
            </tr>
            <tr>
                <td>Desigination:</td>
                <td><select name="des">
                        <option value="developer" <?php if($employees[0]->role=="developer"){echo "selected";} ?> >Developer</option>
                        <option value="designer" <?php if($employees[0]->role=="designer"){echo "selected";} ?> >Designer</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td>Mob no:</td>
                <td><input type="number" name="mob" value="<?= $employees[0]->contact; ?>"></td>
            </tr>
            <tr>
                <td></td>
                <td><input type="submit" value="Update" name="upd"></td>
            </tr>
        </form>
        </tbody>
    </table>
    <?php
}
if(isset($_POST['upd']))
{
    global $wpdb;
    $table_name=$wpdb->prefix.'employee_list';
    $id=$_POST['id'];
    $nm=$_POST['nm'];
    $ad=$_POST['adrs'];
    $d=$_POST['des'];
    $m=$_POST['mob'];
    $wpdb->update(
        $table_name,
        array(
            'name'=>$nm,
            'address'=>$ad,
            'role'=>$d,
            'contact'=>$m
        ),
        array(
            'id'=>$id
        )
    );
    $url=admin_url('admin.php?page=Employee_List');
    //header("location:http://localhost/wordpressmyplugin/wordpress/wp-admin/admin.php?page=Employee_Listing");
}
?>

Employee_Delete.php

<?php
//echo "employee delete";
function employee_delete(){
    echo "employee delete";
    if(isset($_GET['id'])){
        global $wpdb;
        $table_name=$wpdb->prefix.'employee_list';
        $i=$_GET['id'];
        $wpdb->delete(
            $table_name,
            array('id'=>$i)
        );
        echo "deleted";
    }
    echo get_site_url() .'/wp-admin/admin.php?page=Employee_List';
    ?>
<!--     <meta http-equiv="refresh" content="0; url=http://localhost/wordpressmyplugin/wordpress/wp-admin/admin.php?page=Employee_Listing" />
 -->    <?php
    //wp_redirect( admin_url('admin.php?page=page=Employee_List'),301 );
    //exit;
    //header("location:http://localhost/wordpressmyplugin/wordpress/wp-admin/admin.php?page=Employee_Listing");
}
?>

#wordpressPluginDevelopment
#CrudPlugin
#TableCreationOn Activation

Learn How to create a custom plugin in WordPress from Scratch



In this video Tutorials, we will learn how to create a custom plugin in WordPress.
Make the plugin visible in the plugin list.
We will set headers in WordPress and Deactive and active plugin.

Plugin headers:
https://developer.wordpress.org/plugins/plugin-basics/header-requirements/

plugin header code

CODE


/**
 * Plugin Name:       My Custom Plugin
 * Plugin URI:        https://example.com/plugins/the-basics/
 * Description:       My custom PLugin description. Handle the basics with this plugin.
 * Version:           1.00
 * Requires at least: 5.0
 * Requires PHP:      7.0
 * Author:            Sahil Gulati
 * Author URI:        https://facebook.com/sahilgulati007
 * License:           GPL v2 or later
 * License URI:       https://www.gnu.org/licenses/gpl-2.0.html
 * Text Domain:       my-custom-plugin
 */

Saturday, September 14, 2019

Sending Mail in WordPress from Localhost or Hosting with Your Email ID using WP mail SMTP





Sending Mail in WordPress from your Localhost or Hosting Provider with the Email ID you want to send it In Hindi
Using Wp Mail Smtp
In this tutorial, I have used Gmail id.
If you are looking to send email from for localhost
check out this video