Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Define a largura das páginas de conteúdo
- */
- if ( ! isset( $content_width ) )$content_width = 552;
- #Define uma constante com a URL principal do site
- define('ABSURL', get_bloginfo('template_url'));
- #Define uma constante com a URL das imagens
- define('IMGURL', ABSURL.'/images');
- #Define uma constante com a URL principal do site
- define('TEMPLATEURL', get_bloginfo('template_url'));
- require( TEMPLATEPATH . '/packsystem/ps_functions.php' );
- if(!is_admin()){
- session_start();
- $force_mobile = is_null( $_GET['forcemobile'] ) ? 0 : 1;
- $no_mobile = is_null( $_GET['nomobile'] ) ? 0 : 1;
- #Salva em sessão as variaveis de mobile,
- if( $force_mobile ){ #força a visualização em mobile
- $_SESSION['forcemobile'] = 1;
- $_SESSION['nomobile'] = 0;
- $no_mobile = null;
- }
- if( $no_mobile ){ #força a visualização padrão
- $_SESSION['nomobile'] = 1;
- $_SESSION['forcemobile'] = 0;
- $force_mobile = null;
- }
- define('MOBILE', $force_mobile || ( is_mobile() && !is_tablet() && !$no_mobile ) );
- } else {
- define( 'MOBILE', false );
- }
- /**
- * Inicia as configurações do Tema
- *
- */
- add_action( 'after_setup_theme', 'ps_setup' );
- if ( ! function_exists( 'ps_setup' ) ):
- function ps_setup() {
- // Adiciona o CSS para aplciar dentro do editor de textos
- add_editor_style('editor-style.css');
- // Add default posts and comments RSS feed links to <head>.
- add_theme_support( 'automatic-feed-links' );
- // Adiciona suporte a Menu
- register_nav_menus( array(
- 'primary' => 'Menu Principal',
- 'left_menu' => 'Menu de Técnicas',
- 'left_menu2' => 'Menu de Técnicas 2',
- 'left_menu3' => 'Menu de Técnicas 3',
- 'right_menu' => 'Menu Extra',
- 'm-primary' => 'Mobile Principal',
- 'm-tecnicas' => 'Mobile Técnicas'
- ) );
- // Adiciona suporte a imagens destagadas em posts e páginas
- add_theme_support( 'post-thumbnails' );
- add_image_size( 'blog-image', 620, 225);
- add_image_size( 'related-thumb', 287, 105);
- add_action( 'pre_get_posts', 'set_blog_posts_per_page' );
- }
- endif;
- /**
- * Adiciona classes para controle no body
- *
- * @param array $classes
- * @return array
- */
- add_filter( 'body_class', 'ps_body_class' );
- function ps_body_class( $classes ) {
- $classes[] = get_platform('ps');
- if(ps_is_blog()){
- $classes[] = 'cat-blog';
- }
- if(MOBILE) $classes[] = 'is-mobile';
- return $classes;
- }
- /**
- * Filtra os temas, para adicionar o mobile e o blog
- *
- * @param string $template
- * @return string
- */
- add_filter( 'template_include', 'ps_template_include', 99 );
- function ps_template_include( $template ) {
- $name = basename($template, '.php');
- if(MOBILE){
- $new_template = locate_template( array( 'mobile-'.$name.'.php' ) );
- if(ps_is_blog()){
- $new_template = locate_template( array( 'mobile-category-blog.php' ) );
- }
- if ( '' != $new_template ) {
- $template = $new_template ;
- }
- }elseif(ps_is_blog()){
- $new_template = locate_template( array( 'category-blog.php' ) );
- if ( '' != $new_template ) {
- $template = $new_template ;
- }
- }
- return $template;
- }
- /**
- * Verifica se a página a ser carregada é do blog
- *
- * @return boolean
- */
- function ps_is_blog(){
- if(is_home() || is_front_page()) return false;
- $cat_blog = false;
- if(is_category()){
- $categ = get_category(get_query_var('cat'));
- $cat_blog = (is_category(8) || $categ->category_parent == 8);
- }else
- if(is_single() && in_category(8)){
- $cat_blog = true;
- }
- return ($cat_blog || is_tag());
- }
- /**
- * Pega o nome das categorias do post
- *
- * @param string $catExclude Código das categorias que não deseja exibir
- * @return array Retorna um array com os links para cada categoria
- */
- function ps_get_cat_names($catExclude = NULL){
- if(!$catExclude) $catExclude = array();
- $nameCats = array();
- foreach((get_the_category()) as $cat){
- if(!in_array($cat->cat_ID, $catExclude)) $nameCats[] = '<a href="'.get_category_link( $cat->term_id ).'">'.$cat->cat_name.'</a>';
- }
- return $nameCats;
- }
- /**
- * Imprime o nome das categorias do post
- *
- * @param string $catExclude Código das categorias que não deseja exibir
- * @param string $sep Separador dos links
- * @return string Retorna uma string com o resultado da função ps_get_cat_names separados pelo conteúdo da variável $sep;
- */
- function ps_the_cat_names($catExclude = NULL, $sep = ', '){
- $cats = ps_get_cat_names($catExclude);
- echo implode($sep, $cats);
- }
- /**
- * Adiciona os scripts necessários para o site
- *
- */
- add_action('wp_enqueue_scripts', 'ps_enqueue_scripts', 999);
- function ps_enqueue_scripts(){
- if (!is_admin()) {
- #wp_register_script( 'packsystem', ABSURL.'/js/js.php', array('jquery'), '1.0', true);
- #wp_enqueue_script( 'packsystem' );
- wp_register_script( 'packsystem1', ABSURL.'/js/gsap/TweenLite.min.js', null, filemtime( get_template_directory().'/js/gsap/TweenLite.min.js' ), true);
- wp_enqueue_script( 'packsystem1' );
- wp_register_script( 'packsystem11', ABSURL.'/js/gsap/CSSPlugin.min.js', null, filemtime( get_template_directory().'/js/gsap/CSSPlugin.min.js' ), true);
- wp_enqueue_script( 'packsystem11' );
- wp_register_script( 'packsystem2', ABSURL.'/js/min.js', array('jquery'), filemtime( get_template_directory().'/js/min.js' ), true);
- wp_enqueue_script( 'packsystem2' );
- }
- }
- /**
- * Função para comprimir os scripts em GZIP
- *
- add_action('wp_enqueue_scripts', 'ps_force_compress');
- function ps_force_compress(){
- global $compress_scripts, $concatenate_scripts;
- $compress_scripts = 1;
- $concatenate_scripts = 1;
- define('ENFORCE_GZIP', true);
- }
- */
- /**
- * Função para registrar as áreas de widget do site
- *
- */
- add_action( 'widgets_init', 'ps_widgets_init' );
- function ps_widgets_init() {
- register_sidebar( array(
- 'name' => 'Lateral Blog',
- 'id' => 'w-sidebar',
- 'before_widget' => '<div id="%1$s" class="widget w-sidebar %2$s">',
- 'after_widget' => "</div></div>",
- 'before_title' => '<h3 class="widget-title">',
- 'after_title' => '</h3><div class="widget-content">',
- ) );
- register_sidebar( array(
- 'name' => 'Rodapé',
- 'id' => 'w-footer',
- 'before_widget' => '<div id="%1$s" class="w-footer %2$s">',
- 'after_widget' => "</div>",
- 'before_title' => '<h3 class="widget-title">',
- 'after_title' => '</h3>',
- ) );
- register_sidebar( array(
- 'name' => 'SubMenu',
- 'id' => 'w-submenu',
- 'before_widget' => '<div id="%1$s" class="w-submenu %2$s">',
- 'after_widget' => "</div>",
- 'before_title' => '<h3 class="widget-title">',
- 'after_title' => '</h3>',
- ) );
- }
- /**
- * Função para pegar a músca que está cadastrada no ADM.
- *
- * @url http://paulapires.com.br/wp-admin/options-general.php?page=ps-custom
- *
- * @return string
- */
- function ps_get_sound(){
- $options = get_option( 'ps_custom_option' );
- $sound = $options['ps_sounds'];
- if(!$sound) $sound = '/wp-content/uploads/2014/10/Trilha-final-do-site.mp3';
- return $sound;
- }
- /**
- * Imprime a função ps_get_sound
- *
- */
- function ps_the_sound(){ echo ps_get_sound();}
- /**
- * Função para pegar uma imagem de fundo das que estão cadastradas no ADM.
- * São cadastradas em: http://paulapires.com.br/wp-admin/options-general.php?page=ps-custom
- *
- * @param string $type Tipo para buscar web ou mobile
- * @return string
- */
- function ps_get_bg($type = 'web'){
- $bg = '';
- $options = get_option( 'ps_custom_option' );
- $opt_bgs = trim($type == 'web' ? $options['ps_backgrounds'] : $options['ps_backgrounds_m']);
- if(!$opt_bgs)
- return '/wp-content/uploads/2015/03/fundo1.jpg';
- $bgs = explode("\n", $opt_bgs);
- while(!$bg)
- $bg = $bgs[array_rand($bgs)];
- return trim($bg);
- }
- /**
- * Imprime a função ps_get_bg
- *
- * @param string $type Tipo para buscar web ou mobile
- */
- function ps_the_bg($type = 'web'){echo ps_get_bg($type);}
- /**
- * Função para imprimir as opções de compartilhamento
- *
- * @param string
- */
- function ps_share()
- {
- $whatsapp_api = get_option('pp_api_settings');
- $whatsapp_number = preg_replace( '/[^0-9]/', '', $whatsapp_api['pp_whats_settings_number'] );
- $whatsapp_text = $whatsapp_api['pp_whats_settings_text'];
- $link = 'https://wa.me/55' . $whatsapp_number;
- if ( ! empty( $whatsapp_number ) && ! empty( $whatsapp_text ) ) {
- $link = 'https://wa.me/55' . $whatsapp_number . '?text=' . $whatsapp_text;
- }
- global $post;
- ps_facebook();
- ps_twitter();
- ps_googleplus();
- ?>
- <ul class="entry-share">
- <?php if ( $whatsapp_number ) : ?>
- <li class="wapp" style="text-align:left;"><a href="<?php echo $link ?>" target="_blank">
- <img src="<?php the_img('whatsapp-logo.png')?>" alt="">
- <span>Via WhatsApp</span>
- </a>
- </li>
- <?php endif; ?>
- <li class="tube"><div class="g-ytsubscribe" data-channel="safhica" data-layout="default" data-count="default"></div></li>
- <li class="face"><div class="fb-share-button" data-href="<?php echo get_permalink(); ?>" data-layout="button_count"></div></li>
- <li class="insta"><a href="https://www.instagram.com/paulapiresastro/" rel="noopener noreferrer nofollow" target="_blank"></a></li>
- <?php echo comments_number( '', '<li class="comments">1 comentário</li>', '<li class="comments">% comentários</li>' );?>
- </ul>
- <?php
- }
- /**
- * Exibe a paginação
- *
- * @param string $nav_id Define o atributo id da tag nav que será impressa
- */
- function ps_content_nav( $nav_id ) {
- global $wp_query;
- #pre($wp_query);
- if ( $wp_query->max_num_pages > 1 ) : ?>
- <p class="tc"><a id="more-pageOnDemand" class="ps-btn-elipse dn" href="#">Carregar mais Artigos</a></p>
- <div id="pageOnDemand" class="tc dn"><img src="<?php the_img('loader3.gif')?>" alt="Carregando" title="Carregando"></div>
- <nav id="<?php echo $nav_id; ?>" class="navigation">
- <?php
- $big = 999999999; // need an unlikely integer
- echo paginate_links( array(
- 'base' => str_replace( $big, '%#%', get_pagenum_link( $big ) ),
- 'format' => '?paged=%#%',
- 'current' => max( 1, get_query_var('paged') ),
- 'total' => $wp_query->max_num_pages,
- 'prev_text' => '«',
- 'next_text' => '»'
- ) );
- ?>
- </nav><!-- #nav-above -->
- <?php endif;
- }
- /**
- * Limpa o conteúdo para exibição do texto sem imagens
- *
- * @param string $content
- * @return string
- */
- function ps_get_the_content($content){
- $content = apply_filters('the_content', $content);
- $content = str_replace(']]>', ']]>', $content);
- return $content;
- }
- /**
- * Conta o número de visitas de cada post
- *
- */
- if(!function_exists('ps_countviews')):
- add_action('wp_footer', 'ps_countviews');
- function ps_countviews() {
- if(!is_single()) return false;
- global $post;
- if(is_int($post)) $post = get_post($post);
- if(wp_is_post_revision($post)) return false;
- $visitas = intval(get_post_meta($post->ID, '_ps_postviews', true));
- if(!update_post_meta($post->ID, '_ps_postviews', ($visitas+1))) {
- add_post_meta($post->ID, '_ps_postviews', 1, true);
- }
- }
- endif;
- /**
- * Exibe o posts mais visualizados em um widget lateral através do shortcode [ps_show_most_views]
- *
- * @param string $content
- * @return $content
- */
- add_filter('widget_text', 'ps_show_most_views');
- function ps_show_most_views($content){
- if(strpos($content, '[ps_show_most_views]') === false) return $content;
- $html = '';
- $query = new WP_Query('posts_per_page=4&orderby=meta_value_num&order=DESC&meta_key=_ps_postviews&cat=8');
- global $post;
- if($query->have_posts()){
- $html.= '<ul class="top-posts">';
- while($query->have_posts()){
- $query->the_post();
- $html.= '<li class="post post-views-'.get_post_meta($post->ID, '_ps_postviews', true).'"><a href="'.get_the_permalink().'" title="'.get_the_title().'" rel="bookmark">'.get_the_title().'</a></li>';
- }
- $html.= '</ul>';
- }
- wp_reset_query();
- $content = str_replace('[ps_show_most_views]', $html, $content);
- return $content;
- }
- /**
- * Exibe o posts em destaque através do shortcode [ps_artigos_destaque]
- *
- * @param string $content
- * @return $content
- */
- add_filter('widget_text', 'ps_show_destaques');
- function ps_show_destaques($content){
- $shotcode = '[ps_artigos_destaque]';
- if(strpos($content, $shotcode) === false) return $content;
- $html = '';
- $query = new WP_Query('posts_per_page=4&meta_key=_ps_isDestaque&meta_value=1&cat=8');
- global $post;
- if($query->have_posts()){
- $html.= '<ul class="top-posts">';
- while($query->have_posts()){
- $query->the_post();
- $html.= '<li class="post post-destaque-'.$post->ID.'"><a href="'.get_the_permalink().'" title="'.get_the_title().'" rel="bookmark">'.get_the_title().'</a></li>';
- }
- $html.= '</ul>';
- }
- wp_reset_query();
- $content = str_replace($shotcode, $html, $content);
- return $content;
- }
- /**
- * Customiza o tamanho das tags
- *
- * @param array $args
- * @return array
- */
- add_filter( 'widget_tag_cloud_args', 'ps_tag_cloud_args' );
- function ps_tag_cloud_args($args) {
- $args['largest'] = 16; //largest tag
- $args['smallest'] = 8; //smallest tag
- return $args;
- }
- /**
- * Permite fazer arquivos separados para cada post de acordo com a categoria
- *
- * @param string $single_template
- * @return $path
- */
- add_filter( 'single_template', 'ps_single_template' );
- function ps_single_template($single_template) {
- global $wp_query, $post;
- foreach((array)get_the_category() as $cat){
- $path = TEMPLATEPATH.'/single-cat-'.$cat->term_id.'.php';
- if(file_exists($path)) return $path;
- $path = TEMPLATEPATH.'/single-cat-'.$cat->slug.'.php';
- if(file_exists($path)) return $path;
- }
- return $single_template;
- }
- /**
- * Adiciona caixa de estilos no editor do WP
- *
- * @param array $buttons
- * @return array
- */
- add_filter('mce_buttons_2', 'ps_mce_buttons_2');
- function ps_mce_buttons_2($buttons) {
- array_unshift($buttons, 'styleselect');
- return $buttons;
- }
- /**
- * Adiciona os itens na caixa de estilos
- *
- * @param string $init_array
- * @return $init_array
- */
- add_filter( 'tiny_mce_before_init', 'ps_insert_formats' );
- function ps_insert_formats( $init_array ) {
- $style_formats = array('{"title":"Botão Elipse", "classes":"ps-btn-elipse", "selector":"a", "wrapper":false}'
- ,'{"title":"Botão de Imprimir", "classes":"ps-btn-print", "selector":"a", "wrapper":false}'
- ,'{"title":"Lista de Links", "classes":"link-list", "selector":"ul", "wrapper":false}'
- ,'{"title":"Link", "classes":"link", "selector":"a", "wrapper":false}'
- );
- $init_array['style_formats'] = '['.implode(',', $style_formats).']';
- return $init_array;
- }
- /**
- * Adiciona os audio e vídeo de acordo com o shortcode
- *
- * @param string $atts Array com os parametros necessários
- * @param string id caso sejam adicionados mais de um vídeo no msmo post, isso garante que não haverá elementos com id duplicado
- * @param string type audio/video
- * @param string url Caminho para o vídeo flv
- * @param string src Caminho para o vídeo m4v
- * @param string altura Altura em pixels do vídeo
- * @param string largura Largura em pixels do vídeo
- * @param boolean autoplay Caso esteja definido, será dado play quando a página terminar de carregar
- * @return string
- * @ Ex: http://www.paulapires.com.br/wp-admin/post.php?post=3237&action=edit
- */
- add_shortcode('ps_media', 'ps_media_add');
- function ps_media_add( $atts ) {
- if(!$atts['url']) return '';
- if(!$atts['id']) $atts['id'] = 1;
- if(!$atts['type']) $atts['type'] = 'audio';
- $atts['autoplay'] = $atts['autoplay'] ? 'autoplay' : '';
- extract($atts);
- $id = $type.'_'.get_the_ID().'-'.$id;
- $w = $largura ? $largura : 'null';
- $h = !$altura && $type == 'audio' ? '55' : ($altura ? $altura : 'null');
- $html = '<div class="media '.$type.' '.$id.'">';
- if(is_mobile()){
- if($autoplay == 'sim') $autoplay = 'autoplay="play"';
- if($type == 'audio'){
- $iPod = stripos($_SERVER['HTTP_USER_AGENT'],"iPod");
- $iPhone = stripos($_SERVER['HTTP_USER_AGENT'],"iPhone");
- $iPad = stripos($_SERVER['HTTP_USER_AGENT'],"iPad");
- //do something with this information
- if( $iPod || $iPhone || $iPad){
- #$html.= '<p> <br><br><audio controls autoplay="false"><source src="'.$url.'" type="audio/mp3"><p>Seu navegador exige que você <a href="'.$url.'">clique aqui</a> novamente para ouvir o áudio.<p></audio></p>';
- $html.= '<p> <br><br>Seu navegador exige que você <a href="'.$url.'">clique aqui</a> novamente para ouvir o áudio.</p>';
- }else{
- $html.= '<p> <br><br><audio controls autoplay="false"><source src="'.$url.'" type="audio/mp3"></audio></p>';
- }
- }else{
- $html.= '<p><video src="'.$src.'" controls style="width:554px;" '.$autoplay.'></video></p>';
- }
- }else{
- $html = '<div class="'.$type.' '.$id.'">';
- $html.= '<div id="'.$id.'"></div>';
- $html.= '<script >jQuery(document).ready(function(e) {Site.addMedia("'.$id.'", "'.$url.'", '.$h.', '.$w.', "'.$autoplay.'");});</script>';
- }
- $html.= '</div>';
- return $html;
- }
- /**
- * Substitui a tag hr para fazer o hr padrão do site
- *
- * @param string $content
- * @return $content
- */
- function ps_replace_hr($content){
- $content = str_replace('<hr>', '<div class="hr"></div>', $content);
- $content = str_replace('<hr/>', '<div class="hr"></div>', $content);
- $content = str_replace('<hr />', '<div class="hr"></div>', $content);
- return $content;
- }
- add_filter('the_content', 'ps_replace_hr');
- /**
- * Formulário de newsletter
- *
- * @param string $content
- * @param string $id Altera o atributo id da tag <form>
- * @return $content
- */
- add_filter('widget_text', 'ps_form_newsletter');
- add_filter('the_content', 'ps_form_newsletter');
- function ps_form_newsletter($content, $id='') {
- if ( strpos( $content, '[ps_form_newsletter]' ) === false ) {
- return $content;
- }
- $form = '
- <form method="post" action="#" id="frmNewsletter'.$id.'" class="frmNewsletter">
- <input type="text" name="mc4wp-TXTNAME" id="nl_nome'.$id.'" placeholder="nome" class="obrig" title="nome" required="required" />
- <input type="email" name="EMAIL" id="nl_email'.$id.'" placeholder="e-mail" class="obrig email" title="E-MAIL" required="required" />
- <input type="submit" id="sbt_frmNewsletter'.$id.'" name="sbt_frmNewsletter" class="submit sbt_frmNewsletter" value="Enviar">
- <span class="loader-submit dn loader_frmNewsletter"><img src="'.ABSURL.'/images/loader3.gif" height="30" alt="Aguarde" class="va"> Enviando</span>
- <input type="hidden" value="1" name="mc4wp-subscribe">
- </form>';
- $content = str_replace( '[ps_form_newsletter]', $form, $content );
- if ( $_SERVER['REQUEST_METHOD'] !== 'POST' ) {
- return $content;
- }
- $msg_form = false;
- $txt_name = isset( $_POST['mc4wp-TXTNAME'] ) ? esc_html( $_POST['mc4wp-TXTNAME'] ) : false;
- $email = isset( $_POST['EMAIL'] ) ? sanitize_email( $_POST['EMAIL'] ) : false;
- if ( ! $txt_name || ! $email ) {
- $msg_form = 'Os campos Nome e E-mail devem ser preenchidos!';
- }
- if ( $txt_name && $email ) {
- $site_url = esc_url( home_url( '/' ) );
- $blog_name = esc_html( get_bloginfo( 'name', 'display' ) );
- $msg = "******************************************************************
- Formulário de Newsletter
- ******************************************************************\n
- Nome: {$txt_name}
- E-mail: {$email}
- Esse e-mail foi enviado através do site {$blog_name}\n{$site_url}
- ";
- //ps_save_form('Newsletter', $nl_nome, $nl_email, $nl_origem);
- ps_send_email( utf8_decode( $msg ), 'Newslleter' );
- $msg_form = 'Obrigado! Seu e-mail foi cadastrado com sucesso!';
- }
- if ( $msg_form ) {
- $content .= '<script>jQuery( document ).ready( function() { alert( "' . $msg_form . '" ) } );</script>';
- }
- return $content;
- }
- /**
- * Envia os e-mails
- *
- * @param string $content Corpo do e-mail
- * @param string $subject Assunto do E-mail
- * @param string $reply E-mail para o qual deve encaminhar quando o usuário responder
- */
- function ps_send_email($content, $subject, $reply = ''){
- $admin_email = 'renata7protegida@gmail.com';
- $subject = get_bloginfo( 'name', 'display' ).' - '.$subject;
- $from = 'naoresponda@paulapires.com.br';
- $headers = 'MIME-Version: 1.0'."\n";
- $headers .= 'Content-type: text/plain; charset=iso-8859-1'."\n";
- #$headers .= 'To: '.$admin_email."\n";
- #$headers .= 'Cc: richard.venancio@gmail.com'."\n";
- #$headers .= 'Bcc: richard.venancio@gmail.com'."\n";
- $headers .= 'From: SITE - Paula Pires <'.$from.'>'."\n";
- if($reply) $headers .= "Reply-to: $reply"."\n";
- #echo '<pre class="dn">'."$admin_email, $subject, $content, $headers, $from".'</pre>';
- $resp = @mail($admin_email, $subject, $content, $headers, "-r".$from);
- }
- /**
- * Customiza a quantidade de caracter aceita no resumo do post
- *
- * @param string $length
- * @return 300
- */
- add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );
- function custom_excerpt_length( $length ) {
- return 300;
- }
- /**
- * Imprime os links para aumentar e diminuir as fontes
- *
- */
- function font_size(){?>
- <span class="font-size">
- <a href="#" class="less" data-min="14" title="Diminuir Fonte">-A</a>
- <a href="#" class="more" data-max="22" title="Aumentar Fonte">+A</a>
- </span>
- <?php
- }
- /**
- * Delimita o tamanho do resumo para exibição garantindo que nenhuma palavra seja cortada ao meio.
- *
- * @param string $n define a quantidade máxima de caracters a ser exibida
- * @return $excerpt
- */
- function ps_get_excerpt($n = 190){
- $excerpt = get_the_excerpt();
- $pos = @strpos($excerpt, ' ', $n);
- if(strlen($excerpt) < $n || $pos === false) return $excerpt;
- return substr($excerpt, 0, $pos);
- }
- /**
- * Customiza o formulário de comentários
- *
- * @param string $nameTextarea Define o label do campo textarea
- */
- function ps_comment_form($nameTextarea = 'Deixe seu comentário'){
- $commenter = wp_get_current_commenter();
- $req = get_option( 'require_name_email' );
- $aria_req = ( $req ? " aria-required='true'" : '' );
- $fields = array(
- 'author' => '<p><label for="author">Nome<br><input id="author" name="author" type="text" class="campo" title="Preencha seu nome" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' required /></label></p>',
- 'email' => '<p><label for="email">E-mail<br><input id="email" name="email" type="text" class="campo" title="Preencha seu e-mail" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' required /></label></p>',
- 'url' => '',
- );
- $comments_args = array(
- 'title_reply'=>'',
- 'comment_notes_after' => '',
- 'comment_notes_before' => '',
- 'cancel_reply_link' => 'Cancelar',
- 'comment_field' => '<label for="comment">'.$nameTextarea.'<br><textarea id="comment" name="comment" title="'.$nameTextarea.'" aria-required="true" required class="campo"></textarea></label>',
- 'label_submit' => 'Enviar >',
- 'title_reply_to' => '',
- 'id_submit' => 'sbt_frmComment',
- 'fields' => $fields
- );
- comment_form($comments_args);
- }
- /**
- * Customiza a lista de comentários
- *
- * @param string $comment
- * @param string $args
- * @param string $depth
- */
- function ps_comment( $comment, $args, $depth ) {
- $GLOBALS['comment'] = $comment;
- switch ( $comment->comment_type ) :
- case 'pingback' :
- case 'trackback' : ?>
- <div <?php comment_class('p-comment h-cite'); ?> id="comment-<?php comment_ID(); ?>">
- <p><?php _e( 'Pingback:', 'ps' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __( 'Edit', 'ps' ), '<span class="edit-link">', '</span>' ); ?></p>
- <?php break;
- default : ?>
- <div <?php comment_class('p-comment h-cite'); ?> id="comment-<?php comment_ID(); ?>">
- <div class="comment-header">
- <?php if ( $comment->comment_approved == '0' ) : ?>
- <em class="comment-awaiting-moderation flr">Seu comentário está aguardando aprovação!</em>
- <?php endif; ?>
- <h4 class="fn p-author"><?php comment_author() ?></h4>
- <span class="data"><?php comment_time('d M, Y')?></span>
- </div>
- <div class="comment-content p-content">
- <?php comment_text(); ?>
- </div>
- <div class="reply">
- <?php comment_reply_link( array_merge( $args, array( 'reply_text' => 'Responder', 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
- </div><!-- .reply -->
- <?php break;
- endswitch;
- }
- /**
- * Adiciona um parametro para que seja possível identificar quando um comentário foi salvo
- *
- * @param string $location
- * @param string $comment
- * @return string
- */
- add_action('comment_post_redirect', 'ps_comment_post_redirect');
- function ps_comment_post_redirect($location, $comment = NULL){
- $location = substr($location, 0, strpos($location, '#'));
- return $location.'?msg=sucesso#sbt_frmComment';
- }
- /**
- * Adiciona o e-mail paulapires7@paulapires.com.br para receber todos os e-mails de comentários
- *
- * @param string $emails
- * @return $emails
- */
- #add_filter('comment_notification_recipients' , 'ps_add_comment_notify');
- function ps_add_comment_notify($emails){
- $emails[] = 'paulapires7@paulapires.com.br';
- $emails[] = 'paulapires@paulapires.com.br';
- return $emails;
- }
- /**
- * Código do Google Analytics
- */
- function ps_ga(){ ?>
- <script >
- (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
- (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
- m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
- })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
- ga('create', 'UA-46955706-1', 'auto');
- ga('require', 'displayfeatures');
- ga('send', 'pageview');
- </script>
- <?php
- }
- function ps_facebook()
- {
- ?>
- <script >
- (function(d, s, id) {
- var js, fjs = d.getElementsByTagName(s)[0];
- if (d.getElementById(id)) return;
- js = d.createElement(s); js.id = id;
- js.src = "//connect.facebook.net/pt_BR/sdk.js#xfbml=1&version=v2.0";
- fjs.parentNode.insertBefore(js, fjs);
- }(document, 'script', 'facebook-jssdk'));
- </script>
- <?php
- }
- function ps_twitter()
- {
- ?>
- <script >
- !function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
- </script>
- <?php
- }
- function ps_googleplus()
- {
- ?>
- <script >
- window.___gcfg = {lang: 'pt-BR'};
- (function() {
- var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
- po.src = 'https://apis.google.com/js/plusone.js';
- var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
- })();
- </script>
- <?php
- }
- function set_blog_posts_per_page( $query )
- {
- if ( is_category() and $query->is_category( 8 ) ){ // Blogs
- $query->set( 'posts_per_page', 6 );
- }
- }
- if(MOBILE){
- add_filter('autoptimize_filter_css_replacetag','my_ao_override_css_replacetag',10,1);
- function my_ao_override_css_replacetag($replacetag) {
- return array("</body>","before");
- }
- }
- function disable_wp_emojicons() {
- // all actions related to emojis
- remove_action( 'admin_print_styles', 'print_emoji_styles' );
- remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
- remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
- remove_action( 'wp_print_styles', 'print_emoji_styles' );
- remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );
- remove_filter( 'the_content_feed', 'wp_staticize_emoji' );
- remove_filter( 'comment_text_rss', 'wp_staticize_emoji' );
- // filter to remove TinyMCE emojis
- add_filter( 'tiny_mce_plugins', 'disable_emojicons_tinymce' );
- }
- add_action( 'init', 'disable_wp_emojicons' );
- function disable_emojicons_tinymce( $plugins ) {
- if ( is_array( $plugins ) ) {
- return array_diff( $plugins, array( 'wpemoji' ) );
- } else {
- return array();
- }
- }
- function _pp_cf7_current_form_title( $out, $pairs, $atts, $shortcode ) {
- global $pp_cf7_current_form_title;
- $pp_cf7_current_form_title = isset( $out['title'] ) ? esc_html( $out['title'] ) : '';
- return $out;
- }
- add_filter( 'shortcode_atts_wpcf7', '_pp_cf7_current_form_title', 99, 4 );
- function _pp_cf7_add_field_hidden_title( $fields ) {
- global $pp_cf7_current_form_title;
- if ( ! function_exists( 'wpcf7_get_current_contact_form' ) ) {
- return $fields;
- }
- $form_title = $pp_cf7_current_form_title;
- $query_title = isset( $_GET['form-title'] ) ? esc_html( $_GET['form-title'] ) : false;
- if ( ! empty( $query_title ) ) {
- $form_title = $query_title;
- } elseif ( empty( $form_title ) ) {
- $current_form = wpcf7_get_current_contact_form();
- $form_title = $current_form->title();
- }
- $fields['_title'] = esc_html( $form_title );
- return $fields;
- }
- add_filter( 'wpcf7_form_hidden_fields', '_pp_cf7_add_field_hidden_title' );
- add_action( 'init', '_pp_check_clear_psft_results' );
- function _pp_check_clear_psft_results() {
- if ( ! wp_next_scheduled ( 'pp_clear_psft_results' ) ) {
- wp_schedule_event( time(), 'daily', 'pp_clear_psft_results' );
- }
- }
- add_action( 'pp_clear_psft_results', '_pp_clear_psft_results' );
- function _pp_clear_psft_results() {
- global $wpdb;
- $wpdb->query( 'DELETE FROM dnvu4lf_psft_results WHERE date < NOW() - INTERVAL 15 DAY' );
- }
- require( TEMPLATEPATH . '/packsystem/ps_admin/ps_admin_custom.php' );
- require( TEMPLATEPATH . '/packsystem/ps_forms_testes/ps_forms_testes.php' );
- require( TEMPLATEPATH . '/packsystem/ps_gallery_post/ps_gallery_post.php' );
- require( TEMPLATEPATH . '/packsystem/ps_banners/ps_banners.php' );
- require( TEMPLATEPATH . '/packsystem/ps_Walker_Nav_Menu/ps_Walker_Nav_Menu.php' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement