init();
self::$tabs->set_parameter("SR_tab");
}
/*----------------------------------------------------------*/
public static function side_menu()
{
add_options_page(SR_PLUGIN_NAME, SR_PLUGIN_NAME, 'manage_options', SRP_PLUGINS::get_app()->get_plugin_slug(), array('SR_plugin_menus', 'side_menu_content'));
}
/*----------------------------------------------------------*/
public static function side_menu_content()
{
if (!current_user_can('manage_options')) {
wp_die(__('You do not have sufficient permissions to access this page.'));
}
echo '
' . SR_PLUGIN_NAME . '
';
echo '
Upgrade to pro version and empower your site SEO, Now 39% off
';
if(SRP_PLUGINS::get_app()->search_plugins('redirection','404-301-seo-redirection')!='')
{
// SRP_PLUGINS::get_app()->echo_message("
There is another redirect plugin (" . SRP_PLUGINS::get_app()->search_plugins('redirection','404-redirection-manager') . ") installed, please deactivate it to avoid conflict",'error');
}
if(SRP_PLUGINS::get_app()->search_plugins('redirect-to-homepage')!='')
{
// SRP_PLUGINS::get_app()->echo_message("
There is another redirect plugin (" . SRP_PLUGINS::get_app()->search_plugins('redirect-to-homepage') . ") installed, please deactivate it to avoid conflict",'error');
}
if(SRP_PLUGINS::get_options()->read_option_value('404_plugin_status')=='0')
{
SRP_PLUGINS::get_app()->echo_message("
The plugin is currently disabled, go to the options tab and enable it!",'warning');
}
if(SRP_PLUGINS::get_options()->read_option_value('404_plugin_status')=='2')
{
SRP_PLUGINS::get_app()->echo_message("
The plugin is currently disabled for admin, go to the options tab and enable it!",'warning');
}
self::$tabs->set_ignore_parameter(array('del', 'search', 'page_num', 'add', 'edit', 'page404','grpID','shown','sort','link_type','link','return','post_operation','post_operation_id','country','rsrc','404_manager_tab','history_manager_tab','redirect_manager_tab'));
self::$tabs->add_file_tab('404_manager', '404 Manager', 'option_404_manager.php', 'file');
self::$tabs->run();
echo '
';
}
/*----------------------------------------------------------*/
public static function hook_menus()
{
add_action('admin_menu', array('SR_plugin_menus', 'side_menu'));
add_action( 'add_meta_boxes', array('SR_plugin_menus','redirect_meta_boxes'), 10, 3 );
}
/*----------------------------------------------------------*/
public static function redirect_meta_boxes()
{
if (SRP_PLUGINS::get_options()->read_option_value('404_show_redirect_box') == '1') {
$post_types = explode(',',SRP_PLUGINS::get_options()->read_option_value('post_types'));
foreach ( $post_types as $post_type ) {
add_meta_box(
'seo_redirection_box',
__(SR_PLUGIN_NAME),
array('SR_plugin_menus','select_box_menu'),
$post_type,
'side'
);
}
}
}
/*----------------------------------------------------------*/
public static function select_box_menu($post)
{
global $wpdb;
if(get_post_status()!='auto-draft')
{
$permalink="";
if (in_array($post->post_status, array('draft', 'pending'))) {
list( $permalink, $postname ) = get_sample_permalink( $post->ID);
$permalink = str_replace( '%postname%', $postname, $permalink );
$permalink = str_replace( '%pagename%', $postname, $permalink );
} else {
$permalink = get_permalink($post->ID);
}
$permalink = SRP_PLUGINS::get_request()->make_relative_url($permalink);
$redirect = $wpdb->get_row(" select id,redirect_from,redirect_to from " . SR_database::WP_SEO_Redirection() ." where redirect_from='$permalink' and cat='link' and blog='" . get_current_blog_id() . "' ");
if($wpdb->num_rows>0)
{
self::redirected_menu($permalink,$redirect);
}
else
{
self::setup_redirect_menu($permalink);
}
}else
{
echo "You can not setup a redirect for this new " . get_post_type() . " before saving it.";
}
}
/*----------------------------------------------------------*/
public static function setup_redirect_menu($permalink,$outcome='echo')
{
self::boxes_style($outcome);
$link= SRP_PLUGINS::get_security()->encode_url($permalink);
$return= SRP_PLUGINS::get_security()->encode_url(SRP_PLUGINS::get_request()->get_current_URL());
$grp=SR_option_manager::get_group_id('Redirected Posts');
$grpwhere = "&grpID=$grp";
$html="