/**
  * Load the posts2posts from the composer package if it is not loaded already.
  */
 public function require_posts_to_posts()
 {
     // Initializes the database tables
     \P2P_Storage::init();
     // Initializes the query mechanism
     \P2P_Query_Post::init();
 }
 function maybe_install()
 {
     if (!current_user_can('manage_options')) {
         return;
     }
     $current_ver = get_option('p2p_storage');
     if ($current_ver == P2P_Storage::$version) {
         return;
     }
     P2P_Storage::install();
     update_option('p2p_storage', P2P_Storage::$version);
 }
 function _p2p_load()
 {
     if (!function_exists('p2p_register_connection_type')) {
         require_once RTBIZ_PATH . '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();
     if (is_admin()) {
         $this->_load_admin();
     }
 }
Exemple #4
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();
    }
}
 function setUp()
 {
     P2P_Storage::install();
     // call before $this->start_transaction()
     parent::setUp();
     foreach (array('actor', 'movie', 'studio') as $ptype) {
         register_post_type($ptype, array('public' => true));
     }
     if (!p2p_type('actor_to_movie')) {
         p2p_register_connection_type(array('name' => 'actor_to_movie', 'from' => 'actor', 'to' => 'movie', 'sortable' => true));
     }
     if (!p2p_type('movies_to_movies')) {
         p2p_register_connection_type(array('name' => 'movies_to_movies', 'from' => 'movie', 'to' => 'movie'));
     }
     if (!p2p_type('posts_to_users')) {
         p2p_register_connection_type(array('name' => 'posts_to_users', 'from' => 'post', 'to' => 'user'));
     }
 }
 /**
  * Bring Importer post types into this class.
  * Runs at import start.
  */
 public function wp_parser_starting_import()
 {
     $importer = new Importer();
     if (!$this->p2p_tables_exist()) {
         \P2P_Storage::init();
         \P2P_Storage::install();
     }
     $this->post_types = array('hook' => $importer->post_type_hook, 'method' => $importer->post_type_method, 'function' => $importer->post_type_function);
 }
Exemple #7
0
<?php

/**
 * Test Order
 *
 * @package Components\Payments\Tests
 */
require_once APP_TESTS_LIB . '/testcase.php';
P2P_Storage::init();
P2P_Storage::install();
/**
 * @group payments
 */
class APP_OrderTest extends APP_UnitTestCase
{
    protected $order;
    public static function setUpBeforeClass()
    {
        appthemes_setup_orders();
    }
    public function setUp()
    {
        parent::setUp();
        $user_id = $this->factory->user->create(array('role' => 'subscriber'));
        wp_set_current_user($user_id);
        $this->order = APP_Order_Factory::create();
    }
    public function test_retrieve_error()
    {
        $this->setExpectedException('PHPUnit_Framework_Error_Warning');
        APP_Order_Factory::retrieve('not an id');
            $args['p2p_type'] = array(0 => 'any');
            foreach (get_posts($args) as $post) {
                // some connections might be ambiguous, spanning multiple connection types; first one wins
                if ($post->p2p_type) {
                    continue;
                }
                $n += $wpdb->update($wpdb->p2p, compact('p2p_type'), array('p2p_id' => $post->p2p_id));
            }
        }
        return $n;
    }
    static function uninstall()
    {
        scb_uninstall_table('p2p');
        scb_uninstall_table('p2pmeta');
        delete_option('p2p_storage');
    }
    static function deleted_object($object_id)
    {
        $object_type = str_replace('deleted_', '', current_filter());
        foreach (P2P_Connection_Type_Factory::get_all_instances() as $p2p_type => $ctype) {
            foreach (array('from', 'to') as $direction) {
                if ($object_type == $ctype->object[$direction]) {
                    p2p_delete_connections($p2p_type, array($direction => $object_id));
                }
            }
        }
    }
}
P2P_Storage::init();