__( 'Menu superior', 'bicbb' ), 'sidemenu' => __( 'Menu redes sociales', 'bicbb' ), 'menubottom' => __( 'Menu en el pie', 'bicbb' ) ) ); } add_action( 'init', 'bicbb_register_my_menus' ); function bicbb_widgets_bicbb() { register_sidebar( array( 'name' => esc_html__( 'widget del pie', 'bicbb' ), 'id' => 'widgetspie', 'description' => esc_html__( 'Add widgets here.', 'bicbb' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ) ); register_sidebar( array( 'name' => esc_html__( 'widget de la columna', 'bicbb' ), 'id' => 'widgetscolumna', 'description' => esc_html__( 'Add widgets here.', 'bicbb' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ) ); } add_action( 'widgets_init', 'bicbb_widgets_bicbb' ); if ( function_exists( 'add_theme_support' ) ) { add_theme_support( 'post-thumbnails' ); } function bicbb_custom_length_excerpt($word_count_limit) { $content = wp_strip_all_tags(get_the_excerpt() , true ); echo wp_trim_words($content, $word_count_limit); } function bicbb_new_excerpt_more( $more ) { return ' ...'; } add_filter('excerpt_more', 'bicbb_new_excerpt_more'); function bicbb_wps_highlight_results($text){ if(is_search()){ $sr = get_query_var('s'); $keys = explode("+",$sr); $text = preg_replace('/('.implode('|', $keys) .')/iu', ''.$sr.'', $text); } return $text; } add_filter('the_excerpt', 'bicbb_wps_highlight_results'); add_filter('the_title', 'bicbb_wps_highlight_results'); add_filter('the_author', 'bicbb_wps_highlight_results'); add_filter( 'posts_search', 'bicbb_db_filter_authors_search' ); function bicbb_db_filter_authors_search( $posts_search ) { if ( !is_search() || empty( $posts_search ) ) return $posts_search; global $wpdb; add_filter( 'pre_user_query', 'bicbb_db_filter_user_query' ); $search = sanitize_text_field( get_query_var( 's' ) ); $args = array( 'count_total' => false, 'search' => sprintf( '*%s*', $search ), 'search_fields' => array( 'display_name', 'user_login', ), 'fields' => 'ID', ); $matching_users = get_users( $args ); remove_filter( 'pre_user_query', 'bicbb_db_filter_user_query' ); if ( empty( $matching_users ) ) return $posts_search; $posts_search = str_replace( ')))', ")) OR ( {$wpdb->posts}.post_author IN (" . implode( ',', array_map( 'absint', $matching_users ) ) . ")))", $posts_search ); return $posts_search; } function bicbb_db_filter_user_query( &$user_query ) { if ( is_object( $user_query ) ) $user_query->query_where = str_replace( "user_nicename LIKE", "display_name LIKE", $user_query->query_where ); return $user_query; } function bicbb_main_scripts() { wp_enqueue_style( 'style', get_stylesheet_uri() ); wp_enqueue_style( 'bicbb_main', get_template_directory_uri() . '/css/bicbb_main.css', array(), '1.1', 'all'); wp_enqueue_style( 'bicbb_normalize', get_template_directory_uri() . '/css/bicbb_normalize.css', array(), '1.1', 'all'); wp_enqueue_style('google-fonts', '//fonts.googleapis.com/css?family=Noto+Serif:400,700|Quicksand:400,500,700', array()); wp_enqueue_script( 'bicbb_main-script', get_template_directory_uri() . '/js/bicbb_main.js', array( 'jquery' )); wp_enqueue_script( 'bicbb_jquery.slides.min', get_template_directory_uri() . '/js/bicbb_jquery.slides.min.js', array( 'jquery' )); wp_enqueue_script( 'bicbb_cookies', get_template_directory_uri() . '/js/bicbb_cookies.js', array( 'jquery' )); if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); } } add_action( 'wp_enqueue_scripts', 'bicbb_main_scripts' ); add_action( 'wp_default_scripts', function( $scripts ) { if ( ! empty( $scripts->registered['jquery'] ) ) { $scripts->registered['jquery']->deps = array_diff( $scripts->registered['jquery']->deps, array( 'jquery-migrate' ) ); } } ); function bicbb_enviar_formulario_por_email(){ if( empty( $_POST['txtnombre'] ) || empty( $_POST['txtmensaje'] ) ): wp_redirect( add_query_arg( array( 'errormsg' => "Campos incompletos" ), get_home_url() . '/contacto') ); exit; endif; $nombre = sanitize_text_field( $_POST['txtnombre'] ); $mensaje = sanitize_text_field( $_POST['txtmensaje'] ); wp_mail( "holabernibernal@gmail.com", "Formulario de contacto", $nombre . " envio este mensaje => " . $mensaje ); wp_redirect( get_home_url() . '/contacto?exito=1'); exit; } add_action('admin_post_nopriv_contacto', 'bicbb_enviar_formulario_por_email'); add_action('admin_post_contacto', 'bicbb_enviar_formulario_por_email'); add_filter('wp_mail_from', 'bicbb_new_mail_from'); add_filter('wp_mail_from_name', 'bicbb_new_mail_from_name'); function bicbb_new_mail_from($old) { return 'nombre@tudominio.es'; } function bicbb_new_mail_from_name($old){ return 'Nombre que quieras poner al remitente'; } add_action( 'after_setup_theme', 'bicbb_wpse_theme_setup' ); function bicbb_wpse_theme_setup() { add_theme_support( 'automatic-feed-links' ); add_theme_support( 'post-thumbnails' ); add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption', ) ); add_theme_support( 'custom-background', apply_filters( 'bicbb_custom_background_args', array( 'default-color' => 'ffffff', 'default-image' => '', ) ) ); add_theme_support( 'customize-selective-refresh-widgets' ); add_theme_support( 'menus' ); add_theme_support( 'title-tag' ); add_editor_style( get_stylesheet_directory_uri() . '/css/editor-style.css' ); add_theme_support( 'custom-logo', array( 'height' => 100, 'width' => 400, 'flex-width' => true, ) ); add_theme_support( 'custom-header', apply_filters( 'bicbb_custom_header_args', array( 'default-image' => '', 'width' => 250, 'height' => 250, 'flex-height' => true ) ) ); load_theme_textdomain( 'bicbb' ); if ( ! isset( $content_width ) ) $content_width = 900; } function bicbb_display_copyright( $iYear = null, $szSeparator = " - ", $szTail = '. Porque somos molones.' ) {echo '';} function bicbb_display_years( $iYear = null, $szSeparator = " - ", $bPrint = true ) { $iCurrentYear = ( date( "Y" ) ); if ( is_int( $iYear ) ) {$iYear = ( $iCurrentYear > $iYear ) ? $iYear = $iYear . $szSeparator . $iCurrentYear : $iYear; } else { $iYear = $iCurrentYear;} if ( $bPrint == true ) echo $iYear; else return $iYear; } ?>