';
}
add_filter('the_content', 'advset_author_bio');
}
# author_bio_html
if( advset_option('author_bio_html') )
remove_filter('pre_user_description', 'wp_filter_kses');
# remove_widget_system
if( advset_option('remove_default_wp_widgets') || advset_option('remove_widget_system') ) {
function advset_unregister_default_wp_widgets() {
unregister_widget('WP_Widget_Pages');
unregister_widget('WP_Widget_Calendar');
unregister_widget('WP_Widget_Archives');
unregister_widget('WP_Widget_Links');
unregister_widget('WP_Widget_Meta');
unregister_widget('WP_Widget_Search');
unregister_widget('WP_Widget_Text');
unregister_widget('WP_Widget_Categories');
unregister_widget('WP_Widget_Recent_Posts');
unregister_widget('WP_Widget_Recent_Comments');
unregister_widget('WP_Widget_RSS');
unregister_widget('WP_Widget_Tag_Cloud');
}
add_action('widgets_init', 'advset_unregister_default_wp_widgets', 1);
}
# remove_widget_system
if( advset_option('remove_widget_system') ) {
# this maybe dont work properly
function advset_remove_widget_support() {
remove_theme_support( 'widgets' );
}
add_action( 'after_setup_theme', 'advset_remove_widget_support', 11 );
# it works fine
function advset_remove_widget_system() {
global $wp_widget_factory;
$wp_widget_factory->widgets = array();
}
add_action('widgets_init', 'advset_remove_widget_system', 1);
# this maybe dont work properly
function disable_all_widgets( $sidebars_widgets ) {
$sidebars_widgets = array( false );
return $sidebars_widgets;
}
add_filter( 'sidebars_widgets', 'disable_all_widgets' );
# remove widgets from menu
function advset_remove_widgets_from_menu() {
$page = remove_submenu_page( 'themes.php', 'widgets.php' );
}
add_action( 'admin_menu', 'advset_remove_widgets_from_menu', 999 );
}
# auto post thumbnails
if( advset_option('auto_thumbs') ) {
// based on "auto posts plugin" 3.3.2
// check post status
function advset_check_post_status( $new_status='' ) {
global $post_ID;
if ('publish' == $new_status)
advset_publish_post($post_ID);
}
//
function advset_publish_post( $post_id ) {
global $wpdb;
// First check whether Post Thumbnail is already set for this post.
if (get_post_meta($post_id, '_thumbnail_id', true) || get_post_meta($post_id, 'skip_post_thumb', true))
return;
$post = $wpdb->get_results("SELECT * FROM {$wpdb->posts} WHERE id = $post_id");
// Initialize variable used to store list of matched images as per provided regular expression
$matches = array();
// Get all images from post's body
preg_match_all('/<\s*img [^\>]*src\s*=\s*[\""\']?([^\""\'>]*)/i', $post[0]->post_content, $matches);
if (count($matches)) {
foreach ($matches[0] as $key => $image) {
/**
* If the image is from wordpress's own media gallery, then it appends the thumbmail id to a css class.
* Look for this id in the IMG tag.
*/
preg_match('/wp-image-([\d]*)/i', $image, $thumb_id);
$thumb_id = $thumb_id[1];
// If thumb id is not found, try to look for the image in DB. Thanks to "Erwin Vrolijk" for providing this code.
if (!$thumb_id) {
$image = substr($image, strpos($image, '"')+1);
$result = $wpdb->get_results("SELECT ID FROM {$wpdb->posts} WHERE guid = '".$image."'");
$thumb_id = $result[0]->ID;
}
// Ok. Still no id found. Some other way used to insert the image in post. Now we must fetch the image from URL and do the needful.
if (!$thumb_id) {
$thumb_id = advset_generate_post_thumbnail($matches, $key, $post[0]->post_content, $post_id);
}
// If we succeed in generating thumg, let's update post meta
if ($thumb_id) {
update_post_meta( $post_id, '_thumbnail_id', $thumb_id );
break;
}
}
}
}
function advset_generate_post_thumbnail( $matches, $key, $post_content, $post_id ) {
// Make sure to assign correct title to the image. Extract it from img tag
$imageTitle = '';
preg_match_all('/<\s*img [^\>]*title\s*=\s*[\""\']?([^\""\'>]*)/i', $post_content, $matchesTitle);
if (count($matchesTitle) && isset($matchesTitle[1])) {
$imageTitle = $matchesTitle[1][$key];
}
// Get the URL now for further processing
$imageUrl = $matches[1][$key];
// Get the file name
$filename = substr($imageUrl, (strrpos($imageUrl, '/'))+1);
if ( !(($uploads = wp_upload_dir(current_time('mysql')) ) && false === $uploads['error']) )
return null;
// Generate unique file name
$filename = wp_unique_filename( $uploads['path'], $filename );
// Move the file to the uploads dir
$new_file = $uploads['path'] . "/$filename";
if (!ini_get('allow_url_fopen'))
$file_data = curl_get_file_contents($imageUrl);
else
$file_data = @file_get_contents($imageUrl);
if (!$file_data) {
return null;
}
file_put_contents($new_file, $file_data);
// Set correct file permissions
$stat = stat( dirname( $new_file ));
$perms = $stat['mode'] & 0000666;
@ chmod( $new_file, $perms );
// Get the file type. Must to use it as a post thumbnail.
$wp_filetype = wp_check_filetype( $filename, $mimes );
extract( $wp_filetype );
// No file type! No point to proceed further
if ( ( !$type || !$ext ) && !current_user_can( 'unfiltered_upload' ) ) {
return null;
}
// Compute the URL
$url = $uploads['url'] . "/$filename";
// Construct the attachment array
$attachment = array(
'post_mime_type' => $type,
'guid' => $url,
'post_parent' => null,
'post_title' => $imageTitle,
'post_content' => '',
);
$thumb_id = wp_insert_attachment($attachment, $file, $post_id);
if ( !is_wp_error($thumb_id) ) {
require_once(ABSPATH . '/wp-admin/includes/image.php');
// Added fix by misthero as suggested
wp_update_attachment_metadata( $thumb_id, wp_generate_attachment_metadata( $thumb_id, $new_file ) );
update_attached_file( $thumb_id, $new_file );
return $thumb_id;
}
return null;
}
add_action('transition_post_status', 'advset_check_post_status');
if( !function_exists('curl_get_file_contents') ) {
function curl_get_file_contents($URL) {
$c = curl_init();
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_URL, $URL);
$contents = curl_exec($c);
curl_close($c);
if ($contents) {
return $contents;
}
return FALSE;
}
}
}
# excerpt length
if( advset_option('excerpt_limit') ) {
function advset_excerpt_length_limit($length) {
return advset_option('excerpt_limit');
}
add_filter( 'excerpt_length', 'advset_excerpt_length_limit', 5 );
}
# excerpt read more link
if( advset_option('excerpt_more_text') ) {
function excerpt_read_more_link() {
return '... '.advset_option('excerpt_more_text').' + ';
}
add_filter('excerpt_more', 'excerpt_read_more_link');
}
# remove jquery migrate script
if( !is_admin() && advset_option('jquery_remove_migrate') ) {
function advset_remove_jquery_migrate(&$scripts) {
$scripts->remove( 'jquery');
$scripts->add( 'jquery', false, array( 'jquery-core' ), '1.10.2' );
}
add_action('wp_default_scripts', 'advset_remove_jquery_migrate');
}
# include jquery google cdn instead local script
if( advset_option('jquery_cnd') ) {
function advset_jquery_cnd() {
wp_deregister_script('jquery');
wp_register_script('jquery', ("//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"), false);
wp_enqueue_script('jquery');
}
add_action('wp_enqueue_scripts', 'advset_jquery_cnd');
}
# facebook og metas
if( !is_admin() && advset_option('facebook_og_metas') ) {
function advset_facebook_og_metas() {
global $post;
if (is_single() || is_page()) { ?>
= 2 || $page >= 2 )
$title = "$title $sep " . sprintf( __( 'Page %s', 'responsive' ), max( $paged, $page ) );
return $title;
}
add_filter( 'wp_title', 'advset_wp_title', 10, 2 );
}
// Scripts settings
require __DIR__.'/actions-scripts.php';
# image sizes
if( $_POST && (advset_option('max_image_size_w')>0 || advset_option('max_image_size_h')>0) ) {
// From "Resize at Upload Plus" 1.3
/* This function will apply changes to the uploaded file */
function advset_resize_image( $array ) {
// $array contains file, url, type
if ($array['type'] == 'image/jpeg' OR $array['type'] == 'image/gif' OR $array['type'] == 'image/png') {
// there is a file to handle, so include the class and get the variables
require_once( dirname(__FILE__).'/class.resize.php' );
$maxwidth = advset_option('max_image_size_w');
$maxheight = advset_option('max_image_size_h');
$imagesize = getimagesize($array['file']); // $imagesize[0] = width, $imagesize[1] = height
if ( $maxwidth == 0 OR $maxheight == 0) {
if ($maxwidth==0) {
$objResize = new RVJ_ImageResize($array['file'], $array['file'], 'H', $maxheight);
}
if ($maxheight==0) {
$objResize = new RVJ_ImageResize($array['file'], $array['file'], 'W', $maxwidth);
}
} else {
if ( ($imagesize[0] >= $imagesize[1]) AND ($maxwidth * $imagesize[1] / $imagesize[0] <= $maxheight) ) {
$objResize = new RVJ_ImageResize($array['file'], $array['file'], 'W', $maxwidth);
} else {
$objResize = new RVJ_ImageResize($array['file'], $array['file'], 'H', $maxheight);
}
}
} // if
return $array;
} // function
add_action('wp_handle_upload', 'advset_resize_image');
}
# remove filters if not in filters admin page
$remove_filters = get_option( 'advset_remove_filters' );
if( !isset($_GET['page'])
|| $_GET['page']!='advanced-settings-filters' && is_array($remove_filters) ) {
if( isset($remove_filters) && is_array($remove_filters) )
foreach( $remove_filters as $tag=>$array )
if( is_array($array) )
foreach( $array as $function=>$_ )
//echo "$tag=>".$function.' ';
remove_filter( $tag, $function );
}
// translate to pt_BR
if( is_admin() && get_locale()==='pt_BR' ) {
add_filter( 'gettext', 'advset_translate', 10, 3 );
global $advset_ptbr;
$advset_ptbr = array(
'Tracked Scripts Check to remove scripts' => 'Scripts rastreados Marque para remover scripts',
'Options' => 'Opções',
'Track' => 'Rastrear',
'Track enqueued scripts' => 'Rastrear scripts incluídos no site',
'Load merged removed scripts in footer' => 'Carregar scripts removidos que foram juntados no rodapé',
'Merge and include removed scripts' => 'Juntar and incluir scripts removidos num único arquivo',
'Remove type="text/javascript" attribute from <script> tag' => 'Remove type="text/javascript" da tag de <script>',
'Remove Trackbacks and Pingbacks from Comment Count' => 'Remove trackbacks e pingbacks dos comentários',
'Limit the excerpt length to' => 'Limitar o tamanho da descrição em',
'words' => 'palavras',
'Add a read more link after excerpt with the text: ' => 'Adicionar "leia mais" depois da descrição com o texto: ',
'Hide the WordPress update message in the Dashboard' => 'Ocultar mensagem de atualização do WordPress',
'Configure site title to use just the wp_title() function (better for hardcode programming)' => 'Configurar título para usar a função wp_title() (para programadores)',
'Be careful, removing a filter can destabilize your system. For security reasons, no filter removal has efects over this page.' => 'Cuidado! Remover um filtro pode desestabilizar seu sistema. Por segurança, nenhum filtro removido terá efeito nesta página.',
'it\'s don\'t remove conditional IE comments like' => 'não remove os comentários condicionais do IE, exemplo:',
'Filters/Actions' => 'Filtros/Ações',
'Save changes' => 'Salvar alterações',
'width' => 'largura',
'height' => 'altura',
'Contents' => 'Conteúdo',
'System' => 'Sistema',
'HTML Code output' => 'Saída do código HTML',
'Hide top admin menu' => 'Esconde menu de administrador do topo',
'Automatically add a FavIcon' => 'Adicionar um FavIcon automático para a página',
'whenever there is a favicon.ico or favicon.png file in the template folder' => 'sempre que houver um arquivo favicon.ico ou favicon.png na pasta do modelo',
'Add a description meta tag using the blog description' => 'Adicionar uma meta tag de descrição usando a descrição do blog',
'Add description and keywords meta tags in each posts' => 'Adicionar uma meta tags de descrição e palavras-chave em cada post',
'Remove header WordPress generator meta tag' => 'Remover meta tag de "gerado pelo WordPress"',
'Remove header WLW Manifest meta tag' => 'Remover meta tag WLW Manifest',
'Current theme already has post thumbnail support' => 'Tema atual já tem suporte a imagem destacada (thumbnails)',
'Automatically generate the Post Thumbnail' => 'Gerar imagem destacada automaticamente',
'from the first image in post' => 'gera a partir da primeira imagem encontrada no post',
'Set JPEG quality to' => 'Alterar qualidade do JPEG para',
'when send and resize images' => 'no momento em que envia ou redimensiona imagens',
'Resize image at upload to max size' => 'Redimensionar a imagem no upload no tamanho máximo',
'if zero resize to max height or dont resize if both is zero' => 'Se zero, redimenciona para largura máxima ou nada faz se os dois valores forem zero',
'if zero resize to max width or dont resize if both is zero' => 'Se zero, redimenciona para altura máxima ou nada faz se os dois valores forem zero',
'Insert author bio in each post' => 'Adicionar descrição do autor em cada post',
'Unregister default WordPress widgets' => 'Remover widgets padrões do WordPress',
'removing some SQL queries can do the database work faster' => 'remove algumas consultas ao banco de dados, isto pode fazer o sistema rodar um pouco mais rápido',
'Disable widget system' => 'Remover sistema de widgets',
'Disable comment system' => 'Remover sistema de comentários',
'Fix post type pagination' => 'Corrige paginação de "post types"',
'Disable Posts Auto Saving' => 'Desabilita função de auto-salvar',
'Compress all code' => 'Comprime todo o código',
'transformations of quotes to smart quotes, apostrophes, dashes, ellipses, the trademark symbol, and the multiplication symbol' => 'estilização de áspas, apóstrofos, elípses, traços, e multiplicação dos símbolos',
'Remove HTML comments' => 'Remover todos os comentários em HTML',
'Display total number of executed SQL queries and page loading time (only admin users can see this)' => 'Mostrar o total de SQLs executadas e o tempo de carregamento da página (apenas administradores podem ver)',
'only admin users can see this' => 'apenas administradores poderão ver',
'inserts a javascript code in the footer' => 'adicionar um código em javascript no final do código HTML',
'Allow HTML in user profile' => 'Permitir códigos HTML na descrição de perfil do autor',
'Remove wptexturize filter' => 'Remove filtro de texturização',
'Remove unnecessary jQuery migrate script (jquery-migrate.min.js)' => 'Remove script em desuso de migração de versão do jQuery (jquery-migrate.min.js)',
'Include jQuery Google CDN instead local script (version 1.11.0)' => 'Inclui script jQuery do CDN do Google ao invés de usar arquivo local (versão 1.11.0)',
'Fix incorrect Facebook thumbnails including OG metas' => 'Corrigir miniaturas do Facebook incluindo metas OG',
'Remove header RSD (Weblog Client Link) meta tag' => 'Remover meta tag de RSD (Weblog Client Link)',
'Remove header shortlink meta tag' => 'Remover meta tag de shortlink',
'Remove header WLW Manifest meta tag (Windows Live Writer link)' => 'Remover meta tag de WLW Manifest (Windows Live Writer link)',
//'' => '',
);
}
function advset_translate( $text ) {
global $advset_ptbr;
$array = $advset_ptbr;
if( isset($array[$text]) )
return $array[$text];
else
return $text;
}
// -----------------------------------------------------------------------
add_action('wp_ajax_advset_filters', 'prefix_ajax_advset_filters');
function prefix_ajax_advset_filters() {
//echo $_POST['tag'].' - '.$_POST['function'];
// security
if( !current_user_can('manage_options') )
return false;
$remove_filters = (array) get_option( 'advset_remove_filters' );
$tag = (string)$_POST['tag'];
$function = (string)$_POST['function'];
if( $_POST['enable']=='true' )
unset($remove_filters[$tag][$function]);
else if ( $_POST['enable']=='false' )
$remove_filters[$tag][$function] = 1;
update_option( 'advset_remove_filters', $remove_filters );
//echo $_POST['enable'];
return true;
}
# Post Types
add_action( 'init', 'advset_register_post_types' );
function advset_register_post_types() {
$post_types = (array) get_option( 'adv_post_types', array() );
#print_r($post_types);
#die();
if( is_admin() && current_user_can('manage_options') && isset($_GET['delete_posttype']) ) {
unset($post_types[$_GET['delete_posttype']]);
update_option( 'adv_post_types', $post_types );
}
if( is_admin() && current_user_can('manage_options') && isset($_POST['advset_action_posttype']) ) {
extract($_POST);
$labels = array(
'name' => $label,
#'singular_name' => @$singular_name,
#'add_new' => @$add_new,
#'add_new_item' => @$add_new_item,
#'edit_item' => @$edit_item,
#'new_item' => @$new_item,
#'all_items' => @$all_items,
#'view_item' => @$view_item,
#'search_items' => @$search_items,
#'not_found' => @$not_found,
#'not_found_in_trash' => @$not_found_in_trash,
#'parent_item_colon' => @$parent_item_colon,
#'menu_name' => @$menu_name
);
$post_types[$type] = array(
'labels' => $labels,
'public' => (bool)@$public,
'publicly_queryable' => (bool)@$publicly_queryable,
'show_ui' => (bool)@$show_ui,
'show_in_menu' => (bool)@$show_in_menu,
'query_var' => (bool)@$query_var,
#'rewrite' => array( 'slug' => 'book' ),
#'capability_type' => 'post',
'has_archive' => (bool)@$has_archive,
'hierarchical' => (bool)@$hierarchical,
#'menu_position' => (int)@$menu_position,
'supports' => (array)$supports,
'taxonomies' => (array)$taxonomies,
);
update_option( 'adv_post_types', $post_types );
}
#print_r($post_types);
if( sizeof($post_types)>0 )
foreach( $post_types as $post_type=>$args ) {
register_post_type( $post_type, $args );
if( in_array( 'thumbnail', $args['supports'] ) ) {
add_theme_support( 'post-thumbnails', array( $post_type, 'post' ) );
/*global $_wp_theme_features;
if( !is_array($_wp_theme_features[ 'post-thumbnails' ]) )
$_wp_theme_features[ 'post-thumbnails' ] = array();
$_wp_theme_features[ 'post-thumbnails' ][0][]= $post_type;*/
#print_r($_wp_theme_features[ 'post-thumbnails' ]);
}
}
}
function advset_powered () {
echo '