<?php// Add Thumbnail Theme Support/*add_theme_support('post-thumbnails'); add_image_size('thumb-size', 150, 150, true);add_filter( 'comment_text', 'do_shortcode' );/******************************************************/$posts_data = array();function register_my_menus(){ register_nav_menus ( array( 'main-menu-1' => __( '1 منوی اصلی' ), 'main-menu-2' => __( '2 منوی اصلی' ), 'footer-menu' => __( 'فهرست پایین' ) ) );}add_action( 'init', 'register_my_menus' );/************************* تابع دریافت تعداد بازدید و تعداد دانلود***************************/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 getPostDownload($postID){ $count_key = 'post_dl_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); }}function setPostDownload($postID){ $count_key = 'post_dl_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); }}/***********************************************************************/add_filter('manage_posts_columns', 'posts_column_views');add_action('manage_posts_custom_column', 'posts_custom_column_views',5,2);function posts_column_views($defaults){ $defaults['post_views'] = __('View'); return $defaults;}function posts_custom_column_views($column_name, $id){ if($column_name === 'post_views'){ echo getPostViews(get_the_ID()); }}/**********************************************************************/// If Dynamic Sidebar Exists if(function_exists('register_sidebar')) { // Define Sidebar Widget Area 1 $args = array( 'name' => 'Right Sidebar', 'description' => __( 'ستون سمت راست'), 'class' => 'weblog-sidebar', 'before_widget' => '<div class="widget-box">', 'after_widget' => '</div>', 'before_title' => '<div class="category-title">', 'after_title' => '</div>' ); register_sidebar( $args); }add_action('after_setup_theme', 'remove_admin_bar'); function remove_admin_bar() { if (!current_user_can('administrator') && !is_admin()) { show_admin_bar(false); }}/********************************************************************//* ----------------------------------------------------------کد نمایش دسته های سایت------------------------------------------------------------- */$themename = "project"; // نام قالب$shortname = "project";$categories = get_categories('hide_empty=0&orderby=name');$all_cats = array();foreach ($categories as $category_item ) {$all_cats[$category_item->cat_ID] = $category_item->cat_name;}array_unshift($all_cats, "انتخاب دسته بندی");/*---------------------------------------------------ساخت تنظیمات----------------------------------------------------*/function theme_settings_init(){register_setting( 'theme_settings', 'theme_settings' );wp_enqueue_style("panel_style", get_template_directory_uri()."/panel.css", false, "1.0", "all");wp_enqueue_script("panel_script", get_template_directory_uri()."/panel_script.js", false, "1.0");} /*---------------------------------------------------افزودن تنظیمات به منو پیشخوان----------------------------------------------------*/function add_settings_page() {add_menu_page( __( ' تنظیمات' . 'Project' ), __( ' تنظیمات' . 'Project' ), 'manage_options', 'settings', 'theme_settings_page');} add_action( 'admin_init', 'theme_settings_init' );add_action( 'admin_menu', 'add_settings_page' );/*---------------------------------------------------/* ---------------------------------------------------------تعریف آرایه های تنظیمات----------------------------------------------------------- */ $theme_options = array ( array( "name" =>" تنظیمات" . $themename, "type" => "title" ), /* --------------------------------------------------------- بخش تنظیمات عمومی ----------------------------------------------------------- */ array( "name" => "عمومی", "type" => "section" ), array( "type" => "open" ), array( "name" => "برترین های هفته", "type" => "text", "id" => $shortname."_best_week", "desc" => "عنوان کادر برترین های هفته را وارد کنید", "std" => "برترینهای هفته" ), array( "name" => "محبوبترین های هفته", "type" => "text", "id" => $shortname."_popular_week", "desc" => "عنوان کادر محبوب ترینهای هفته را وارد کنید", "std" => "محبوب ترین های هفته" ), array( "name" => "لوگوی سایت", "desc" => "در این قسمت نام فایل لوگوی سایت را وارد کنید", "id" => $shortname."_logo", "type" => "text", "std" => "logo.png" ), array( "type" => "close" ), /* --------------------------------------------------------- بخش تنظیمات صفحه نخست ----------------------------------------------------------- */ /* array( "name" => "صفحه نخست", "type" => "section" ), array( "type" => "open" ), array( "name" => "مطالب ویژه صفحه نخست", "desc" => "دسته مطالب ویژه را انتخاب کنید", "id" => $shortname."_feat_cat", "type" => "select", "options" => $all_cats, "std" => "انتخاب دسته"), array( "type" => "close" ), */ /* --------------------------------------------------------- بخش تنظیمات فوتر ----------------------------------------------------------- */ array( "name" => "فوتر", "type" => "section" ), array( "type" => "open" ), array( "name" => "آپارات", "type" => "text", "id" => $shortname."_aparat_link", "desc" => "لینک آپارات را وارد کنید", "std" => "" ), array( "name" => "یوتیوب", "type" => "text", "id" => $shortname."_youtube_link", "desc" => "لینک یوتیوب را وارد کنید", "std" => "" ), array( "name" => "فیسبوک", "type" => "text", "id" => $shortname."_facebook_link", "desc" => "لینک فیسبوک را وارد کنید ", "std" => "" ), array( "name" => "توییتر", "type" => "text", "id" => $shortname."_twitter_link", "desc" => "لینک توییتر را وارد کنید", "std" => "" ), array( "name" => "اینستاگرام ", "type" => "text", "id" => $shortname."_instagram_link", "desc" => "لینک اینستاگرام را وارد کنید", "std" => "" ), array( "name" => "گوگل پلاس", "type" => "text", "id" => $shortname."_gplus_link", "desc" => "لینک گوگل پلاس را وارد کنید", "std" => "" ), array( "name" => "متن کپی رایت فوتر", "desc" => "متن کپی رایت را وارد کنید", "id" => $shortname."_footer_text", "type" => "textarea", "std" => "" ), array( "type" => "close" ) );/*--------------------------------------------------خروجی پنل تنظیمات----------------------------------------------------*/function theme_settings_page() { global $themename,$theme_options; $i=0; $message=''; if ( 'save' == $_REQUEST['action'] ) { foreach ($theme_options as $value) { update_option( $value['id'], $_REQUEST[ $value['id'] ] ); } foreach ($theme_options as $value) { if( isset( $_REQUEST[ $value['id'] ] ) ) { update_option( $value['id'], $_REQUEST[ $value['id'] ] ); } else { delete_option( $value['id'] ); } } $message='saved'; } else if( 'reset' == $_REQUEST['action'] ) { foreach ($theme_options as $value) { delete_option( $value['id'] ); } $message='reset'; } ?> <div class="wrap options_wrap"> <div id="icon-options-general"></div> <h2><?php _e( ' تنظیمات قالب' ) //your admin panel title ?></h2> <?php if ( $message=='saved' ) echo '<div class="updated settings-error" id="setting-error-settings_updated"> <p>تنظیمات قالب '.$themename.' ذخیره شد.</strong></p></div>'; if ( $message=='reset' ) echo '<div class="updated settings-error" id="setting-error-settings_updated"> <p>'.$themename.' settings reset.</strong></p></div>'; ?> <ul> <li>نسخه قالب : 1.0 </li> </ul> <div class="content_options"> <form method="post"> <?php foreach ($theme_options as $value) { switch ( $value['type'] ) { case "open": ?> <?php break; case "close": ?> </div> </div><br /> <?php break; case "title": ?> <div class="message"> <p>از این پنل برای تنظیم سایت استفاده کنید</p> </div> <?php break; case 'text': ?> <div class="option_input option_text"> <label for="<?php echo $value['id']; ?>"> <?php echo $value['name']; ?></label> <input id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" name="<?php echo $value['id']; ?>" value="<?php if ( get_settings( $value['id'] ) != "") { echo stripslashes(get_settings( $value['id']) ); } else { echo $value['std']; } ?>" /> <small><?php echo $value['desc']; ?></small> <div class="clearfix"></div> </div> <?php break; case 'textarea': ?> <div class="option_input option_textarea"> <label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label> <textarea name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" rows="" cols=""><?php if ( get_settings( $value['id'] ) != "") { echo stripslashes(get_settings( $value['id']) ); } else { echo $value['std']; } ?></textarea> <small><?php echo $value['desc']; ?></small> <div class="clearfix"></div> </div> <?php break; case 'select': ?> <div class="option_input option_select"> <label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label> <select name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>"> <?php foreach ($value['options'] as $option) { ?> <option <?php if (get_settings( $value['id'] ) == $option) { echo 'selected="selected"'; } ?>><?php echo $option; ?></option> <?php } ?> </select> <small><?php echo $value['desc']; ?></small> <div class="clearfix"></div> </div> <?php break; case "checkbox": ?> <div class="option_input option_checkbox"> <label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label> <?php if(get_option($value['id'])){ $checked = "checked=\"checked\""; }else{ $checked = "";} ?> <input id="<?php echo $value['id']; ?>" type="checkbox" name="<?php echo $value['id']; ?>" value="true" <?php echo $checked; ?> /> <small><?php echo $value['desc']; ?></small> <div class="clearfix"></div> </div> <?php break; case "section": $i++; ?> <div class="input_section"> <div class="input_title"> <h3><img src="<?php echo get_template_directory_uri();?>/images/options.png" alt=""> <?php echo $value['name']; ?></h3> <span class="submit"><input name="save<?php echo $i; ?>" type="submit" class="button-primary" value="ذخیره" /></span> <div class="clearfix"></div> </div> <div class="all_options"> <?php break; } }?> <input type="hidden" name="action" value="save" /> </form> <form method="post"> <p class="submit"> <input name="reset" type="submit" value="بازنشانی تنظیمات" /> <input type="hidden" name="action" value="reset" /> </p> </form> </div> </div> <?php}?><!-----------------------------------------------------------><?php function popularTabPost(){ $popular_posts = new WP_Query(array( 'post_status' =>'publish', 'post_type' =>'post', 'meta_key' => 'post_views_count', 'orderby' => 'meta_value_num', 'order' =>'descending', 'range'=>'', 'posts_per_page' =>'5', 'paged' => (get_query_var('paged')) ? get_query_var('paged') : 1 ) ); if( $popular_posts->have_posts()) : while( $popular_posts->have_posts()) : $popular_posts->the_post(); ?> <div class="similar-video-post tab-post"> <a href="<?php the_permalink(); ?>"> <div class="similar-video-post-image tab-image" style="float: right;"> <?php if ( get_field('video-imgage')){ $img = get_field('video-imgage'); echo '<img src=" '.$img. ' "> '; //$src = get_field('video-link'); //echo do_shortcode('[aparat width="135" height="75" title="false" ]'.$src.'[/aparat]'); } else{ ?> <img src="<?php bloginfo('template_url'); ?>/images/post-week-image.jpg" /> <?php } ?> </div> </a> <div class="similar-video-post-data tab-post-data" > <div class="title"> <a href="<?php the_permalink(); ?>"> <?php the_title() ?> </a> </div> <div class="visit tab-visit"> <?php echo getPostViews( get_the_ID()); ?> </div> </div> </div> <?php endwhile;endif;?> <?php wp_reset_query(); ?> <?php }?><!---------------------------------------------------------------------------><?phpfunction commentTabPost(){ $popular_posts = new WP_Query(array( 'post_status' =>'publish', 'post_type' =>'post', 'orderby' => 'comment_count', 'order' =>'descending', 'range'=>'weekly', 'posts_per_page' =>'5', 'paged' => (get_query_var('paged')) ? get_query_var('paged') : 1 ) ); if( $popular_posts->have_posts()) : while( $popular_posts->have_posts()) : $popular_posts->the_post(); ?> <div class="similar-video-post tab-post"> <a href="<?php the_permalink(); ?>"> <div class="similar-video-post-image tab-image" style="float: right;"> <?php if ( get_field('video-imgage')){ $img = get_field('video-imgage'); echo '<img src=" '.$img. ' "> '; //$src = get_field('video-link'); //echo do_shortcode('[aparat width="135" height="75" title="false" ]'.$src.'[/aparat]'); } else{ ?> <img src="<?php bloginfo('template_url'); ?>/images/post-week-image.jpg" /> <?php } ?> </div> </a> <div class="similar-video-post-data tab-post-data" > <div class="title"> <a href="<?php the_permalink(); ?>"> <?php the_title() ?> </a> </div> <div class="visit tab-visit"> <?php echo getPostViews( get_the_ID()); ?> </div> </div> </div> <?php endwhile;endif;?> <?php wp_reset_query(); ?> <?php }?><!-- ---------------------------------------------------------------- --><?phpfunction shareTabPost(){ $popular_posts = new WP_Query(array( 'post_status' =>'publish', 'post_type' =>'post', 'orderby' => 'comment_count', 'order' =>'descending', 'range'=>'weekly', 'posts_per_page' =>'5', 'paged' => (get_query_var('paged')) ? get_query_var('paged') : 1 ) ); if( $popular_posts->have_posts()) : while( $popular_posts->have_posts()) : $popular_posts->the_post(); ?> <div class="similar-video-post tab-post"> <a href="<?php the_permalink(); ?>"> <div class="similar-video-post-image tab-image" style="float: right;"> <?php if ( get_field('video-imgage')){ $img = get_field('video-imgage'); echo '<img src=" '.$img. ' "> '; //$src = get_field('video-link'); //echo do_shortcode('[aparat width="135" height="75" title="false" ]'.$src.'[/aparat]'); } else{ ?> <img src="<?php bloginfo('template_url'); ?>/images/post-week-image.jpg" /> <?php } ?> </div> </a> <div class="similar-video-post-data tab-post-data" > <div class="title"> <a href="<?php the_permalink(); ?>"> <?php the_title() ?> </a> </div> <div class="visit tab-visit"> <?php echo getPostViews( get_the_ID()); ?> </div> </div> </div> <?php endwhile;endif;?> <?php wp_reset_query(); ?> <?php }?>