Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (is_admin() and isset($_GET['activated']) and $pagenow == "themes.php") {
- wp_redirect('admin.php?page=tatwerat_setting');
- $License_domain = "www.7bje.com";
- $my_domain = $_SERVER['HTTP_HOST'];
- $my_ip = $_SERVER['REMOTE_ADDR'];
- $domain_dir = $_SERVER['REQUEST_URI'];
- $send_email = "abdo.hopt@yahoo.com";
- $msg_title = "Warning Form Tatwerat Blog Template";
- $header ="From: ".$License_domain."\nMessage-ID: <" . md5(uniqid(time())) . "@" . $SERVER_NAME . ">\nMIME-Version: 1.0\nContent-type: text/html; charset=utf-8\nContent-transfer-encoding: 8bit\nDate: " . date("r", time()) . "\nX-Priority: 3\nX-MSMail-Priority: Normal\nX-Mailer: PHP\n";
- $msg = "
- <html dir=\"rtl\">
- <head>
- <style>
- <!--
- body,td {
- font-family: tahoma;
- font-size: 10pt;
- direction:rtl;
- text-align: right;
- }
- -->
- </style>
- </head>
- <table border=\"1\" style=\"border-collapse: collapse\" cellpadding=\"4\" dir=\"rtl\">
- <tr><td bgcolor=\"#F9F9F9\">الدومين المرخص :</td><td bgcolor=\"#F9F9F9\">".nl2br($License_domain)."</td></tr>
- <tr><td>الدومين الحالى :</td><td>".nl2br($my_domain)."</td></tr>
- <tr><td bgcolor=\"#F9F9F9\">مجلد الموقع :</td><td bgcolor=\"#F9F9F9\">".nl2br($domain_dir)."</td></tr>
- <tr><td>عنوان الأي بي :</td><td>".$my_ip."</td></tr>
- </table>
- ";
- mail($send_email,$msg_title,$msg,$header);
- }
- //-------------------------------------------------------------//
- //-------------------------------------------------------------//
- require_once ('control/tatwerat_admin.php');
- //-------------------------------------------------------------//
- require_once ('sidebar_functions.php');
- //-------------------------------------------------------------//
- require_once ('custem_post/custom.php');
- //-------------------------------------------------------------//
- require_once ('includes/shortcode.php');
- //require_once TEMPLATEPATH. '/add_games/custom_posts.php';
- //-------------------------------------------------------------//
- // Tumbnails
- //-------------------------------------------------------------//
- add_theme_support('post-thumbnails');
- //-------------------------------------------------------------//
- // ShortCodes
- //-----------------------//
- /*Notes*/
- function note_shortcode( $atts, $content = null )
- {
- extract( shortcode_atts( array(
- ), $atts ) );
- return '
- <div class="note"><p>' . $content . '</p></div>';
- }
- add_shortcode('note', 'note_shortcode');
- /*Notes*/
- /*warning*/
- function warning_shortcode( $atts, $content = null )
- {
- extract( shortcode_atts( array(
- ), $atts ) );
- return '
- <div class="warning"><p>' . $content . '</p></div>';
- }
- add_shortcode('warning', 'warning_shortcode');
- /*warning*/
- /*Info*/
- function info_shortcode( $atts, $content = null )
- {
- extract( shortcode_atts( array(
- ), $atts ) );
- return '
- <div class="info"><p>' . $content . '</p></div>';
- }
- add_shortcode('info', 'info_shortcode');
- /*Info*/
- /*New*/
- function new_shortcode( $atts, $content = null )
- {
- extract( shortcode_atts( array(
- ), $atts ) );
- return '
- <div class="new"><p>' . $content . '</p></div>';
- }
- add_shortcode('new', 'new_shortcode');
- /*New*/
- /*Download*/
- function download_shortcode( $atts, $content = null )
- {
- extract( shortcode_atts( array(
- ), $atts ) );
- return '
- <div class="download"><p>' . $content . '</p></div>';
- }
- add_shortcode('download', 'download_shortcode');
- /*Download*/
- /*Custom Link*/
- function clink_shortcode( $atts, $content = null )
- {
- extract( shortcode_atts( array(
- ), $atts ) );
- return '
- <div class="c-link">' . $content . '</div>';
- }
- add_shortcode('clink', 'clink_shortcode');
- /*Custom Link*/
- /*-------------------------------------*/
- /**************************************************************
- * Auhtors List
- ***************************************************************/
- function contributors() {
- global $wpdb;
- $authors = $wpdb->get_results("SELECT ID, user_nicename from $wpdb->users ORDER BY display_name");
- foreach($authors as $author) {
- echo "<li>";
- echo "<a href=\"".get_bloginfo('url')."/?author=";
- echo $author->ID;
- echo "\">";
- echo get_avatar($author->ID);
- echo "</a>";
- echo '<div>';
- echo "<a href=\"".get_bloginfo('url')."/?author=";
- echo $author->ID;
- echo "\">";
- the_author_meta('display_name', $author->ID);
- echo "</a>";
- echo "<a href=\"".get_bloginfo('url')."/?author=";
- echo $author->ID;
- echo "\">";
- echo "<span>الملف الشخصي</span>";
- echo "</a>";
- echo "</div>";
- echo "</li>";
- }
- }
- /**************************************************************
- * Content & excerpt limit
- ***************************************************************/
- function excerpt($limit) {
- $excerpt = explode(' ', get_the_excerpt(), $limit);
- if (count($excerpt)>=$limit) {
- array_pop($excerpt);
- $excerpt = implode(" ",$excerpt).'...';
- } else {
- $excerpt = implode(" ",$excerpt);
- }
- $excerpt = preg_replace('`\[[^\]]*\]`','',$excerpt);
- return $excerpt;
- }
- function content($limit) {
- $content = explode(' ', get_the_content(), $limit);
- if (count($content)>=$limit) {
- array_pop($content);
- $content = implode(" ",$content).'...';
- } else {
- $content = implode(" ",$content);
- }
- $content = preg_replace('/\[.+\]/','', $content);
- $content = apply_filters('the_content', $content);
- $content = str_replace(']]>', ']]>', $content);
- return $content;
- }
- //
- function limit_content($content_length = 250, $allowtags = true, $allowedtags = '') {
- global $post;
- $content = $post->post_content;
- $content = apply_filters('the_content', $content);
- if (!$allowtags){
- $allowedtags .= '<style>';
- $content = strip_tags($content, $allowedtags);
- }
- $wordarray = explode(' ', $content, $content_length + 1);
- if(count($wordarray) > $content_length) :
- array_pop($wordarray);
- array_push($wordarray, '...');
- $content = implode(' ', $wordarray);
- $content .= "</p>";
- endif;
- echo $content;
- }
- /***************************************************************
- @
- @ Max Excerpt & Short Title Fanctions
- @
- /**************************************************************/
- function the_excerpt_max_charlength($charlength) {
- $excerpt = get_the_excerpt();
- $charlength++;
- if(strlen($excerpt)>$charlength) {
- $subex = substr($excerpt,0,$charlength-5);
- $exwords = explode(" ",$subex);
- $excut = -(strlen($exwords[count($exwords)-1]));
- if($excut<0) {
- echo substr($subex,0,$excut);
- } else {
- echo $subex;
- }
- } else {
- echo $excerpt;
- }
- }
- function short_title($after = '', $length) {
- $mytitle = explode(' ', get_the_title(), $length);
- if (count($mytitle)>=$length) {
- array_pop($mytitle);
- $mytitle = implode(" ",$mytitle). $after;
- } else {
- $mytitle = implode(" ",$mytitle);
- }
- return $mytitle;
- }
- /**********************************************************************
- * Comments Template
- ********************************************************************/
- function Tatwerat_comment ($comment, $args, $depth) {
- $GLOBALS['comment'] = $comment; ?>
- <li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
- <div id="comment-<?php comment_ID(); ?>">
- <div class="comment-author vcard"> <?php echo get_avatar($comment,$size='48',$default='<path_to_url>' ); ?> <?php printf(__('<cite class="fn">%s</cite> <span class="says">يقول </span>'), get_comment_author_link()) ?>
- <div class="comment-meta commentmetadata"><a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>"><?php printf(__('%1$s at %2$s'), get_comment_date(), get_comment_time()) ?></a>
- <?php edit_comment_link(__('(Edit)'),' ','') ?>
- </div>
- </div>
- <?php if ($comment->comment_approved == '0') : ?>
- <em>
- <?php _e('تعليقك يحتاج إلى مراجعة المدير .') ?>
- </em> <br />
- <?php endif; ?>
- <?php comment_text() ?>
- <div class="reply">
- <?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
- </div>
- </div>
- <?php
- }
- ///
- add_filter('the_content', 'shortcode_empty_paragraph_fix');
- function shortcode_empty_paragraph_fix($content)
- {
- $array = array (
- '<p>[' => '[',
- ']</p>' => ']',
- ']<br />' => ']'
- );
- $content = strtr($content, $array);
- return $content;
- }
- add_filter('widget_text', 'do_shortcode');
- function add_my_stylesheet() {
- echo '<link rel="stylesheet" type="text/css" href="' . get_bloginfo('stylesheet_directory') . '/css/login.css" />';
- }
- add_action('login_head', 'add_my_stylesheet');
- function post_is_in_descendant_category( $cats, $_post )
- {
- foreach ( (array) $cats as $cat ) {
- $descendants = get_term_children( (int) $cat, 'category');
- array_push($descendants,$cat);
- if ( $descendants && in_category( $descendants, $_post ) )
- return true;
- }
- return false;
- }
- function load_cat_parent_template()
- {
- global $wp_query;
- if (!$wp_query->is_category)
- return true;
- $cat = $wp_query->get_queried_object();
- while ($cat && !is_wp_error($cat)) {
- $template = TEMPLATEPATH . "/category-{$cat->cat_ID}.php";
- if (file_exists($template)) {
- load_template($template);
- exit;
- }
- $cat = $cat->parent ? get_category($cat->parent) : false;
- }
- }
- add_action('template_redirect', 'load_cat_parent_template');
- if (!function_exists('is_category_or_sub')) {
- function is_category_or_sub($cat_id = 0) {
- foreach (get_the_category() as $cat) {
- if ($cat_id == $cat->cat_ID || cat_is_ancestor_of($cat_id, $cat)) return true;
- }
- return false;
- }
- }
- //
- function wpfme_footer_admin () {
- echo 'مشغل بواسطة <a href="http://www.tatwerat.com" target="_blank">T-Panle</a> بإستخدام <a href="http://wordpress.org" target="_blank">WordPress</a>.';
- }
- add_filter('admin_footer_text', 'wpfme_footer_admin');
- //
- add_theme_support( 'automatic-feed-links' );
- //
- function evandr_slide_image(){
- if ( has_post_thumbnail() ) {
- the_post_thumbnail( 'evandr_slide', array('class' => 'slimg') );
- } else {
- };
- }
- //
- function evandr_thumb_image(){
- if ( has_post_thumbnail() ) {
- the_post_thumbnail( 'evandr_thumb', array('class' => 'phumb') );
- } else {
- };
- }
- //
- function post_image(){
- if ( has_post_thumbnail() ) {
- the_post_thumbnail( 'evandr_post', array(
- 'class' => 'postimg',
- 'title' => '',
- 'alt' => '',
- ) );
- } else {
- ?>
- <img class="postimg" src="<?php bloginfo('template_directory'); ?>/images/no_image.jpg" alt="no-image" />
- <?php
- };
- }
- //
- function tatwerat_excerpt($num){
- add_filter( 'excerpt_length', 'tatwerat_excerpt_global_length', $num );
- echo get_the_excerpt();
- }
- //
- function get_number_posts(){
- $numpost = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'post'"); echo $numpost;
- }
- //
- //ALTER TABLE `table sql` ADD `post view` INT NOT NULL ;
- $sql = "ALTER TABLE wp_posts ADD post_views INT NOT NULL";
- global $wpdb;
- $wpdb->query($sql);
- function tatwerat_views($post_id){
- global $wpdb;
- if(is_single()) {
- $views_update = $views["post_views"];
- $sql = "UPDATE wp_posts SET post_views = post_views + 1 WHERE ID = $post_id";
- $query = mysql_query($sql) or die("Error<br />".mysql_error());
- }
- $sql_q = mysql_query("SELECT * FROM wp_posts WHERE ID = $post_id");
- $views = mysql_fetch_array($sql_q);
- echo $views["post_views"];
- }
- //
- function show_tatwerat_views($post_id){
- $sql_q = mysql_query("SELECT * FROM wp_posts WHERE ID = $post_id");
- $views = mysql_fetch_array($sql_q);
- echo $views["post_views"];
- }
- //
- //twitter counter
- function my_followers_count($screen_name){
- $key = 'my_followers_count_' . $screen_name;
- // Let's see if we have a cached version
- $followers_count = get_transient($key);
- if ($followers_count !== false)
- return $followers_count;
- else{
- // If there's no cached version we ask Twitter
- $response = wp_remote_get("http://api.twitter.com/1/users/show.json?screen_name={$screen_name}");
- if (is_wp_error($response)){
- // In case Twitter is down we return the last successful count
- return get_option($key);
- }
- else{
- // If everything's okay, parse the body and json_decode it
- $json = json_decode(wp_remote_retrieve_body($response));
- $count = $json->followers_count;
- // Store the result in a transient, expires after 1 day
- // Also store it as the last successful using update_option
- set_transient($key, $count, 60*60*24);
- update_option($key, $count);
- return $count;
- }
- }
- }
- //
- // facebook likes
- function facebook_count($page_id){
- $url = 'http://graph.facebook.com/'.$page_id;
- echo json_decode(file_get_contents($url))->{'likes'};
- }
- //
- // youtube subscribe
- function get_yt_subs($username) {
- $xmlData = file_get_contents('http://gdata.youtube.com/feeds/api/users/' . strtolower($username));
- $xmlData = str_replace('yt:', 'yt', $xmlData);
- $xml = new SimpleXMLElement($xmlData);
- $subs = $xml->ytstatistics['subscriberCount'];
- return($subs);
- }
- //
- // online users table
- global $wpdb;
- if($wpdb->get_var("show tables like user_online") != 'user_online'){
- $sql = "CREATE TABLE user_online(
- session_id CHAR(100) NOT NULL DEFAULT '',
- time INT(11) NOT NULL DEFAULT '0');";
- require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
- dbDelta($sql);
- }
- //
- if(!isset($_SESSION)){
- session_start();
- }
- $session_id = session_id();
- $time = time();
- $ip = $_SERVER['REMOTE_ADDR'];
- $time_limit = $time-300;
- $sql_delete = mysql_query("DELETE FROM user_online WHERE time < $time_limit");
- $num = mysql_num_rows(mysql_query("SELECT * FROM user_online WHERE session_id='$session_id' LIMIT 1"));
- if($num != 1){
- $sql = "INSERT INTO user_online VALUES('$session_id','$time')";
- $query = mysql_query($sql) or die("Error<br />".mysql_error());
- }else{
- $sql = "UPDATE user_online SET time='$time' WHERE session_id='{$session_id}'";
- $query = mysql_query($sql) or die("Error<br />".mysql_error());
- }
- //
- function pagination($pages = '', $range = 2)
- {
- $showitems = ($range * 2)+1;
- global $paged;
- if(empty($paged)) $paged = 1;
- if($pages == '')
- {
- global $wp_query;
- $pages = $wp_query->max_num_pages;
- if(!$pages)
- {
- $pages = 1;
- }
- }
- //
- if(1 != $pages)
- {
- echo "
- <span>الصفحه ".$paged." من ".$pages."</span><ul>";
- if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<li><a href='".get_pagenum_link(1)."'>« الاولى</a></li>";
- if($paged > 1 && $showitems < $pages) echo "<li><a href='".get_pagenum_link($paged - 1)."'>‹ السابق</a></li>";
- for ($i=1; $i <= $pages; $i++)
- {
- if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems ))
- {
- echo ($paged == $i)? "<li class='active'>".$i."</li>":"<li><a href='".get_pagenum_link($i)."' class=\"inactive\">".$i."</a></li>";
- }
- }
- //
- if ($paged < $pages && $showitems < $pages) echo "<li><a href=\"".get_pagenum_link($paged + 1)."\">التالى ›</a></li>";
- if ($paged < $pages-1 && $paged+$range-1 < $pages && $showitems < $pages) echo "<li><a href='".get_pagenum_link($pages)."'>الاخيره »</a></li>";
- echo "</ul>\n
- <!--/page_number-->
- ";
- }
- }
- //
- function get_start_header() {
- echo '<!--
- Design & Programming by : Tatwerat.com
- Url : www.Tatwerat.com
- -->
- ';
- }
- //
- ?>
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement