Esempio n. 1
1
function image_setup($postid)
{
    global $post;
    $post = get_post($postid);
    // get url
    if (!preg_match('/<img ([^>]*)src=(\\"|\')(.+?)(\\2)([^>\\/]*)\\/*>/', $post->post_content, $matches)) {
        reset_colors($post);
        return false;
    }
    // url setup
    $post->image_url = $matches[3];
    if (!($post->image_url = preg_replace('/\\?w\\=[0-9]+/', '', $post->image_url))) {
        return false;
    }
    $post->image_url = clean_url($post->image_url, 'raw');
    $previous_md5 = get_post_meta($post->ID, 'image_md5', true);
    $previous_url = get_post_meta($post->ID, 'image_url', true);
    if (md5($post->image_tag) != $previous_md5 or $post->image_url != $previous_url) {
        reset_colors($post);
        add_post_meta($post->ID, 'image_url', $post->image_url);
        add_post_meta($post->ID, 'image_md5', md5($post->image_tag));
        //image tag setup
        $extra = $matches[1] . ' ' . $matches[5];
        $extra = preg_replace('/width=(\\"|\')[0-9]+(\\1)/', '', $extra);
        $extra = preg_replace('/height=(\\"|\')[0-9]+(\\1)/', '', $extra);
        $width = is_vertical($post->image_url) ? MIN_WIDTH : MAX_WIDTH;
        delete_post_meta($post->ID, 'image_tag');
        add_post_meta($post->ID, 'image_tag', '<img src="' . $post->image_url . '?w=' . $width . '" ' . $extra . ' />');
        // get colors
        get_all_colors($post);
        return false;
    }
    return true;
}
Esempio n. 2
0
 /**
  * Field Render Function.
  *
  * Takes the vars and outputs the HTML for the field in the settings
  *
  * @since VIBE_Options 1.0
  */
 function render()
 {
     $class = isset($this->field['class']) ? $this->field['class'] : '';
     if (!isset($this->value) || !$this->value) {
         $this->value = $this->field['std'];
     }
     $needle = strtoupper($this->field['id']);
     $theme_colors = array('BODYBG', 'COLOR', 'DARKBG', 'DARKERBG', 'DARKESTBG', 'DARKCOLOR', 'DARKBORDER', 'DARKTITLECOLOR', 'PRIMARYCOLOR', 'PRIMARYLIGHTCOLOR', 'PRIMARYBORDER', 'LIGHTBG', 'LIGHTERBG', 'LIGHTESTBG', 'LIGHTCOLOR', 'LIGHTBORDER', 'LIGHTERBORDER', 'LIGHTERCOLOR', 'LIGHTESTCOLOR', 'LIGHTERBORDER', 'SPECIALBG', 'SPECIALLIGHTBG', 'SPECIALBORDER', 'SPECIALCOLOR');
     if (in_array($needle, $theme_colors)) {
         global $vibe_options;
         if (isset($vibe_options['custom_theme'])) {
             if (!$vibe_options['custom_theme']) {
                 $this->value = reset_colors($needle);
             }
         }
     }
     echo '<div class="farb-popup-wrapper">';
     echo '<input type="text" id="' . $this->field['id'] . '" name="' . $this->args['opt_name'] . '[' . $this->field['id'] . ']" value="' . $this->value . '" class="' . $class . ' popup-colorpicker" style="width:70px;"/>';
     echo '<div class="farb-popup"><div class="farb-popup-inside"><div id="' . $this->field['id'] . 'picker" class="color-picker"></div></div></div>';
     echo isset($this->field['desc']) && !empty($this->field['desc']) ? ' <span class="description">' . $this->field['desc'] . '</span>' : '';
     echo '</div>';
 }
Esempio n. 3
0
function print_stylesheet()
{
    global $post;
    reset_colors($post);
    $color = get_all_colors($post);
    // hack for array keys like -1 being stored in post_meta as 4294967295
    foreach ($color->bg as $key => $value) {
        if (is_int($key) && $key > 0) {
            $key = -(4294967296.0 - $key);
        }
        $new_color->bg[$key] = $value;
    }
    foreach ($color->fg as $key => $value) {
        if (is_int($key) && $key > 0) {
            $key = -(4294967296.0 - $key);
        }
        $new_color->fg[$key] = $value;
    }
    $color = $new_color;
    // end hack
    ?>
	#page {
	  	background-color:#<?php 
    echo $color->bg['-1'];
    ?>
;
		color:#<?php 
    echo $color->fg['-2'];
    ?>
;
	}
	
	a,a:link, a:visited {
		color: #<?php 
    echo $color->fg['-3'];
    ?>
;
	}

  	a:hover, a:active {
		color: #<?php 
    echo $color->bg['+2'];
    ?>
;
	}
	
		h1, h1 a, h1 a:link, h1 a:visited, h1 a:active {
		color: #<?php 
    echo $color->fg['0'];
    ?>
;
		}
		h1 a:hover {
			color:#<?php 
    echo $color->bg['+2'];
    ?>
;
		}
		.navigation a, .navigation a:link, 
		.navigation a:visited, .navigation a:active {
		 
		  	color: #<?php 
    echo $color->fg['0'];
    ?>
;
		}
		h1:hover, h2:hover, h3:hover, h4:hover, h5:hover h6:hover,
		.navigation a:hover {
			color:#<?php 
    echo $color->fg['-2'];
    ?>
;
		}
		
	.description,
	h3#respond,
	#comments,
	h2, h2 a, h2 a:link, h2 a:visited, h2 a:active,
	h3, h3 a, h3 a:link, h3 a:visited, h3 a:active,
	h4, h4 a, h4 a:link, h4 a:visited, h4 a:active,
	h5, h5 a, h5 a:link, h5 a:visited, h5 a:active,
	h6, h6 a, h6 a:link, h6 a:visited, h6 a:active {
	  	/* Use the corresponding foreground color */
	  	color: #<?php 
    echo $color->fg['-1'];
    ?>
;
		border-color: #<?php 
    echo $color->bg['+3'];
    ?>
;
	}

	#postmetadata, #commentform p, .commentlist li, #post, #postmetadata .sleeve, #post .sleeve, #content, h3#respond, h3#comments {
		color: #<?php 
    echo $color->fg['-2'];
    ?>
;
		border-color: #<?php 
    echo $color->fg['-2'];
    ?>
;
	} <?php 
}