load_modules();
}
}
/**
* Check if we just got activated.
*/
if ( !function_exists( 'aioseop_activate' ) ) {
function aioseop_activate() {
global $aiosp_activation;
$aiosp_activation = true;
}
}
/**
* Check if settings need to be updated / migrated from old version.
*/
if ( !function_exists( 'aioseop_update_settings_check' ) ) {
function aioseop_update_settings_check() {
global $aioseop_options;
if ( ( isset( $_POST['aioseop_migrate_options'] ) ) ||
( empty( $aioseop_options ) ) )
aioseop_mrt_mkarry();
// WPML has now attached to filters, read settings again so they can be translated
$aioseop_options = get_option( 'aioseop_options' );
if ( !empty( $aioseop_options['aiosp_archive_noindex'] ) ) { // migrate setting for noindex archives
$aioseop_options['aiosp_archive_date_noindex'] = $aioseop_options['aiosp_archive_author_noindex'] = $aioseop_options['aiosp_archive_noindex'];
unset( $aioseop_options['aiosp_archive_noindex'] );
update_option( 'aioseop_options', $aioseop_options );
}
}
}
/**
* Initialize settings to defaults.
*/
if ( !function_exists( 'aioseop_mrt_mkarry' ) ) {
function aioseop_mrt_mkarry() {
global $aiosp;
global $aioseop_options;
$naioseop_options = $aiosp->default_options();
if( get_option( 'aiosp_post_title_format' ) ) {
foreach( $naioseop_options as $aioseop_opt_name => $value ) {
if( $aioseop_oldval = get_option( $aioseop_opt_name ) ) {
$naioseop_options[$aioseop_opt_name] = $aioseop_oldval;
}
if( $aioseop_oldval == '' ) {
$naioseop_options[$aioseop_opt_name] = '';
}
delete_option( $aioseop_opt_name );
}
}
add_option( 'aioseop_options', $naioseop_options );
$aioseop_options = $naioseop_options;
}
}
if ( !function_exists( 'aioseop_activate_pl' ) ) {
function aioseop_activate_pl() {
if( $aioseop_options = get_option( 'aioseop_options' ) ) {
$aioseop_options['aiosp_enabled'] = "0";
if( empty( $aioseop_options['aiosp_posttypecolumns'] ) ) {
$aioseop_options['aiosp_posttypecolumns'] = array('post','page');
}
update_option('aioseop_options', $aioseop_options);
}
}
}
if ( !function_exists( 'aioseop_get_version' ) ) {
function aioseop_get_version() {
return AIOSEOP_VERSION;
}
}
if ( !function_exists( 'aioseop_option_isset' ) ) {
function aioseop_option_isset( $option ) {
global $aioseop_options;
return ( ( isset( $aioseop_options[$option] ) ) && $aioseop_options[$option] );
}
}
if ( !function_exists( 'aioseop_addmycolumns' ) ) {
function aioseop_addmycolumns() {
global $aioseop_options, $pagenow;
$aiosp_posttypecolumns = Array();
if ( !empty( $aioseop_options) && !empty( $aioseop_options['aiosp_posttypecolumns'] ) ) {
$aiosp_posttypecolumns = $aioseop_options['aiosp_posttypecolumns'];
}
if ( !empty( $pagenow ) && ( $pagenow == 'upload.php' ) )
$post_type = 'attachment';
elseif ( !isset( $_GET['post_type'] ) )
$post_type = 'post';
else
$post_type = $_GET['post_type'];
add_action( 'admin_head', 'aioseop_admin_head' );
if( is_array( $aiosp_posttypecolumns ) && in_array( $post_type, $aiosp_posttypecolumns ) ) {
if ( $post_type == 'page' )
add_filter( 'manage_pages_columns', 'aioseop_mrt_pcolumns' );
elseif ( $post_type == 'attachment' )
add_filter( 'manage_media_columns', 'aioseop_mrt_pcolumns' );
else
add_filter( 'manage_posts_columns', 'aioseop_mrt_pcolumns' );
if ( $post_type == 'attachment' )
add_action( 'manage_media_custom_column', 'aioseop_mrt_pccolumn', 10, 2 );
elseif ( is_post_type_hierarchical( $post_type ) )
add_action( 'manage_pages_custom_column', 'aioseop_mrt_pccolumn', 10, 2 );
else
add_action( 'manage_posts_custom_column', 'aioseop_mrt_pccolumn', 10, 2 );
}
}
}
if ( !function_exists( 'aioseop_mrt_pcolumns' ) ) {
function aioseop_mrt_pcolumns( $aioseopc ) {
global $aioseop_options;
$aioseopc['seotitle'] = __( 'SEO Title', 'all_in_one_seo_pack' );
$aioseopc['seodesc'] = __( 'SEO Description', 'all_in_one_seo_pack' );
if ( empty( $aioseop_options['aiosp_togglekeywords'] ) )
$aioseopc['seokeywords'] = __( 'SEO Keywords', 'all_in_one_seo_pack' );
return $aioseopc;
}
}
if ( !function_exists( 'aioseop_admin_head' ) ) {
function aioseop_admin_head() {
echo '';
?>
' . __( 'No', 'all_in_one_seo_pack' ) . ' ' . $target . '' ; endif;
$output = $result . '';
$output .= '
';
die( "jQuery('div#aioseop_" . $target . "_" . $post_id . "').fadeOut('fast', function() {
jQuery('div#aioseop_" . $target . "_" . $post_id . "').html(" . json_encode( $output ) . ").fadeIn('fast');
});" );
}
}
if ( !function_exists( 'aioseop_ajax_init' ) ) {
function aioseop_ajax_init() {
if ( !empty( $_POST ) && !empty( $_POST['settings'] ) && !empty( $_POST['nonce-aioseop']) && !empty( $_POST['options'] ) ) {
$_POST = stripslashes_deep( $_POST );
$settings = esc_attr( $_POST['settings'] );
if ( ! defined( 'AIOSEOP_AJAX_MSG_TMPL' ) )
define( 'AIOSEOP_AJAX_MSG_TMPL', "jQuery('div#aiosp_$settings').fadeOut('fast', function(){jQuery('div#aiosp_$settings').html('%s').fadeIn('fast');});" );
if ( !wp_verify_nonce($_POST['nonce-aioseop'], 'aioseop-nonce') ) die( sprintf( AIOSEOP_AJAX_MSG_TMPL, __( "Unauthorized access; try reloading the page.", 'all_in_one_seo_pack' ) ) );
} else {
die(0);
}
}
}
if ( !function_exists( 'aioseop_ajax_save_url' ) ) {
function aioseop_ajax_save_url() {
aioseop_ajax_init();
$options = Array();
parse_str( $_POST['options'], $options );
foreach( $options as $k => $v ) $_POST[$k] = $v;
$_POST['action'] = 'aiosp_update_module';
global $aiosp, $aioseop_module_list, $aioseop_modules;
aioseop_load_modules( $aioseop_module_list );
$aiosp->admin_menu();
$module = $aioseop_modules->return_module( "All_in_One_SEO_Pack_Sitemap" );
$_POST['location'] = null;
$_POST['Submit'] = 'ajax';
$module->add_page_hooks();
$_POST = $module->get_current_options( $_POST, null );
$module->handle_settings_updates( null );
$options = $module->get_current_options( Array(), null );
$output = $module->display_custom_options( '', Array( 'name' => 'aiosp_sitemap_addl_pages', 'type' => 'custom', 'save' => true, 'value' => $options['aiosp_sitemap_addl_pages'], 'attr' => '' ) );
$output = str_replace( "'", "\'", $output );
$output = str_replace( "\n", '\n', $output );
die( sprintf( AIOSEOP_AJAX_MSG_TMPL, $output ) );
}
}
if ( !function_exists( 'aioseop_ajax_delete_url' ) ) {
function aioseop_ajax_delete_url() {
aioseop_ajax_init();
$options = Array();
$options = esc_attr( $_POST['options'] );
$_POST['action'] = 'aiosp_update_module';
global $aiosp, $aioseop_module_list, $aioseop_modules;
aioseop_load_modules( $aioseop_module_list );
$aiosp->admin_menu();
$module = $aioseop_modules->return_module( "All_in_One_SEO_Pack_Sitemap" );
$_POST['location'] = null;
$_POST['Submit'] = 'ajax';
$module->add_page_hooks();
$_POST = $module->get_current_options( $_POST, null );
if ( !empty( $_POST['aiosp_sitemap_addl_pages'] ) && ( !empty( $_POST['aiosp_sitemap_addl_pages'][ $options ] ) ) ) {
unset( $_POST['aiosp_sitemap_addl_pages'][ $options ] );
if ( empty( $_POST['aiosp_sitemap_addl_pages'] ) )
$_POST['aiosp_sitemap_addl_pages'] = '';
else
$_POST['aiosp_sitemap_addl_pages'] = serialize( $_POST['aiosp_sitemap_addl_pages'] );
$module->handle_settings_updates( null );
$options = $module->get_current_options( Array(), null );
$output = $module->display_custom_options( '', Array( 'name' => 'aiosp_sitemap_addl_pages', 'type' => 'custom', 'save' => true, 'value' => $options['aiosp_sitemap_addl_pages'], 'attr' => '' ) );
$output = str_replace( "'", "\'", $output );
$output = str_replace( "\n", '\n', $output );
} else {
$output = sprintf( __( "Row %s not found; no rows were deleted.", 'all_in_one_seo_pack' ), esc_attr( $options ) );
}
die( sprintf( AIOSEOP_AJAX_MSG_TMPL, $output ) );
}
}
if (!function_exists('aioseop_ajax_save_settings')) {
function aioseop_ajax_save_settings() {
aioseop_ajax_init();
$options = Array();
parse_str( $_POST['options'], $options );
$_POST = $options;
$_POST['action'] = 'aiosp_update_module';
global $aiosp, $aioseop_module_list, $aioseop_modules;
aioseop_load_modules( $aioseop_module_list );
$aiosp->admin_menu();
$module = $aioseop_modules->return_module( $_POST['module'] );
unset( $_POST['module'] );
if ( empty( $_POST['location'] ) ) $_POST['location'] = null;
$_POST['Submit'] = 'ajax';
$module->add_page_hooks();
// $_POST = $module->get_current_options( $_POST, $_POST['location'] );
$output = $module->handle_settings_updates( $_POST['location'] );
$output = '
' . $output . '