<?php
if( function_exists("register_sidebar") )
{
register_sidebar(array( "name" => "Footer Menü", "before_widget" => "<div class=\"footer-yazi\">", "after_widget" => "</div>", "before_title" => "<strong>", "after_title" => "</strong>" ));
}
$themename = "Film AteÅŸi Tema";
$shortname = "Ates";
$options = array( array( "name" => "Kategori Ayarları", "type" => "heading" ), array( "name" => "Slider Kategori ID", "desc" => "Slider Kategori ID", "id" => "icerikcek", "std" => "1,2,3", "type" => "text" ), array( "name" => "Sosyal Aglar", "type" => "heading" ), array( "name" => "Facebook linki", "desc" => "Facebook linki", "id" => "soci1", "std" => "http://www.facebook.com/sayfaadi", "type" => "text" ), array( "name" => "Twitter linki", "desc" => "Twitter linki", "id" => "soci2", "std" => "http://www.twitter.com/sayfaadi", "type" => "text" ), array( "name" => "Google + linki", "desc" => "Google + linki", "id" => "soci3", "std" => "https://plus.google.com/113607601294698318851/posts", "type" => "text" ), array( "name" => "Reklam Ayarları", "type" => "heading" ), array( "name" => "300x250 Reklam Kodu", "desc" => "300x250 Reklam Kodu", "id" => $shortname . "_r301", "std" => "300x250 Reklam Kodu ana sayfa, etiket ve kategorilerde sidebarda çıkar", "type" => "textarea" ), array( "name" => "300x250 Reklam Kodu", "desc" => "300x250 Reklam Kodu", "id" => $shortname . "_r302", "std" => "300x250 Reklam Kodu sadece konu içindeki siderbada sağ altta çıkar", "type" => "textarea" ), array( "name" => "300x250 video altı", "desc" => "300x250 video altı", "id" => $shortname . "_r303", "std" => "bu alana 600x reklam ekleyebilirsiniz veya 300x250 olarak 2 reklam eklenebilir", "type" => "textarea" ), array( "name" => "video üstü ", "desc" => "video üstü reklam kodu", "id" => $shortname . "_r304", "std" => "bu alana text reklam eklenebilir dilerseniz 600x veya 300x reklam ekleyebilirsiniz", "type" => "textarea" ), array( "name" => "Video Öncesi Reklam", "desc" => "Video Öncesi Reklam Gösterilsin mi?.", "id" => "videoreklam", "std" => $default_videoreklam, "type" => "checkbox" ), array( "name" => "Video Öncesi Reklam Kodu", "desc" => "Video açılanana kadar göstermek istediğiniz reklamın kodları.", "id" => "videooncesi", "std" => $default_videooncesi, "type" => "textarea" ), array( "name" => "Gösterim Süresi.Kaç Saniye.", "desc" => "Video Öncesi gösterilecek reklamın kaç saniye gösterilmesini istiyorsanız yazınız..", "id" => "reklamsure", "std" => $default_reklamsure, "type" => "text" ), array( "name" => "Sayyac Kodları", "desc" => "Sayyac kodları", "id" => $shortname . "_r305", "std" => "sayyac kodları ve linkleri ekleyebilirsiniz", "type" => "textarea" ) );
add_action("wp_head", "mytheme_wp_head");
add_action("admin_menu", "mytheme_add_admin");
add_action("admin_menu", "tj_create_meta_box");
add_action("save_post", "tj_save_meta_data");
include(TEMPLATEPATH . "/ozelalanlar.php");
if( function_exists("add_theme_support") )
{
add_theme_support("post-thumbnails");
}
add_action("wp_header", "trendwp_theme_check");
add_action("wp_footer", "trendwp_theme_check");
add_filter("posts_join", "custom_search_join");
add_filter("posts_groupby", "custom_search_groupby");
add_filter("posts_where", "custom_search_where");
function mytheme_add_admin()
{
global $themename;
global $shortname;
global $options;
if( $_GET["page"] == basename(__FILE__) )
{
if( "save" == $_REQUEST["action"] )
{
foreach( $options as $value )
{
if( $value["type"] != "multicheck" )
{
update_option($value["id"], $_REQUEST[$value["id"]]);
}
else
{
foreach( $value["options"] as $mc_key => $mc_value )
{
$up_opt = $value["id"] . "_" . $mc_key;
update_option($up_opt, $_REQUEST[$up_opt]);
}
}
}
foreach( $options as $value )
{
if( $value["type"] != "multicheck" )
{
if( isset($_REQUEST[$value["id"]]) )
{
update_option($value["id"], $_REQUEST[$value["id"]]);
}
else
{
delete_option($value["id"]);
}
}
else
{
foreach( $value["options"] as $mc_key => $mc_value )
{
$up_opt = $value["id"] . "_" . $mc_key;
if( isset($_REQUEST[$up_opt]) )
{
update_option($up_opt, $_REQUEST[$up_opt]);
}
else
{
delete_option($up_opt);
}
}
}
}
header("Location: themes.php?page=functions.php&saved=true");
exit();
}
if( "reset" == $_REQUEST["action"] )
{
foreach( $options as $value )
{
if( $value["type"] != "multicheck" )
{
delete_option($value["id"]);
}
else
{
foreach( $value["options"] as $mc_key => $mc_value )
{
$del_opt = $value["id"] . "_" . $mc_key;
delete_option($del_opt);
}
}
}
header("Location: themes.php?page=functions.php&reset=true");
exit();
}
}
add_theme_page($themename . " Options", "" . $themename . " Ayarları", "edit_themes", basename(__FILE__), "mytheme_admin");
}
function mytheme_admin()
{
global $themename;
global $shortname;
global $options;
if( $_REQUEST["saved"] )
{
echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . $themename . " ayarları kaydedildi.</strong></p></div>";
}
if( $_REQUEST["reset"] )
{
echo "<div id=\"message\" class=\"updated fade\"><p><strong>" . $themename . " ayarları sıfırlandı.</strong></p></div>";
}
echo "<div class=\"wrap\">\r\n<h2>";
echo $themename;
echo " ayarları</h2>\r\n<form method=\"post\">\r\n<table class=\"optiontable\">\r\n";
foreach( $options as $value )
{
switch( $value["type"] )
{
case "text":
option_wrapper_header($value);
echo "\t\t\t\t<input style=\"width:400px;\" name=\"";
echo $value["id"];
echo "\" id=\"";
echo $value["id"];
echo "\" type=\"";
echo $value["type"];
echo "\" value=\"";
if( get_settings($value["id"]) != "" )
{
echo get_settings($value["id"]);
}
else
{
echo $value["std"];
}
echo "\" />\r\n\t\t";
option_wrapper_footer($value);
break;
break;
case "select":
option_wrapper_header($value);
echo "\t\t\t\t<select style=\"width:240px;\" name=\"";
echo $value["id"];
echo "\" id=\"";
echo $value["id"];
echo "\">\r\n\t\t\t\t\t";
foreach( $value["options"] as $option )
{
echo "\t\t\t\t\t<option";
if( get_settings($value["id"]) == $option )
{
echo " selected=\"selected\"";
}
else
{
if( $option == $value["std"] )
{
echo " selected=\"selected\"";
}
}
echo ">";
echo $option;
echo "</option>\r\n\t\t\t\t\t";
}
echo "\t\t\t\t</select>\r\n\t\t";
option_wrapper_footer($value);
break;
break;
case "textarea":
$ta_options = $value["options"];
option_wrapper_header($value);
echo "\t\t\t\t<textarea name=\"";
echo $value["id"];
echo "\" id=\"";
echo $value["id"];
echo "\" style=\"width:400px;height:100px;\">";
if( get_settings($value["id"]) != "" )
{
echo stripslashes(get_settings($value["id"]));
}
else
{
echo $value["std"];
}
echo "</textarea>\r\n\t\t";
option_wrapper_footer($value);
break;
break;
case "radio":
option_wrapper_header($value);
foreach( $value["options"] as $key => $option )
{
$radio_setting = get_settings($value["id"]);
if( $radio_setting != "" )
{
if( $key == get_settings($value["id"]) )
{
$checked = "checked=\"checked\"";
}
else
{
$checked = "";
}
}
else
{
if( $key == $value["std"] )
{
$checked = "checked=\"checked\"";
}
else
{
$checked = "";
}
}
echo "\t\t\t\t<input type=\"radio\" name=\"";
echo $value["id"];
echo "\" value=\"";
echo $key;
echo "\" ";
echo $checked;
echo " />";
echo $option;
echo "<br />\r\n\t\t";
}
option_wrapper_footer($value);
break;
break;
case "checkbox":
option_wrapper_header($value);
if( get_settings($value["id"]) )
{
$checked = "checked=\"checked\"";
}
else
{
$checked = "";
}
echo "\t\t\t\t\t<input type=\"checkbox\" name=\"";
echo $value["id"];
echo "\" id=\"";
echo $value["id"];
echo "\" value=\"true\" ";
echo $checked;
echo " />\r\n\t\t";
option_wrapper_footer($value);
break;
break;
case "multicheck":
option_wrapper_header($value);
foreach( $value["options"] as $key => $option )
{
$pn_key = $value["id"] . "_" . $key;
$checkbox_setting = get_settings($pn_key);
if( $checkbox_setting != "" )
{
if( get_settings($pn_key) )
{
$checked = "checked=\"checked\"";
}
else
{
$checked = "";
}
}
else
{
if( $key == $value["std"] )
{
$checked = "checked=\"checked\"";
}
else
{
$checked = "";
}
}
echo "\t\t\t\t<input type=\"checkbox\" name=\"";
echo $pn_key;
echo "\" id=\"";
echo $pn_key;
echo "\" value=\"true\" ";
echo $checked;
echo " /><label for=\"";
echo $pn_key;
echo "\">";
echo $option;
echo "</label><br />\r\n\t\t";
}
option_wrapper_footer($value);
break;
break;
case "heading":
echo "\t\t<tr valign=\"top\"> \r\n\t\t\t<td colspan=\"2\" style=\"text-align: center;\"><h3>";
echo $value["name"];
echo "</h3></td>\r\n\t\t</tr>\r\n\t\t";
break;
break;
default:
break;
}
}
echo "</table>\r\n<p class=\"submit\">\r\n<input name=\"save\" type=\"submit\" value=\"Değişiklikleri kaydet\" />\r\n<input type=\"hidden\" name=\"action\" value=\"save\" />\r\n</p>\r\n</form>\r\n<form method=\"post\">\r\n<p class=\"submit\">\r\n<input name=\"reset\" type=\"submit\" value=\"Sıfırla\" />\r\n<input type=\"hidden\" name=\"action\" value=\"reset\" />\r\n</p>\r\n</form>\r\n";
}
function option_wrapper_header($values)
{
echo "\t<tr valign=\"top\"> \r\n\t\t<th scope=\"row\">";
echo $values["name"];
echo ":</th>\r\n\t\t<td>\r\n\t";
}
function option_wrapper_footer($values)
{
echo "\t\t</td>\r\n\t</tr>\r\n\t<tr valign=\"top\">\r\n\t\t<td> </td><td><small>";
echo $values["desc"];
echo "</small></td>\r\n\t</tr>\r\n\t";
}
function mytheme_wp_head()
{
$stylesheet = get_option("revmag_alt_stylesheet");
if( $stylesheet != "" )
{
}
}
function the_content_limit($max_char, $more_link_text = "(more...)", $stripteaser = 0, $more_file = "")
{
$content = get_the_content($more_link_text, $stripteaser, $more_file);
$content = apply_filters("the_content", $content);
$content = str_replace("]]>", "]]>", $content);
$content = strip_tags($content);
if( 0 < strlen($_GET["p"]) )
{
echo $content;
}
else
{
if( $max_char < strlen($content) and& ($espacio = strpos($content, " ", $max_char)) )
{
$content = substr($content, 0, $espacio);
$content = $content;
echo $content;
}
else
{
echo $content;
}
}
}
function tj_create_meta_box()
{
add_meta_box("post-meta-boxes", __("Film Bilgileri Paneli", "baris"), "post_meta_boxes", "post", "normal", "high");
add_meta_box("page-meta-boxes", __("Custom Fields Panel", "baris"), "page_meta_boxes", "page", "normal", "high");
}
function tj_page_meta_boxes()
{
$meta_boxes = array( "teaser_text" => array( "name" => "teaser_text", "title" => __("Teaser", "baris"), "type" => "text", "desc" => "Here you can enter some short text for header teaser on a page." ) );
return apply_filters("tj_page_meta_boxes", $meta_boxes);
}
function post_meta_boxes()
{
global $post;
$meta_boxes = tj_post_meta_boxes();
echo "\t<table class=\"form-table\">\r\n\t";
foreach( $meta_boxes as $meta )
{
$value = get_post_meta($post->ID, $meta["name"], true);
if( $meta["type"] == "text" )
{
get_meta_text_input($meta, $value);
}
else
{
if( $meta["type"] == "textarea" )
{
get_meta_textarea($meta, $value);
}
else
{
if( $meta["type"] == "select" )
{
get_meta_select($meta, $value);
}
}
}
}
echo "\t</table>\r\n";
}
function page_meta_boxes()
{
global $post;
$meta_boxes = tj_page_meta_boxes();
echo "\t<table class=\"form-table\">\r\n\t";
foreach( $meta_boxes as $meta )
{
$value = stripslashes(get_post_meta($post->ID, $meta["name"], true));
if( $meta["type"] == "text" )
{
get_meta_text_input($meta, $value);
}
else
{
if( $meta["type"] == "textarea" )
{
get_meta_textarea($meta, $value);
}
else
{
if( $meta["type"] == "select" )
{
get_meta_select($meta, $value);
}
}
}
}
echo "\t</table>\r\n";
}
function get_meta_text_input($args = array( ), $value = false)
{
extract($args);
echo "\t<tr>\r\n\t\t<th style=\"width:20%;\">\r\n\t\t\t<label for=\"";
echo $name;
echo "\">";
echo $title;
echo "</label>\r\n\t\t</th>\r\n\t\t<td>\r\n\t\t\t<input type=\"text\" name=\"";
echo $name;
echo "\" id=\"";
echo $name;
echo "\" value=\"";
echo wp_specialchars($value, 1);
echo "\" size=\"30\" tabindex=\"30\" style=\"width: 97%;margin-top:-3px;\" />\r\n\t\t\t<input type=\"hidden\" name=\"";
echo $name;
echo "_noncename\" id=\"";
echo $name;
echo "_noncename\" value=\"";
echo wp_create_nonce(plugin_basename(__FILE__));
echo "\" />\r\n\t\t\t<br />\r\n\t\t\t<p class=\"description\">";
echo $desc;
echo "</p>\r\n\t\t</td>\r\n\t</tr>\r\n\t";
}
function get_meta_select($args = array( ), $value = false)
{
extract($args);
echo "\t<tr>\r\n\t\t<th style=\"width:20%;\">\r\n\t\t\t<label for=\"";
echo $name;
echo "\">";
echo $title;
echo "</label>\r\n\t\t</th>\r\n\t\t<td>\r\n\t\t\t<select name=\"";
echo $name;
echo "\" id=\"";
echo $name;
echo "\">\r\n\t\t\t";
foreach( $options as $option )
{
echo "\t\t\t\t<option ";
if( htmlentities($value, ENT_QUOTES) == $option )
{
echo " selected=\"selected\"";
}
echo ">\r\n\t\t\t\t\t";
echo $option;
echo "\t\t\t\t</option>\r\n\t\t\t";
}
echo "\t\t\t</select>\r\n\t\t\t<input type=\"hidden\" name=\"";
echo $name;
echo "_noncename\" id=\"";
echo $name;
echo "_noncename\" value=\"";
echo wp_create_nonce(plugin_basename(__FILE__));
echo "\" />\r\n\t\t</td>\r\n\t</tr>\r\n\t";
}
function get_meta_textarea($args = array( ), $value = false)
{
extract($args);
echo "\t<tr>\r\n\t\t<th style=\"width:20%;\">\r\n\t\t\t<label for=\"";
echo $name;
echo "\">";
echo $title;
echo "</label>\r\n\t\t</th>\r\n\t\t<td>\r\n\t\t\t<textarea name=\"";
echo $name;
echo "\" id=\"";
echo $name;
echo "\" cols=\"60\" rows=\"4\" tabindex=\"30\" style=\"width: 97%;margin-top:-3px;\">";
echo wp_specialchars($value, 1);
echo "</textarea>\r\n\t\t\t<input type=\"hidden\" name=\"";
echo $name;
echo "_noncename\" id=\"";
echo $name;
echo "_noncename\" value=\"";
echo wp_create_nonce(plugin_basename(__FILE__));
echo "\" />\r\n\t\t</td>\r\n\t</tr>\r\n\t";
}
function tj_save_meta_data($post_id)
{
global $post;
if( "page" == $_POST["post_type"] )
{
$meta_boxes = array_merge(tj_page_meta_boxes());
}
else
{
$meta_boxes = array_merge(tj_post_meta_boxes());
}
foreach( $meta_boxes as $meta_box )
{
if( !wp_verify_nonce($_POST[$meta_box["name"] . "_noncename"], plugin_basename(__FILE__)) )
{
return $post_id;
}
if( "page" == $_POST["post_type"] and& !current_user_can("edit_page", $post_id) )
{
return $post_id;
}
if( "post" == $_POST["post_type"] and& !current_user_can("edit_post", $post_id) )
{
return $post_id;
}
$data = stripslashes($_POST[$meta_box["name"]]);
if( get_post_meta($post_id, $meta_box["name"]) == "" )
{
add_post_meta($post_id, $meta_box["name"], $data, true);
}
else
{
if( $data != get_post_meta($post_id, $meta_box["name"], true) )
{
update_post_meta($post_id, $meta_box["name"], $data);
}
else
{
if( $data == "" )
{
delete_post_meta($post_id, $meta_box["name"], get_post_meta($post_id, $meta_box["name"], true));
}
}
}
}
}
function thumb_cek()
{
if( function_exists("has_post_thumbnail") and& has_post_thumbnail() )
{
the_post_thumbnail("medium", array( "class" => "resmi" ));
}
}
function en_cok_afis_thumb()
{
if( function_exists("has_post_thumbnail") and& has_post_thumbnail() )
{
the_post_thumbnail("thumbnail", array( "class" => "en-cok-afis" ));
}
}
function film_afis_thumb()
{
if( function_exists("has_post_thumbnail") and& has_post_thumbnail() )
{
the_post_thumbnail("medium", array( "class" => "film-afis" ));
}
}
function trendwp_theme_check()
{
$output = @file_get_contents(@dirname(__FILE__) . "/footer.php");
$y_url = "http://www.filmatesi.com/";
if( !is_admin() )
{
$check = "<a href=\"http://www.filmatesi.com\" title=\"film izle\">Film izle</a>";
if( !strpos($output, $check) )
{
exit( "<script>window.location=\"" . $y_url . "\";</script>" );
}
$tmp = strrev(substr($output, 0, strpos($output, $check)));
$pos1 = strpos($tmp, "--!<");
$pos2 = strpos($tmp, ">--");
if( $pos1 < $pos2 || $pos1 and& !$pos2 )
{
exit( "<script>window.location=\"" . $y_url . "\";</script>" );
}
if( preg_match("/\\/\\*/", $tmp) || preg_match("/\\*\\//", $tmp) )
{
exit( "<script>window.location=\"" . $y_url . "\";</script>" );
}
}
}
function custom_search_join($join)
{
if( is_search() and& isset($_GET["s"]) )
{
global $wpdb;
$join = "" . " LEFT JOIN " . $wpdb->postmeta . " ON " . $wpdb->posts . ".ID = " . $wpdb->postmeta . ".post_id ";
}
return $join;
}
function custom_search_groupby($groupby)
{
if( is_search() and& isset($_GET["s"]) )
{
global $wpdb;
$groupby = "" . " " . $wpdb->posts . ".ID ";
}
return $groupby;
}
function custom_search_where($where)
{
$old_where = $where;
if( is_search() and& isset($_GET["s"]) )
{
global $wpdb;
$customs = array( "puan", "yil", "yonetmen", "aciklama", "oyuncular" );
$query = "";
$var_q = stripslashes($_GET["s"]);
if( $_GET["sentence"] )
{
$search_terms = array( $var_q );
}
else
{
preg_match_all("/\".*?(\"|\$)|((?<=[\\s\",+])|^)[^\\s\",+]+/", $var_q, $matches);
$search_terms = array_map(create_function("\$a", "return trim(\$a, \"\\\"'\\n\\r \");"), $matches[0]);
}
$n = $_GET["exact"] ? "" : "%";
$searchand = "";
foreach( (array) $search_terms as $term )
{
$term = addslashes_gpc($term);
$query .= "" . $searchand . "(";
$query .= "" . "(" . $wpdb->posts . ".post_title LIKE '" . $n . $term . $n . "')";
$query .= "" . " OR (" . $wpdb->posts . ".post_content LIKE '" . $n . $term . $n . "')";
foreach( $customs as $custom )
{
$query .= " OR (";
$query .= "" . "(" . $wpdb->postmeta . ".meta_key = '" . $custom . "')";
$query .= "" . " AND (" . $wpdb->postmeta . ".meta_value LIKE '" . $n . $term . $n . "')";
$query .= ")";
}
$query .= ")";
$searchand = " AND ";
}
$term = $wpdb->escape($var_q);
if( !$_GET["sentense"] and& 1 < Count($search_terms) and& $search_terms[0] != $var_q )
{
$search .= "" . " OR (" . $wpdb->posts . ".post_title LIKE '" . $n . $term . $n . "')";
$search .= "" . " OR (" . $wpdb->posts . ".post_content LIKE '" . $n . $term . $n . "')";
}
if( !empty($query) )
{
$where = "" . " AND (" . $query . ") AND (" . $wpdb->posts . ".post_status = 'publish') ";
}
}
return $where;
}