Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jan 4th, 2013  |  syntax: PHP  |  size: 1.41 KB  |  views: 18  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. class InnerbotPartnerPagesFrontend extends InnerbotPartnerPages {
  2.  
  3.         private $data;
  4.  
  5.         public function __construct() {
  6.                
  7.                 add_action( 'wp_enqueue_scripts', array( $this, 'action_enqueues' ) );
  8.                 add_action( 'init', array( $this, 'action_validate_partner_site' ) );
  9.  
  10.         }
  11.  
  12.         public function action_validate_partner_site() {
  13.        
  14.                 $url = ( !empty( $_SERVER['HTTPS'] ) ) ? "https://" . $_SERVER['HTTP_HOST'] : "http://" . $_SERVER['HTTP_HOST'] ;
  15.                 $partner_id = $this->is_valid_partner( $_SERVER['HTTP_HOST'] );
  16.  
  17.                 if( ($url != WP_HOME || $url != WP_SITEURL) /*&&  $partner_id !== FALSE*/ ) {
  18.                         add_action( 'template_redirect', array( $this, 'action_do_partner_site') );            
  19.                 }
  20.  
  21.         }
  22.  
  23.         public function is_valid_partner( $domain_name ) {
  24.                 global $wp_query, $post;
  25.                
  26.                 // $args = array( 'meta_key' => 'ibpp_domain_to_map' ); // fails
  27.                 // $args = array( 'meta_query' => array( 'key' => 'ibpp_domain_to_map' ) ); // fails
  28.                 // $args = array( 'post_type' => 'certified-partner' ); // fails too, even tho its valid post type
  29.                 $args = array(
  30.                         'meta_query' => array(
  31.                                 array(
  32.                                         'key'=>'ibpp_domain_to_map'
  33.                                 )
  34.                         )
  35.                 ); // retrieves irrelevant posts, they don't have the desired meta_key
  36.  
  37.                 $wp_query = new WP_Query($args);
  38.  
  39.                 while( $wp_query->have_posts()) :
  40.                         $wp_query->the_post();
  41.                         wp_die( the_id() ); // never reaches this point
  42.                         return $post->ID;
  43.                 endwhile;
  44.  
  45.                 return false;
  46.  
  47.         }
  48.  
  49. }