load_modules(); } } if ( ! function_exists( 'aioseop_get_options' ) ) { /** * @return mixed|void */ function aioseop_get_options() { global $aioseop_options; $aioseop_options = get_option( 'aioseop_options' ); $aioseop_options = apply_filters( 'aioseop_get_options', $aioseop_options ); return $aioseop_options; } } if ( ! function_exists( 'aioseop_update_settings_check' ) ) { /** * Check if settings need to be updated / migrated from old version. * * @TODO See when this is from and if we can move it elsewhere... our new db updates/upgrades class? */ function aioseop_update_settings_check() { global $aioseop_options; if ( empty( $aioseop_options ) || isset( $_POST['aioseop_migrate_options'] ) ) { aioseop_mrt_mkarry(); } // WPML has now attached to filters, read settings again so they can be translated. aioseop_get_options(); $update_options = false; if ( ! empty( $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_options = true; } if ( ! empty( $aioseop_options['aiosp_archive_title_format'] ) && empty( $aioseop_options['aiosp_date_title_format'] ) ) { $aioseop_options['aiosp_date_title_format'] = $aioseop_options['aiosp_archive_title_format']; unset( $aioseop_options['aiosp_archive_title_format'] ); $update_options = true; } if ( ! empty( $aioseop_options['aiosp_archive_title_format'] ) && ( $aioseop_options['aiosp_archive_title_format'] === '%date% | %blog_title%' ) ) { $aioseop_options['aiosp_archive_title_format'] = '%archive_title% | %blog_title%'; $update_options = true; } if ( $update_options ) { update_option( 'aioseop_options', $aioseop_options ); } } } } if ( ! function_exists( 'aioseop_mrt_mkarry' ) ) { /** * Initialize settings to defaults. * * @TODO Should also move. */ 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_get_version' ) ) { /** * Returns the version. * * I'm not sure why we have BOTH a function and a constant for this. -mrt * * @return string */ function aioseop_get_version() { return AIOSEOP_VERSION; } } if ( ! function_exists( 'aioseop_option_isset' ) ) { /** * Checks if an option isset. * * @param $option * * @return bool */ function aioseop_option_isset( $option ) { global $aioseop_options; return ( isset( $aioseop_options[ $option ] ) && $aioseop_options[ $option ] ); } } if ( ! function_exists( 'aioseop_addmycolumns' ) ) { /** * Adds posttype columns. * */ 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( $_REQUEST['post_type'] ) ) { $post_type = 'post'; } else { $post_type = $_REQUEST['post_type']; } if ( is_array( $aiosp_posttypecolumns ) && in_array( $post_type, $aiosp_posttypecolumns ) ) { add_action( 'admin_head', 'aioseop_admin_head' ); 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' ) ) { /** * @param $aioseopc * * @return mixed */ 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() { wp_enqueue_script( 'aioseop_welcome_js', AIOSEOP_PLUGIN_URL . 'js/quickedit_functions.js', array( 'jquery' ), AIOSEOP_VERSION); ?> ID; if ( ! empty( $_GET['aioseop_reset_notices'] ) ) { delete_user_meta( $user_id, 'aioseop_ignore_notice' ); } if ( ! empty( $_GET['aioseop_ignore_notice'] ) ) { add_user_meta( $user_id, 'aioseop_ignore_notice', $_GET['aioseop_ignore_notice'], false ); } } } } if ( ! function_exists( 'aioseop_output_notice' ) ) { /** * @param $message * @param string $id * @param string $class * * @return bool */ function aioseop_output_notice( $message, $id = '', $class = 'updated fade' ) { $class = 'aioseop_notice ' . $class; if ( ! empty( $class ) ) { $class = ' class="' . esc_attr( $class ) . '"'; } if ( ! empty( $id ) ) { $class .= ' id="' . esc_attr( $id ) . '"'; } $dismiss = ' '; echo "
' . $message . '
'; } return aioseop_output_notice( $message, $id, $class ); } } if ( ! function_exists( 'aioseop_ajax_save_meta' ) ) { function aioseop_ajax_save_meta() { if ( ! empty( $_POST['_inline_edit'] ) && ( $_POST['_inline_edit'] !== 'undefined' ) ) { check_ajax_referer( 'inlineeditnonce', '_inline_edit' ); } $post_id = intval( $_POST['post_id'] ); $new_meta = strip_tags( $_POST['new_meta'] ); $target = $_POST['target_meta']; check_ajax_referer( 'aioseop_meta_' . $target . '_' . $post_id, '_nonce' ); $result = ''; if ( in_array( $target, Array( 'title', 'description', 'keywords', ) ) && current_user_can( 'edit_post', $post_id ) ) { update_post_meta( $post_id, '_aioseop_' . $target, esc_attr( $new_meta ) ); $result = get_post_meta( $post_id, '_aioseop_' . $target, true ); } else { die(); } if ( $result != '' ): $label = "'; else: $label = "" . __( 'No', 'all-in-one-seo-pack' ) . ' ' . $target . ''; endif; $nonce = wp_create_nonce( "aioseop_meta_{$target}_{$post_id}" ); $output = '' . '
' . $label;
die( "jQuery('div#aioseop_" . $target . '_' . $post_id . "').fadeOut('fast', function() { var my_label = " . json_encode( $output ) . ";
jQuery('div#aioseop_" . $target . '_' . $post_id . "').html(my_label).fadeIn('fast');
});" );
}
}
if ( ! function_exists( 'aioseop_ajax_init' ) ) {
function aioseop_ajax_init() {
if ( ! empty( $_POST ) && ! empty( $_POST['settings'] ) && ( ! empty( $_POST['nonce-aioseop'] ) || ( ! empty( $_POST['nonce-aioseop-edit'] ) ) ) && ! 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 );
}
}
}
/**
* @param $return
* @param $url
* @param $attr
*
* @return mixed
*/
function aioseop_embed_handler_html( $return, $url, $attr ) {
return AIO_ProGeneral::aioseop_embed_handler_html();
}
function aioseop_ajax_update_oembed() {
AIO_ProGeneral::aioseop_ajax_update_oembed();
}
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_modules;
aioseop_load_modules();
$aiosp->admin_menu();
if ( ! empty( $_POST['settings'] ) && ( $_POST['settings'] === 'video_sitemap_addl_pages' ) ) {
$module = $aioseop_modules->return_module( 'All_in_One_SEO_Pack_Video_Sitemap' );
} elseif ( ! empty( $_POST['settings'] ) && ( $_POST['settings'] === 'news_sitemap_addl_pages' ) ) {
$module = $aioseop_modules->return_module( 'All_in_One_SEO_Pack_News_Sitemap' );
} else {
$module = $aioseop_modules->return_module( 'All_in_One_SEO_Pack_Sitemap' );
}
$_POST['location'] = null;
$_POST['Submit'] = 'ajax';
$module->add_page_hooks();
$prefix = $module->get_prefix();
$_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' => $prefix . 'addl_pages',
'type' => 'custom',
'save' => true,
'value' => $options[ $prefix . '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_modules;
aioseop_load_modules();
$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 = (Array) $module->get_current_options( $_POST, null );
if ( ! empty( $_POST['aiosp_sitemap_addl_pages'] ) && is_object( $_POST['aiosp_sitemap_addl_pages'] ) ) {
$_POST['aiosp_sitemap_addl_pages'] = (Array) $_POST['aiosp_sitemap_addl_pages'];
}
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'] = json_encode( $_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_scan_header' ) ) {
function aioseop_ajax_scan_header() {
$_POST['options'] = 'foo';
aioseop_ajax_init();
$options = Array();
parse_str( $_POST['options'], $options );
foreach ( $options as $k => $v ) {
$_POST[ $k ] = $v;
}
$_POST['action'] = 'aiosp_update_module';
$_POST['location'] = null;
$_POST['Submit'] = 'ajax';
ob_start();
do_action( 'wp' );
global $aioseop_modules;
$module = $aioseop_modules->return_module( 'All_in_One_SEO_Pack_Opengraph' );
wp_head();
$output = ob_get_clean();
global $aiosp;
$output = $aiosp->html_string_to_array( $output );
$meta = '';
$metatags = Array(
'facebook' => Array( 'name' => 'property', 'value' => 'content' ),
'twitter' => Array( 'name' => 'name', 'value' => 'value' ),
'google+' => Array( 'name' => 'itemprop', 'value' => 'content' ),
);
$metadata = Array(
'facebook' => Array(
'title' => 'og:title',
'type' => 'og:type',
'url' => 'og:url',
'thumbnail' => 'og:image',
'sitename' => 'og:site_name',
'key' => 'fb:admins',
'description' => 'og:description',
),
'google+' => Array(
'thumbnail' => 'image',
'title' => 'name',
'description' => 'description',
),
'twitter' => Array(
'card' => 'twitter:card',
'url' => 'twitter:url',
'title' => 'twitter:title',
'description' => 'twitter:description',
'thumbnail' => 'twitter:image',
),
);
if ( ! empty( $output ) && ! empty( $output['head'] ) && ! empty( $output['head']['meta'] ) ) {
foreach ( $output['head']['meta'] as $v ) {
if ( ! empty( $v['@attributes'] ) ) {
$m = $v['@attributes'];
foreach ( $metatags as $type => $tags ) {
if ( ! empty( $m[ $tags['name'] ] ) && ! empty( $m[ $tags['value'] ] ) ) {
foreach ( $metadata[ $type ] as $tk => $tv ) {
if ( $m[ $tags['name'] ] == $tv ) {
$meta .= "| Meta For Site | Kind of Meta | Element Name | Element Value |
|---|
' . $output . '
' . $output . '