Example #1
0
function _p2p_load()
{
    load_plugin_textdomain(P2P_TEXTDOMAIN, '', basename(dirname(__FILE__)) . '/lang');
    require_once dirname(__FILE__) . '/core/init.php';
    register_uninstall_hook(__FILE__, array('P2P_Storage', 'uninstall'));
    if (is_admin()) {
        _p2p_load_admin();
    }
}
Example #2
0
function _p2p_load()
{
    load_plugin_textdomain(P2P_TEXTDOMAIN, '', basename(dirname(__FILE__)) . '/lang');
    // Prevent activation issues if a bundled version of P2P core is already loaded.
    if (function_exists('p2p_register_connection_type')) {
        return;
    }
    require_once dirname(__FILE__) . '/core/init.php';
    register_uninstall_hook(__FILE__, array('P2P_Storage', 'uninstall'));
    if (is_admin()) {
        _p2p_load_admin();
    }
}
Example #3
0
function _p2p_load()
{
    load_plugin_textdomain(P2P_TEXTDOMAIN, '', basename(dirname(__FILE__)) . '/lang');
    if (!function_exists('p2p_register_connection_type')) {
        require_once dirname(__FILE__) . '/vendor/scribu/lib-posts-to-posts/autoload.php';
    }
    P2P_Storage::init();
    P2P_Query_Post::init();
    P2P_Query_User::init();
    P2P_URL_Query::init();
    P2P_Widget::init();
    P2P_Shortcodes::init();
    register_uninstall_hook(__FILE__, array('P2P_Storage', 'uninstall'));
    if (is_admin()) {
        _p2p_load_admin();
    }
}
<?php

_p2p_load_admin();
require_once __DIR__ . '/mock-column.php';
class P2P_Tests_Column extends WP_UnitTestCase
{
    function test_default_title()
    {
        $ctype = p2p_register_connection_type(array('name' => __FUNCTION__, 'from' => 'post', 'to' => 'page', 'title' => array('from' => 'POST', 'to' => 'PAGE')));
        // from
        $mock = new P2P_Column_Mock($ctype->set_direction('from'));
        $columns = $mock->add_column(array());
        $this->assertCount(1, $columns);
        $this->assertEquals('POST', reset($columns));
        // to
        $mock = new P2P_Column_Mock($ctype->set_direction('to'));
        $columns = $mock->add_column(array());
        $this->assertCount(1, $columns);
        $this->assertEquals('PAGE', reset($columns));
    }
    function test_column_title()
    {
        $ctype = p2p_register_connection_type(array('name' => __FUNCTION__, 'from' => 'post', 'to' => 'page', 'from_labels' => array('column_title' => 'POST COLUMN'), 'to_labels' => array('column_title' => 'PAGE COLUMN')));
        // from
        $mock = new P2P_Column_Mock($ctype->set_direction('from'));
        $columns = $mock->add_column(array());
        $this->assertCount(1, $columns);
        $this->assertEquals('POST COLUMN', reset($columns));
        // to
        $mock = new P2P_Column_Mock($ctype->set_direction('to'));
        $columns = $mock->add_column(array());