💚This plugin is currently being extensively revised.
If you have any questions or wishes, just get in touch.
' . __('DEPRECATED') . ' ' . __('This option will be removed in an upcoming version.') . '';
}
function advset_page_experimental() {
return ' ' . __('EXPERIMENTAL') . '';
}
# Add plugin option in Plugins page
function advset_plugin_action_links( $links, $file ) {
if ( $file == plugin_basename( basename(dirname(__FILE__)).'/index.php' ) ) {
$links[] = ''.__('Settings').'';
}
return $links;
}
# Disable The “Please Update Now” Message On WordPress Dashboard
if ( advset_option('hide_update_message') ) {
add_action( 'admin_menu', '__advsettings_hide_update_message', 2 );
function __advsettings_hide_update_message() {
remove_action( 'admin_notices', 'update_nag', 3 );
}
}
# Add a Custom Dashboard Logo
# from https://www.codementor.io/wordpress/tutorial/wordpress-functions-php-cheatsheet
if ( advset_option('dashboard_logo') ) {
add_action('wp_before_admin_bar_render', '__advsettings_dashboard_logo');
function __advsettings_dashboard_logo() {
if(is_admin())
echo '
';
}
}
# Remove Trackbacks and Pingbacks from Comment Count
# from https://www.codementor.io/wordpress/tutorial/wordpress-functions-php-cheatsheet
if ( advset_option('remove_pingbacks_trackbacks_count') ) {
add_filter('get_comments_number', '__advsettings_comment_count', 0);
function __advsettings_comment_count( $count ) {
if ( ! is_admin_area() ) {
global $id;
$comments = get_comments('status=approve&post_id=' . $id);
$comments_by_type = separate_comments($comments);
return count($comments_by_type['comment']);
}
else {
return $count;
}
}
}
# Remove admin menu
if( advset_option('remove_menu') )
add_filter('show_admin_bar' , '__return_false'); // Remove admin menu
# Configure FeedBurner
if( advset_option('feedburner') ) {
function appthemes_custom_rss_feed( $output, $feed ) {
if ( strpos( $output, 'comments' ) )
return $output;
if( strpos(advset_option('feedburner'), '/')===FALSE )
return esc_url( 'https://feeds.feedburner.com/'.advset_option('feedburner') );
else
return esc_url( advset_option('feedburner') );
}
add_action( 'feed_link', 'appthemes_custom_rss_feed', 10, 2 );
}
# Favicon
if( advset_option('favicon') ) {
function __advsettings_favicon() {
if( file_exists(TEMPLATEPATH.'/favicon.ico') )
echo ''."\r\n";
elseif( file_exists(TEMPLATEPATH.'/favicon.png') )
echo ''."\r\n";
}
add_action( 'wp_head', '__advsettings_favicon' );
}
# Add blog description meta tag
if( advset_option('description') ) {
function __advsettings_blog_description() {
if(is_home() || !advset_option('single_metas'))
echo ''."\r\n";
}
add_action( 'wp_head', '__advsettings_blog_description' );
}
# Add description and keyword meta tag in posts
if( advset_option('single_metas') ) {
function __advsettings_single_metas() {
global $post;
if( is_single() || is_page() ) {
$tag_list = get_the_terms( $post->ID, 'post_tag' );
if( $tag_list ) {
foreach( $tag_list as $tag )
$tag_array[] = $tag->name;
echo ''."\r\n";
}
$excerpt = strip_tags($post->post_content);
$excerpt = strip_shortcodes($excerpt);
$excerpt = str_replace(array('\n', '\r', '\t'), ' ', $excerpt);
$excerpt = substr($excerpt, 0, 125);
if( !empty($excerpt) )
echo ''."\r\n";
}
}
add_action( 'wp_head', '__advsettings_single_metas' );
}
# Remove header generator
if( advset_option('remove_generator') )
remove_action('wp_head', 'wp_generator');
# Remove WLW
if( advset_option('remove_wlw') )
remove_action('wp_head', 'wlwmanifest_link');
# Thumbnails support
if( advset_option('add_thumbs') ) {
function __advsettings_add_thumbs(){
add_theme_support( 'post-thumbnails' );
}
add_action('after_setup_theme', '__advsettings_add_thumbs');
if( !current_theme_supports('post-thumbnails') )
define( 'ADVSET_THUMBS', '1' );
}
# JPEG Quality
if( advset_option('jpeg_quality', 0)>0 && $_SERVER['HTTP_HOST']!='localhost' ) {
add_filter('jpeg_quality', '__advsettings_jpeg_quality');
function __advsettings_jpeg_quality(){
return (int) advset_option('jpeg_quality');
}
}
# REL External
if( advset_option('rel_external') ) {
function ____replace_targets( $content ) {
$content = str_replace('target="_self"', '', $content);
return str_replace('target="_blank"', 'rel="external"', $content);
}
add_filter( 'the_content', '____replace_targets' );
}
# Fix post type pagination
if( advset_option('post_type_pag') ) {
# following are code adapted from Custom Post Type Category Pagination Fix by jdantzer
function fix_category_pagination($qs){
if(isset($qs['category_name']) && isset($qs['paged'])){
$qs['post_type'] = get_post_types($args = array(
'public' => true,
'_builtin' => false
));
array_push($qs['post_type'],'post');
}
return $qs;
}
add_filter('request', 'fix_category_pagination');
}
# Disable auto save
if( advset_option('disable_auto_save') ) {
define('AUTOSAVE_INTERVAL', 60 * 60 * 24 * 365 * 100); // save interval => 100 years
}
# Remove wptexturize
if( advset_option('remove_wptexturize') ) {
remove_filter('the_content', 'wptexturize');
remove_filter('comment_text', 'wptexturize');
remove_filter('the_excerpt', 'wptexturize');
}
# Filtering the code
if( advset_option('compress') || advset_option('remove_comments') ) {
add_action('template_redirect','____template');
function ____template() { ob_start('____template2'); }
function ____template2($code) {
# dont remove conditional IE comments "/', '', $code);
/* exemples:
*
* [html code] ...
* old code replaced: $code = preg_replace('//', '', $code);
* */
if( advset_option('compress') )
$code = trim( preg_replace( '/\s+(?![^<>]*<\/pre>)/', ' ', $code ) );
return $code;
}
}
# Remove comments system
if( advset_option('remove_comments_system') ) {
function __av_comments_close( $open, $post_id ) {
#$post = get_post( $post_id );
#if ( 'page' == $post->post_type )
#$open = false;
return false;
}
add_filter( 'comments_open', '__av_comments_close', 10, 2 );
function __av_empty_comments_array( $open, $post_id ) {
return array();
}
add_filter( 'comments_array', '__av_empty_comments_array', 10, 2 );
// Removes from admin menu
function __av_remove_admin_menus() {
remove_menu_page( 'edit-comments.php' );
}
add_action( 'admin_menu', '__av_remove_admin_menus' );
// Removes from admin bar
function __av_admin_bar_render() {
global $wp_admin_bar;
$wp_admin_bar->remove_menu('comments');
}
add_action( 'wp_before_admin_bar_render', '__av_admin_bar_render' );
}
# Disable author pages
if ( advset_option('disable_author_pages') ) {
function advset_disable_author_pages__template_redirect() {
global $wp_query;
if ( is_author() ) {
$wp_query->set_404();
status_header(404);
}
}
add_action( 'template_redirect', 'advset_disable_author_pages__template_redirect' );
function advset_disable_author_pages__wp_sitemaps_add_provider( $provider, $name ) {
if ( 'users' === $name ) {
return false;
}
return $provider;
}
add_filter( 'wp_sitemaps_add_provider', 'advset_disable_author_pages__wp_sitemaps_add_provider', 10, 2 );
}
# Google Analytics
if( advset_option('analytics') ) {
add_action('wp_footer', '____analytics'); // Load custom styles
function ____analytics(){
$ga_code = advset_option('analytics');
echo "