Skip to content
This repository has been archived by the owner on May 5, 2021. It is now read-only.

Commit

Permalink
Merge pull request #152 from Codeinwp/development
Browse files Browse the repository at this point in the history
Improved code quality
Removed unused code
Improved sanitization function for palette colors options
Regenerate pot file
Update tags in readme.txt
Fixed escaping issues
Changed required plugins to recommended
  • Loading branch information
rodica-andronache authored Oct 5, 2016
2 parents fe526ed + fee9546 commit 274b55e
Show file tree
Hide file tree
Showing 20 changed files with 398 additions and 274 deletions.
1 change: 0 additions & 1 deletion archive.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
* @package zillah
*/

global $wp_customize;
$zillah_sidebar_show = get_theme_mod( 'zillah_sidebar_show', false );

get_header(); ?>
Expand Down
56 changes: 24 additions & 32 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ function zillah_brand(){
} else {
$zillah_logo_old = get_theme_mod( 'zillah_logo_old', false );
echo '<a href="'.esc_url( home_url( '/' ) ).'" class="custom-logo-link" rel="home" itemprop="url">';
echo '<img width="630" height="290" src="'.$zillah_logo_old.'" class="custom-logo" alt="'.esc_attr( get_bloginfo( 'name', 'display' ) ).'" itemprop="logo">';
echo '<img width="630" height="290" src="'.esc_url($zillah_logo_old).'" class="custom-logo" alt="'.esc_attr( get_bloginfo( 'name', 'display' ) ).'" itemprop="logo">';
echo '</a>';
}

Expand Down Expand Up @@ -378,8 +378,6 @@ function zillah_brand(){

function zillah_slider(){

global $post;

$zillah_home_slider_show = get_theme_mod( 'zillah_home_slider_show', false );

if ( ! is_paged() && is_front_page() && ( $zillah_home_slider_show === true || $zillah_home_slider_show === false && is_customize_preview() ) ):
Expand All @@ -398,7 +396,7 @@ function zillah_slider(){

$slider_posts = new WP_Query( $args );

$size = intval( round( $slider_posts->post_count / 2, 0, PHP_ROUND_HALF_DOWN) );
$size = (int)( round( $slider_posts->post_count / 2, 0, PHP_ROUND_HALF_DOWN) );

echo "<div id=\"home-carousel\" class=\"carousel slide home-carousel" . esc_attr( $zillah_home_slider_show === false && is_customize_preview() ? " zillah-only-customizer" : "" ) . "\" data-ride=\"carousel\">";

Expand All @@ -425,11 +423,11 @@ function zillah_slider(){
<?php endif; ?>

<div class="item-inner-half">
<a href="<?php esc_url( the_permalink() ); ?>" class="item-inner-link"></a>
<a href="<?php the_permalink(); ?>" class="item-inner-link"></a>
<?php the_post_thumbnail( 'zillah-slider-thumbnail' ); ?>
<div class="carousel-caption">
<div class="carousel-caption-inner">
<p class="carousel-caption-title" data-postid="<?php the_ID(); ?>"data-excerpt="<?php echo esc_html( get_the_excerpt() ); ?>" data-published="<?php echo get_the_date(); ?>"><a href="<?php esc_url( the_permalink() ); ?>"><?php the_title(); ?></a></p>
<p class="carousel-caption-title" data-postid="<?php the_ID(); ?>" data-excerpt="<?php echo esc_html( get_the_excerpt() ); ?>" data-published="<?php echo get_the_date(); ?>"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></p>
<p class="carousel-caption-category"><?php echo get_the_category_list( ', ' ); ?></p>
</div>
</div>
Expand Down Expand Up @@ -505,12 +503,11 @@ function zillah_php_style() {
$zillah_c1 = $zillah_picker->color1;
$zillah_c2 = $zillah_picker->color2;
$zillah_c3 = $zillah_picker->color3;
$zillah_c4 = $zillah_picker->color4;
$zillah_c5 = $zillah_picker->color5;
}

$header_text_color = get_header_textcolor();
}

$header_text_color = get_theme_mod('header_textcolor','7fcaad');
$zillah_first_font_one = get_theme_mod( 'zillah_google_fonts_one' );
$zillah_first_font_two = get_theme_mod( 'zillah_google_fonts_two' );

Expand All @@ -523,12 +520,17 @@ function zillah_php_style() {

$zillah_font_size = get_theme_mod( 'zillah_select_box_font_size', '16px' );

if( isset( $zillah_c5 ) ) {
$rgb = zillah_get_rgb( $zillah_c5 );
}

echo '<style id="zillah_customizr_pallete" type="text/css">';

if( !empty( $header_text_color ) ) {
echo '
.site-title a, .site-title a:visited {
color: #'. esc_attr( $header_text_color ) . '
}
';
}

if(!empty($zillah_palette_picker)){

/* Color 1 */
Expand Down Expand Up @@ -576,7 +578,6 @@ function zillah_php_style() {
a.more-link:visited,
.reply a,
a.post-edit-link, a.post-edit-link:visited,
.site-title a, .site-title a:visited,
.tags-links a:visited,
.logged-in-as a, .logged-in-as a:visited {
color: ' . $zillah_c2 . ';
Expand All @@ -587,14 +588,14 @@ function zillah_php_style() {
}
}
';
}

if( !empty( $header_text_color ) ) {
echo '
if( empty( $header_text_color ) ) {
echo '
.site-title a, .site-title a:visited {
color: #' . esc_attr( $header_text_color ) . '
color: '. $zillah_c2 . '
}
';
}
}

/* Color 3 */
Expand Down Expand Up @@ -651,7 +652,7 @@ function zillah_php_style() {
';
}

/* Color 5 */
/* Color 4 */
if( !empty( $zillah_c5 ) ) {
echo '
body {
Expand Down Expand Up @@ -749,19 +750,8 @@ function zillah_php_style() {
echo '</style>';
}

/**
* Converts a HEX value to RGB.
*/
function zillah_get_rgb( $color ) {

preg_match_all('!\d+!', $color, $matches);

return array( 'red' => $matches[0][0], 'green' => $matches[0][1], 'blue' => $matches[0][2] );
}


function zillah_custom_excerpt_length( $length ) {
global $wp_customize;
$zillah_sidebar_show = get_theme_mod( 'zillah_sidebar_show', false );

if( $zillah_sidebar_show ) {
Expand Down Expand Up @@ -814,12 +804,14 @@ function zillah_post_image() {

/* Get the first image from post */
function zillah_catch_that_image() {
global $post, $posts;
global $post;
$first_img = false;
ob_start();
ob_end_clean();
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
$first_img = ! empty( $matches[1][0] ) ? $matches[1][0] : false;
preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
if( !empty( $matches[1][0] ) ){
$first_img = $matches[1][0];
}
return $first_img;
}

Expand Down
17 changes: 9 additions & 8 deletions inc/class/zillah-google-fonts.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,19 @@ public function render_content() {
$control_id = $this->control_id;

$ti_google_fonts = '';
foreach( $options['ti_google_fonts'] as $zilla_font ) {
$ti_input_value = implode( '|', $zilla_font);
$ti_google_fonts .= '<label class="ti-google-font-label" style="font-family:\''.$zilla_font['font_family'].'\','.$zilla_font['type'].'"><input type="radio" name="'.$control_id.'" value="'. $ti_input_value .'">'. $zilla_font['font_family'] .'</label>';
if(!empty($options['ti_google_fonts'])){
foreach( $options['ti_google_fonts'] as $zilla_font ) {
$ti_input_value = implode( '|', $zilla_font);
$ti_google_fonts .= '<label class="ti-google-font-label" style="font-family:\''.esc_attr($zilla_font['font_family']).'\','.esc_attr($zilla_font['type']).'"><input type="radio" name="'.esc_attr($control_id).'" value="'. esc_attr($ti_input_value) .'">'. esc_html($zilla_font['font_family']) .'</label>';
}

// Hackily add in the data link parameter.
$ti_google_fonts = str_replace( '<input', '<input ' . $this->get_link(), $ti_google_fonts );
}

// Hackily add in the data link parameter.
$ti_google_fonts = str_replace( '<input', '<input ' . $this->get_link(), $ti_google_fonts );

printf(
'<div class="ti-google-fonts"><span class="customize-control-title">%s</span><div class="ti-google-fonts-wrap">%s</div></div>',
$this->label,
$ti_google_fonts
( !empty($ti_google_fonts) ? $ti_google_fonts : __('No fonts to show', 'zillah') )
);

}
Expand Down
53 changes: 28 additions & 25 deletions inc/class/zillah-palette-picker.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,43 +13,48 @@ public function render_content() {

$values = $this->value();
$json = json_decode($values);

$zillah_pallete = array(
array(
'pallete_name'=>'p1',
'palette_name'=>'p1',
'color1'=>'#be624d',
'color2'=>'#f5876e',
'color3'=>'#be624d',
'color4'=>'#f6f6f6',
'color5'=>'#6f6e6b'
),
array(
'pallete_name'=>'p1',
'palette_name'=>'p1',
'color1'=>'#b0606d',
'color2'=>'#f59f4c',
'color3'=>'#ffc154',
'color4'=>'#fafafa',
'color5'=>'#6f6e6b'
),
array(
'pallete_name'=>'p1',
'palette_name'=>'p1',
'color1'=>'#333331',
'color2'=>'#c2a26f',
'color3'=>'#E2C9A1',
'color4'=>'#f6f6f6',
'color5'=>'#6f6e6b'
),
);
?>
<label>
<span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
</label>

if(!empty($this->label)) { ?>
<label>
<span class="customize-control-title"><?php echo $this->label; ?></span>
</label>
<?php
} ?>

<div class="zillah_palette_selected">
<div class="zillah_palette_input">
<?php
if(!empty($json)){
foreach($json as $color){
echo '<span style="background-color:'.$color.'"></span>';
foreach($json as $key => $value){
if($key !== 'palette_name' && $key !== 'color5'){
echo '<span style="background-color:'.esc_attr($value).'"></span>';
}
}
} else {
esc_html_e('Default','zillah');
Expand All @@ -59,24 +64,22 @@ public function render_content() {
<div class="zillah_dropdown">&#x25BC;</div>
</div>
<ul class="zillah_palette_picker">
<li class="zillah_pallete_default">
<?php
esc_html_e('Default','zillah'); ?>
</li>
<?php
echo '<li class="zillah_pallete_default">';
esc_html_e('Default','zillah');
echo '</li>';
foreach($zillah_pallete as $pallete){
echo '<li class="'.$pallete['pallete_name'].'">';
echo '<span style="background-color:'.$pallete['color1'].'"></span>';
echo '<span style="background-color:'.$pallete['color2'].'"></span>';
echo '<span style="background-color:'.$pallete['color3'].'"></span>';
echo '<span style="background-color:'.$pallete['color4'].'"></span>';
echo '<span style="background-color:'.$pallete['color5'].'"></span>';
foreach($zillah_pallete as $palette){
echo '<li class="'.$palette['palette_name'].'">';
echo '<span style="background-color:'.$palette['color1'].'"></span>';
echo '<span style="background-color:'.$palette['color2'].'"></span>';
echo '<span style="background-color:'.$palette['color3'].'"></span>';
echo '<span style="background-color:'.$palette['color4'].'"></span>';
echo '<span style="background-color:'.$palette['color5'].'"></span>';
echo '</li>';
}
?>
} ?>
</ul>
<input class='zillah_palette_colector' type='hidden' value='' <?php $this->link(); ?> />
<?php
}
}

?>
} ?>
3 changes: 1 addition & 2 deletions inc/class/zillah_category-selector-control.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,4 @@ public function render_content() {
);
}
}
}
?>
} ?>
1 change: 0 additions & 1 deletion inc/custom-header.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
function zillah_custom_header_setup() {
add_theme_support( 'custom-header', apply_filters( 'zillah_custom_header_args', array(
'default-image' => '',
'default-text-color' => '7fcaad',
'width' => 1000,
'height' => 250,
'flex-height' => true,
Expand Down
Loading

0 comments on commit 274b55e

Please sign in to comment.