array(
'url' => '%s/images/home-bg-thumb.jpg',
'thumbnail_url' => '%s/images/bg-01.jpg',
'description' => esc_html__('Wheel', 'asycom')
)
));
$defaults_custom_header = array(
'default-image' => ASYCOM_IMAGES . '/bg-01.jpg',
'width' => 1366,
'height' => 600,
'flex-height' => false,
'flex-width' => false,
'uploads' => true,
'random-default' => false,
'header-text' => true,
'default-text-color' => '',
'wp-head-callback' => '',
'admin-head-callback' => '',
'admin-preview-callback' => '',
);
add_theme_support('custom-header', $defaults_custom_header);
/* Add support for title tag. */
add_theme_support('title-tag');
/* Add support for gallery. */
add_theme_support('html5', array(
'search-form',
'comment-form',
'comment-list',
'gallery',
'caption',
));
/* Add support for post thumbnails. */
add_theme_support('post-thumbnails');
/* Register nav menus. */
register_nav_menus(array(
'primary' => esc_html__('Primary (Main Menu)', 'asycom')
));
$custom_logo_defaults = array(
'height' => 256,
'width' => 65,
'flex-height' => true,
'flex-width' => true,
'header-text' => array('site-title', 'site-description'),
);
add_theme_support('custom-logo', $custom_logo_defaults);
}
add_action('after_setup_theme', 'asycom_theme_setup');
}
/* -------------------------------------------
* 3 - GET POST META
* ------------------------------------------- */
if (!function_exists('asycom_post_meta')) {
function asycom_post_meta($args=null) {
if (get_post_type() === 'post') {
if (!empty($args) && is_array($args) && $args["cats"] != false) {
$categories_list = get_the_category_list(' ');
if (!empty($categories_list)) {
printf('
%1$s
',$categories_list);
}
}
if (!empty($args) && is_array($args) && $args["tags"] != false) {
if (get_the_tag_list()) {
echo get_the_tag_list('');
}
}
echo '' . esc_html__('By', 'asycom');
printf(' %2$s ', esc_url(get_author_posts_url(get_the_author_meta('ID'))), get_the_author());
esc_attr_e('on', 'asycom');
echo ' ' . esc_html(get_the_date()) . '
';
}
}
}
/* -------------------------------------------
* 4 - PAGINATION
* ------------------------------------------- */
if (!function_exists('asycom_pagination')) {
function asycom_pagination() {
$args = array(
'prev_next' => false,
'type' => 'array'
);
$pagination = paginate_links($args);
if (is_array($pagination)) {
echo '';
}
}
}
/* -------------------------------------------
* 5 - REGISTER WIDGET AREAS
* ------------------------------------------- */
if (!function_exists('asycom_widget_init')) {
function asycom_widget_init() {
if (function_exists('register_sidebar')) {
register_sidebar(array(
'name' => esc_html__('Main Widget Area', 'asycom'),
'id' => 'main-sidebar',
'description' => esc_html__('Appears in the blog pages', 'asycom'),
'before_widget' => '',
'after_widget' => '
',
'before_title' => ''
));
register_sidebar(array(
'name' => esc_html__('Footer 1', 'asycom'),
'id' => 'footer-1',
'description' => esc_html__('Add widgets here to appear in your footer area 1.', 'asycom'),
'before_widget' => '',
'before_title' => '',
));
register_sidebar(array(
'name' => esc_html__('Footer 2', 'asycom'),
'id' => 'footer-2',
'description' => esc_html__('Add widgets here to appear in your footer area 2.', 'asycom'),
'before_widget' => '',
'before_title' => '',
));
register_sidebar(array(
'name' => esc_html__('Footer 3', 'asycom'),
'id' => 'footer-3',
'description' => esc_html__('Add widgets here to appear in your footer area 3.', 'asycom'),
'before_widget' => '',
'before_title' => '',
));
register_sidebar(array(
'name' => esc_html__('Footer 4', 'asycom'),
'id' => 'footer-4',
'description' => esc_html__('Add widgets here to appear in your footer area 4.', 'asycom'),
'before_widget' => '',
'before_title' => '',
));
}
}
add_action('widgets_init', 'asycom_widget_init');
}
/* -------------------------------------------
* 6 - REGISTER Scripts
* ------------------------------------------- */
if (!function_exists('asycom_scripts')) {
function asycom_scripts() {
/* Register scripts */
wp_register_script('bootstrap-js', ASYCOM_JS . '/bootstrap.js', array('jquery'), false, false, TRUE);
wp_register_script('slim-menu', ASYCOM_JS . '/jquery.slimmenu.min.js', array('jquery'), false, false, true);
wp_register_script('in-view', ASYCOM_JS . '/in-view.min.js', array('jquery'), false, false, true);
wp_register_script('percircle', ASYCOM_JS . '/percircle.min.js', array('jquery'), false, false, true);
wp_register_script('masonry-v4', ASYCOM_JS . '/masonry.pkgd.min.js', false, false, false);
wp_register_script('main-js', ASYCOM_JS . '/main.js', false, false, true);
/* Load scripts */
wp_enqueue_script('bootstrap-js');
wp_enqueue_script('in-view');
wp_enqueue_script('jquery-easing');
wp_enqueue_script('slim-menu');
wp_enqueue_script('percircle');
wp_enqueue_script('masonry-v4');
wp_enqueue_script('main-js');
if (is_singular()) {
wp_enqueue_script("comment-reply");
}
/* Load stylesheets */
wp_enqueue_style('bootstrap-css', ASYCOM_THEMEROOT . '/assets/css/bootstrap.css');
wp_enqueue_style('slim-menu-css', ASYCOM_THEMEROOT . '/assets/css/slimmenu.min.css');
wp_enqueue_style('animate-css', ASYCOM_THEMEROOT . '/assets/css/animate.css');
wp_enqueue_style('percircle-css', ASYCOM_THEMEROOT . '/assets/css/percircle.min.css');
wp_enqueue_style('main-css', ASYCOM_THEMEROOT . '/assets/css/main.css');
wp_enqueue_style('google-font', 'https://fonts.googleapis.com/css?family=Raleway:100,200,300,400,700');
}
add_action('wp_enqueue_scripts', 'asycom_scripts');
}
/* -------------------------------------------
* 7 - COMMENTS NAV
* ------------------------------------------- */
if (!function_exists('asycom_comment_nav')) {
function asycom_comment_nav() {
// Are there comments to navigate through?
if (get_comment_pages_count() > 1 && get_option('page_comments')) :
?>
';
return $items;
}
/* -------------------------------------------
* 9 - CONTENT WIDTH
* ------------------------------------------- */
function asycom_content_width() {
$GLOBALS['content_width'] = apply_filters('asycom_content_width', 750);
}
add_action('after_setup_theme', 'asycom_content_width', 0);
/* -------------------------------------------
* 10 - Excerpt Length
* ------------------------------------------- */
function asycom_excerpt_length($length) {
return 20;
}
add_filter('excerpt_length', 'asycom_excerpt_length', 999);
/* -------------------------------------------
* 11 - CUSTOMIZER
* ------------------------------------------- */
load_template(get_template_directory() . '/includes/customizer.php');
load_template(get_template_directory() . '/includes/alpha-color-picker/alpha-color-picker.php');
load_template(get_template_directory() . '/includes/controls/select/contact-form-7-customize.php');
load_template(get_template_directory() . '/includes/controls/select/taxonomy-dropdown-custom-control.php');
/* -----------------------------------------------------------------------------------
* 12 - COMMENT
* ----------------------------------------------------------------------------------- */
function asycom_get_discussion_data() {
static $discussion, $post_id;
$current_post_id = get_the_ID();
if ($current_post_id === $post_id) {
return $discussion; /* If we have discussion information for post ID, return cached object */
} else {
$post_id = $current_post_id;
}
$comments = get_comments(
array(
'post_id' => $current_post_id,
'orderby' => 'comment_date_gmt',
'order' => get_option('comment_order', 'asc'), /* Respect comment order from Settings ยป Discussion. */
'status' => 'approve',
'number' => 20, /* Only retrieve the last 20 comments, as the end goal is just 6 unique authors */
)
);
$authors = array();
foreach ($comments as $comment) {
$authors[] = ( (int) $comment->user_id > 0 ) ? (int) $comment->user_id : $comment->comment_author_email;
}
$authors = array_unique($authors);
$discussion = (object) array(
'authors' => array_slice($authors, 0, 6), /* Six unique authors commenting on the post. */
'responses' => get_comments_number($current_post_id), /* Number of responses. */
);
return $discussion;
}
/* -----------------------------------------------------------------------------------
* 13 - NAVIGATION WALKER
* ----------------------------------------------------------------------------------- */
function asycom_custom_walker() {
$args = array(
'container_class' => 'main-nav-wrapper',
'menu_class' => ' ',
'container_id' => 'main-menu-1',
'theme_location' => 'primary',
'container' => 'ul',
'menu_class' => 'slimmenu',
'menu_id' => ''
);
if (has_nav_menu('primary')) {
return false;
}
if (current_user_can('edit_theme_options')) {
$fb_output = null;
if ($args['container']) {
$fb_output = '<' . $args['container'];
if ($args['container_id']) {
$fb_output .= ' id="' . $args['container_id'] . '"';
}
if ($args['container_class']) {
$fb_output .= ' class="' . $args['container_class'] . '"';
}
$fb_output .= '>';
}
$fb_output .= 'Add a menu';
$fb_output .= '
';
if ($args['container']) {
$fb_output .= '' . $args['container'] . '>';
}
$allowed_html = array(
'a' => array(
'href' => array(),
),
'div' => array(
'id' => array(),
'class' => array(),
),
'ul' => array(
'class' => array(),
),
'li' => array(),
);
echo wp_kses($fb_output, $allowed_html);
}
}
function asycom_image_alt_by_url( $image_url ) {
global $wpdb;
if( empty( $image_url ) ) {
return false;
}
$query_arr = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE guid='%s';", strtolower( $image_url ) ) );
$image_id = ( ! empty( $query_arr ) ) ? $query_arr[0] : 0;
return get_post_meta( $image_id, '_wp_attachment_image_alt', true );
}