tag in the document head, and expect WordPress to * provide it for us. */ add_theme_support( 'title-tag' ); /* * Enable support for Post Thumbnails on posts and pages. * * @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/ */ add_theme_support('post-thumbnails' ); // Add featured image sizes add_image_size( 'featured-large', 640, 294, true ); // width, height, crop add_image_size( 'featured-small', 320, 147, true ); // Add other useful image sizes for use through Add Media modal add_image_size( 'medium-width', 480 ); add_image_size( 'medium-height', 9999, 480 ); add_image_size( 'medium-something', 280,280,true ); // Register the three useful image sizes for use in Add Media modal add_filter( 'image_size_names_choose', 'wpshout_custom_sizes' ); function wpshout_custom_sizes( $sizes ) { return array_merge( $sizes, array( 'medium-width' => __( 'Medium Width' ,'bothainah'), 'medium-height' => __( 'Medium Height' ,'bothainah' ), 'medium-something' => __( 'Medium Something','bothainah' ), ) ); } function catch_that_image() { global $post, $posts; $first_img = ''; ob_start(); ob_end_clean(); if( has_post_thumbnail() ) return the_post_thumbnail( 'thumbnail' ); $output = preg_match_all('//i', $post->post_content, $matches); $first_img = $matches [1] [0]; if(empty($first_img)){ //Defines a default image $first_img = get_template_directory_uri()."/images/default.png"; } return $first_img; } /** * HEX Color sanitization callback. * * - Sanitization: hex_color * - Control: text, WP_Customize_Color_Control * * Note: sanitize_hex_color_no_hash() can also be used here, depending on whether * or not the hash prefix should be stored/retrieved with the hex color value. * * @see sanitize_hex_color() https://developer.wordpress.org/reference/functions/sanitize_hex_color/ * @link sanitize_hex_color_no_hash() https://developer.wordpress.org/reference/functions/sanitize_hex_color_no_hash/ * * @param string $hex_color HEX color to sanitize. * @param WP_Customize_Setting $setting Setting instance. * @return string The sanitized hex color if not null; otherwise, the setting default. */ function sk_sanitize_hex_color( $hex_color, $setting ) { // Sanitize $input as a hex value. $hex_color = sanitize_hex_color( $hex_color ); // If $input is a valid hex value, return it; otherwise, return the default. return ( ! is_null( $hex_color ) ? $hex_color : $setting->default ); } /** * Image sanitization callback. * * Checks the image's file extension and mime type against a whitelist. If they're allowed, * send back the filename, otherwise, return the setting default. * * - Sanitization: image file extension * - Control: text, WP_Customize_Image_Control * * @see wp_check_filetype() https://developer.wordpress.org/reference/functions/wp_check_filetype/ * * @param string $image Image filename. * @param WP_Customize_Setting $setting Setting instance. * @return string The image filename if the extension is allowed; otherwise, the setting default. */ function sk_sanitize_image( $image, $setting ) { /* * Array of valid image file types. * * The array includes image mime types that are included in wp_get_mime_types() */ $mimes = array( 'jpg|jpeg|jpe' => 'image/jpeg', 'gif' => 'image/gif', 'png' => 'image/png', 'bmp' => 'image/bmp', 'tif|tiff' => 'image/tiff', 'ico' => 'image/x-icon' ); // Return an array with file extension and mime_type. $file = wp_check_filetype( $image, $mimes ); // If $image has a valid mime_type, return it; otherwise, return the default. return ( $file['ext'] ? $image : $setting->default ); } /** * Checkbox sanitization callback. * * Sanitization callback for 'checkbox' type controls. This callback sanitizes `$checked` * as a boolean value, either TRUE or FALSE. * * @param bool $checked Whether the checkbox is checked. * @return bool Whether the checkbox is checked. */ function sk_sanitize_checkbox( $checked ) { // Boolean check. return ( ( isset( $checked ) && true == $checked ) ? true : false ); } /** * Customizer: Add Sections * * This code adds a Section with multiple Settings and Controls to the Customizer * * @package code-examples * @copyright Copyright (c) 2015, WordPress Theme Review Team * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU General Public License, v2 (or newer) */ /** * Theme Options Customizer Implementation. * * Implement the Theme Customizer for Theme Settings. * * @link http://ottopress.com/2012/how-to-leverage-the-theme-customizer-in-your-own-themes/ * * @param WP_Customize_Manager $wp_customize Object that holds the customizer data. */ function sk_register_theme_customizer( $wp_customize ) { /* * Failsafe is safe */ if ( ! isset( $wp_customize ) ) { return; } /** * Add Header Section for General Options. * * @uses $wp_customize->add_section() https://developer.wordpress.org/reference/classes/wp_customize_manager/add_section/ * @link $wp_customize->add_section() https://codex.wordpress.org/Class_Reference/WP_Customize_Manager/add_section */ $wp_customize->add_section( // $id 'sk_section_header', // $args array( 'title' => __( 'Header Background', 'bothainah' ), 'description' => __( 'Set background color and/or background image for the header', 'bothainah' ), 'priority' => 9 ) ); /** * Header Background Color setting. * * - Setting: Header Background Color * - Control: WP_Customize_Color_Control * - Sanitization: hex_color * * Uses a color wheel to configure the Header Background Color setting. * * @uses $wp_customize->add_setting() https://developer.wordpress.org/reference/classes/wp_customize_manager/add_setting/ * @link $wp_customize->add_setting() https://codex.wordpress.org/Class_Reference/WP_Customize_Manager/add_setting */ $wp_customize->add_setting( // $id 'header_background_color_setting', // $args array( 'sanitize_callback' => 'sk_sanitize_hex_color', 'transport' => 'postMessage' ) ); /** * Header Background Image setting. * * - Setting: Header Background Image * - Control: WP_Customize_Image_Control * - Sanitization: image * * Uses the media manager to upload and select an image to be used as the header background image. * * @uses $wp_customize->add_setting() https://developer.wordpress.org/reference/classes/wp_customize_manager/add_setting/ * @link $wp_customize->add_setting() https://codex.wordpress.org/Class_Reference/WP_Customize_Manager/add_setting */ $wp_customize->add_setting( // $id 'header_background_image_setting', // $args array( 'default' => '', 'sanitize_callback' => 'sk_sanitize_image', 'transport' => 'postMessage' ) ); /** * Display Header Backgroud Image Repeat setting. * * - Setting: Display Header Backgroud Image Repeat * - Control: checkbox * - Sanitization: checkbox * * Uses a checkbox to configure the display of the header background image repeat checkbox. * * @uses $wp_customize->add_setting() https://developer.wordpress.org/reference/classes/wp_customize_manager/add_setting/ * @link $wp_customize->add_setting() https://codex.wordpress.org/Class_Reference/WP_Customize_Manager/add_setting */ $wp_customize->add_setting( // $id 'header_background_image_repeat_setting', // $args array( 'default' => true, 'sanitize_callback' => 'sk_sanitize_checkbox', 'transport' => 'postMessage' ) ); /** * Display Header Backgroud Image Size setting. * * - Setting: Display Header Backgroud Image Size * - Control: checkbox * - Sanitization: checkbox * * Uses a checkbox to configure the display of the header background image repeat checkbox. * * @uses $wp_customize->add_setting() https://developer.wordpress.org/reference/classes/wp_customize_manager/add_setting/ * @link $wp_customize->add_setting() https://codex.wordpress.org/Class_Reference/WP_Customize_Manager/add_setting */ $wp_customize->add_setting( // $id 'header_background_image_size_setting', // $args array( 'default' => false, 'sanitize_callback' => 'sk_sanitize_checkbox', 'transport' => 'postMessage' ) ); /** * Core Color control. * * - Control: Color * - Setting: Header Background Color * - Sanitization: hex_color * * Register "WP_Customize_Color_Control" to be used to configure the Header Background Color setting. * * @uses $wp_customize->add_control() https://developer.wordpress.org/reference/classes/wp_customize_manager/add_control/ * @link $wp_customize->add_control() https://codex.wordpress.org/Class_Reference/WP_Customize_Manager/add_control * * @uses WP_Customize_Color_Control() https://developer.wordpress.org/reference/classes/wp_customize_color_control/ * @link WP_Customize_Color_Control() https://codex.wordpress.org/Class_Reference/WP_Customize_Color_Control */ $wp_customize->add_control( new WP_Customize_Color_Control( // $wp_customize object $wp_customize, // $id 'header_background_color', // $args array( 'settings' => 'header_background_color_setting', 'section' => 'sk_section_header', 'label' => __( 'Header Background Color', 'bothainah' ), 'description' => __( 'Select the background color for header.', 'bothainah' ), ) ) ); /** * Image Upload control. * * Control: Image Upload * Setting: Header Background Image * Sanitization: image * * Register "WP_Customize_Image_Control" to be used to configure the Header Background Image setting. * * @uses $wp_customize->add_control() https://developer.wordpress.org/reference/classes/wp_customize_manager/add_control/ * @link $wp_customize->add_control() https://codex.wordpress.org/Class_Reference/WP_Customize_Manager/add_control * * @uses WP_Customize_Image_Control() https://developer.wordpress.org/reference/classes/wp_customize_image_control/ * @link WP_Customize_Image_Control() https://codex.wordpress.org/Class_Reference/WP_Customize_Image_Control */ $wp_customize->add_control( new WP_Customize_Image_Control( // $wp_customize object $wp_customize, // $id 'header_background_image', // $args array( 'settings' => 'header_background_image_setting', 'section' => 'sk_section_header', 'label' => __( 'Header Background Image', 'bothainah' ), 'description' => __( 'Select the background image for header.', 'bothainah' ) ) ) ); /** * Basic Checkbox control. * * - Control: Basic: Checkbox * - Setting: Display Header Backgroud Image Repeat * - Sanitization: checkbox * * Register the core "checkbox" control to be used to configure the Display Header Backgroud Image Repeat setting. * * @uses $wp_customize->add_control() https://developer.wordpress.org/reference/classes/wp_customize_manager/add_control/ * @link $wp_customize->add_control() https://codex.wordpress.org/Class_Reference/WP_Customize_Manager/add_control */ $wp_customize->add_control( // $id 'header_background_image_repeat', // $args array( 'settings' => 'header_background_image_repeat_setting', 'section' => 'sk_section_header', 'type' => 'checkbox', 'label' => __( 'Background Repeat', 'bothainah' ), 'description' => __( 'Should the header background image repeat?', 'bothainah' ), ) ); /** * Basic Checkbox control. * * - Control: Basic: Checkbox * - Setting: Display Header Backgroud Image Size * - Sanitization: checkbox * * Register the core "checkbox" control to be used to configure the Display Header Backgroud Image Size setting. * * @uses $wp_customize->add_control() https://developer.wordpress.org/reference/classes/wp_customize_manager/add_control/ * @link $wp_customize->add_control() https://codex.wordpress.org/Class_Reference/WP_Customize_Manager/add_control */ $wp_customize->add_control( // $id 'header_background_image_size', // $args array( 'settings' => 'header_background_image_size_setting', 'section' => 'sk_section_header', 'type' => 'checkbox', 'label' => __( 'Background Stretch', 'bothainah' ), 'description' => __( 'Should the header background image stretch in full?', 'bothainah' ), ) ); } // Settings API options initilization and validation. add_action( 'customize_register', 'sk_register_theme_customizer' ); /** * Registers the Theme Customizer Preview with WordPress. * * @package sk * @since 0.3.0 * @version 0.3.0 */ function sk_customizer_live_preview() { wp_enqueue_script( 'sk-theme-customizer', get_stylesheet_directory_uri() . '/js/theme-customizer.js', array( 'customize-preview' ), '0.1.0', true ); } // end sk_customizer_live_preview add_action( 'customize_preview_init', 'sk_customizer_live_preview' ); /** * Writes the Header Background related controls' values out to the 'head' element of the document * by reading the value(s) from the theme mod value in the options table. */ function sk_customizer_css() { if ( ! get_theme_mod( 'header_background_color_setting' ) && '' === get_theme_mod( 'header_background_image_setting' ) && false === get_theme_mod( 'header_background_image_repeat_setting' ) && false === get_theme_mod( 'header_background_image_size_setting' ) ) { return; } ?> Connect'; $nav_args = array( 'theme_location' => 'social', 'container' => 'div', 'container_id' => 'menu-social', 'container_class' => 'menu menu-social', 'menu_id' => 'menu-social-items', 'menu_class' => 'menu-items', 'depth' => 1, 'link_before' => '', 'link_after' => '', 'fallback_cb' => '', ); wp_nav_menu( $nav_args ); } /* end menu social media*/ // This theme uses wp_nav_menu() in one location. register_nav_menus( array( 'menu-1' => esc_html__( 'Primary', 'bothainah' ), ) ); /* * Switch default core markup for search form, comment form, and comments * to output valid HTML5. */ add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption', ) ); // Set up the WordPress core custom background feature. add_theme_support( 'custom-background', apply_filters( 'bothainah_custom_background_args', array( 'default-color' => 'ffffff', 'default-image' => '', ) ) ); // Add theme support for selective refresh for widgets. add_theme_support( 'customize-selective-refresh-widgets' ); } endif; add_action( 'after_setup_theme', 'bothainah_setup' ); /** * Set the content width in pixels, based on the theme's design and stylesheet. * * Priority 0 to make it available to lower priority callbacks. * * @global int $content_width */ function bothainah_content_width() { $GLOBALS['content_width'] = apply_filters( 'bothainah_content_width', 640 ); } add_action( 'after_setup_theme', 'bothainah_content_width', 0 ); /** * Register widget area. * * @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar */ function bothainah_widgets_init() { register_sidebar( array( 'name' => esc_html__( 'Sidebar', 'bothainah' ), 'id' => 'sidebar-1', 'description' => esc_html__( 'Add widgets here.', 'bothainah' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ) ); } add_action( 'widgets_init', 'bothainah_widgets_init' ); /** * Enqueue scripts and styles. */ function bothainah_scripts() { wp_enqueue_style( 'bothainah-style', get_stylesheet_uri() ); wp_enqueue_script( 'bothainah-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '20151215', true ); wp_enqueue_script( 'bothainah-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20151215', true ); if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); } } add_action( 'wp_enqueue_scripts', 'bothainah_scripts' ); /*emil*/ add_action( 'phpmailer_init', 'wpse8170_phpmailer_init' ); function wpse8170_phpmailer_init( PHPMailer $phpmailer ) { $phpmailer->Host = 'smtp.gmail.com'; $phpmailer->Port = 25; // could be different $phpmailer->Username = 'ypurEmail.com'; // if required $phpmailer->Password = 'yourPassword'; // if required $phpmailer->SMTPAuth = true; // if required $phpmailer->IsSMTP(); } /*editor*/ add_theme_support('editor_style'); add_editor_style('styles.css'); /** * Implement the Custom Header feature. */ require get_template_directory() . '/inc/custom-header.php'; /** * Custom template tags for this theme. */ require get_template_directory() . '/inc/template-tags.php'; /** * Custom functions that act independently of the theme templates. */ require get_template_directory() . '/inc/extras.php'; /** * Customizer additions. */ require get_template_directory() . '/inc/customizer.php'; /** * Load Jetpack compatibility file. */ require get_template_directory() . '/inc/jetpack.php';