Created
November 29, 2012 15:08
-
-
Save juanramon/4169676 to your computer and use it in GitHub Desktop.
Block Theme Pages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php if ( !defined('ABS_PATH') ) exit('ABS_PATH is not loaded. Direct access is not allowed.'); | |
class ThemeBlockPages | |
{ | |
var $location; | |
var $section; | |
public function __construct() | |
{ | |
$this->location = Rewrite::newInstance()->get_location(); | |
$this->section = Rewrite::newInstance()->get_section(); | |
osc_add_hook('init', array(&$this, 'blocked_pages'), 1); | |
} | |
function blocked_pages() | |
{ | |
// blocked sections | |
switch( $this->location ) { | |
case('item'): | |
// blocked section in item | |
if( !in_array($this->section, array('activate', 'mark', 'send_friend', 'send_friend_post', 'contact', 'add_comment', 'add_comment')) ) { | |
return; | |
} | |
case('user'): | |
// blocked section in user | |
if( !in_array($this->section, array('activate_alert', 'unsub_alert', 'pub_profile', 'contact_post', 'alerts', 'activate_alert', 'unsub_alert', 'deleteResource')) ) { | |
return; | |
} | |
case('custom'): | |
case('page'): | |
case('contact'): | |
case('search'): | |
case(''): | |
$this->throw_404(); | |
break; | |
} | |
} | |
private function throw_404() | |
{ | |
Rewrite::newInstance()->set_location('error'); | |
header('HTTP/1.1 404 Not Found'); | |
osc_current_web_theme_path('404.php'); | |
exit; | |
} | |
} | |
// End of file: ./theme/class/ThemeBlockPages.class.php |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment