esc_html__( 'Sidebar', 'royalnews' ), 'id' => 'royalnews-main-sidebar', 'description' => esc_html__( 'Widgets in this area will be shown on side of the page.', 'royalnews' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', )); register_sidebar( array( 'name' => esc_html__( 'Footer Widget Area', 'royalnews' ), 'id' => 'royalnews_footer_area', 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', )); register_sidebar( array( 'name' => esc_html__( 'After Header Widget Area', 'royalnews' ), 'id' => 'royalnews_after_header', 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', )); register_sidebar( array( 'name' => esc_html__( 'Before footer Widget Area', 'royalnews' ), 'id' => 'royalnews_before_footer', 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', )); } } add_action( 'widgets_init', 'royalnews_init_sidebar' ); if( !function_exists( 'royalnews_essentials_theme_supports' ) ){ /** * Register different essentials things for theme * @since 1.0 * @package RoyalNews */ function royalnews_essentials_theme_supports(){ /* Add theme support for Custom Logo. */ $custom_logo_args = array( 'width' => 180, 'height' => 60, 'flex-width' => true, 'flex-height' => true, ); add_theme_support( 'custom-logo', $custom_logo_args ); /* Switch default core markup for search form, comment form, and comments. to output valid HTML5. */ $html5_args = array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption', ); add_theme_support( 'html5', $html5_args ); /* Gutenberg wide images. */ add_theme_support( 'align-wide' ); add_theme_support( 'wp-block-styles' ); /* Add default posts and comments RSS feed links to head. */ add_theme_support( 'automatic-feed-links' ); /* Let WordPress manage the document title. */ add_theme_support( 'title-tag' ); /* Enable support for Post Thumbnails on posts and pages. */ add_theme_support( 'post-thumbnails' ); /* Add theme support for selective refresh for widgets. */ add_theme_support( 'customize-selective-refresh-widgets' ); /* Post formats. */ add_theme_support( 'post-formats', array( 'gallery', 'image', 'link', 'quote', 'video', 'audio', 'status', 'aside', ) ); add_theme_support( 'responsive-embeds' ); # Set up the WordPress core custom background feature. add_theme_support( 'custom-background', apply_filters( 'royalnews_custom_background_args', array( 'default-color' => 'ffffff' ) ) ); /* Customize Selective Refresh Widgets. */ add_theme_support( 'customize-selective-refresh-widgets' ); add_theme_support( 'post-thumbnails' ); /** * This variable is intended to be overruled from themes. * Open WPCS issue: {@link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/1043}. * phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound */ $GLOBALS['content_width'] = apply_filters( 'content_width_setup', 640 ); /** * Make theme available for translation. * Translations can be filed in the /languages/ directory. */ load_theme_textdomain( 'royalnews', get_theme_file_uri( 'languages' ) ); /** * Register Menus * @since 1.0 * @package RoyalNews */ register_nav_menus( array( 'primary-menu' => esc_html__( 'Primary Menu', 'royalnews' ), 'social-menu-header' => esc_html__( 'Social Menu Header', 'royalnews' ) ) ); # header image options add_theme_support( 'custom-header', apply_filters( 'royalnews_header_media_args' , array( 'default-text-color' => '000000', 'width' => 1366, 'height' => 400, 'flex-height' => true, 'default-image' => '', ))); /** * Support to new page template wp 5.8 */ add_theme_support( 'block-templates' ); } } add_action( 'after_setup_theme', 'royalnews_essentials_theme_supports' ); /** * Modified excerpt length * @since 1.0 * @package RoyalNews */ function royalnews_excerpt_length( $length ){ if( is_admin() ){ return $length; } $length = royalnews_value( 'excerpt_length' ); return $length; } add_filter( 'excerpt_length', 'royalnews_excerpt_length' ); /** * Modified excerpt readmore * @since 1.0 * @package RoyalNews */ function royalnews_excerpt_more( $text ){ if( is_admin() ){ return $text; } $more = sprintf( '...
%2$s
', esc_url( get_the_permalink() ), royalnews_value( 'read_more_text' ) ); return $more; } add_filter( 'excerpt_more', 'royalnews_excerpt_more' ); /** * Return Body class * @since 1.0 * @package RoyalNews */ function royalnews_body_classes( $classes ){ if( royalnews_value( 'sticky-header' ) ){ $classes[] = _ROYALNEWS_PREFIX.'-sticky-header'; } if( royalnews_value( 'enable_sidebar' ) ){ $classes[] = 'royalnews-sidebar-enable'; }else{ $classes[] = 'royalnews-sidebar-disabled'; } if( !royalnews_value( 'enable-social' ) ){ $classes[] = 'royalnews-social-menu-disabled'; } $post_per_row = royalnews_value( 'post_per_row' ); if( '1' == $post_per_row ){ $classes[] = 'royalnews-blog-one'; }elseif( '2' == $post_per_row ){ $classes[] = 'royalnews-blog-two'; }elseif( '3' == $post_per_row ){ $classes[] = 'royalnews-blog-three'; } return $classes; } add_action( 'body_class', 'royalnews_body_classes' ); function royalnews_meta_field(){ $post_types = array( 'page' ); foreach ( $post_types as $type ) { $post = new RoyalNews_Meta_Fields( $type ); if( 'page' == $type ){ $options = array( 'disable-banner' => array( 'type' => 'checkbox', 'label' => esc_html__( 'Disable Banner', 'royalnews' ), ) ); } $post->add_meta_box( esc_html__( 'RoyalNews Settings', 'royalnews' ), $options ); } } add_action( 'init', 'royalnews_meta_field' ); function royalnews_customize_register( $wp_customize ){ /** * modify customizer options * @since 1.0 * @package RoyalNews */ $wp_customize->get_control( 'header_textcolor' )->section = 'title_tagline'; $wp_customize->get_control( 'header_textcolor' )->label = esc_html__( 'Site Identity Color', 'royalnews' ); $wp_customize->get_section( 'header_image' )->title = esc_html__( 'Banner Options', 'royalnews' ); $wp_customize->get_section( 'header_image' )->panel = 'royalnews_options'; # change background color section $wp_customize->get_control( 'background_color' )->section = 'royalnews_general_options'; # change background image panel $wp_customize->get_section( 'background_image' )->panel = 'royalnews_options'; } add_action( 'customize_register', 'royalnews_customize_register' ); /** * Add cart icon if woocommerce active * @since 1.0 * @package RoyalNews */ function royalnews_add_cart_icon() { if ( !class_exists( 'WooCommerce' ) ) { return; } if ( is_cart() || is_checkout() ) { return; } $count = WC()->cart->cart_contents_count; $string = wc_get_cart_url(); ?>
0 ) ? esc_html( $count ) : 0; ?>
$post_to_display ? $post_to_display : -1, 'post_status' => 'publish' )); foreach ( $recent_posts as $post) { $posts[] = $post[ 'ID' ]; } }elseif( 'category' == $type ){ $args = array( 'post_type' => 'post', 'posts_per_page' => $post_to_display ? $post_to_display : -1, 'orderby' => 'date', 'order' => 'DESC', 'ignore_sticky_posts' => 1, ); if( $cat_id ){ $args[ 'cat' ] = $cat_id; } $query = new WP_Query( $args ); if ( $query->have_posts() ) { while ( $query->have_posts() ) { $query->the_post(); $posts[] = get_the_ID(); } } wp_reset_postdata(); } if( empty( $posts ) ){ return false; }else{ return $posts; } } } /** * Plugin recommendation * @since 1.0 * @package RoyalNews */ function royalnews_required_plugins(){ $plugins = array( array( 'name' => esc_html__( 'Kirki Customizer Framework', 'royalnews' ), 'slug' => 'kirki', 'description' => esc_html__( 'Please Install Kirki to use options', 'royalnews' ), 'required' => true, ) ); tgmpa( $plugins ); } add_action( 'tgmpa_register', 'royalnews_required_plugins' );