File: /var/www/indoadvisory/wp/wp-content/plugins/indexnow/includes/class-indexnow-url-submission.php
<?php
/**
* The core plugin class.
*
* This is used to define admin-specific hooks.
*
* Also maintains the unique identifier of this plugin as well as the current
* version of the plugin.
*
* @since 1.0.0
* @package BWT_IndexNow
* @subpackage BWT_IndexNow/includes
* @author Microsoft Bing <bingwpus@microsoft.com>
*/
class BWT_IndexNow {
/**
* The loader that's responsible for maintaining and registering all hooks that power
* the plugin.
*
* @since 0.01.01
* @access protected
* @var BWT_IndexNow_Loader $loader Maintains and registers all hooks for the plugin.
*/
protected $loader;
/**
* The unique identifier of this plugin.
*
* @since 0.01.01
* @access protected
* @var string $plugin_name The string used to uniquely identify this plugin.
*/
protected $plugin_name;
/**
* The current version of the plugin.
*
* @since 0.01.01
* @access protected
* @var string $version The current version of the plugin.
*/
protected $version;
/**
* Define the core functionality of the plugin.
*
* Set the plugin name and the plugin version that can be used throughout the plugin.
* Load the dependencies and set the hooks for the admin area.
*
* @since 0.01.01
*/
public function __construct($plugin_name) {
if ( defined( 'BWT_INDEXNOW_PLUGIN_VERSION' ) ) {
$this->version = BWT_INDEXNOW_PLUGIN_VERSION;
} else {
$this->version = '1.0.3';
}
$this->plugin_name = $plugin_name;
$this->load_dependencies();
$this->define_admin_hooks();
}
/**
* Load the required dependencies for this plugin.
*
* Include the following files that make up the plugin:
*
* - BWT_IndexNow_Loader. Orchestrates the hooks of the plugin.
* - BWT_IndexNow_Admin. Defines all hooks for the admin area.
*
* Create an instance of the loader which will be used to register the hooks
* with WordPress.
*
* @since 0.01.01
* @access private
*/
private function load_dependencies() {
/**
* The class responsible for orchestrating the actions and filters of the
* core plugin.
*/
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-indexnow-url-submission-loader.php';
/**
* The class responsible for defining all actions that occur in the admin area.
*/
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-indexnow-url-submission-admin.php';
$this->loader = new BWT_IndexNow_Loader();
}
/**
* Register all of the hooks related to the admin area functionality
* of the plugin.
*
* @since 0.01.01
* @access private
*/
private function define_admin_hooks() {
$plugin_admin = new BWT_IndexNow_Admin( $this->get_plugin_name(), $this->get_version() );
$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
// Save/Update our plugin options.
$this->loader->add_action( 'admin_init', $plugin_admin, 'options_update');
$this->loader->add_action( 'rest_api_init', $plugin_admin, 'register_routes');
$this->loader->add_action( 'template_redirect', $plugin_admin, 'check_for_indexnow_page' );
// Add a new admin menu.
$this->loader->add_action( 'admin_menu', $plugin_admin, 'add_plugin_admin_menu' );
// Add Settings link to the plugin.
$plugin_basename = plugin_basename( plugin_dir_path( __DIR__ ) . 'indexnow-url-submission.php' );
$this->loader->add_filter( 'plugin_action_links_' . $plugin_basename, $plugin_admin, 'add_action_links' );
// Add url submit action & post publishing.
$this->loader->add_action( 'transition_post_status', $plugin_admin, 'on_post_published', 10, 3 );
}
/**
* Run the loader to execute all of the hooks with WordPress.
*
* @since 0.01.01
*/
public function run() {
$this->loader->run();
}
/**
* The name of the plugin used to uniquely identify it within the context of
* WordPress and to define internationalization functionality.
*
* @since 1.0.0
* @return string The name of the plugin.
*/
public function get_plugin_name() {
return $this->plugin_name;
}
/**
* The reference to the class that orchestrates the hooks with the plugin.
*
* @since 1.0.0
* @return BWT_IndexNow_Loader Orchestrates the hooks of the plugin.
*/
public function get_loader() {
return $this->loader;
}
/**
* Retrieve the version number of the plugin.
*
* @since 1.0.0
* @return string The version number of the plugin.
*/
public function get_version() {
return $this->version;
}
}