PHP code example of wordpress-phoenix / abstract-plugin-base

1. Go to this page and download the library: Download wordpress-phoenix/abstract-plugin-base library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

wordpress-phoenix / abstract-plugin-base example snippets



/**
 * Plugin Name: Custom My Plugin
 * Plugin URI: https://github.com/
 */

// Avoid direct calls to this file, because now WP core and framework has been used
if ( ! function_exists( 'add_filter' ) ) {
	header( 'Status: 403 Forbidden' );
	header( 'HTTP/1.1 403 Forbidden' );
	exit();
}

// Create plugin instance on plugins_loaded action to maximize flexibility of wp hooks and filters system.



namespace Custom\My_Plugin;

use WPAZ_Plugin_Base\V_2_6\Abstract_Plugin;

/**
 * Class App
 */
class App extends Abstract_Plugin {

	public static $autoload_class_prefix = __NAMESPACE__;

	protected static $current_file = __FILE__;

	public static $autoload_type = 'psr-4';

	// Set to 2 when you use 2 namespaces in the main app file
	public static $autoload_ns_match_depth = 2;

	public function onload( $instance ) {
		// Nothing yet
	}

	public function init() {
		do_action( static::class . '_before_init' );

		// Do plugin stuff usually looks something like
		// $subclass = new OptionalAppSubfolder\Custom_Class_Subclass();
		// $subclass->custom_plugin_function();

		do_action( static::class . '_after_init' );
	}

	public function authenticated_init() {
		if ( ! is_user_logged_in() ) {
			return;
		}

		// Ready for wp-admin - but not