示例#1
0
 /**
  * Initialize the plugin autoload files
  *
  * @since 3.1.1
  *
  * @return void
  */
 public function init()
 {
     search_replace_textdomain();
     if ($this->user_can_access() === TRUE) {
         /**
          * Load the Requisite library. Alternatively you can use composer's
          */
         require_once __DIR__ . '/requisite/src/Requisite/Requisite.php';
         Requisite::init();
         $autoloader = new SPLAutoLoader();
         $autoloader->addRule(new Psr4(__DIR__, 'Inpsyde\\SearchReplace'));
         $plugin = new Plugin();
         $plugin->run();
     }
 }
/**
 * Load and init in WP Environment.
 */
function init()
{
    if (!is_admin()) {
        return;
    }
    // This sets the capability needed to run the plugin.
    if (!current_user_can('manage_options')) {
        return;
    }
    load_textdomain();
    /**
     * Load the Requisite library. Alternatively you can use composer's
     */
    require_once __DIR__ . '/inc/requisite/src/Requisite/Requisite.php';
    Requisite::init();
    $autoloader = new SPLAutoLoader();
    $autoloader->addRule(new Psr4(__DIR__ . '/inc', 'Inpsyde\\SearchReplace'));
    // Start the plugin.
    $plugin = new Plugin();
    $plugin->run(__FILE__);
}
/**
 * register the $dir directory to an Requisite autoloader
 *
 * @param string                  $dir (plugin base dir)
 * @param Requisite\SPLAutoLoader $requisite
 *
 * @return Requisite\SPLAutoLoader
 */
function register_autoloading($dir, Requisite\SPLAutoLoader $requisite)
{
    $requisite->addRule(new Requisite\Rule\NamespaceDirectoryMapper($dir . '/inc', __NAMESPACE__));
    return $requisite;
}