示例#1
0
文件: Load.php 项目: pmvc/pmvc
 /**
  * Include plugin only.
  *
  * @param array $init    Default plugins
  * @param array $folders Extra plugin folder
  *
  * @return bool
  */
 public static function plug(array $init = [], array $folders = [])
 {
     include_once __DIR__ . '/../include.php';
     self::initPlugInFolder();
     if (!empty($folders)) {
         addPlugInFolders($folders);
     }
     if (!empty($init)) {
         initPlugin($init);
     }
 }
示例#2
0
 *
 * @return bool
 */
function initPlugin()
{
    global $wpdb;
    // check if wp_s3podcasts table exist
    $result = $wpdb->get_results("SHOW TABLES LIKE 'wp_s3podcasts'");
    // if wp_s3podcasts table does not exist, them create it
    if (empty($result)) {
        $result = $wpdb->get_results("\n\t\t\tCREATE TABLE `wp_s3podcasts` (\n\t\t\t\t`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,\n\t\t\t\t`title` VARCHAR(100) NOT NULL,\n\t\t\t\t`description` TEXT NULL,\n\t\t\t\t`url` VARCHAR(255) NOT NULL,\n\t\t\t\t`filename` VARCHAR(200) NOT NULL,\n\t\t\t\t`user` VARCHAR(60) NOT NULL,\n\t\t\t\t`date` DATETIME NOT NULL,\n\t\t\t\tPRIMARY KEY (`id`)\n\t\t\t)\n\t\t\tCOLLATE='utf8_general_ci'\n\t\t\tENGINE=MyISAM;\n\t\t");
    }
    return true;
}
// init the plugin
initPlugin();
// handle form post from add.php file
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    addPodcast();
    header('Location: ' . $_SERVER['HTTP_REFERER']);
}
if ($_SERVER['REQUEST_METHOD'] == 'GET' && isset($_GET['action'])) {
    // single delete
    if (!empty($_GET['id'])) {
        deletePodcast($_GET['id']);
    }
    // mass delete
    if (!empty($_GET['media'])) {
        // get ids
        $ids = $_GET['media'];
        // delete selected podcasts
            echo ' selected="selected" ';
        }
    }
}
//  Dashboard Widget
require_once 'widget.php';
//  Translating the Plugin
require_once 'ptranslation.php';
// dont load not in admin
if (!is_admin()) {
    return;
}
/* config and settings classes */
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'actions.php';
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'settings.php';
//  require all files only if plugin activated
function requireForFunction()
{
    /* load classes */
    require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . 'box.php';
    require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . 'box_section.php';
    require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . 'helper.php';
    require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . 'data_collectors/wp_slot.php';
    require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . 'data_collectors/calculator.php';
    require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . 'data_collectors/post_saver.php';
    /* vendors */
    require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'vendors' . DIRECTORY_SEPARATOR . 'simple_html_dom.php';
}
// and we start
initPlugin(new onpage_post_seo_actions());
示例#4
0
 public function testIncludeOnly()
 {
     initPlugin(['test' => [_PLUGIN_FILE => __DIR__ . '/../resources/FakePlugInclude.php']], true);
     $this->assertTrue(class_exists(__NAMESPACE__ . '\\FakePlugInclude'), 'Class should exists');
     $this->assertFalse(exists('test', 'plugin'), 'Plugin should not exists');
 }