xxxxxxxxxx
#plugin perimary file header
<?php
/**
* Plugin Name: My Plugin
* Plugin URI: https://example.com/plugins/pdev
* Description: A short description of the plugin.
* Version: 1.0.0
* Requires at least: 5.3
* Requires PHP: 5.6
* Author: John Doe
* Author URI: https://example.com
* License: GPL v2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: pdev
* Domain Path: /public/lang
*/
#plugin license (primary file)
/*
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#misc functions
-sanitize_text_field($text)
-checked( $value1, $value2, false )
-selected( $value1, $value2, false )
-
-
-
-
#path/url functions
-plugin_dir_path( $file )
-plugin_dir_url( $file )
-plugins_url( $path = '', $plugin = '' )
-site_url(), home_url(), admin_url(), rest_url(), includes_url(), content_url(),
#hooks
-register_activation_hook( string $file, callable $function )
-register_deactivation_hook( string $file, callable $function )
-register_uninstall_hook( string $file, callable $function )
-add_action( 'admin_menu', 'menu creation function' )
#menu/submenu functions
-add_menu_page( page_title, menu_title, capability, menu_slug, function,
icon_url, position )
-add_submenu_page( parent_slug, page_title, menu_title, capability,
menu_slug, function )
-add_options_page( page_title, menu_title, capability, menu_slug,
function)
-add_posts_page( page_title, menu_title, capability, menu_slug,
function)
-add_media_page( page_title, menu_title, capability, menu_slug,
function)
-add_links_page( page_title, menu_title, capability, menu_slug,
function)
-add_pages_page( page_title, menu_title, capability, menu_slug,
function)
-add_management_page( page_title, menu_title, capability, menu_slug,
function)
-add_comments_page( page_title, menu_title, capability, menu_slug,
function)
-add_themes_page( page_title, menu_title, capability, menu_slug,
function)
-add_plugins_page( page_title, menu_title, capability, menu_slug,
function)
-add_user_page( page_title, menu_title, capability, menu_slug,
function)
# Settings API
- add_settings_field( $id, $title, $callback, $page, $section = 'default', $args = array() )
- add_settings_section( $id, $title, $callback, $page )
- register_setting( $option_group, $option_name, $args )
- unregister_setting( $option_group, $option_name, $args )
- settings_fields( $option_group )
- do_settings_sections( $page )
-
-
-
#Escape functions
- esc_html( $text )
- esc_attr( $text )
- sanitize_text_field( $text )
-
-
-
-
xxxxxxxxxx
WP-CLI is the command-line interface for WordPress. You can update plugins, configure multisite installations and much more, without using a web browser.
## Download WordPress
wp core download
## Generate wp-config.php file
wp core config – dbname=<dbname>
--dbuser=<dbuser> – dbpass=<dbpass>
--dbprefix=<dbprefix>
## Install WordPress
wp core install – url="your_domain_name"
--title="Your Blog Title" – admin_user="admin"
--admin_password="your_password"
--admin_email="your_email"
## Search plugin
wp plugin search yoast
## Install plugin
wp plugin install pluginname
## List plugins
wp plugin list
## List installed themes
wp theme list
## Search for new themes
wp theme search keyword
## Install theme
wp theme install bootstrap-four
## Activate theme
wp theme activate bootstrap-four
## List posts
wp post list
## Edit post
wp post edit 1
## Post update
wp post update 1
--post_title="Your New title..."
## Create posts
wp post create
--post_status=publish
--post_title="Second Post"
--edit
## Login WordPress db
wp db cli
## List WordPress users
wp db query "SELECT user_login, ID FROM wp_users;"
## Change WordPress post author
wp post update 6 – post_author=1
## Optimize db
wp db optimize
## Update WordPress
wp core update
## Update WordPress DB
wp core update-db
## Update all plugins
wp plugin update – all