Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class InnerbotPartnerPagesFrontend extends InnerbotPartnerPages {
- private $data;
- public function __construct() {
- add_action( 'wp_enqueue_scripts', array( $this, 'action_enqueues' ) );
- add_action( 'init', array( $this, 'action_validate_partner_site' ) );
- }
- public function action_validate_partner_site() {
- $url = ( !empty( $_SERVER['HTTPS'] ) ) ? "https://" . $_SERVER['HTTP_HOST'] : "http://" . $_SERVER['HTTP_HOST'] ;
- $partner_id = $this->is_valid_partner( $_SERVER['HTTP_HOST'] );
- if( ($url != WP_HOME || $url != WP_SITEURL) /*&& $partner_id !== FALSE*/ ) {
- add_action( 'template_redirect', array( $this, 'action_do_partner_site') );
- }
- }
- public function is_valid_partner( $domain_name ) {
- global $wp_query, $post;
- // $args = array( 'meta_key' => 'ibpp_domain_to_map' ); // fails
- // $args = array( 'meta_query' => array( 'key' => 'ibpp_domain_to_map' ) ); // fails
- // $args = array( 'post_type' => 'certified-partner' ); // fails too, even tho its valid post type
- $args = array(
- 'meta_query' => array(
- array(
- 'key'=>'ibpp_domain_to_map'
- )
- )
- ); // retrieves irrelevant posts, they don't have the desired meta_key
- $wp_query = new WP_Query($args);
- while( $wp_query->have_posts()) :
- $wp_query->the_post();
- wp_die( the_id() ); // never reaches this point
- return $post->ID;
- endwhile;
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement