WP Manifestindependent plugin directory
manifest / developer / course-plugin

Course Plugin

Handle the basics with this plugin.

by RawlM · github.com/raulvs14/course-plugin · website

0stars
0forks

Install

No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:

wp plugin install https://github.com/raulvs14/course-plugin/archive/refs/heads/master.zip

Plugin file - [plugin-file].php

  1. Create header file using header requirements
  2. Create admin pages administration screens
  3. Create admin menu using:
  4. Create hook for the admin menu add_action
  5. Activate plugin

Custom Post Types - [type_slug].php

  1. Install Custom Post Type UI
  2. Create new post type:
    • Type slug
    • Plural Label
    • Singular Label
    • Public - False
    • Has Archive - False
    • Exclude From Search - True
    • With Front - False
  3. Create cpt/[type_slug].php file
  4. Export the created cpt from CPT UI under Tools -> Get Code
  5. Add it to the file cpt/[type_slug].php
  6. Include this file under [plugin-file].php using include_once
  7. Remove custom post type from menu by setting show_in_menu to false in the [type_slug].php file
  8. Rename the function [plugin_short]register[type_slug]

Create custom database tables

  1. Create method in your [plugin-file].php [plugin_short]_create_plugin_tables:
    • Use global $wpdb WPDB
    • Create query
    • Use dbDelta to execute the error
  2. Create a method for plugin activation
  3. Register activation hook for plugin activation method

Shortcodes

Shortcodes support page

  1. Create custom shortcode by registering shortcode function with add_shortcode

  2. Create function that will replace the shortcode

  3. Register hooks for shortcode using init

Add JS and CSS

Create functions that will:

  1. Register the scripts and styles

    Register scripts

    Register styles

  2. Queue the scripts and styles

    Enqueue scripts

    Enqueue styles

  3. Create hooks

    Admin enqueue scripts hook

    Enqueue scripts hook

  4. Ajax save response - create script and register hooks

    WP ajax

    WP ajax nopriv

  5. Handling AJAX responses Nonce

Create custom admin columns

  1. Create custom admin columns function and register it as a filter Add filter

    Manage edit-post type columns

    Provide value for custom post type columns

Create admin page for statistics

  1. Create ajax functions for admin HTML and register
  2. Create function for HTML
  3. Create event listener for stats page

Create admin use

  1. Update page html and create function for db query for preview statistics

ISSUES

  1. Forgot password -> create md5 password and copy it to replace it in database
  2. Can't update -> check rights if the files are for correct user
  3. Can't connect to database:
    • Grant privileges
       mysql > grant all privileges on . to 'root'@'IP' identified by 'root_password'; mysql> flush privileges;
    • For IDE database connection: add UTC, when you get timezone error
    • Test remote connection:
      mysql -u <username> -h <ip_address_of_the_machine_having_mysql_server> -p <port_number> -p
  4. Does not send mail -> logout and try to send mail, it will give mail() error
    • sudo apt-get install sendmail
    • sudo sendmailconfig - choose "Yes"
    • sudo service apache2 restart