'; } } add_action('wp_head', 'accesspress_mag_header_scripts'); /*---------Enqueue custom admin panel JS---------------*/ function accesspress_mag_admin_scripts(){ wp_enqueue_script('accesspress-mag-custom-admin', get_template_directory_uri(). '/inc/option-framework/js/custom-admin.js', array( 'jquery')); } add_action('admin_enqueue_scripts','accesspress_mag_admin_scripts'); /*---------Enqueue admin css---------------*/ function accesspress_mag_admin_css(){ wp_enqueue_style('accesspress-mag-admin', get_template_directory_uri(). '/inc/option-framework/css/accesspress-mag-admin.css'); } add_action('admin_head','accesspress_mag_admin_css'); /*-----------------------Homepage slider--------------------------*/ function accesspress_mag_slider_cb(){ $slider_category = of_get_option( 'homepage_slider_category' ); if(empty($slider_category)){ $slider_category=''; } $slide_count = of_get_option( 'count_slides' ); $slide_info = of_get_option( 'slider_info' ); $posts_perpage_value = $slide_count*4; $slider_args = array( 'category_name'=>$slider_category, 'post_type'=>'post', 'post_status'=>'publish', 'posts_per_page'=>$posts_perpage_value, 'order'=>'DESC', 'meta_query' => array( array( 'key' => '_thumbnail_id', 'compare' => '!=', 'value' => null ) ) ); $slider_query = new WP_Query($slider_args); $slide_counter = 0; if($slider_query->have_posts()) { echo '
'; while($slider_query->have_posts()) { $slide_counter++; $slider_query->the_post(); $post_image_id = get_post_thumbnail_id(); $post_big_image_path = wp_get_attachment_image_src( $post_image_id, 'accesspress-mag-slider-big-thumb', true ); $post_small_image_path = wp_get_attachment_image_src( $post_image_id, 'accesspress-mag-slider-small-thumb', true ); $post_image_alt = get_post_meta( $post_image_id, '_wp_attachment_image_alt', true ); if($slide_counter%4==1): ?>
name ); ?>
<?php echo esc_attr($post_image_alt);?>

';}?>
name ); ?>
<?php echo esc_attr($post_image_alt);?>

'; } } add_action( 'accesspress_mag_slider', 'accesspress_mag_slider_cb', 10 ); function accesspress_mag_slider_script(){ $slider_controls = ( of_get_option( 'slider_controls' ) == "1" ) ? "true" : "false"; $slider_auto_transaction = ( of_get_option( 'slider_auto_transition' ) == "1" ) ? "true" : "false"; $slider_pager = ( of_get_option( 'slider_pager' ) == "1" ) ? "true" : "false"; ?> ID, 'accesspress_mag_sidebar_layout', true ); $page_sidebar = get_post_meta( $post -> ID, 'accesspress_mag_page_sidebar_layout', true ); if('post'==get_post_type()){ if($post_sidebar=='global-sidebar'){ $post_class = $global_sidebar; } else { $post_class = $post_sidebar; } $classes[] = 'single-post-'.$post_class; } else { $classes[] = 'page-'.$page_sidebar; } } elseif(is_archive()){ $archive_sidebar = of_get_option( 'global_archive_sidebar' ); $classes[] = 'archive-'.$archive_sidebar; } elseif(is_search()){ $archive_sidebar = of_get_option( 'global_archive_sidebar' ); $classes[] = 'archive-'.$archive_sidebar; }else{ $classes[] = 'page-right-sidebar'; } return $classes; } add_filter( 'body_class', 'accesspress_mag_sidebar_layout_class' ); /*--------------Template style layout for post & pages----------------------*/ function accesspress_mag_template_layout_class($classes){ global $post; if( is_404()){ $classes[] = ' '; }elseif(is_singular()){ $global_template= of_get_option( 'global_post_template' ); $post_template = get_post_meta( $post -> ID, 'accesspress_mag_post_template_layout', true ); if('post'==get_post_type()){ if($post_template=='global-template'){ $post_template_class = $global_template; } else { $post_template_class = $post_template; } $classes[] = 'single-post-'.$post_template_class; } } elseif(is_archive()){ $archive_template = of_get_option( 'global_archive_template' ); $classes[] = 'archive-page-'.$archive_template; } elseif(is_search()){ $archive_template = of_get_option( 'global_archive_template' ); $classes[] = 'archive-page-'.$archive_template; }else{ $classes[] = 'page-default-template'; } return $classes; } add_filter( 'body_class', 'accesspress_mag_template_layout_class' ); /*---------------------Website layout---------------------------------*/ function accesspress_mag_website_layout_class( $classes ){ $website_layout = of_get_option( 'website_layout_option' ); if($website_layout == 'boxed' ){ $classes[] = 'boxed-layout'; } else { $classes[] = 'fullwidth-layout'; } return $classes; } add_filter( 'body_class', 'accesspress_mag_website_layout_class' ); /*----------------------Meta post on -----------------------------------*/ function accesspress_mag_post_meta_cb(){ global $post; $show_post_views = of_get_option('show_post_views'); $show_comment_count = of_get_option('show_comment_count'); if($show_comment_count==1){ $post_comment_count = get_comments_number( $post->ID ); echo ''.esc_attr( $post_comment_count ).''; } if($show_post_views==1){ echo ''.esc_html( accesspress_mag_getPostViews(get_the_ID()) ).''; } } add_action( 'accesspress_mag_post_meta', 'accesspress_mag_post_meta_cb', 10 ); function accesspress_mag_home_posted_on_cb(){ global $post; $show_post_views = of_get_option('show_post_views'); $show_comment_count = of_get_option('show_comment_count'); $show_post_date = of_get_option('post_show_date'); $time_string = ''; if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) { $time_string = ''; } $time_string = sprintf( $time_string, esc_attr( get_the_date( 'c' ) ), esc_html( get_the_date() ), esc_attr( get_the_modified_date( 'c' ) ), esc_html( get_the_modified_date() ) ); if($show_post_date==1){ $posted_on = sprintf( _x( '%s', 'post date', 'accesspress-mag' ), '' . $time_string . '' ); } else { $posted_on = ''; } echo '' . $posted_on . ''; if($show_comment_count==1){ $post_comment_count = get_comments_number( $post->ID ); echo ''.esc_attr( $post_comment_count ).''; } if($show_post_views==1){ echo ''.esc_html( accesspress_mag_getPostViews(get_the_ID()) ).''; } } add_action( 'accesspress_mag_home_posted_on', 'accesspress_mag_home_posted_on_cb', 10 ); /*-------------------Excerpt length---------------------*/ function accesspress_mag_customize_excerpt_more( $more ) { return '...'; } add_filter( 'excerpt_more', 'accesspress_mag_customize_excerpt_more' ); function accesspress_mag_word_count( $string, $limit ) { $string = strip_tags( $string ); $string = strip_shortcodes( $string ); $words = explode( ' ', $string ); return implode( ' ', array_slice( $words, 0, $limit )); } function accesspress_mag_letter_count( $content, $limit ) { $striped_content = strip_tags( $content ); $striped_content = strip_shortcodes( $striped_content ); $limit_content = mb_substr( $striped_content, 0 , $limit ); if( $limit_content < $content ){ $limit_content .= "..."; } return $limit_content; } /*---------------Get excerpt content-------------------*/ function accesspress_mag_excerpt(){ global $post; $excerpt_type = of_get_option( 'excerpt_type' ); $excerpt_length = of_get_option( 'excerpt_lenght' ); $excerpt_content = get_the_content($post -> ID); //$excerpt_content = get_post_field('post_content', $post -> ID); if( $excerpt_type == 'letters' ){ $excerpt_content = accesspress_mag_letter_count( $excerpt_content, $excerpt_length ); } else { $excerpt_content = accesspress_mag_word_count( $excerpt_content, $excerpt_length ); } echo '

'. $excerpt_content .'

'; } /*---------------- BreadCrumb --------------------------*/ function accesspress_mag_breadcrumbs() { global $post; $trans_here = of_get_option( 'trans_you_are_here' ); if( empty( $trans_here ) ){ $trans_here = __( 'You are here', 'accesspress-mag' ); } $trans_home = of_get_option( 'trans_home' ); if( empty( $trans_home ) ){ $trans_home = __( 'Home', 'accesspress-mag' ); } $trans_search = of_get_option( '' ); //if( empty() ) $showOnHome = 0; // 1 - show breadcrumbs on the homepage, 0 - don't show $delimiter = ' > '; // delimiter between crumbs $home = $trans_home; // text for the 'Home' link $showHomeLink = of_get_option( 'show_home_link_breadcrumbs' ); $showCurrent = of_get_option( 'show_article_breadcrumbs' ); // 1 - show current post/page title in breadcrumbs, 0 - don't show $before = ''; // tag before the current crumb $after = ''; // tag after the current crumb $homeLink = home_url(); if (is_home() || is_front_page()) { if ($showOnHome == 1) echo '
' . $home . '
'; } else { if($showHomeLink == 1){ echo '
'.esc_attr( $trans_here ).'
' . $home . ' ' . $delimiter . ' '; } else { echo '
'.esc_attr( $trans_here ).'
' . $home . ' ' . $delimiter . ' '; } if ( is_category() ) { $thisCat = get_category(get_query_var('cat'), false); if ($thisCat->parent != 0) echo get_category_parents($thisCat->parent, TRUE, ' ' . $delimiter . ' '); echo $before . single_cat_title('', false) . $after; } elseif ( is_search() ) { echo $before . __( "Search results for", "accesspress-mag" ).' "' . get_search_query() . '"' . $after; } elseif ( is_day() ) { echo '' . get_the_time('Y') . ' ' . $delimiter . ' '; echo '' . get_the_time('F') . ' ' . $delimiter . ' '; echo $before . get_the_time('d') . $after; } elseif ( is_month() ) { echo '' . get_the_time('Y') . ' ' . $delimiter . ' '; echo $before . get_the_time('F') . $after; } elseif ( is_year() ) { echo $before . get_the_time('Y') . $after; } elseif ( is_single() && !is_attachment() ) { if ( get_post_type() != 'post' ) { $post_type = get_post_type_object(get_post_type()); $slug = $post_type->rewrite; echo '' . $post_type->labels->singular_name . ''; if ($showCurrent == 1) echo ' ' . $delimiter . ' ' . $before . get_the_title() . $after; } else { $cat = get_the_category(); $cat = $cat[0]; $cats = get_category_parents($cat, TRUE, ' ' . $delimiter . ' '); if ($showCurrent == 0) $cats = preg_replace("#^(.+)\s$delimiter\s$#", "$1", $cats); echo $cats; if ($showCurrent == 1) echo $before . get_the_title() . $after; } } elseif ( !is_single() && !is_page() && get_post_type() != 'post' && !is_404() ) { $post_type = get_post_type_object(get_post_type()); echo $before . $post_type->labels->singular_name . $after; } elseif ( is_attachment() ) { $parent = get_post($post->post_parent); $cat = get_the_category($parent->ID); $cat = $cat[0]; echo get_category_parents($cat, TRUE, ' ' . $delimiter . ' '); echo '' . $parent->post_title . ''; if ($showCurrent == 1) echo ' ' . $delimiter . ' ' . $before . get_the_title() . $after; } elseif ( is_page() && !$post->post_parent ) { if ($showCurrent == 1) echo $before . get_the_title() . $after; } elseif ( is_page() && $post->post_parent ) { $parent_id = $post->post_parent; $breadcrumbs = array(); while ($parent_id) { $page = get_page($parent_id); $breadcrumbs[] = '' . get_the_title($page->ID) . ''; $parent_id = $page->post_parent; } $breadcrumbs = array_reverse($breadcrumbs); for ($i = 0; $i < count($breadcrumbs); $i++) { echo $breadcrumbs[$i]; if ($i != count($breadcrumbs)-1) echo ' ' . $delimiter . ' '; } if ($showCurrent == 1) echo ' ' . $delimiter . ' ' . $before . get_the_title() . $after; } elseif ( is_tag() ) { echo $before . 'Posts tagged "' . single_tag_title('', false) . '"' . $after; } elseif ( is_author() ) { global $author; $userdata = get_userdata($author); echo $before . 'Author: ' . $userdata->display_name . $after; } elseif ( is_404() ) { echo $before . 'Error 404' . $after; } else { } if ( get_query_var('paged') ) { if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) echo ' ('; echo __('Page' , 'accesspress-mag') . ' ' . get_query_var('paged'); if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) echo ')'; } echo '
'; } } /*--------------WooCommerce breadcrumbs---------------------*/ add_filter( 'woocommerce_breadcrumb_defaults', 'accesspress_mag_woocommerce_breadcrumbs' ); function accesspress_mag_woocommerce_breadcrumbs() { $seperator = ' > '; //$seperator =of_get_option( 'breadcrumb_seperator' ); $trans_home = of_get_option( 'trans_home' ); if( empty( $trans_home ) ){ $trans_home = __( 'Home', 'accesspress-mag' ); } $home_text = $trans_home ; $trans_here = of_get_option( 'trans_you_are_here' ); if( empty( $trans_here ) ){ $trans_here = __( 'You are here', 'accesspress-mag' ); } //$home_text =of_get_option( 'breadcrumb_home' ); return array( 'delimiter' => " ".$seperator." ", 'before' => '', 'after' => '', 'wrap_before' => '', 'home' => _x( $home_text, 'breadcrumb', 'woocommerce' ), ); } add_action( 'init', 'accesspress_mag_remove_wc_breadcrumbs' ); function accesspress_mag_remove_wc_breadcrumbs() { remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0 ); } $accesspress_show_breadcrumb = of_get_option( 'show_hide_breadcrumbs' ); if((function_exists('accesspress_mag_woocommerce_breadcrumbs') && $accesspress_show_breadcrumb == 1)) { add_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 10, 0 ); } /*------------Remove bbpress breadcrumbs-----------------------*/ function accesspress_mag_bbp_no_breadcrumb ($arg){ return true ; } add_filter('bbp_no_breadcrumb', 'accesspress_mag_bbp_no_breadcrumb' ); /*--------------Install Required Plugins----------------------*/ function accesspress_mag_required_plugins() { /** * Array of plugin arrays. Required keys are name and slug. * If the source is NOT from the .org repo, then source is also required. */ $plugins = array( // This is an example of how to include a plugin pre-packaged with a theme. array( 'name' => __( 'Newsletter', 'accesspress-mag' ), //The plugin name 'slug' => 'newsletter', // The plugin slug (typically the folder name) 'required' => false, // If false, the plugin is only 'recommended' instead of required. 'force_activation' => false, // If true, plugin is activated upon theme activation and cannot be deactivated until theme switch. 'force_deactivation' => false, // If true, plugin is deactivated upon theme switch, useful for theme-specific plugins. ), array( 'name' => __( 'AccessPress Social Icons', 'accesspress-mag' ), //The plugin name 'slug' => 'accesspress-social-icons', // The plugin slug (typically the folder name) 'required' => false, // If false, the plugin is only 'recommended' instead of required. 'force_activation' => false, // If true, plugin is activated upon theme activation and cannot be deactivated until theme switch. 'force_deactivation' => false, // If true, plugin is deactivated upon theme switch, useful for theme-specific plugins. ), array( 'name' => __( 'AccessPress Social Counter', 'accesspress-mag' ), //The plugin name 'slug' => 'accesspress-social-counter', // The plugin slug (typically the folder name) 'required' => false, // If false, the plugin is only 'recommended' instead of required. 'force_activation' => false, // If true, plugin is activated upon theme activation and cannot be deactivated until theme switch. 'force_deactivation' => false, // If true, plugin is deactivated upon theme switch, useful for theme-specific plugins. ), array( 'name' => __( 'AccessPress Social Share', 'accesspress-mag' ), //The plugin name 'slug' => 'accesspress-social-share', // The plugin slug (typically the folder name) 'required' => false, // If false, the plugin is only 'recommended' instead of required. 'force_activation' => false, // If true, plugin is activated upon theme activation and cannot be deactivated until theme switch. 'force_deactivation' => false, // If true, plugin is deactivated upon theme switch, useful for theme-specific plugins. ), ); /** * Array of configuration settings. Amend each line as needed. * If you want the default strings to be available under your own theme domain, * leave the strings uncommented. * Some of the strings are added into a sprintf, so see the comments at the * end of each line for what each argument will be. */ $config = array( 'default_path' => '', // Default absolute path to pre-packaged plugins. 'menu' => 'accesspress-install-plugins', // Menu slug. 'has_notices' => true, // Show admin notices or not. 'dismissable' => true, // If false, a user cannot dismiss the nag message. 'dismiss_msg' => '', // If 'dismissable' is false, this message will be output at top of nag. 'is_automatic' => true, // Automatically activate plugins after installation or not. 'message' => '', // Message to output right before the plugins table. 'strings' => array( 'page_title' => __( 'Install Required Plugins', 'accesspress-mag' ), 'menu_title' => __( 'Install Plugins', 'accesspress-mag' ), 'installing' => __( 'Installing Plugin: %s', 'accesspress-mag' ), // %s = plugin name. 'oops' => __( 'Something went wrong with the plugin API.', 'accesspress-mag' ), 'notice_can_install_required' => _n_noop( 'This theme requires the following plugin: %1$s.', 'This theme requires the following plugins: %1$s.' ), // %1$s = plugin name(s). 'notice_can_install_recommended' => _n_noop( 'This theme recommends the following plugin: %1$s.', 'This theme recommends the following plugins: %1$s.' ), // %1$s = plugin name(s). 'notice_cannot_install' => _n_noop( 'Sorry, but you do not have the correct permissions to install the %s plugin. Contact the administrator of this site for help on getting the plugin installed.', 'Sorry, but you do not have the correct permissions to install the %s plugins. Contact the administrator of this site for help on getting the plugins installed.' ), // %1$s = plugin name(s). 'notice_can_activate_required' => _n_noop( 'The following required plugin is currently inactive: %1$s.', 'The following required plugins are currently inactive: %1$s.' ), // %1$s = plugin name(s). 'notice_can_activate_recommended' => _n_noop( 'The following recommended plugin is currently inactive: %1$s.', 'The following recommended plugins are currently inactive: %1$s.' ), // %1$s = plugin name(s). 'notice_cannot_activate' => _n_noop( 'Sorry, but you do not have the correct permissions to activate the %s plugin. Contact the administrator of this site for help on getting the plugin activated.', 'Sorry, but you do not have the correct permissions to activate the %s plugins. Contact the administrator of this site for help on getting the plugins activated.' ), // %1$s = plugin name(s). 'notice_ask_to_update' => _n_noop( 'The following plugin needs to be updated to its latest version to ensure maximum compatibility with this theme: %1$s.', 'The following plugins need to be updated to their latest version to ensure maximum compatibility with this theme: %1$s.' ), // %1$s = plugin name(s). 'notice_cannot_update' => _n_noop( 'Sorry, but you do not have the correct permissions to update the %s plugin. Contact the administrator of this site for help on getting the plugin updated.', 'Sorry, but you do not have the correct permissions to update the %s plugins. Contact the administrator of this site for help on getting the plugins updated.' ), // %1$s = plugin name(s). 'install_link' => _n_noop( 'Begin installing plugin', 'Begin installing plugins' ), 'activate_link' => _n_noop( 'Begin activating plugin', 'Begin activating plugins' ), 'return' => __( 'Return to Required Plugins Installer', 'accesspress-mag' ), 'plugin_activated' => __( 'Plugin activated successfully.', 'accesspress-mag' ), 'complete' => __( 'All plugins installed and activated successfully. %s', 'accesspress-mag' ), // %s = dashboard link. 'nag_type' => 'updated' // Determines admin notice type - can only be 'updated', 'update-nag' or 'error'. ) ); tgmpa( $plugins, $config ); } add_action( 'tgmpa_register', 'accesspress_mag_required_plugins' );