'; } /* $page_background_option = of_get_option('page_background_option'); $show_slider = of_get_option('show_slider'); echo ""; */ } add_action('wp_head', 'accesspress_header_scripts'); function apmag_admin_scripts(){ // Enqueue custom admin panel JS wp_enqueue_script( 'apmag-custom-admin', OPTIONS_FRAMEWORK_DIRECTORY . 'js/custom-admin.js', array( 'jquery') ); } add_action('admin_enqueue_scripts','apmag_admin_scripts'); /*-----------------------Homepage slider--------------------------*/ function accesspress_mag_slider_cb(){ $slider_category = of_get_option( 'homepage_slider_category' ); $trans_continue = of_get_option( 'trans_continue_reading' ); if( empty( $trans_continue ) ){ $trans_continue = 'Continue Reading'; } 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,'slider-big-thumb',true); $post_small_image_path = wp_get_attachment_image_src($post_image_id,'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);?>

'. accesspress_word_count(get_the_content(),27) .'

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

'; } else { get_template_part( 'demo-content/demo-slider-content'); } } add_action( 'accesspress_mag_slider', 'accesspress_mag_slider_cb', 10 ); function accesspress_mag_slider_script(){ $slider_category = of_get_option( 'homepage_slider_category' ); if( $slider_category!='0' ) { $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, 'product_review_option', true ); if( $post_review_type != 'norate' ){ $product_rating = get_post_meta($post -> ID, 'product_rating', true); $count = count($product_rating); $total_review = 0; foreach ($product_rating as $key => $value) { $star_value = $value[ 'feature_star' ]; $total_review = $total_review+$star_value; } $total_review = $total_review/$count; //$final_value = round( $total_review, 1, PHP_ROUND_HALF_UP); $final_value = ceiling($total_review, 0.5) ; echo display_product_rating($final_value); } } add_action( 'accesspress_mag_post_review', 'accesspress_mag_post_review_cb', 10 ); /*--------------------- Product Review for single post-----------------------------*/ function accesspress_mag_single_post_review_cb(){ global $post; $trans_summary = of_get_option( 'trans_summary' ); if( empty( $trans_summary ) ){ $trans_summary = 'Summary'; } $trans_review = of_get_option( 'trans_review_overview' ); if( empty( $trans_review ) ){ $trans_review = 'Review overview' ; } $post_review_type = get_post_meta( $post -> ID, 'product_review_option', true ); if($post_review_type!='norate'){ $product_rating_description = get_post_meta($post->ID, 'product_rate_description', true); ?>
ID, 'product_rating', true); $count = count($product_rating); echo '
'; $total_review = 0; foreach ($product_rating as $key => $value) { $featured_name = $value['feature_name']; $star_value = $value['feature_star']; if(empty($star_value)) $star_value = 0.5; $total_review = $total_review+$star_value; ?> '; $total_review = $total_review/$count; //$final_value = round( $total_review, 1); $final_value = ceiling($total_review, 0.5) ; ?>
'; } // Populate the half-rated star, if any if ( $fraction == 0.5 ) { echo ''; } // Populate the unrated stars, if any if ( $unrated > 0 ) { for ( $j=0; $j<$unrated; $j++ ) echo ''; } } } /*--------------------- Post Views-------------------*/ function getPostViews($postID){ $count_key = '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, '0'); return "0"; } return $count; } function setPostViews($postID) { $count_key = 'post_views_count'; $count = get_post_meta($postID, $count_key, true); if($count==''){ $count = 0; delete_post_meta($postID, $count_key); add_post_meta($postID, $count_key, '0'); }else{ $count++; update_post_meta($postID, $count_key, $count); } } // Remove issues with prefetching adding extra views remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0); /*-----------------Dynamic Css-------------------*/ function accesspress_pro_custom_css(){ $apmag_bg_image = of_get_option( 'site_background' ); $apmag_bg_color = of_get_option( 'site_background_color' ); $apmag_bg_reapet = of_get_option( 'repeat_background' ); $apmag_bg_position = of_get_option( 'position_background' ); $apmag_bg_attachment = of_get_option( 'attached_background' ); $apmag_bg_size = of_get_option( 'stretch_background' ); echo ''; } add_action('wp_head','accesspress_pro_custom_css'); /*--------------Sidebar layout for post & pages----------------------*/ function accesspress_mag_sidebar_layout_class($classes){ global $post; if( is_404()){ $classes[] = ' '; }elseif(is_singular()){ $global_sidebar= of_get_option( 'global_post_sidebar' ); $post_sidebar = get_post_meta( $post -> 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 ''.$post_comment_count.''; } if($show_post_views==1){ echo ''.getPostViews(get_the_ID()).''; } } add_action( 'accesspress_mag_post_meta', 'accesspress_mag_post_meta_cb', 10 ); /* function accesspress_mag_block_post_on_cb(){ global $post; $show_post_date = of_get_option('post_show_date'); $show_post_views = of_get_option('show_post_views'); $show_comment_count = of_get_option('show_comment_count'); if($show_post_date==1){ echo ''. get_the_date().''; } if($show_comment_count==1){ echo ''.get_comments_number( $post->ID ).''; } if($show_post_views==1){ echo ''.getPostViews(get_the_ID()).''; } } add_action( 'accesspress_mag_block_post_on', 'accesspress_mag_block_post_on_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 ''.$post_comment_count.''; } if($show_post_views==1){ echo ''.getPostViews(get_the_ID()).''; } } add_action( 'accesspress_mag_home_posted_on', 'accesspress_mag_home_posted_on_cb', 10 ); /*-------------------Excerpt length---------------------*/ function accesspress_customize_excerpt_more( $more ) { return '...'; } add_filter( 'excerpt_more', 'accesspress_customize_excerpt_more' ); function accesspress_word_count( $string, $limit ) { $words = explode( ' ', $string ); return implode( ' ', array_slice( $words, 0, $limit )); } function accesspress_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_letter_count( $excerpt_content, $excerpt_length ); } else { $excerpt_content = accesspress_word_count( $excerpt_content, $excerpt_length ); } echo '

'.$excerpt_content.'

'; } /*---------------- BreadCrumb --------------------------*/ function accesspress_breadcrumbs() { global $post; $trans_here = of_get_option( 'trans_you_are_here' ); if( empty( $trans_here ) ){ $trans_here = 'You are here'; } $trans_home = of_get_option( 'trans_home' ); if( empty( $trans_home ) ){ $trans_home = 'Home'; } $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 '
'; } else { if($showHomeLink == 1){ echo '
'.$trans_here.'
' . $home . ' ' . $delimiter . ' '; } else { echo '
'.$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_woocommerce_breadcrumbs' ); function accesspress_woocommerce_breadcrumbs() { $seperator = ' > '; //$seperator =of_get_option( 'breadcrumb_seperator' ); $trans_home = of_get_option( 'trans_home' ); if( empty( $trans_home ) ){ $trans_home = 'Home'; } $home_text = $trans_home ; $trans_here = of_get_option( 'trans_you_are_here' ); if( empty( $trans_here ) ){ $trans_here = 'You are here'; } //$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_remove_wc_breadcrumbs' ); function accesspress_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_woocommerce_breadcrumbs') && $accesspress_show_breadcrumb == 1)) { add_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 10, 0 ); } /*------------Remove bbpress breadcrumbs-----------------------*/ add_filter('bbp_no_breadcrumb', function($arg) { return true; } ); /*--------------Install Required Plugins----------------------*/ function accesspress_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', //The plugin name 'slug' => 'newsletter', // The plugin slug (typically the folder name) 'required' => true, // 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' => true, // If true, plugin is deactivated upon theme switch, useful for theme-specific plugins. ), array( 'name' => 'AccessPress Social Icons', //The plugin name 'slug' => 'accesspress-social-icons', // The plugin slug (typically the folder name) 'required' => true, // 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' => true, // If true, plugin is deactivated upon theme switch, useful for theme-specific plugins. ), array( 'name' => 'AccessPress Social Counter', //The plugin name 'slug' => 'accesspress-social-counter', // The plugin slug (typically the folder name) 'required' => true, // 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' => true, // If true, plugin is deactivated upon theme switch, useful for theme-specific plugins. ), array( 'name' => 'AccessPress Social Share', //The plugin name 'slug' => 'accesspress-social-share', // The plugin slug (typically the folder name) 'required' => true, // 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' => true, // 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' => false, // 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_required_plugins' ); //add_filter('show_admin_bar', '__return_false'); /*------For shordcode in widget text-----------------*/ add_filter('widget_text', 'do_shortcode'); /*---------Enqueue admin css---------------*/ function accesspress_mag_admin_css(){ wp_enqueue_style('apmag-admin', get_template_directory_uri(). '/inc/option-framework/css/apmag-admin.css'); } add_action('admin_head','accesspress_mag_admin_css'); /*---------Check audio file--------------*/ /* function check_file_is_audio( $tmp ) { $allowed = array( 'audio/mpeg', 'audio/x-mpeg', 'audio/mpeg3', 'audio/x-mpeg-3', 'audio/aiff', 'audio/mid', 'audio/x-aiff', 'audio/x-mpequrl','audio/midi', 'audio/x-mid', 'audio/x-midi','audio/wav','audio/x-wav','audio/xm','audio/x-aac','audio/basic', 'audio/flac','audio/mp4','audio/x-matroska','audio/ogg','audio/s3m','audio/x-ms-wax', 'audio/xm' ); // check REAL MIME type $finfo = finfo_open(FILEINFO_MIME_TYPE); $type = finfo_file($finfo, $tmp ); finfo_close($finfo); // check to see if REAL MIME type is inside $allowed array if( in_array($type, $allowed) ) { return true; } else { return false; } }*/