Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $padd_themename = 'Marikit-Blue';
- $padd_shortname = 'marikit-blue';
- $padd_prefix = 'padd';
- //Activate post-image functionality (WP 2.9+)
- if ( function_exists( 'add_theme_support' ) )
- add_theme_support( 'post-thumbnails' );
- function get_image_path ($post_id = null) {
- if ($post_id == null) {
- global $post;
- $post_id = $post->ID;
- }
- $theImageSrc = wp_get_attachment_url( get_post_thumbnail_id($post_id) );
- global $blog_id;
- 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;
- }
- if (function_exists('register_sidebar')) {
- register_sidebar(array(
- 'name' => 'Side Bar',
- 'before_widget' => '<div class="box box-%2$s">',
- 'after_widget' => '</div></div>',
- 'before_title' => '<div class="title"><h2>',
- 'after_title' => '</h2></div><div class="interior">',
- )
- );
- }
- require get_theme_root() . '/' . $padd_shortname . '/functions/option.php';
- require get_theme_root() . '/' . $padd_shortname . '/functions/advertisement.php';
- $options_general = array(
- new Option(
- $padd_prefix . '_facebook_id',
- 'Faceboook ID',
- 'Your <a href="http://www.facebook.com">Facebook</a> profile ID.',
- 'textbox',
- '250'
- ),
- new Option(
- $padd_prefix . '_twitter_username',
- 'Twitter Username',
- 'Your <a href="http://twitter.com">Twitter</a> user name. You may leave it blank if you don\'t have one but we recommend
- to <a href="http://twitter.com/signup">create an account</a>.',
- 'textbox',
- '250'
- ),
- new Option(
- $padd_prefix . '_stumbleupon_id',
- 'StumbleUpon ID',
- 'Your <a href="http://www.stumbleupon.com">StumbleUpon</a> ID.',
- 'textbox',
- '250'
- ),
- new Option(
- $padd_prefix . '_delicious_id',
- 'Delicious ID',
- 'Your <a href="http://www.delicious.com">Delicious</a> ID.',
- 'textbox',
- '250'
- ),
- new Option(
- $padd_prefix . '_digg_id',
- 'Digg ID',
- 'Your <a href="http://www.digg.com">Digg</a> ID.',
- 'textbox',
- '250'
- ),
- new Option(
- $padd_prefix . '_google_analytics',
- 'Google Analytics Code',
- 'The code provided by Google Analytics. This is optional, though.',
- 'textarea'
- ),
- new Option(
- $padd_prefix . '_youtube_code',
- 'YouTube Embed Code',
- 'The code provided by YouTube for displaying a video located at the sidebar. In order to fit inside the sidebar, set the
- <code><object></code> and <code><embed></code> width to 288 and height to 238. The YouTube provides the smallest possible
- video size is 320 x 265 (without borders).',
- 'textarea'
- ),
- );
- $options_google = array(
- new Option(
- $padd_prefix . '_ad_468_60',
- 'Google Adsense Banner (468x60) Ad Code',
- 'This is for the Google Adsense Banner Ad located above every blog entry, search result, and categories.',
- 'textarea'
- ),
- );
- $options_yourads = array(
- new Advertisement(
- $padd_prefix . '_banner',
- 'Full Banner (468x60)',
- 'The advertisement found at the right side of the blog title.'
- ),
- new Advertisement(
- $padd_prefix . '_sqbtn_1',
- 'Square Ad 1 (125x125)',
- 'The advertisement found at the top of the rightmost side bar.'
- ),
- new Advertisement(
- $padd_prefix . '_sqbtn_2',
- 'Square Ad 2 (125x125)',
- 'The advertisement found at the top of the rightmost side bar.'
- ),
- new Advertisement(
- $padd_prefix . '_sqbtn_3',
- 'Square Ad 3 (125x125)',
- 'The advertisement found at the top of the rightmost side bar.'
- ),
- new Advertisement(
- $padd_prefix . '_sqbtn_4',
- 'Square Ad 4 (125x125)',
- 'The advertisement found at the top of the rightmost side bar.'
- ),
- );
- function themefunction_add_admin() {
- global $padd_themename, $padd_shortname, $options_general, $options_gallery, $options_google, $options_yourads;
- if ( $_GET['page'] == basename(__FILE__) ) {
- if ( 'save' == $_REQUEST['action'] ) {
- foreach ($options_general as $opt) {
- update_option($opt->getKeyword(),$_REQUEST[$opt->getKeyword()]);
- }
- foreach ($options_google as $opt) {
- update_option($opt->getKeyword(),stripslashes($_REQUEST[$opt->getKeyword()]));
- }
- foreach ($options_yourads as $opt) {
- update_option($opt->getKeyword('img'),$_REQUEST[$opt->getKeyword('img')]);
- update_option($opt->getKeyword('web'),$_REQUEST[$opt->getKeyword('web')]);
- }
- header("Location: themes.php?page=functions.php&saved=true");
- die;
- } else if ( 'reset' == $_REQUEST['action'] ) {
- foreach ($options_general as $opt) {
- delete_option($opt->getKeyword());
- }
- foreach ($options_gallery as $opt) {
- delete_option($opt->getKeyword());
- }
- foreach ($options_google as $opt) {
- delete_option($opt->getKeyword());
- }
- foreach ($options_yourads as $opt) {
- delete_option($opt->getKeyword('img'));
- delete_option($opt->getKeyword('web'));
- }
- header("Location: themes.php?page=functions.php&reset=true");
- die;
- }
- }
- add_theme_page($padd_themename ." Options", $padd_themename . " Options", 'edit_themes', basename(__FILE__), 'themefunction_admin');
- }
- function themefunction_admin() {
- global $padd_themename, $padd_shortname, $options_general, $options_gallery, $options_google, $options_yourads;
- if ( $_REQUEST['saved'] ) echo '<div id="message" class="updated fade"><p><strong>'.$padd_themename.' settings saved.</strong></p></div>';
- if ( $_REQUEST['reset'] ) echo '<div id="message" class="updated fade"><p><strong>'.$padd_themename.' settings reset.</strong></p></div>';
- require get_theme_root() . '/' . $padd_shortname . '/functions/userinterface.php';
- }
- add_action('admin_menu', 'themefunction_add_admin');
- /********************************************/
- /**** Functions used for hooking filters ****/
- /********************************************/
- function themefunction_alter_list_pages($string) {
- $string = str_replace(array("\n","\r","\t"),'', $string);
- $pattern = array('/<ul[^<>]*>/','/<\/ul[^<>]*>/');
- $replace = array('','');
- $string = preg_replace($pattern,$replace,$string);
- $pattern = array('/<a[^<>]*>/','/<\/a[^<>]*>/');
- $replace = array('$0<span><span>','</span></span>$0');
- $string = preg_replace($pattern,$replace,$string);
- $string = str_replace(array('</a><li','</li></li>'),array('</a></li><li','</li>'),$string);
- return $string;
- }
- function themefunction_alter_page_menu($string) {
- $string = themefunction_alter_list_pages($string);
- $pattern = array('/<div[^<>]*>/','/<\/div[^<>]*>/');
- $replace = array('','');
- $string = preg_replace($pattern,$replace,$string);
- return $string;
- }
- function themefunction_alter_category_menu($string) {
- $string = themefunction_alter_list_pages($string);
- $pattern = array('/<div[^<>]*>/','/<\/div[^<>]*>/');
- $replace = array('<span>$0','$0</span>');
- $string = preg_replace($pattern,$replace,$string);
- return $string;
- }
- function themefunction_alter_links($string) {
- $pattern = array('/<a[^<>]*>/','/<\/a[^<>]*>/');
- $replace = array('<span>$0','$0</span>');
- $string = preg_replace($pattern,$replace,$string);
- return $string;
- }
- /***********************************************/
- /**** Add filters when necessary **************/
- /***********************************************/
- add_filter('wp_list_pages','themefunction_alter_links');
- add_filter('wp_list_cats','themefunction_alter_links');
- add_filter('wp_list_bookmarks','themefunction_alter_links');
- add_filter('get_archives_link','themefunction_alter_links');
- /***********************************************/
- /**** Functions used for modifying the look ****/
- /***********************************************/
- function themefunction_page_menu() {
- add_filter('wp_page_menu','themefunction_alter_page_menu');
- wp_page_menu('show_home=1&title_li=');
- remove_filter('wp_page_menu','themefunction_alter_page_menu');
- }
- function themefunction_category_menu() {
- add_filter('wp_list_categories','themefunction_alter_category_menu');
- wp_list_categories('sort_column=name&optioncount=0&hierarchical=0&list=0&title_li=');
- remove_filter('wp_list_categories','themefunction_alter_page_menu');
- }
- function themefunction_cleanup($str) {
- global $akpc, $post;
- $show = true;
- $show = apply_filters('akpc_display_popularity', $show, $post);
- if (is_feed() || is_admin_page() || get_post_meta($post->ID, 'hide_popularity', true) || !$show) {
- return $str;
- }
- return $str.'';
- }
- function themefunction_list_bookmarks() {
- $array = array();
- $array[] = 'category_before=';
- $array[] = 'category_after=';
- $array[] = 'categorize=0';
- $array[] = 'title_li=';
- wp_list_bookmarks(implode('&',$array));
- }
- function themefunction_recent_post() {
- echo '<ul>';
- wp_get_archives('type=postbypost&limit=5');
- echo '</ul>';
- }
- function themefunction_get_categories($cat_id) {
- if ('' != get_the_category_by_ID($cat_id)) {
- echo '<li>';
- echo '<a href="' . get_category_link($cat_id) . '">' . get_the_category_by_ID($cat_id) . '</a>';
- if ('' != (get_category_children($cat_id))) {
- echo '<ul>';
- wp_list_categories('hide_empty=0&title_li=&child_of=' . $cat_id);
- echo '</ul>';
- }
- echo '</li>';
- }
- }
- function themefunction_recent_comments($limit=5) {
- global $wpdb, $comments, $comment;
- if ( !$comments = wp_cache_get( 'recent_comments', 'widget' ) ) {
- $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT $limit");
- wp_cache_add( 'recent_comments', $comments, 'widget' );
- }
- ?>
- <ul id="recentcomments">
- <?php
- if ( $comments ) : foreach ( (array) $comments as $comment) :
- echo '<li class="recentcomments"><span><span>' . sprintf(__('%1$s on %2$s'), get_comment_author_link(), '<a href="'. get_comment_link($comment->comment_ID) . '">' . get_the_title($comment->comment_post_ID) . '</a>') . '</span></span></li>';
- endforeach; endif;?>
- </ul>
- <?php
- }
- //EXCERPT
- function excerpt_length( $length ) {
- return 10;
- }
- add_filter( 'excerpt_length', 'excerpt_length' );
- function continue_reading_link() {
- return '';
- }
- function auto_excerpt_more( $more ) {
- return ' …' . continue_reading_link();
- }
- add_filter( 'excerpt_more', 'auto_excerpt_more' );
- function custom_excerpt_more( $output ) {
- if ( has_excerpt() && ! is_attachment() ) {
- $output .= continue_reading_link();
- }
- return $output;
- }
- add_filter( 'get_the_excerpt', 'custom_excerpt_more' );
- //EXCERPT
- function themefunction_comments($comment, $args, $depth) {
- $GLOBALS['comment'] = $comment; ?>
- <li <?php comment_class(); ?> id="comment-<?php comment_ID() ?>">
- <div class="comment" id="div-comment-<?php comment_ID(); ?>">
- <div class="comment-author vcard">
- <?php echo get_avatar($comment,$size='32',$default='<path_to_url>' ); ?>
- <?php printf(__('<cite class="fn">%s</cite> <span class="says">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('Your comment is awaiting moderation.') ?></em>
- <?php endif; ?>
- <?php comment_text() ?>
- <div class="reply">
- <?php comment_reply_link(array_merge( $args, array('add_below' => 'div-comment', 'depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
- </div>
- </div>
- <?php
- }
- function themefunction_imageresizer ($atts, $content=null){
- return '<img src="' . get_theme_root() . '/' . $padd_shortname . '/functions/timthumb.php?src=' . $content . '&w=300&h=250&zc=1" alt="">';
- }
- add_shortcode('img', 'themefunction_imageresizer');
- function themefunction_catch_that_image() {
- global $post, $posts;
- $first_img = '';
- ob_start();
- ob_end_clean();
- $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
- $first_img = $matches [1] [0];
- // no image found display default image instead
- if(empty($first_img)){
- $first_img = get_bloginfo('wpurl') . '/wp-content/themes/marikit-blue/images/thumbnail.png';
- }
- return $first_img;
- }
- function themefunction_getTinyUrl($url) {
- $tinyurl = file_get_contents("http://tinyurl.com/api-create.php?url=".$url);
- return $tinyurl;
- }
- function themefunction_twitter_parse($feed) {
- $stepOne = explode("<content type=\"html\">", $feed);
- $stepTwo = explode("</content>", $stepOne[1]);
- $tweet = $stepTwo[0];
- $tweet = str_replace("<", "<", $tweet);
- $tweet = str_replace(">", ">", $tweet);
- return $tweet;
- }
- function themefunction_twitter_get_recent_entry($user) {
- $feed = 'http://search.twitter.com/search.atom?q=from:' . $user . '&rpp=1';
- $twitterFeed = file_get_contents($feed);
- return themefunction_twitter_parse($twitterFeed);
- }
- function themefunction_twitter_get_recent_entries($user) {
- $feed = 'http://search.twitter.com/search.atom?q=from:' . $user . '&rpp=3';
- $twitterFeed = file_get_contents($feed);
- $twitterFeed = str_replace("<", "<", $twitterFeed);
- $twitterFeed = str_replace(">", ">", $twitterFeed);
- $clean = explode("<content type=\"html\">", $twitterFeed);
- $amount = count($clean) - 1;
- echo '<ul class="twitter">';
- for ($i = 1; $i <= $amount-1; $i++) {
- $cleaner = explode("</content>", $clean[$i]);
- echo '<li class="twitter-item">';
- echo $cleaner[0];
- echo '</li>';
- }
- $cleaner = explode("</content>", $clean[$i]);
- echo '<li class="twitter-lastitem">';
- echo $cleaner[0];
- echo '</li>';
- echo '</ul>';
- }
- //ADD METABOX
- $prefix = 'dbt_';
- $meta_box = array(
- 'id' => 'my-meta-box',
- 'title' => 'Coupon Information Box',
- 'page' => 'post',
- 'context' => 'normal',
- 'priority' => 'high',
- 'fields' => array(
- array(
- 'name' => 'Coupon Affiliate Link',
- 'desc' => 'Enter Coupon Affiliate Link',
- 'id' => $prefix . 'affiliate_link',
- 'type' => 'text',
- 'std' => ''
- ),
- array(
- 'name' => 'Coupon Code',
- 'desc' => 'Enter Coupon Code',
- 'id' => $prefix . 'coupon_code',
- 'type' => 'text',
- 'std' => ''
- )
- )
- );
- add_action('admin_menu', 'mytheme_add_box');
- // Add meta box
- function mytheme_add_box() {
- global $meta_box;
- add_meta_box($meta_box['id'], $meta_box['title'], 'mytheme_show_box', $meta_box['page'], $meta_box['context'], $meta_box['priority']);
- }
- // Callback function to show fields in meta box
- function mytheme_show_box() {
- global $meta_box, $post;
- // Use nonce for verification
- echo '<input type="hidden" name="mytheme_meta_box_nonce" value="', wp_create_nonce(basename(__FILE__)), '" />';
- echo '<table class="form-table">';
- foreach ($meta_box['fields'] as $field) {
- // get current post meta data
- $meta = get_post_meta($post->ID, $field['id'], true);
- echo '<tr>',
- '<th style="width:20%"><label for="', $field['id'], '">', $field['name'], '</label></th>',
- '<td>';
- switch ($field['type']) {
- case 'text':
- echo '<input type="text" name="', $field['id'], '" id="', $field['id'], '" value="', $meta ? $meta : $field['std'], '" size="30" style="width:97%" />',
- '<br />', $field['desc'];
- break;
- case 'textarea':
- echo '<textarea name="', $field['id'], '" id="', $field['id'], '" cols="60" rows="4" style="width:97%">', $meta ? $meta : $field['std'], '</textarea>',
- '<br />', $field['desc'];
- break;
- case 'select':
- echo '<select name="', $field['id'], '" id="', $field['id'], '">';
- foreach ($field['options'] as $option) {
- echo '<option', $meta == $option ? ' selected="selected"' : '', '>', $option, '</option>';
- }
- echo '</select>';
- break;
- case 'radio':
- foreach ($field['options'] as $option) {
- echo '<input type="radio" name="', $field['id'], '" value="', $option['value'], '"', $meta == $option['value'] ? ' checked="checked"' : '', ' />', $option['name'];
- }
- break;
- case 'checkbox':
- echo '<input type="checkbox" name="', $field['id'], '" id="', $field['id'], '"', $meta ? ' checked="checked"' : '', ' />';
- break;
- }
- echo '<td>',
- '</tr>';
- }
- echo '</table>';
- }
- add_action('save_post', 'mytheme_save_data');
- // Save data from meta box
- function mytheme_save_data($post_id) {
- global $meta_box;
- // verify nonce
- if (!wp_verify_nonce($_POST['mytheme_meta_box_nonce'], basename(__FILE__))) {
- return $post_id;
- }
- // check autosave
- if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
- return $post_id;
- }
- // check permissions
- if ('page' == $_POST['post_type']) {
- if (!current_user_can('edit_page', $post_id)) {
- return $post_id;
- }
- } elseif (!current_user_can('edit_post', $post_id)) {
- return $post_id;
- }
- foreach ($meta_box['fields'] as $field) {
- $old = get_post_meta($post_id, $field['id'], true);
- $new = $_POST[$field['id']];
- if ($new && $new != $old) {
- update_post_meta($post_id, $field['id'], $new);
- } elseif ('' == $new && $old) {
- delete_post_meta($post_id, $field['id'], $old);
- }
- }
- }
- ?>
Add Comment
Please, Sign In to add comment