Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- ini_set('display_errors', 1);
- define('THEME_INCLUDE',TEMPLATEPATH.'/include/');
- define('THUMB',get_template_directory_uri().'/include/thumbnailer.php');
- $themename = "Hasmi";
- $shortname = "hasmi";
- add_theme_support('menus');
- add_theme_support('automatic-feed-links');
- add_editor_style('editor-style.css');
- add_theme_support('post-thumbnails');
- /* Requiring Files */
- require_once(THEME_INCLUDE.'shortcodes.php');
- require_once(THEME_INCLUDE.'hijri.php');
- require_once(THEME_INCLUDE.'social-widget.php');
- require_once(THEME_INCLUDE.'BFI_Thumb.php');
- // require_once(THEME_INCLUDE.'facebook-widget.php');
- // require_once(THEME_INCLUDE.'instagram-widget.php');
- // require_once(THEME_INCLUDE.'flickr-widget.php');
- // require_once(THEME_INCLUDE.'twitter-widget.php');
- // require_once(THEME_INCLUDE.'twitteroauth/twitteroauth.php'); // grab twitteroauth from correct place
- if(is_admin()){
- require_once(THEME_INCLUDE.'generate-metabox.php');
- require_once(THEME_INCLUDE.'generate-metabox2.php');
- require_once(THEME_INCLUDE.'theme-options.php');
- require_once(THEME_INCLUDE.'settings/metabox-settings.php');
- require_once(THEME_INCLUDE.'settings/theme-settings.php');
- }
- // Registering Widget
- register_widget('social_icons');
- // register_widget('facebook_like');
- // register_widget('instagram_images');
- // register_widget('flickr_images');
- // register_widget('tweet_widget');
- add_theme_support('menus');
- add_theme_support('automatic-feed-links');
- add_editor_style('editor-style.css');
- add_theme_support('post-thumbnails');
- /* Registering Sidebars */
- if (function_exists('register_sidebar')){
- register_sidebar(
- array(
- 'id'=>'sidebar',
- 'name'=>'Sidebar',
- 'before_widget' => '<div id="%1$s" class="group style1 widget %2$s"><div class="group-content">',
- 'after_widget' => '</div></div>',
- 'before_title' => '<div class="group-title"><h2 class="widgettitle">',
- 'after_title' => '</h2></div>'
- )
- );
- register_sidebar(
- array(
- 'id'=>'footer1',
- 'name'=>'Footer 1',
- 'before_widget' => '<div id="%1$s" class="widget %2$s">',
- 'after_widget' => '</div>',
- 'before_title' => '<h2 class="widgettitle">',
- 'after_title' => '</h2>'
- )
- );
- register_sidebar(
- array(
- 'id'=>'footer2',
- 'name'=>'Footer 2',
- 'before_widget' => '<div id="%1$s" class="widget %2$s">',
- 'after_widget' => '</div>',
- 'before_title' => '<h2 class="widgettitle">',
- 'after_title' => '</h2>'
- )
- );
- register_sidebar(
- array(
- 'id'=>'footer3',
- 'name'=>'Footer 3',
- 'before_widget' => '<div id="%1$s" class="widget %2$s">',
- 'after_widget' => '</div>',
- 'before_title' => '<h2 class="widgettitle">',
- 'after_title' => '</h2>'
- )
- );
- register_sidebar(
- array(
- 'id'=>'floatingbanner',
- 'name'=>'Floating Banner',
- 'before_widget' => '<span>',
- 'after_widget' => '</span>'
- )
- );
- };
- /**********************************
- * Theme Menu
- **********************************/
- function theme_menu($loc='',$id='',$class=''){
- if (function_exists('wp_nav_menu') && has_nav_menu($loc))
- wp_nav_menu(array(
- 'theme_location' => $loc,
- 'container' => '',
- 'menu_class' => $class,
- 'menu_id' => $id
- ));
- }
- if (function_exists('register_nav_menu'))
- register_nav_menus(array(
- 'primary_menu'=>'Primary Menu',
- 'secondary_menu'=>'Secondary Menu',
- 'footer_menu'=>'Footer Menu'
- )
- );
- /*******************************
- * pagination
- ********************************/
- function theme_pagination($pages = '', $range = 2){
- global $paged;
- $showitems = ($range * 2)+1;
- if(empty($paged)) $paged = 1;
- if($pages == ''){
- global $wp_query;
- $pages = $wp_query->max_num_pages;
- if(!$pages) { $pages = 1; }
- }
- if(1 != $pages){
- echo "<div id='pagination'>";
- if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<a href='".get_pagenum_link(1)."'>«</a>";
- if($paged > 1 && $showitems < $pages) echo "<a href='".get_pagenum_link($paged - 1)."'>‹</a>";
- for ($i=1; $i <= $pages; $i++){
- if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems )){
- echo ($paged == $i)? "<span class='current'>".$i."</span>":"<a href='".get_pagenum_link($i)."' class='inactive' >".$i."</a>";
- }
- }
- if ($paged < $pages && $showitems < $pages) echo "<a href='".get_pagenum_link($paged + 1)."'>›</a>";
- if ($paged < $pages-1 && $paged+$range-1 < $pages && $showitems < $pages) echo "<a href='".get_pagenum_link($pages)."'>»</a>";
- echo "</div>\n";
- }
- }
- /****************************************
- * Get Real Image Path, needed on WPMU
- ****************************************/
- function get_image_path ($theImageSrc) {
- if (isset($blog_id) && $blog_id > 0) {
- $imageParts = explode('/files/', $theImageSrc);
- if (isset($imageParts[1])) {
- $theImageSrc = '/blogs.dir/' . $blog_id . '/files/' . $imageParts[1];
- }
- }
- return $theImageSrc;
- }
- /***************************************
- * Smart Post Image
- ***************************************/
- function post_image($first=true){
- global $post;
- $image='';
- $image_id = get_post_thumbnail_id($post->ID);
- $image = get_image_path(wp_get_attachment_image_src($image_id,"full"));
- $firstimage=get_first_image();
- $image = $image[0];
- // if(get_option('hasmi_video_thumb') && get_post_meta( $post->ID, "video_link") ) {
- // $link = get_post_meta( $post->ID, "video_link");
- // $image = video_image($link[0]);
- // }
- if ($image) {
- return $image;
- } elseif(!empty($firstimage) && $first != false) {
- return $firstimage;
- } else{
- return false;
- }
- }
- /*************************************
- * Get first image from post
- *************************************/
- function get_first_image(){
- global $post, $posts;
- $first_img = '';
- ob_start();
- ob_end_clean();
- $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
- $first_img="";
- if(isset($matches[1][0])) $first_img = $matches[1][0];
- return $first_img;
- }
- /***************************************
- * Comment list callback function
- ***************************************/
- function theme_comments($comment, $args, $depth) {
- $GLOBALS['comment'] = $comment; ?>
- <li <?php comment_class(); ?> id="comment-<?php comment_ID() ?>">
- <article class="comment-inner">
- <?php echo get_avatar($comment,$size='68'); ?>
- <footer class="comment-meta">
- <div class="comment-author vcard clearfix">
- <span class="fn"><?php comment_author_link()?></span>
- <a href=""><time><?php comment_date('j M Y'); ?></time></a>
- </div>
- <div class="reply">
- <?php comment_reply_link( array_merge( $args, array('reply_text' => 'Reply', 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
- </div>
- </footer>
- <div class="comment-content">
- <?php if ($comment->comment_approved == '0') : ?>
- <p><em>Your comment will appear here once it moderated by Administrator</em></p>
- <?php endif; ?>
- <?php echo get_comment_text(); ?>
- </div>
- </article>
- <?php
- }
- /* Limit generated words */
- function string_limit_words($string, $word_limit)
- {
- $words = explode(' ', $string, ($word_limit + 1));
- if(count($words) > $word_limit) array_pop($words);
- return implode(' ', $words);
- }
- /* Custom Excerpt Length */
- function custom_excerpt_length( $length ) { return 20; }
- add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );
- /* Custom Exceprt More text */
- function new_excerpt_more( $more ) { return '...'; }
- add_filter('excerpt_more', 'new_excerpt_more');
- // add_filter('widget_text', 'do_shortcode');
- function remove_silly_dot($title){
- return str_replace(array(".::","."), "", $title);
- }
- add_filter("the_title",'remove_silly_dot');
- /* tinyMCE Custom Button */
- function tiny_button( $hook ) {
- if( $hook == 'post.php' || $hook == 'post-new.php' ) {
- wp_register_script( 'tinymce_scripts', get_template_directory_uri().'/include/tinymce/js/scripts.js', "",false, true );
- wp_enqueue_script('tinymce_scripts');
- }
- }
- add_action('admin_enqueue_scripts', 'tiny_button');
- /* Including scripts safely */
- function js_theme() {
- wp_register_script( 'bootstrap', get_template_directory_uri().'/js/bootstrap.js', "", null, true);
- // wp_register_script( 'google-map',"http://maps.google.com/maps/api/js?sensor=false&language=en", "", null, true);
- wp_register_script( 'fancy', get_template_directory_uri()."/js/jquery.fancybox.pack.js", "", null, true );
- wp_register_script( 'fancymedia', get_template_directory_uri()."/js/jquery.fancybox-media.js", "", null, true );
- wp_register_script('theme_plugins', get_template_directory_uri().'/js/plugins.js', "", null, true);
- wp_enqueue_script( array('jquery','bootstrap','theme_plugins','fancy','fancymedia' ));
- }
- add_action('wp_enqueue_scripts', 'js_theme');
- function quoteslider(){
- $i=1;
- while($i<=5){
- $quote = get_option("hasmi_quote$i");
- if(!empty($quote)){
- $quotes[]=array(
- "quote"=>get_option("hasmi_quote$i"),
- "cite"=>get_option("hasmi_cite$i")
- );
- }
- $i++;
- }
- echo "<div id='quote-container'>";
- echo '<ul id="quote-list" class="bjqs">';
- foreach($quotes as $quote): ?>
- <li>
- <blockquote>
- <p><?php echo $quote["quote"] ?></p>
- <cite>- <?php echo $quote["cite"] ?></cite>
- </blockquote>
- </li>
- <?php endforeach;
- echo '</ul>';
- echo '</div>';
- }
- function hot_news(){
- query_posts(array("post_type"=>"post","posts_per_page"=>5));
- while(have_posts()) : the_post(); ?>
- <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
- <?php
- endwhile;
- wp_reset_query();
- }
- function fbfan($pageid) {
- $data = file_get_contents('http://graph.facebook.com/' . $pageid);
- if($data){
- $info = json_decode($data);
- return $info->likes;
- }else{
- return false;
- }
- }
- function twitterCounts($username){
- // WordPress Transient API Caching
- $cacheKey = $username . '-cache';
- $cached = get_transient($cacheKey);
- if (false !== $cached)
- {return $cached;}
- // Call and instantiate twitterOAuth. Modify the path to where you uploaded twitteroauth
- require_once (THEME_INCLUDE.'/twitteroauth/twitteroauth.php');
- // Replace the four parameters below with the information from your Twitter developer application.
- $twitterConnection = new TwitterOAuth(get_option("hasmi_twitter_consumer_key"),get_option("hasmi_twitter_consumer_secret"),get_option("hasmi_twitter_access_token"), get_option("hasmi_twitter_access_token_secret"));
- // Send the API request
- $twitterData = $twitterConnection->get('users/show', array('screen_name' => $username));
- // Extract the follower and tweet counts
- $followerCount = $twitterData->followers_count;
- $tweetCount = $twitterData->statuses_count;
- $output = $followerCount . " followers, " . $tweetCount . " tweets";
- set_transient($cacheKey,$output,3600);
- return $output;
- }
- function localize_day($date){
- $hari = array(1=>"Senin","Selasa","Rabu","Kamis","Jum'at","Sabtu","Ahad");
- $day = date("N",$date);
- return $hari[$day];
- }
- function get_latest_youtube ($channel,$limit) {
- // error_reporting(E_ALL);
- $feedURL = 'http://gdata.youtube.com/feeds/api/users/' . $channel . '/uploads?max-results='.$limit.'&v=2&alt=jsonc';
- // $sxml = simplexml_load_file($feedURL);
- $json = file_get_contents($feedURL,0,null,null);
- $json_output = json_decode($json,true);
- if($json_output ){
- foreach ($json_output["data"]["items"] as $entry) {
- $data[]=array(
- "id"=>$entry["id"],
- "url"=>$entry["player"]["default"],
- "thumbnail"=>"http://i1.ytimg.com/vi/".$entry["id"]."/0.jpg",
- "title"=>$entry["title"],
- "desc"=>$entry["description"],
- "watch"=>"http://www.youtube.com/watch?v=".$entry["id"]
- );
- }
- return $data;
- }else{return false;}
- }
- function resize_image($url,$w,$h){
- $params = array( 'width' => $w,'height'=>$h, 'crop'=>true );
- $image = bfi_thumb( $url, $params );
- return $image;
- // return THUMB."?src=".$url."&w=".$w."&h=".$h."&zc=1";
- }
- // function test(){
- // return "http://www.hasmi.org/wp-content/uploads/2013/11/Mar%E2%80%99atush-Shalihah.jpg";
- // }
- // $test = test();
- // echo resize_image($test,20,20);
- /* Background pattern */
- function custom_background(){
- global $shortname;
- $backgroundsrc=get_template_directory_uri()."/images/patterns/";
- $backgroundpattern=get_option($shortname.'_backgroundpattern');
- $backgroundcolor=get_option($shortname.'_backgroundcolor');
- if($backgroundpattern && $backgroundpattern !== "no-pattern"){
- $bodyback='background-image:url("'.$backgroundsrc.$backgroundpattern.'.png") !important;';
- }else{
- $bodyback='background-image:none !important;';
- }
- if($backgroundcolor){
- $bodycolr='background-color:'.$backgroundcolor.' !important;';
- }
- echo "<style>";
- echo "body{";
- echo $bodyback;
- echo $bodycolr;
- echo "}";
- echo $headercolr;
- echo "</style>";
- }
- function get_tweet($user_name="",$limit=5){
- $screen_name = $user_name; // my twitter username
- $number_of_tweets = $limit; // how many do I want?
- $consumerkey = get_option("hasmi_twitter_consumer_key");//"THHJbiXcFZn5JszuH6kSLQ";
- $consumersecret = get_option("hasmi_twitter_consumer_secret");//"7uuxDcEyGDYHMzndRP3pLlcCUEU1I6TDSmGINBhCJY";
- $accesstoken = get_option("hasmi_twitter_access_token");//"275397346-xcq8qLgdRU4Gte2RisTv2ivxyEl5H4WHUoa7x8ux";
- $accesstokensecret = get_option("hasmi_twitter_access_token_secret");//"lUzdmDGZ8nnsWd743LNlIEhXZq7AtMAkKL8nsIs7xqoe2";
- $twitterconn = new TwitterOAuth($consumerkey, $consumersecret, $accesstoken, $accesstokensecret);
- $latesttweets = $twitterconn->get("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=".$screen_name."&count=".$number_of_tweets);
- echo "<ul>";
- foreach($latesttweets as $tweet){ ?>
- <li><p><?php echo preg_replace('/http:\/\/([a-z0-9_\.\-\+\&\!\#\~\/\,]+)/i', '<a href="http://$1" target="_blank">http://$1</a>', $tweet->text); ?></p></li>
- <?php
- }
- echo "</ul>";
- }
- add_filter('widget_text', 'do_shortcode');
- // wp_list_bookmarks();
- // if(function_exists("wp_list_bookmarks")){
- // $args = array(
- // "category_name"=>"sponsor",
- // "categorize"=>0,
- // "title_li"=>null,
- // "show_images"=>true
- // );
- // wp_list_bookmarks($args);
- // }
- function get_partner_links($args){
- ob_start();
- wp_list_bookmarks($args);
- return $ouput = ob_get_clean();
- }
- /*function insert_fb_in_head()
- {
- if (is_singular()) {
- $image = resize_image(post_image(true),200,200);
- $title = get_the_title();
- $type = 'article';
- }
- else {
- $image = get_template_directory_uri()."/images/logo.png";
- $title = bloginfo('name');
- $type = 'blog';
- }
- echo '<meta property="og:image" content="' . $image . '"/>';
- }
- add_action( 'wp_head', 'insert_fb_in_head', 5 );*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement