Example #1
0
 /**
  * Initialize the plugin
  */
 private function init()
 {
     // Load plugin text domain
     load_plugin_textdomain('related-posts-for-wp', false, dirname(plugin_basename(RP4WP_PLUGIN_FILE)) . '/languages/');
     // Check for multisite, we don't support that
     if (is_multisite() && (is_admin() || is_network_admin())) {
         add_action('admin_notices', array('RP4WP_Multisite_Notice', 'display'));
         add_action('network_admin_notices', array('RP4WP_Multisite_Notice', 'display'));
         return;
     }
     // Check if we need to run the installer
     if (is_admin() && get_option(RP4WP_Constants::OPTION_DO_INSTALL, false)) {
         // Delete do install site option
         delete_option(RP4WP_Constants::OPTION_DO_INSTALL);
         // Redirect to installation wizard
         wp_redirect(admin_url() . '?page=rp4wp_install&rp4wp_nonce=' . wp_create_nonce(RP4WP_Constants::NONCE_INSTALL), 307);
         exit;
     }
     if (is_admin()) {
         // Check if we need to display an 'is installing' notice
         $is_installing_notice = new RP4WP_Is_Installing_Notice();
         $is_installing_notice->check();
     }
     // Setup settings
     add_action('init', array($this, 'setup_settings'));
     // Filters
     $filters = (include dirname(RP4WP_PLUGIN_FILE) . '/includes/filters.php');
     $manager_filter = new RP4WP_Manager_Filter($filters);
     $manager_filter->load_filters();
     // Hooks
     $actions = (include dirname(RP4WP_PLUGIN_FILE) . '/includes/actions.php');
     $manager_hook = new RP4WP_Manager_Hook($actions);
     $manager_hook->load_hooks();
     // Include template functions
     if (!is_admin()) {
         require_once plugin_dir_path(self::get_plugin_file()) . '/includes/template-functions.php';
     }
     // Setup the nag
     if (is_admin()) {
         $nag_manager = new RP4WP_Nag_Manager();
         $nag_manager->setup();
     }
 }
 /**
  * Initialize the plugin
  */
 private function init()
 {
     // Setup the autoloader
     self::setup_autoloader();
     // Load plugin text domain
     load_plugin_textdomain('related-posts-for-wp', false, dirname(plugin_basename(RP4WP_PLUGIN_FILE)) . '/languages/');
     // Check if we need to run the installer
     if (is_admin() && get_site_option(RP4WP_Constants::OPTION_DO_INSTALL, false)) {
         // Delete do install site option
         delete_site_option(RP4WP_Constants::OPTION_DO_INSTALL);
         // Redirect to installation wizard
         wp_redirect(admin_url() . '?page=rp4wp_install', 307);
         exit;
     }
     if (is_admin()) {
         // Check if we need to display an 'is installing' notice
         $is_installing_notice = new RP4WP_Is_Installing_Notice();
         $is_installing_notice->check();
     }
     // Setup settings
     add_action('init', array($this, 'setup_settings'));
     // Filters
     $manager_filter = new RP4WP_Manager_Filter(plugin_dir_path(RP4WP_PLUGIN_FILE) . 'classes/filters/');
     $manager_filter->load_filters();
     // Hooks
     $manager_hook = new RP4WP_Manager_Hook(plugin_dir_path(RP4WP_PLUGIN_FILE) . 'classes/hooks/');
     $manager_hook->load_hooks();
     // Include template functions
     if (!is_admin()) {
         require_once plugin_dir_path(self::get_plugin_file()) . '/includes/template-functions.php';
     }
     // Setup the nag
     if (is_admin()) {
         $nag_manager = new RP4WP_Nag_Manager();
         $nag_manager->setup();
     }
 }
Example #3
0
 /**
  * Initialize the plugin
  */
 private function init()
 {
     if (!class_exists('RP4WP_Updater')) {
         include plugin_dir_path(RP4WP_PLUGIN_FILE) . '/includes/updater/class-rp4wp-updater.php';
     }
     // Load plugin text domain
     load_plugin_textdomain('related-posts-for-wp', false, dirname(plugin_basename(RP4WP_PLUGIN_FILE)) . '/languages/');
     // Check if we need to upgrade
     if (is_admin() && (false === defined('DOING_AJAX') || false === DOING_AJAX)) {
         $upgrade_manager = new RP4WP_Upgrade_Manager();
         add_action('admin_init', array($upgrade_manager, 'check'));
     }
     // Check if we need to run the installer
     if (is_admin() && get_option(RP4WP_Constants::OPTION_DO_INSTALL, false)) {
         // Redirect the user
         add_action('init', array($this, 'redirect_to_installer'), 1);
         // Delete do install site option
         delete_option(RP4WP_Constants::OPTION_DO_INSTALL);
     }
     if (is_admin()) {
         // Check if we need to display an 'is installing' notice
         $is_installing_notice = new RP4WP_Is_Installing_Notice();
         $is_installing_notice->check();
     }
     // Setup settings
     $this->setup_settings();
     // Filters
     $filters = (include dirname(RP4WP_PLUGIN_FILE) . '/includes/filters.php');
     $manager_filter = new RP4WP_Manager_Filter($filters);
     $manager_filter->load_filters();
     // Hooks
     $actions = (include dirname(RP4WP_PLUGIN_FILE) . '/includes/actions.php');
     $manager_hook = new RP4WP_Manager_Hook($actions);
     $manager_hook->load_hooks();
     // Include template functions
     if (!is_admin()) {
         require_once plugin_dir_path(self::get_plugin_file()) . '/includes/template-functions.php';
     }
     // WP-CLI commands
     if (defined('WP_CLI') && WP_CLI) {
         $commands = new RP4WP_Cli_Command_Provider();
         $commands->register();
     }
 }