WordPress.org

Make WordPress Themes


Ignore:
Location:
apricot-blog/1.1.3
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • apricot-blog/1.1.3/functions.php

    r83111 r83111  
    77 * @since Apricot 1.0 
    88 */ 
    9 ?> 
    10  
    11  
    12 <?php 
    139 
    1410 
    1511/* Initial Theme Actions */ 
    16 function apricot_initialize() { 
    17  
     12function apricot_initialize() 
     13{ 
    1814    add_action( 'wp_enqueue_scripts', 'apricot_scripts_and_styles', 999 ); 
    1915    add_action( 'widgets_init', 'apricot_register_sidebars' ); 
     
    2723 
    2824/* Buffer Template Content */ 
    29 function load_template_part($template_name, $part_name=null) { 
     25function load_template_part($template_name, $part_name=null) 
     26{ 
    3027    ob_start(); 
    3128    get_template_part($template_name, $part_name); 
     
    3633 
    3734 
    38  
    3935function apricot_strip_first_content_gallery( $content ) { 
    4036    if ( 'gallery' == get_post_format() ) { 
     
    4440    return $content; 
    4541} 
    46  
    47  
    4842 
    4943 
     
    119113$theme_columns = get_theme_mod('apricot_col_layout','one'); 
    120114$theme_columns = isset($_COOKIE['layout']) ? $_COOKIE['layout'] : $theme_columns; 
    121 if ( isset($_GET['layout']) && ( $_SERVER['HTTP_HOST']=='localhost' || $_SERVER['HTTP_HOST']=='ncrafts.net' ) ) 
    122 { 
    123     $theme_columns = $_GET['layout']=='one' ? 'one' : 'two'; 
    124     setcookie('layout', $theme_columns, time() + (86400 * 30), "/"); 
    125 } 
    126  
    127 if ( ( $_SERVER['HTTP_HOST']=='localhost' || $_SERVER['HTTP_HOST']=='ncrafts.net' ) ) 
    128 { 
    129     $args = array( 
    130         'posts_per_page'   => 3, 
    131         'meta_key'         => 'apricot_is_checked', 
    132         'meta_value'       => 'true', 
    133         'post_type'        => 'post', 
    134         'post_status'      => 'publish', 
    135         'suppress_filters' => true, 
    136         'orderby'          => 'post_date', 
    137         'order'            => 'DESC' 
    138         ); 
    139     $custom_posts = get_posts( $args ); 
    140     $featured = array(); 
    141     foreach($custom_posts as $post) : setup_postdata($post); 
    142     $featured[] = get_the_ID(); 
    143     endforeach; 
    144     wp_reset_query(); 
    145     $featured = isset($featured) ? $featured : array(); 
    146     $featured = isset($_GET['featured']) ? explode(',', $_GET['featured']) : $featured; 
    147     //setcookie('featured', $featured, time() + (86400 * 30), "/"); 
    148 } 
    149115 
    150116$box_layout = get_theme_mod('apricot_box_layout','top'); 
    151117$box_layout = isset($_COOKIE['box']) ? $_COOKIE['box'] : $box_layout; 
    152 if ( isset($_GET['box']) && ( $_SERVER['HTTP_HOST']=='localhost' || $_SERVER['HTTP_HOST']=='ncrafts.net' ) ) 
    153 { 
    154     $box_layout = $_GET['box']=='top' ? 'top' : 'left'; 
    155     setcookie('box', $box_layout, time() + (86400 * 30), "/"); 
    156 } 
    157118 
    158119$theme_color = get_theme_mod('apricot_theme_color','#f08080'); 
    159120$theme_color = isset($_COOKIE['color']) ? $_COOKIE['color'] : $theme_color; 
    160 if ( isset($_GET['color']) && ( $_SERVER['HTTP_HOST']=='localhost' || $_SERVER['HTTP_HOST']=='ncrafts.net' ) ) 
    161 { 
    162     $theme_color = $_GET['color']; 
    163     setcookie('color', $theme_color, time() + (86400 * 30), "/"); 
    164 } 
    165121 
    166122$sidebar_home = get_theme_mod('apricot_sidebar_home','1'); 
    167123$sidebar_home = isset($_COOKIE['sidebar']) ? $_COOKIE['sidebar'] : $sidebar_home; 
    168 if ( isset($_GET['sidebar']) && ( $_SERVER['HTTP_HOST']=='localhost' || $_SERVER['HTTP_HOST']=='ncrafts.net' ) ) 
    169 { 
    170     $sidebar_home = $_GET['sidebar']=='1' ? '1' : '0'; 
    171     setcookie('sidebar', $sidebar_home, time() + (86400 * 30), "/"); 
    172 } 
     124 
    173125$sidebar_post = get_theme_mod('apricot_sidebar_post','1'); 
    174126$sidebar_post = isset($_COOKIE['sidebar']) ? $_COOKIE['sidebar'] : $sidebar_post; 
    175 if ( isset($_GET['sidebar']) && ( $_SERVER['HTTP_HOST']=='localhost' || $_SERVER['HTTP_HOST']=='ncrafts.net' ) ) 
    176 { 
    177     $sidebar_post = $_GET['sidebar']=='1' ? '1' : '0'; 
    178     setcookie('sidebar', $sidebar_post, time() + (86400 * 30), "/"); 
    179 } 
     127 
    180128$sidebar_archive = get_theme_mod('apricot_sidebar_archive','1'); 
    181129$sidebar_archive = isset($_COOKIE['sidebar']) ? $_COOKIE['sidebar'] : $sidebar_archive; 
    182 if ( isset($_GET['sidebar']) && ( $_SERVER['HTTP_HOST']=='localhost' || $_SERVER['HTTP_HOST']=='ncrafts.net' ) ) 
    183 { 
    184     $sidebar_archive = $_GET['sidebar']=='1' ? '1' : '0'; 
    185     setcookie('sidebar', $sidebar_archive, time() + (86400 * 30), "/"); 
    186 } 
     130 
    187131global $featured, $box_layout, $theme_columns, $theme_color, $sidebar_home, $sidebar_post, $sidebar_archive; 
    188132 
     
    193137 
    194138 
    195 add_action('wp_ajax_apricot_form_submit', 'apricot_form_submit'); 
    196 add_action('wp_ajax_nopriv_apricot_form_submit', 'apricot_form_submit'); 
    197 function apricot_form_submit() 
    198 { 
    199     if ( empty($_POST['name']) || empty($_POST['email']) || empty($_POST['comment']) ) 
    200     { 
    201         echo json_encode(array('error'=> __('All fields are required','apricot') )); 
    202         die(); 
    203     } 
    204     if(!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) 
    205     { 
    206         echo json_encode(array('error'=> __('Invalid email','apricot') )); 
    207         die(); 
    208     } 
    209     if (get_option('contact_email_to')=='') 
    210     { 
    211         echo json_encode(array('error'=> __('Email to not specified','apricot') )); 
    212         die(); 
    213     } 
    214  
    215     $name = esc_attr($_POST['name']); 
    216     $email = esc_attr($_POST['email']); 
    217     $comment = esc_attr($_POST['comment']); 
    218  
    219     $headers = ''; 
    220     $headers .= 'From: '.get_option('contact_email_from')."\r\n"; 
    221     $headers .= 'Reply-To: '.$email."\r\n"; 
    222  
    223     $subject = __("Contact Form Submission (".get_bloginfo('name').")",''); 
    224  
    225     $message = ''; 
    226     $message .= __('Name','apricot').":     $name\n"; 
    227     $message .= __('Email','apricot').":        $email\n"; 
    228     $message .= __('Comments','apricot').":     $comment\n"; 
    229  
    230     $sent = wp_mail(get_option('contact_email_to'), $subject, $message, $headers); 
    231     if ($sent || $_SERVER['HTTP_HOST']=='ncrafts.net') 
    232     { 
    233         echo json_encode(array('success'=> __('Message Sent','apricot') )); 
    234         die(); 
    235     } 
    236     else 
    237     { 
    238         echo json_encode(array('error'=> __('Failed. Please try again later.','apricot') )); 
    239         die(); 
    240     } 
    241 } 
    242139 
    243140 
     
    295192} 
    296193 
    297  
    298  
    299 /* Track Post Views for Widget */ 
    300 function apricot_track_post_views ($post_id) { 
    301     if ( !is_single() ) return; 
    302     if ( empty ( $post_id) ) { 
    303         global $post; 
    304         $post_id = $post->ID;    
    305     } 
    306     $count_key = 'apricot_post_views'; 
    307     $count_value = get_post_meta($post_id, $count_key, true); 
    308     if($count_value==''){ 
    309         $count_value = 0; 
    310         delete_post_meta($post_id, $count_key); 
    311         add_post_meta($post_id, $count_key, '1'); 
    312     }else{ 
    313         $count_value++; 
    314         update_post_meta($post_id, $count_key, $count_value); 
    315     } 
    316 } 
    317 add_action( 'wp_head', 'apricot_track_post_views'); 
    318194remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0); 
    319195 
     
    911787} 
    912788function apricot_sanitize_logo( $input ) { 
    913     return $input; 
     789    return esc_url_raw($input); 
    914790} 
    915791function apricot_sanitize_string( $input ) { 
     
    917793} 
    918794function apricot_sanitize_basic( $input ) { 
    919     return $input; 
     795    return esc_sql($input); 
    920796} 
    921797 
     
    11921068            ?> 
    11931069        <?php echo $before_widget; ?> 
    1194         <div class='widgettitle'><span class='active'><?php _e('Latest','apricot'); ?></span><span><?php _e('Popular','apricot'); ?></span></div> 
     1070        <div class='widgettitle'><span class='active'><?php _e('Latest','apricot'); ?></span></div> 
    11951071        <div class='apricot_recent_posts_cover'> 
    11961072            <ul class='apricot_recent_posts_list recent active'> 
     
    12101086                <?php endwhile; ?> 
    12111087            </ul> 
    1212             <?php 
    1213             wp_reset_postdata(); 
    1214             $r = new WP_Query( apply_filters( 'widget_posts_args', array( 'posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true, 'meta_key' => 'apricot_post_views','orderby' => 'meta_value_num' ) ) ); 
    1215             ?> 
    1216             <ul class='apricot_recent_posts_list popular'> 
    1217                 <?php while ( $r->have_posts() ) : $r->the_post(); ?> 
    1218                     <?php 
    1219                     $image = wp_get_attachment_image_src( get_post_thumbnail_id( ), 'thumbnail' ); 
    1220                     ?>         
    1221                     <li> 
    1222                         <a href="<?php the_permalink() ?>" title="<?php echo esc_attr( get_the_title() ? get_the_title() : get_the_ID() ); ?>"> 
    1223                             <span class='img'><?php echo isset($image[0]) ? "<img alt='' src='$image[0]'/>":""; ?></span> 
    1224                             <span class='text'> 
    1225                                 <span class="post-head"><?php if ( get_the_title() ) the_title(); else the_ID(); ?></span> 
    1226                                 <span class="post-date post-views"><?php echo get_post_meta( get_the_ID(), 'apricot_post_views', true ).' '; _e('views','apricot'); ?></span> 
    1227                             </span> 
    1228                         </a> 
    1229                     </li> 
    1230                 <?php endwhile; ?> 
    1231             </ul> 
    12321088        </div> 
    12331089        <?php echo $after_widget; ?> 
     
    12941150    /* Fonts */ 
    12951151    wp_enqueue_style( 'source-sans-pro', '//fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700' ); 
    1296  
    1297     /* Mother Script */ 
    1298     wp_enqueue_script( 'jquery' ); 
    12991152 
    13001153    /* Comments */ 
  • apricot-blog/1.1.3/header.php

    r83111 r83111  
    77 * @since Apricot 1.0 
    88 */ 
    9 ?> 
    10  
    11  
    12 <!DOCTYPE html> 
     9?><!DOCTYPE html> 
    1310<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes() ?>> 
    1411<head> 
     
    126123    <script> 
    127124        window.loadFonts = []; 
    128         <?php if ( ( $_SERVER['HTTP_HOST']=='localhost' || $_SERVER['HTTP_HOST']=='ncrafts.net' ) ) 
    129         { 
    130             ?> 
    131             window.theme_color = '<?php echo $theme_color; ?>'; 
    132             window.box_layout = '<?php echo $box_layout; ?>'; 
    133             window.theme_columns = '<?php echo $theme_columns; ?>'; 
    134             window.sidebar_home = '<?php echo $sidebar_home; ?>'; 
    135             <?php 
    136         } 
    137         ?> 
    138125    </script> 
    139126    <?php 
  • apricot-blog/1.1.3/script.js

    r83111 r83111  
    2828    jQuery('[href="?layout='+encodeURIComponent(window.theme_columns)+'"]').parent().addClass('current-menu-item-fake'); 
    2929    jQuery('[href="?sidebar='+encodeURIComponent(window.sidebar_home)+'"]').parent().addClass('current-menu-item-fake'); 
    30  
    31     jQuery(document).on('submit','.apricot_form',function(event){ 
    32         event.preventDefault(); 
    33         var data = jQuery(this).serialize(); 
    34         jQuery(this).find('.response').text('').removeClass('error success'); 
    35         jQuery(this).find('.submit').val('...').attr('disabled','disabled'); 
    36         jQuery.ajax({ 
    37             url: apricot.ajaxurl, 
    38             type: "POST", 
    39             context: jQuery(this), 
    40             data: 'action=apricot_form_submit&'+data, 
    41             dataType: 'json', 
    42             success: function (response) { 
    43                 jQuery(this).find('.submit').val(jQuery(this).find('.submit').attr('data-text')).removeAttr('disabled'); 
    44                 if (response.error) 
    45                 { 
    46                     jQuery(this).find('.response').text(response.error).addClass('error'); 
    47                 } 
    48                 if (response.success) 
    49                 { 
    50                     jQuery(this).find('.response').text(response.success).addClass('success'); 
    51                     jQuery(this).find('.main-form').slideUp('fast'); 
    52                 } 
    53             }, 
    54             error: function (response) { 
    55  
    56             } 
    57         }); 
    58     }); 
    5930}); 
    6031jQuery(document).mouseup(function (e) 
  • apricot-blog/1.1.3/style.css

    r83111 r83111  
    66Author: Nishant Agrawal 
    77Author URI: https://twitter.com/nish_crafts 
    8 Version: 1.1.2 
     8Version: 1.1.3 
    99License: GNU General Public License v2 or later 
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html 
     
    20042004    opacity: .8; 
    20052005    font-family: Arial; 
    2006 } 
    2007 .apricot_form 
    2008 { 
    2009     position: relative; 
    2010     z-index: 101; 
    2011 } 
    2012 .apricot_form .response 
    2013 { 
    2014     text-align: center; 
    2015     font-size: 1em; 
    2016     margin: 6px auto; 
    2017 } 
    2018 .apricot_form .response.error 
    2019 { 
    2020     color: red; 
    2021 } 
    2022 .apricot_form .response.success 
    2023 { 
    2024     color: green; 
    2025     font-size: 1.1em; 
    2026     border-radius: 2px; 
    2027     width: 100%; 
    2028     margin: 1em auto; 
    2029     border: 1px solid green; 
    2030     padding: 15px; 
    2031     text-align: center; 
    2032 } 
    2033 .apricot_form input, 
    2034 .apricot_form textarea 
    2035 { 
    2036     padding: 10px 12px; 
    2037     font-size: 1.1em; 
    2038     width: 100%; 
    2039     border-radius: 2px; 
    2040     border: 1px solid #ccc; 
    2041     border-top-color: #aaa; 
    2042     border-left-color: #aaa; 
    2043     outline: none; 
    2044     box-shadow: none; 
    2045 } 
    2046 .apricot_form input[type="submit"] 
    2047 { 
    2048     border: 1px solid transparent; 
    2049     color: white; 
    20502006} 
    20512007 
Note: See TracChangeset for help on using the changeset viewer.