Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- 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']]);
- continue;
- }
- foreach ($value['options'] as $mc_value => $mc_key) {
- $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']]);
- continue;
- }
- delete_option($value['id']);
- continue;
- }
- foreach ($value['options'] as $mc_value => $mc_key) {
- $up_opt = $value['id'] . '_' . $mc_key;
- if (isset($_REQUEST[$up_opt])) {
- update_option($up_opt, $_REQUEST[$up_opt]);
- continue;
- }
- delete_option($up_opt);
- }
- }
- header('Location: themes.php?page=functions.php&saved=true');
- exit();
- } else {
- if ('reset' == $_REQUEST['action']) {
- foreach ($options as $value) {
- if ($value['type'] != 'multicheck') {
- delete_option($value['id']);
- continue;
- }
- foreach ($value['options'] as $mc_value => $mc_key) {
- $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">
- <h2>';
- echo $themename;
- echo ' ayarlar?</h2>
- <form method="post">
- <table class="optiontable">
- ';
- foreach ($options as $value) {
- switch ($value['type']) {
- case 'text': {
- option_wrapper_header($value);
- echo ' <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 '" />
- ';
- option_wrapper_footer($value);
- break;
- }
- case 'select': {
- option_wrapper_header($value);
- echo ' ';
- echo '<s';
- echo 'elect style="width:240px;" name="';
- echo $value['id'];
- echo '" id="';
- echo $value['id'];
- echo '">
- ';
- foreach ($value['options'] as $option) {
- echo ' <option';
- if (get_settings($value['id']) == $option) {
- echo ' selected="selected"';
- } else {
- if ($option == $value['std']) {
- echo ' selected="selected"';
- }
- }
- echo '>';
- echo $option;
- echo '</option>
- ';
- }
- echo ' </select>
- ';
- option_wrapper_footer($value);
- break;
- }
- case 'textarea': {
- $ta_options = $value['options'];
- option_wrapper_header($value);
- echo ' <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>
- ';
- option_wrapper_footer($value);
- break;
- }
- case 'radio': {
- option_wrapper_header($value);
- foreach ($value['options'] as $option => $key) {
- $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 ' <input type="radio" name="';
- echo $value['id'];
- echo '" value="';
- echo $key;
- echo '" ';
- echo $checked;
- echo ' />';
- echo $option;
- echo '<br />
- ';
- }
- option_wrapper_footer($value);
- break;
- }
- case 'checkbox': {
- option_wrapper_header($value);
- if (get_settings($value['id'])) {
- $checked = 'checked="checked"';
- } else {
- $checked = '';
- }
- echo ' <input type="checkbox" name="';
- echo $value['id'];
- echo '" id="';
- echo $value['id'];
- echo '" value="true" ';
- echo $checked;
- echo ' />
- ';
- option_wrapper_footer($value);
- break;
- }
- case 'multicheck': {
- option_wrapper_header($value);
- foreach ($value['options'] as $option => $key) {
- $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 ' <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 />
- ';
- }
- option_wrapper_footer($value);
- break;
- }
- case 'heading': {
- echo ' <tr valign="top">
- <td colspan="2" style="text-align: center;"><h3>';
- echo $value['name'];
- echo '</h3></td>
- </tr>
- ';
- break;
- }
- default: {
- break;
- }
- }
- }
- echo '</table>
- <p class="submit">
- <input name="save" type="submit" value="Degisiklikleri kaydet" />
- <input type="hidden" name="action" value="save" />
- </p>
- </form>
- <form method="post">
- <p class="submit">
- <input name="reset" type="submit" value="S?f?rla" />
- <input type="hidden" name="action" value="reset" />
- </p>
- </form>
- ';
- }
- function option_wrapper_header($values)
- {
- echo ' <tr valign="top">
- <th scope="row">';
- echo $values['name'];
- echo ':</th>
- <td>
- ';
- }
- function option_wrapper_footer($values)
- {
- echo ' </td>
- </tr>
- <tr valign="top">
- <td> </td><td>';
- echo '<s';
- echo 'mall>';
- echo $values['desc'];
- echo '</small></td>
- </tr>
- ';
- }
- 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;
- return null;
- }
- if (($max_char < strlen($content) && $espacio = strpos($content, ' ', $max_char))) {
- $content = substr($content, 0, $espacio);
- echo $content;
- return null;
- }
- 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 ' <table class="form-table">
- ';
- foreach ($meta_boxes as $meta) {
- $value = get_post_meta($post->ID, $meta['name'], true);
- if ($meta['type'] == 'text') {
- get_meta_text_input($meta, $value);
- continue;
- }
- if ($meta['type'] == 'textarea') {
- get_meta_textarea($meta, $value);
- continue;
- }
- if ($meta['type'] == 'select') {
- get_meta_select($meta, $value);
- continue;
- }
- }
- echo ' </table>
- ';
- }
- function page_meta_boxes()
- {
- global $post;
- $meta_boxes = tj_page_meta_boxes();
- echo ' <table class="form-table">
- ';
- 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);
- continue;
- }
- if ($meta['type'] == 'textarea') {
- get_meta_textarea($meta, $value);
- continue;
- }
- if ($meta['type'] == 'select') {
- get_meta_select($meta, $value);
- continue;
- }
- }
- echo ' </table>
- ';
- }
- function get_meta_text_input($args = array(), $value = false)
- {
- extract($args);
- echo ' <tr>
- <th style="width:20%;">
- <label for="';
- echo $name;
- echo '">';
- echo $title;
- echo '</label>
- </th>
- <td>
- <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;" />
- <input type="hidden" name="';
- echo $name;
- echo '_noncename" id="';
- echo $name;
- echo '_noncename" value="';
- echo wp_create_nonce(plugin_basename(__FILE__));
- echo '" />
- <br />
- <p class="description">';
- echo $desc;
- echo '</p>
- </td>
- </tr>
- ';
- }
- function get_meta_select($args = array(), $value = false)
- {
- extract($args);
- echo ' <tr>
- <th style="width:20%;">
- <label for="';
- echo $name;
- echo '">';
- echo $title;
- echo '</label>
- </th>
- <td>
- ';
- echo '<s';
- echo 'elect name="';
- echo $name;
- echo '" id="';
- echo $name;
- echo '">
- ';
- foreach ($options as $option) {
- echo ' <option ';
- if (htmlentities($value, ENT_QUOTES) == $option) {
- echo ' selected="selected"';
- }
- echo '>
- ';
- echo $option;
- echo ' </option>
- ';
- }
- echo ' </select>
- <input type="hidden" name="';
- echo $name;
- echo '_noncename" id="';
- echo $name;
- echo '_noncename" value="';
- echo wp_create_nonce(plugin_basename(__FILE__));
- echo '" />
- </td>
- </tr>
- ';
- }
- function get_meta_textarea($args = array(), $value = false)
- {
- extract($args);
- echo ' <tr>
- <th style="width:20%;">
- <label for="';
- echo $name;
- echo '">';
- echo $title;
- echo '</label>
- </th>
- <td>
- <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>
- <input type="hidden" name="';
- echo $name;
- echo '_noncename" id="';
- echo $name;
- echo '_noncename" value="';
- echo wp_create_nonce(plugin_basename(__FILE__));
- echo '" />
- </td>
- </tr>
- ';
- }
- 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'] && !current_user_can('edit_page', $post_id))) {
- return $post_id;
- }
- if (('post' == $_POST['post_type'] && !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);
- continue;
- }
- if ($data != get_post_meta($post_id, $meta_box['name'], true)) {
- update_post_meta($post_id, $meta_box['name'], $data);
- continue;
- }
- if ($data == '') {
- delete_post_meta($post_id, $meta_box['name'], get_post_meta($post_id, $meta_box['name'], true));
- continue;
- }
- }
- }
- function thumb_cek()
- {
- if ((function_exists('has_post_thumbnail') && has_post_thumbnail())) {
- the_post_thumbnail('medium', array(
- 'class' => 'resmi'
- ));
- }
- }
- function en_cok_afis_thumb()
- {
- if ((function_exists('has_post_thumbnail') && has_post_thumbnail())) {
- the_post_thumbnail('thumbnail', array(
- 'class' => 'en-cok-afis'
- ));
- }
- }
- function film_afis_thumb()
- {
- if ((function_exists('has_post_thumbnail') && 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 && !$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() && 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() && isset($_GET['s']))) {
- global $wpdb;
- $groupby = '' . ' ' . $wpdb->posts . '.ID ';
- }
- return $groupby;
- }
- function custom_search_where($where)
- {
- $old_where = $where;
- if ((is_search() && 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'] && 1 < Count($search_terms)) && $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;
- }
- if (function_exists('register_sidebar')) {
- register_sidebar(array(
- 'name' => 'Footer Menu',
- 'before_widget' => '<div class="footer-yazi">',
- 'after_widget' => '</div>',
- 'before_title' => '<strong>',
- 'after_title' => '</strong>'
- ));
- }
- $themename = 'Film Atesi 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 c?kar',
- 'type' => 'textarea'
- ),
- array(
- 'name' => '300x250 Reklam Kodu',
- 'desc' => '300x250 Reklam Kodu',
- 'id' => $shortname . '_r302',
- 'std' => '300x250 Reklam Kodu sadece konu icindeki siderbada sag altta c?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 ustu ',
- 'desc' => 'video ustu reklam kodu',
- 'id' => $shortname . '_r304',
- 'std' => 'bu alana text reklam eklenebilir dilerseniz 600x veya 300x reklam ekleyebilirsiniz',
- 'type' => 'textarea'
- ),
- array(
- 'name' => 'Video Oncesi Reklam',
- 'desc' => 'Video Oncesi Reklam Gosterilsin mi?.',
- 'id' => 'videoreklam',
- 'std' => $default_videoreklam,
- 'type' => 'checkbox'
- ),
- array(
- 'name' => 'Video Oncesi Reklam Kodu',
- 'desc' => 'Video ac?lanana kadar gostermek istediginiz reklam?n kodlar?.',
- 'id' => 'videooncesi',
- 'std' => $default_videooncesi,
- 'type' => 'textarea'
- ),
- array(
- 'name' => 'Gosterim Suresi.Kac Saniye.',
- 'desc' => 'Video Oncesi gosterilecek reklam?n kac saniye gosterilmesini 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');
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement