WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Load WP Core in another Framework (SHORTINIT + WP_QUERY) (3 posts)

  1. Thiago Macedo
    Member
    Posted 3 years ago #

    Hey guys

    I'm trying to integrate WP Core in the Yii Framework, to not have to port it (too expensive).
    So, after configuring Yii Framework to allow wp-config inclusion, I've managed the following:

    define( 'ABSPATH', $this->wordpress_path . '/' );
            define('WP_USE_THEMES', false);
            define('WP_ALLOW_MULTISITE', false);
            define('SHORTINIT', true);
    
            define( 'TABLE_PREFIX', 'wp_8_' );
    
            require_once( ABSPATH . 'wp-config.php' );

    I have cofigure wp-config in order to it allow me to setup this constants.

    Then fellows comes the problem. I'm able to load it in SHORTINIT mode. But when it comes to full mode I havent had luck (wp_not_installed or another dont let me pass).

    Well, well, finally the question. I'm trying, in these scenario, to load after wp-config SHORTINIT the WP_Query class, or some other stuff I should eventually need.

    I started including "INC + query.php" but it's like trouble finding.. there must be too many code behind it (taxonomies are the first).

    I'll keep on tryin, but if there's a good soul to point something out in that matter (wp_query loading process), would be appreciated :)

    Cheers!

  2. Thiago Macedo
    Member
    Posted 3 years ago #

    Ended up with this running code on my External Application (little testing)

    define( 'ABSPATH', $this->wordpress_path . '/' );
            define('WP_USE_THEMES', false);
            define('WP_ALLOW_MULTISITE', false);
            define('SHORTINIT', true);
    
            //Use this for MU Installations (need to configure wp-config to see this var)
            define( 'TABLE_PREFIX', 'wp_8_' );
    
            //Default load
            require( ABSPATH . 'wp-config.php' );
    
            //Loading code from wp-settings after SHORTINIT
            require( ABSPATH . WPINC . '/l10n.php' );
            require( ABSPATH . WPINC . '/formatting.php' );
            require( ABSPATH . WPINC . '/capabilities.php' );
            require( ABSPATH . WPINC . '/query.php' );
            require( ABSPATH . WPINC . '/user.php' );
            require( ABSPATH . WPINC . '/meta.php' );
            require( ABSPATH . WPINC . '/general-template.php' );
            require( ABSPATH . WPINC . '/link-template.php' );
            require( ABSPATH . WPINC . '/post.php' );
            require( ABSPATH . WPINC . '/comment.php' );
            require( ABSPATH . WPINC . '/rewrite.php' );
            require( ABSPATH . WPINC . '/script-loader.php' );
            require( ABSPATH . WPINC . '/taxonomy.php' );
    
            create_initial_taxonomies();
            create_initial_post_types();
    
            require( ABSPATH . WPINC . '/pluggable.php' );
    
            wp_set_internal_encoding();
            wp_functionality_constants( );
    
            $GLOBALS['wp_the_query'] =& new WP_Query();
            $GLOBALS['wp_query'] =& $GLOBALS['wp_the_query'];
            $GLOBALS['wp_rewrite'] =& new WP_Rewrite();
            $GLOBALS['wp'] =& new WP();
            $GLOBALS['wp']->init();
    
            wp();

    And like this on wp-config.php

    if ( defined('TABLE_PREFIX') )
        $GLOBALS['table_prefix'] = TABLE_PREFIX;
    else
        $GLOBALS['table_prefix'] = 'wp_';
    
    if ( !defined('WP_ALLOW_MULTISITE') ) {
        define('WP_ALLOW_MULTISITE', true);
        define( 'MULTISITE', true );
        define( 'SUBDOMAIN_INSTALL', true );
        $base = '/';
        define( 'DOMAIN_CURRENT_SITE', 'budi.net' );
        define( 'PATH_CURRENT_SITE', '/' );
        define( 'SITE_ID_CURRENT_SITE', 1 );
        define( 'BLOG_ID_CURRENT_SITE', 1 );
    
        define( 'SUNRISE', 'on' );
    }
  3. smart1k
    Member
    Posted 2 years ago #

    Hoho! Nice Job. I was searching something like this. Thanks a lot!

Topic Closed

This topic has been closed to new replies.

About this Topic