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' );
if ( function_exists( 'add_image_size' ) ) {
add_image_size( 'fully-list', '650', '430', true );
}
// This theme uses wp_nav_menu() in one location.
register_nav_menus( array(
'primary' => esc_html__( 'Primary', 'angllia' ),
'menu_footer' => esc_html__( 'Menu Footer', 'angllia' ),
) );
/*
* 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',
));
/*
* Enable support for Post Formats.
* See https://developer.wordpress.org/themes/functionality/post-formats/
*/
add_theme_support( 'post-formats', array(
'image', 'video', 'audio', 'quote', 'gallery',
) );
/**
* Register widget area.
*
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
*/
function fully_widgets_init() {
register_sidebar( array(
'name' => esc_html__( 'Sidebar', 'angllia' ),
'id' => 'sidebar-1',
'description' => '',
'before_widget' => '',
'before_title' => '
',
) );
}
add_action( 'widgets_init', 'fully_widgets_init' );
/*
* Function Get Widgets
*/
function fully_get_widgets() {
$sidebar_options = array(
'0' => esc_html__('Select Sidebar','angllia')
);
foreach ($GLOBALS['wp_registered_sidebars'] as $sidebar) {
$sidebar_options[$sidebar['id']] = $sidebar['name'];
}
return $sidebar_options;
}
add_action('init','fully_get_widgets', 5);
/**
* Enqueue scripts and styles.
*/
function fully_scripts() {
wp_enqueue_style( 'css-bootstrap', get_template_directory_uri() . '/css/bootstrap.min.css' );
wp_enqueue_style( 'css-jasny-bootstrap', get_template_directory_uri() . '/css/jasny-bootstrap.min.css' );
wp_enqueue_style( 'css-font-awesome', get_template_directory_uri() . '/font-awesome-4.2.0/css/font-awesome.css' );
wp_enqueue_style( 'css-font-fontello', get_template_directory_uri() . '/css/fontello/fontello.css' );
wp_enqueue_style( 'css-effect2', get_template_directory_uri() . '/css/effect2.css' );
wp_enqueue_style( 'css-animate', get_template_directory_uri() . '/css/animate.css' );
wp_enqueue_style( 'css-selectbox', get_template_directory_uri() . '/rslib/scripts/jquery.rs.selectbox/jquery.rs.selectbox.css' );
wp_enqueue_style( 'css-slider-pro', get_template_directory_uri() . '/js/slider-pro/slider-pro.min.css' );
wp_enqueue_style( 'css-slick', get_template_directory_uri() . '/js/slick/slick.css' );
wp_enqueue_style( 'css-owl-carousel', get_template_directory_uri() . '/js/owl-carousel/owl.carousel.css' );
wp_enqueue_style( 'css-rs-wp-v1.2', get_template_directory_uri() . '/css/rs-wp-v1.2.css' );
wp_enqueue_style( 'css-main', get_template_directory_uri() . '/css/main.css' );
wp_enqueue_style( 'css-responsive', get_template_directory_uri() . '/css/responsive.css' );
wp_enqueue_style( 'fully-style', get_stylesheet_uri() );
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'js-rara', get_template_directory_uri() . '/rslib/plugins/rara/rara.js', 'jquery', '', true );
wp_enqueue_script( 'js-jquery.stickit', get_template_directory_uri() . '/js/jquery.stickit.js', 'jquery', '', true );
wp_enqueue_script( 'js-bootstrap', get_template_directory_uri() . '/js/bootstrap.min.js', 'jquery', '', true );
wp_enqueue_script( 'js-isotope', get_template_directory_uri() . '/js/isotope.js', 'jquery', '', true );
wp_enqueue_script( 'js-wow.min', get_template_directory_uri() . '/js/wow.min.js', 'jquery', '', true );
wp_enqueue_script( 'js-selectbox', get_template_directory_uri() . '/rslib/scripts/jquery.rs.selectbox/jquery.rs.selectbox.js', 'jquery', '', true );
wp_enqueue_script( 'js-appear', get_template_directory_uri() . '/js/appear.js', 'jquery', '', true );
wp_enqueue_script( 'js-jquery.easing.1.3', get_template_directory_uri() . '/js/jquery.easing.1.3.js', 'jquery', '', true );
wp_enqueue_script( 'js-slick', get_template_directory_uri() . '/js/slick/slick.min.js', 'jquery', '', true );
wp_enqueue_script( 'js-slider-pro', get_template_directory_uri() . '/js/slider-pro/jquery.sliderPro.min.js', 'jquery', '', true );
wp_enqueue_script( 'js-owl-carousel', get_template_directory_uri() . '/js/owl-carousel/owl.carousel.min.js', 'jquery', '', true );
wp_enqueue_script( 'js-main', get_template_directory_uri() . '/js/main.js', 'jquery', '', true );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
wp_localize_script( 'fully-js-custom', 'fully_main', array(
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'themeurl' => get_template_directory_uri(),
'homeurl' => home_url("/"),
));
}
add_action( 'wp_enqueue_scripts', 'fully_scripts' );
add_filter( 'mce_css', 'mcekit_editor_style');
function mcekit_editor_style($mce_css) {
if ( ! empty( $mce_css ) )
$mce_css .= ',';
$style_uri = get_stylesheet_directory_uri();
$style_dir = get_stylesheet_directory();
//$mce_css = array();
$mce_css .= add_query_arg(
'version',
filemtime( "$style_dir/rst-writerEditorCSS.min.css" ),
"$style_uri/rst-writerEditorCSS.min.css"
);
return $mce_css;
}
function rst_fonts_url() {
$fonts_url = '';
$Playfair = _x( 'on', 'Playfair Display font: on or off', 'angllia' );
$Montserrat = _x( 'on', 'Montserrat font: on or off', 'angllia' );
$Cantata_one = _x( 'on', 'Cantata+One font: on or off', 'angllia' );
$Limelight = _x( 'on', 'Limelight font: on or off', 'angllia' );
$Chivo = _x( 'on', 'Chivo font: on or off', 'angllia' );
$Merriweather = _x( 'on', 'Merriweather font: on or off', 'angllia' );
$Droid_serif = _x( 'on', 'Droid+Serif font: on or off', 'angllia' );
$Old_standard = _x( 'on', 'Old+Standard+TT font: on or off', 'angllia' );
$Ptsans = _x( 'on', 'PT Sans font: on or off', 'angllia' );
$open_sans = _x( 'on', 'Open Sans font: on or off', 'angllia' );
$Dawning = _x( 'on', 'Dawning font: on or off', 'angllia' );
$lato = _x( 'on', 'Lato font: on or off', 'angllia' );
if ( 'off' !== $Chivo || 'off' !== $Limelight || 'off' !== $Cantata_one || 'off' !== $Montserrat || 'off' !== $Dawning || 'off' !== $Playfair || 'off' !== $Droid_serif || 'off' !== $Old_standard || 'off' !== $Ptsans || 'off' !== $open_sans || 'off' !== $Merriweather || 'off' !== $lato ) {
$font_families = array();
if ( 'off' !== $Montserrat ) {
$font_families[] = 'Montserrat';
}
if ( 'off' !== $Chivo ) {
$font_families[] = 'Chivo';
}
if ( 'off' !== $Limelight ) {
$font_families[] = 'Limelight';
}
if ( 'off' !== $Cantata_one ) {
$font_families[] = 'Cantata One';
}
if ( 'off' !== $Dawning ) {
$font_families[] = 'Dawning of a New Day';
}
if ( 'off' !== $Playfair ) {
$font_families[] = 'Playfair Display:400,400italic,700,700italic';
}
if ( 'off' !== $Merriweather ) {
$font_families[] = 'Merriweather:400,400italic';
}
if ( 'off' !== $Droid_serif ) {
$font_families[] = 'Droid Serif:400,400italic,700';
}
if ( 'off' !== $Old_standard ) {
$font_families[] = 'Old Standard TT:400,400italic,700';
}
if ( 'off' !== $Ptsans ) {
$font_families[] = 'PT Sans:400,700,400italic,700italic';
}
if ( 'off' !== $open_sans ) {
$font_families[] = 'Open Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800&subset=latin,vietnamese';
}
if ( 'off' !== $lato ) {
$font_families[] = 'Lato:400,700,300,100,300italic,400italic,700italic';
}
$query_args = array(
'family' => urlencode( implode( '|', $font_families ) ),
'subset' => urlencode( 'latin,latin-ext' ),
);
$fonts_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' );
}
add_editor_style( str_replace( ',', '%2C', $fonts_url ) );
return esc_url_raw( $fonts_url );
}
/*
function rst_fonts_admin_url() {
$query_args = array(
'family' => $rs_global_google_font_family_out
);
wp_register_style( 'rst_custom_enqueue_google_font', add_query_arg( $query_args, "//fonts.googleapis.com/css" ), array(), null );
wp_enqueue_style( 'rst_custom_enqueue_google_font' );
$link_font = add_query_arg( $query_args, "//fonts.googleapis.com/css" );
add_editor_style( str_replace( ',', '%2C', $link_font ) );
}
*/
function rst_slug_scripts_styles() {
wp_enqueue_style( 'rst-fonts', rst_fonts_url(), array(), null );
}
add_action( 'wp_enqueue_scripts', 'rst_slug_scripts_styles' );
add_action( 'admin_enqueue_scripts', 'rst_slug_scripts_styles' );
function rst_backend_enqueue() {
wp_enqueue_style( 'my_custom_script', esc_url( get_template_directory_uri() ) .'/inc/css/style-backend.css' );
}
add_action( 'admin_enqueue_scripts', 'rst_backend_enqueue', 10000 );
function rst_jquery_block() {
?>
'Select Sidebar'
);
foreach ($GLOBALS['wp_registered_sidebars'] as $sidebar) {
$sidebar_options[$sidebar['id']] = $sidebar['name'];
}
return $sidebar_options;
}
add_action('init','rst_get_my_widgets');
/**
* Load Jetpack compatibility file.
*/
require get_template_directory() . '/inc/jetpack.php';
function rst_get_attachment_image_src( $attributes_id, $size ){
$attributes = wp_get_attachment_image_src( $attributes_id, $size );
return $attributes[0];
}
//Get page by template-name.php
function rst_get_page_by_template_name($template_name = ''){
$pages = get_pages(array(
'meta_key' => '_wp_page_template',
'meta_value' => (string) $template_name
));
foreach($pages as $page){
$post_id = $page->ID;
}
$post_id = isset($post_id) ? $post_id : null;
return($post_id);
}
/*
* Function Count View
*/
function rst_set_post_views($postID) {
$count_key = 'rst_post_views_count';
$count = get_post_meta($postID, $count_key, true);
if($count==''){
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, '1');
}else{
$count++;
update_post_meta($postID, $count_key, $count);
}
}
function rst_track_post_views ($post_id) {
if ( !is_single() ) return;
if ( empty ( $post_id) ) {
global $post;
$post_id = $post->ID;
}
rst_set_post_views($post_id);
}
//To keep the count accurate, lets get rid of prefetching
add_action( 'wp_head', 'rst_track_post_views');
function rst_get_post_views($postID){
$count_key = 'rst_post_views_count';
$count = get_post_meta($postID, $count_key, true);
if($count=='' || $count <= 1 ){
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, '1');
return "1 View";
}
return $count.' Views';
}
/*
* Function Get Excerpt
*/
function rst_get_excerpt_by_id($post, $length = 0, $tags = '', $extra = '...') {
if(is_int($post)) {
$post = get_post($post);
} elseif(!is_object($post)) {
return false;
}
if( is_object($post) ) setup_postdata($post);
if($length == 0) return apply_filters('the_content', $post->post_content);
// $the_excerpt = apply_filters( 'get_the_excerpt', $post->post_excerpt );
$the_excerpt = ( empty($post->post_excerpt) ) ? $post->post_content : $post->post_excerpt;
$the_excerpt = strip_shortcodes(strip_tags($the_excerpt), $tags);
$the_excerpt = preg_split('/\b/', $the_excerpt, $length * 2+1);
$excerpt_waste = array_pop($the_excerpt);
$the_excerpt = implode($the_excerpt);
$the_excerpt = trim($the_excerpt);
$the_excerpt = str_replace("\n","",$the_excerpt);
$the_excerpt = str_replace("\r","",$the_excerpt);
if( $the_excerpt != '' )
$the_excerpt .= $extra;
wp_reset_postdata();
return apply_filters('the_content', $the_excerpt);
}
if(!function_exists('rst_crop_content')) {
function rst_crop_content($input = "", $number = 9999){
if(!is_int($number))
$number=999;
if($input!=""){
if($number==""){
return $input;
}
else{
$array_crop_content = array();
$array_crop_content = explode(" ", $input);
$result_content = '';
for($i=0; $i<$number; $i++){
if(isset($array_crop_content[$i])){
$result_content .= $array_crop_content[$i] . " ";
}
}
return $result_content;
}
}
else
return "";
}
}
add_action('init','rst_get_excerpt_by_id');
function rst_get_template_part( $slug, $name="" ) {
ob_start();
get_template_part( $slug, $name );
return ob_get_clean();
}
function rst_no_set_menu() {
if ( current_user_can('manage_options') ) {
echo '';
}
}
function rst_get_the_archive_title($before="",$after="") {
if ( is_category() ) {
$title = '' . rst_get_translate('Browsing Category','translation_category') .': '. '' . single_cat_title( '', false ) . '
';
} elseif ( is_tag() ) {
$title = ''. rst_get_translate('Browsing Tag','browsing_tag') .': '. '' . single_tag_title( '', false ) . '
';
} elseif ( is_author() ) {
$title = ''. rst_get_translate('Author','translation_author') .': '. '' . single_tag_title( '', false ) . '
';
} elseif ( is_year() ) {
$title = ''. rst_get_translate('Yearly Archives','yearly_archives').': '. '' . get_the_date( 'Y') . '
';
} elseif ( is_month() ) {
$title = ''. rst_get_translate('Monthly Archives','monthly_archives').': '. '' . get_the_date( 'F Y') . '
';
} elseif ( is_day() ) {
$title = ''. rst_get_translate('Daily Archives','daily_archives').': '. '' . get_the_date( 'F j, Y') . '
';
} elseif ( is_tax( 'post_format' ) ) {
if ( is_tax( 'post_format', 'post-format-aside' ) ) {
$title = 'Asides';
} elseif ( is_tax( 'post_format', 'post-format-gallery' ) ) {
$title = 'Galleries';
} elseif ( is_tax( 'post_format', 'post-format-image' ) ) {
$title = 'Images';
} elseif ( is_tax( 'post_format', 'post-format-video' ) ) {
$title = 'Videos';
} elseif ( is_tax( 'post_format', 'post-format-quote' ) ) {
$title = 'Quotes';
} elseif ( is_tax( 'post_format', 'post-format-link' ) ) {
$title = 'Links';
} elseif ( is_tax( 'post_format', 'post-format-status' ) ) {
$title = 'Statuses';
} elseif ( is_tax( 'post_format', 'post-format-audio' ) ) {
$title = 'Audio';
} elseif ( is_tax( 'post_format', 'post-format-chat' ) ) {
$title = 'Chats';
}
} elseif ( is_post_type_archive() ) {
$title = ''.rst_get_translate('Archives','translation_archives') .': ' . '' . post_type_archive_title( '', false ) . '
';
} elseif ( is_tax() ) {
$tax = get_taxonomy( get_queried_object()->taxonomy );
/* translators: 1: Taxonomy singular name, 2: Current taxonomy term */
$title = $tax->labels->singular_name. ': '. '' . single_term_title( '', false ) . '
';
} else {
$title = rst_get_translate('Archives','translation_archives');
}
/**
* Filter the archive title.
*
* @since 4.1.0
*
* @param string $title Archive title to be displayed.
*/
return apply_filters( 'get_the_archive_title', $before.$title.$after );
}
add_filter( 'request', 'fuly_alter_the_query' );
function fuly_alter_the_query( $request ) {
if( isset($request['paged']) && !(is_admin()) ){
$request['posts_per_page'] = 1;
}
return $request;
}
}
endif;
add_action( 'after_setup_theme', 'fully_setup' );