Skip to content

Instantly share code, notes, and snippets.

@juanramon
Created November 29, 2012 15:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juanramon/4169676 to your computer and use it in GitHub Desktop.
Save juanramon/4169676 to your computer and use it in GitHub Desktop.
Block Theme Pages
<?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