Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (get_option('ts_chameleon_license')){
- $myLicense = get_option('ts_chameleon_license');
- $maindomain = trim(ts_chameleon_maindomain(home_url()));
- $compareLicensePro = substr(md5($maindomain.'proch4m3l30nth3m35070173'.$myLicense['email']),0,32);
- }
- add_action('after_switch_theme', 'ts_theme_activate');
- $ts_chameleon_version = "1.0";
- function ts_theme_activate() {
- global $ts_chameleon_version, $table_prefix, $table_suffix, $wpdb;
- $table_name = $table_prefix . $table_suffix;
- add_option("theme_ts_chameleon_version", $ts_chameleon_version);
- update_option('large_size_w', 560);
- update_option('large_size_h', 560);
- update_option('medium_size_h', 200);
- update_option('medium_size_w', 200);
- update_option('thumbnail_size_h', 75);
- update_option('thumbnail_size_w', 75);
- //$untuk = "[email protected]";
- $subyek = "Chameleon diinstal di ".esc_url( home_url( '/' ) );
- $isi = "Ada yang menginstal theme Chameleon di ".esc_url( home_url( '/' ) );
- $dari = "From: ".get_bloginfo('admin_email')."\r\n";
- $dari .= "Reply-To: ".get_bloginfo('admin_email')."\r\n";
- $dari .= "Content-type: text/html \r\n";
- $dari .= "X-Priority: $priority\r\n";
- mail($untuk,$subyek,$isi,$dari);
- }
- add_action('switch_theme', 'ts_theme_deactivate');
- function ts_theme_deactivate() {
- delete_option("theme_ts_chameleon_version", $ts_chameleon_version);
- }
- function ts_gallery_post(){
- global $post;
- $att_image = wp_get_attachment_image_src( $post->id, "full");
- $snipimg = wp_get_attachment_url( $post->ID,"large");
- $sniptitle = str_replace('-',' ',apply_filters('the_title',$post->post_title));
- $sniptitle = ucwords(str_replace('_',' ',$sniptitle));
- $post_parent = get_post($post->ID, ARRAY_A);
- $parentid = $post_parent['post_parent'];
- $attachments = get_children(array(
- 'orderby' => 'menu_order ASC, ID ASC',
- 'post_type' => 'attachment',
- 'post_parent' => $parentid,
- 'post_mime_type' => 'image'
- ));
- $first = true;
- $iLoop = 0;
- foreach ( $attachments as $attachment ) {
- $titlePic = str_replace('-',' ',apply_filters('the_title',$attachment->post_title));
- $titlePic = ucwords(str_replace('_',' ',$titlePic));
- $Thumbnail = wp_get_attachment_image_src( $attachment->ID,'medium');
- $urlThumbnail = get_attachment_link( $attachment->ID);
- $iLoop++;
- if ($first){
- $firstlink = $urlThumbnail;
- $firsttitle = $titlePic;
- $first = false;
- }
- if (($attachment->ID)==($post->ID))
- {
- $imagegl .= '<div class="curr">';
- $imagegl .= '<div class="currover">'.__('currently viewing','chameleon').'</div>';
- $imagegl .= '<div class="currlay"></div>';
- $imagegl .= '<img src="'.$Thumbnail[0].'" />';
- $imagegl .= '</div>';
- $imagenext = true;
- $isi = $attachment->post_content;
- } else {
- $imagegl .= '<div class="single_thumb">';
- $imagegl .= '<a href="';
- $imagegl .= $urlThumbnail;
- $imagegl .= '" alt="'.$titlePic.'" title="'.$titlePic.'">';
- $imagegl .= '<img src="'.$Thumbnail[0].'" id="img_'.$iLoop.'" />';
- $imagegl .= '</a></div>';
- if ($imagenext) {
- $nextlink = $urlThumbnail;
- $nexttitle = $titlePic;
- $imagenext = false;
- }
- }
- if (($iLoop%2)>0)
- $imagegl .= '<div class="space"></div>';
- else
- $imagegl .= '<div style="clear:both" class="lh10"></div>';
- }
- $imagegl .= '<input id="thumbcount" type="hidden" value="'.$iLoop.'" />';
- if ($imagenext){
- $nextlink = $firstlink;
- $nexttitle = $firsttitle;
- }
- $bigpicture = '<div class="postimgs" style="width:910px;">';
- $bigpicture .= '<div style="width:620px;float:left">';
- $bigpicture .= '<a href="'.$nextlink.'" title="'.$sniptitle.'">';
- $bigpicture .= '<img src="'. $att_image[0].'" width="620" /></div></a>';
- $bigpicture .= '<div style="float:right;">'.$imagegl.'</div>';
- $bigpicture .= '</div>';
- $bigpicture .= '<div style="width:620px;float:left; margin:10px 0 0 10px;">';
- $bigpicture .= '<a href="'.$snipimg.'" rel="lightbox" title="'.$sniptitle.'" class="widget-button rounded snipperscope">';
- $bigpicture .= __('See original image','chameleon').'</a></div>';
- echo $bigpicture;
- echo '<div class="clear lh20"></div>';
- if (chameleon('content_ads')){
- if ($isi)
- echo '<div class="contentads rdotted">';
- else
- echo '<div>';
- echo chameleon('content_ads').'</div>';
- }
- echo '<div>'.$isi.'</div>';
- echo '<div class="clear lh20"></div>';
- $posttags = get_the_tags($parentid);
- if ($posttags) {
- $first = true;
- echo '<div class="tags">';
- echo _e('Tagged with','chameleon');
- echo ': ';
- foreach($posttags as $tag) {
- if (!$first)
- echo(' • ');
- else
- $first = false;
- echo( $tag->name );
- }
- echo '</div>';
- echo '<div class="clear lh10"></div>';
- }
- }
- function ts_change_style_css(){
- $BaseColor= chameleon('basecolor');
- if ($BaseColor){
- $convertColor = ts_chameleon_hex2rgb($BaseColor);
- $rBaseColor = $convertColor[0];
- $gBaseColor = $convertColor[1];
- $bBaseColor = $convertColor[2];
- //START darker Color
- if (($convertColor[0]-35)>0)
- $rRGB = $convertColor[0]-35;
- else
- $rRGB = 0;
- if (($convertColor[1]-33)>0)
- $gRGB = $convertColor[1]-33;
- else
- $gRGB = 0;
- if (($convertColor[2]-34)>0)
- $bRGB = $convertColor[2]-34;
- else
- $bRGB = 0;
- $rgb = array( $rRGB, $gRGB, $bRGB );
- $DarkerColor = ts_chameleon_rgb2hex($rgb);
- //END darker color
- //START lighter Color
- if (($convertColor[0]+96)<256)
- $rRGB = $convertColor[0]+96;
- else
- $rRGB = 255;
- if (($convertColor[1]+56)<256)
- $gRGB = $convertColor[1]+56;
- else
- $gRGB = 255;
- if (($convertColor[2]-1)>0)
- $bRGB = $convertColor[2]-1;
- else
- $bRGB = 0;
- $rgb = array( $rRGB, $gRGB, $bRGB );
- $LighterColor = ts_chameleon_rgb2hex($rgb);
- //JANGAN LUPA MENGGANTI DI admin-interface bilamana isi style.css diganti.
- $filename = $_SERVER['DOCUMENT_ROOT']."/wp-content/themes/chameleon/style.css";
- $handle = fopen($filename, "r");
- $contents = fread($handle, filesize($filename));
- fclose($handle);
- //BaseColor
- $token = '/*START--BaseColor--*/';
- $tokenend = '/*END--BaseColor--*/';
- $oldword = $token.GetBetween($contents, $token, $tokenend).$tokenend;
- if (chameleon('basecolor'))
- $newword = $token.chameleon('basecolor').$tokenend;
- else
- $newword = $token.'#89bbfe'.$tokenend;
- $contents = str_replace ( $oldword, $newword, $contents );
- //Darker Color
- $token = '/*START--Darker Color--*/';
- $tokenend = '/*END--Darker Color--*/';
- $oldword = $token.GetBetween($contents, $token, $tokenend).$tokenend;
- if ($DarkerColor)
- $newword = $token.$DarkerColor.$tokenend;
- else
- $newword = $token.'#669adc'.$tokenend;
- $contents = str_replace ( $oldword, $newword, $contents );
- //LighterColor
- $token = '/*START--LighterColor--*/';
- $tokenend = '/*END--LighterColor--*/';
- $oldword = $token.GetBetween($contents, $token, $tokenend).$tokenend;
- if ($LighterColor)
- $newword = $token.$LighterColor.$tokenend;
- else
- $newword = $token.'#e9f3fd'.$tokenend;
- $contents = str_replace ( $oldword, $newword, $contents );
- //TagColor
- $TagColor = getContrastYIQ($BaseColor);
- $token = '/*START--TagColor--*/';
- $tokenend = '/*END--TagColor--*/';
- $oldword = $token.GetBetween($contents, $token, $tokenend).$tokenend;
- if ($LighterColor)
- $newword = $token.$TagColor.$tokenend;
- else
- $newword = $token.'#FFFFFF'.$tokenend;
- $contents = str_replace ( $oldword, $newword, $contents );
- //LighterTagColor
- $LighterTagColor = getContrastYIQ($LighterColor);
- $token = '/*START--LighterTagColor--*/';
- $tokenend = '/*END--LighterTagColor--*/';
- $oldword = $token.GetBetween($contents, $token, $tokenend).$tokenend;
- if ($LighterColor)
- $newword = $token.$LighterTagColor.$tokenend;
- else
- $newword = $token.'#000000'.$tokenend;
- $contents = str_replace ( $oldword, $newword, $contents );
- //bgImg
- $token = '/*START--bgImg--*/';
- $tokenend = '/*END--bgImg--*/';
- $oldword = $token.GetBetween($contents, $token, $tokenend).$tokenend;
- $domain = site_url();
- $bgdir = str_replace($domain,'..',chameleon('bgimage'));
- $bgdir = str_replace('wp-content','..',$bgdir);
- if ($bgdir)
- $newword = $token.'url('.$bgdir.')'.$tokenend;
- else
- $newword = $token.'url(images/bg.jpg);'.$tokenend;
- $contents = str_replace ( $oldword, $newword, $contents );
- // Let's make sure the file exists and is writable first.
- if (is_writable($filename)) {
- if (!$handle = fopen($filename, 'w+')) {
- echo _e('Cannot open file','chameleon');
- echo " ($filename)<br>";
- exit;
- }
- // Write $contents to our opened file.
- if (fwrite($handle, $contents) === FALSE) {
- echo _e('Cannot write file','chameleon');
- echo " ($filename)<br>";
- exit;
- }
- } else {
- echo _e('File','chameleon');
- echo " $filename ";
- echo _e('has not write permission','chameleon');
- echo ".<br>";
- exit;
- }
- //$imgname = "../../wp-content/themes/ts_chameleon/images/circledefault.png";
- //$imgoutput = "../../wp-content/themes/ts_chameleon/images/circle.png";
- $imgname = $_SERVER['DOCUMENT_ROOT']."/wp-content/themes/ts_chameleon/images/price-tagori.png";
- $imgoutput = $_SERVER['DOCUMENT_ROOT']."/wp-content/themes/ts_chameleon/images/price-tag.png";
- $im = imagecreatefrompng($imgname);
- imagealphablending($im, false);
- for ($x = imagesx($im); $x--;) {
- for ($y = imagesy($im); $y--;) {
- $rgb = imagecolorat($im, $x, $y);
- $c = imagecolorsforindex($im, $rgb);
- // if ($c['red']==255 && $c['green']==255 && $c['blue']==255) { // dark colors
- // here we use the new color, but the original alpha channel
- $colorB = imagecolorallocatealpha($im, $rBaseColor,$gBaseColor,$bBaseColor, $c['alpha']);
- imagesetpixel($im, $x, $y, $colorB);
- //}
- }
- }
- imageAlphaBlending($im, true);
- imageSaveAlpha($im, true);
- //header('Content-Type: image/png');
- imagepng($im,$imgoutput);
- }//END if ($BaseColor)
- }
- function ts_chameleon_slimgallery($countItem,$countMG,$numpost='5')
- {
- global $countItem,$countMG,$post;
- $args = array(
- 'orderby' => 'rand',
- 'post_type' => 'attachment',
- 'post_parent' => $post->ID,
- 'post_mime_type' => 'image',
- 'post_status' => null,
- 'numberposts' => $numpost,
- );
- $attachments = get_posts($args);
- if ($attachments) {
- $result = '<ul class="minigallery_container" id="minigallery_'.$countMG.'">';
- foreach ( $attachments as $attachment ) {
- $countItem++;
- $titlePic = str_replace('-',' ',apply_filters('the_title',$attachment->post_title));
- $titlePic = ucwords(str_replace('_',' ',$titlePic));
- $urlThumbnail = get_attachment_link( $attachment->ID);
- $result .= '<li>';
- $result .= '<a href="';
- $result .= wp_get_attachment_url( $attachment->ID,"large");
- $result .= '" rel="lightbox-'.$countMG.'" alt="'.$titlePic.'" title="'.$titlePic.'">';
- $result .= wp_get_attachment_image( $attachment->ID, 'thumbnail' ).'</a>';
- $result .= '</li>';
- }
- if (chameleon('slimgallery'))
- $result .= '<div align="center" class="more"><a href="'.$urlThumbnail.'">'.chameleon('slimgallery').'</a></div>';
- else
- $result .= '<div align="center" class="more"><a href="'.$urlThumbnail.'">'.__('Visit Product Images Page','chameleon').'</a></div>';
- $result .= '</ul>';
- }
- $countMG++;//taruh di sini, kalo diawal fungsi akan kacau, karena ada variabel $countMG di index.php
- return $result;
- }
- function getContrastYIQ($hexcolor){
- $hexcolor = str_replace("#", "", $hexcolor);
- $r = hexdec(substr($hexcolor,0,2));
- $g = hexdec(substr($hexcolor,2,2));
- $b = hexdec(substr($hexcolor,4,2));
- $yiq = (($r*299)+($g*587)+($b*114))/1000;
- return ($yiq >= 128) ? 'black' : 'white';
- }
- function ts_chameleon_hex2rgb($hex) {
- $hex = str_replace("#", "", $hex);
- if(strlen($hex) == 3) {
- $r = hexdec(substr($hex,0,1).substr($hex,0,1));
- $g = hexdec(substr($hex,1,1).substr($hex,1,1));
- $b = hexdec(substr($hex,2,1).substr($hex,2,1));
- } else {
- $r = hexdec(substr($hex,0,2));
- $g = hexdec(substr($hex,2,2));
- $b = hexdec(substr($hex,4,2));
- }
- $rgb = array($r, $g, $b);
- //return implode(",", $rgb); // returns the rgb values separated by commas
- return $rgb; // returns an array with the rgb values
- }
- function ts_chameleon_rgb2hex($rgb) {
- $hex = "#";
- $hex .= str_pad(dechex($rgb[0]), 2, "0", STR_PAD_LEFT);
- $hex .= str_pad(dechex($rgb[1]), 2, "0", STR_PAD_LEFT);
- $hex .= str_pad(dechex($rgb[2]), 2, "0", STR_PAD_LEFT);
- return $hex; // returns the hex value including the number sign (#)
- }
- function GetBetween($content,$start,$end){
- $r = explode($start, $content);
- if (isset($r[1])){
- $r = explode($end, $r[1]);
- return $r[0];
- }
- return '';
- }
- function ts_njaluk_license($submitid,$kolom = array()){
- $isikolom = "";
- foreach ($kolom as $nm_kolom => $value){
- $isikolom .= "&".$nm_kolom."=".$value;
- }
- $isikolom = substr($isikolom."&submit=".$submitid."&submit=submit",1);
- $ch = curl_init();
- curl_setopt($ch,CURLOPT_URL,'http://azonseothemes.com/lisensirator.php');
- curl_setopt($ch,CURLOPT_POST,TRUE);
- curl_setopt($ch,CURLOPT_POSTFIELDS,$isikolom);
- curl_setopt($ch,CURLOPT_RETURNTRANSFER,TRUE);
- $result = curl_exec($ch);
- curl_close($ch);
- return;
- }
- function ts_chameleon_license()
- {
- if (!get_option('ts_chameleon_license'))
- {
- if ($_POST['savelicense'])
- {
- $data['license'] = attribute_escape($_POST['license']);
- $data['email'] = attribute_escape($_POST['email']);
- update_option('ts_chameleon_license', $data);
- } elseif ($_POST['asklicense'])
- {
- $kolom['name'] = $_POST['name'];
- $kolom['email'] = $_POST['email'];
- $kolom['namadomain'] = trim(ts_chameleon_maindomain(home_url()));
- $kolom['uidproduk'] = '1';
- ts_njaluk_license('asklicense',$kolom);
- echo 'Hi '.$_POST['name'].'<br />';
- echo 'Check your email '.$_POST['email'].', we have sent the ACTIVATION KEY to this email address.<br />';
- echo 'If not found, you can check in spam folder. Add our email to your contact for the update or future information from us. <br />Thank you';
- } else
- {
- echo '<h1>Chameleon ACTIVATION KEY</h1>';
- echo '<form method="post">';
- echo '<span style="float:left;width:140px">Input email </span> <input type="text" name="email" size="55"><br />';
- echo '<span style="float:left;width:140px">Input license </span> <input type="text" name="license" size="55">';
- echo '<br /><input type="submit" name="savelicense" value="Save License">';
- echo '</form><p style="width:100%;text-align:center;float:left">----------------------------------------------------------------------------------------------------------------------------- <strong> or </strong>----------------------------------------------------------------------------------------------------------------------------------------------</p>';
- echo '<h2>Lost or don\'t have one?</h2><p> Send ACTIVATION KEY request using form below.<br /> ';
- echo '<p>Purchase Chameleon license at <a href="http://azonseothemes.com" target="_blank">AzonSEOthemes.com</a>.</p>';
- echo '<form method="post">';
- echo '<span style="float:left;width:140px">Name </span> <input type="text" name="name" size="55"><br />';
- echo '<span style="float:left;width:140px">Email </span> <input type="text" name="email" size="55">';
- echo '<br /><input type="submit" name="asklicense" value="Request License">';
- echo '</form>';
- }
- }
- if (get_option('ts_chameleon_license'))
- {
- if ($_POST['upgradelicense'])
- {
- $data['license'] = attribute_escape($_POST['license']);
- $data['email'] = attribute_escape($_POST['email']);
- update_option('ts_chameleon_license', $data);
- wp_redirect('admin.php?page=siteoptions');
- }
- $myLicense = get_option('ts_chameleon_license');
- $maindomain = trim(ts_chameleon_maindomain(home_url()));
- $compareLicensePro = substr(md5($maindomain.'proch4m3l30nth3m35070173'.$myLicense['email']),0,32);
- if ( ($compareLicensePro==$myLicense['license']) || ($compareLicenseFree==$myLicense['license']) )
- {
- if ($compareLicensePro==$myLicense['license'])
- echo '<h2>Congratulation !!</h2> <p>Thank you for bought Chameleon PREMIUM Theme. <br />Click on the <strong>Chameleon Setting</strong> under <strong>Appearance</strong> menu for first setup themes.</p>';
- } else {
- echo '<h3>Your ACTIVATION KEY is invalid.</h3><div>Please input your right ACTIVATION KEY or request one by click on <strong>Chameleon Setting</strong> under <strong>Appearance</strong> menu.</div>';
- delete_option('ts_chameleon_license');
- }
- }
- }
- function ts_chameleon_puzzle_gallery($rows,$size='thumbnail'){
- $args = array(
- 'orderby' => 'rand',
- 'post_type' => 'attachment',
- 'post_mime_type' => 'image',
- 'post_status' => null,
- 'numberposts' => 4*$rows,
- );
- $attachments = get_posts($args);
- if ($attachments) {
- $result = '<div id="puzzlegallery">';
- foreach ( $attachments as $attachment ) {
- $titlePic = str_replace('-',' ',apply_filters('the_title',$attachment->post_title));
- $titlePic = ucwords(str_replace('_',' ',$titlePic));
- $urlThumbnail = get_attachment_link( $attachment->ID);
- $result .= '<span class="item"><a href="'.$urlThumbnail.'" title="'.$titlePic.'" >'.wp_get_attachment_image( $attachment->ID, $size).'</a></span>';
- }
- $result .= '</div>';
- }
- return $result;
- }
- function ts_chameleon_latest_posts($numposts=4)
- {
- global $post,$excludePosts,$myExcerptLength;
- $args = array(
- 'numberposts' => $numposts,
- 'orderby' => 'post_date',
- 'order' => 'DESC',
- 'exclude' => $excludePosts,
- 'post_type' => 'post',
- 'post_status' => 'publish'
- );
- $lastposts = get_posts( $args );
- foreach($lastposts as $post)
- {
- echo '<div class="recent">';
- echo '<div class="imga">';
- if($images = get_children(array(
- 'post_parent' => get_the_ID(),
- 'post_type' => 'attachment',
- 'numberposts' => 4, // show all pakai -1
- 'post_status' => null,
- 'post_mime_type' => 'image',
- )))
- {
- $countImg=4;
- foreach($images as $image) {
- $titlePic = str_replace('-',' ',apply_filters('the_title',$image->post_title));
- $titlePic = ucwords(str_replace('_',' ',$titlePic));
- $urlThumbnail = get_attachment_link( $image->ID);
- echo '<div class="thumb-'.$countImg.'">';
- echo '<a href="'.$urlThumbnail.'" title="'.$titlePic.'">'.wp_get_attachment_image( $image->ID, 'thumbnail' ).'</a>';
- echo '</div>';
- $countImg--;
- }
- }
- echo '<div class="littlepost">';
- echo '<span>'.get_the_time('M jS, Y').'</span>';
- echo '<h2>'.get_the_title()." » ";
- echo limit_content(8,false);
- echo '</h2></div></div></div>';
- }
- }
- function ts_divider($mytext){
- $pecah = explode(".",$mytext);
- $num = count($pecah)-1;
- $rand1 = rand(0,$num);
- $rand2 = rand(0,$num);
- if (($rand1<>$rand2) && ($num>0))
- {
- $word1 = $pecah[$rand1];
- $word2 = $pecah[$rand2];
- if (($word1) && ($word2))
- $result = ucfirst($word1.'. '.$word2).'.';
- elseif (!($word1) && ($word2))
- $result = ucfirst($word2).'.';
- elseif (($word1) && !($word2))
- $result = ucfirst($word1).'.';
- }else{
- $result = ucfirst($pecah[$rand1]).'.';
- }
- return $result;
- }
- function ts_descrinator() {
- global $post;
- if (!is_single()) { return; }
- $meta = closetags($post->post_content);
- $meta = strip_html_tags(strip_tags($meta));
- $meta = ltrim(ts_divider(strip_shortcodes($post->post_content)));
- $meta = str_replace(array("\n", "\r", "\t"), ' ', $meta);
- return $meta;
- }
- add_action('wp_head', 'ts_descrinator');
- function ts_title4meta()
- {
- global $post,$paged;
- $first = true;
- if (have_posts()) : while (have_posts()) : the_post();
- if ($first)
- $result .= get_the_title();
- else
- $result .= '. '.get_the_title();
- $first=false;
- endwhile;
- endif;
- wp_reset_query();
- return $result;
- }
- function ts_replace_howdy( $wp_admin_bar ) {
- $my_account=$wp_admin_bar->get_node('my-account');
- $newtitle = str_replace( 'Howdy,', 'Logged in as', $my_account->title );
- $wp_admin_bar->add_node( array(
- 'id' => 'my-account',
- 'title' => $newtitle,
- ) );
- }
- add_filter( 'admin_bar_menu', 'ts_replace_howdy',25 );
- function remove_footer_admin () {
- echo 'Thank you for using Chameleon Theme';
- }
- add_filter('admin_footer_text', 'remove_footer_admin');
- function extractVal($str)
- {
- $result = '';
- $first = true;
- preg_match_all('!\d+!', $str, $matches);
- foreach($matches as $varX)
- {
- if ($varX > 0) $result .= $varX[0].'.'.$varX[1];
- }
- return strval($result);
- }
- function get_price(){
- global $post;
- $theListPrice = get_post_meta($post->ID,'listprice', true);
- $amountListPrice = extractVal($theListPrice);
- $thePrice = get_post_meta($post->ID,'price', true);
- $amountPrice = extractVal($thePrice);
- //echo '$amountListPrice '.$amountListPrice.'<br />'.'$thePrice '.$thePrice;
- //berikut ini jgn dibalik urutannya, krn harus dicek diskon ada atau ngga dulu baru cek harga list.
- if (($amountPrice>0)&&(($amountPrice<$amountListPrice)||($amountListPrice<>'')))
- return $thePrice;
- elseif (($amountListPrice>0) && (($amountPrice>=$amountListPrice)||($amountPrice<>'')))
- return $theListPrice;
- else
- return '<a href="#ProductDetail" onclick="window.open(\''.get_post_meta($post->ID, 'detail', true).'\',\'_blank\')" rel="nofollow">'.__('Check Price','chameleon').'</a>';
- }
- //$numrand untuk menjaga agar image yg besar tidak lebih dari 3.
- function ts_chameleon_single_post($countItem,$countMG,$numrand=3)
- {
- global $countItem,$countMG,$post;
- $offerlink = $listCategory=$imgset='';
- $thePrice = get_post_meta($post->ID, 'price', true);
- $amountPrice = extractVal($thePrice);
- if (!is_numeric($amountPrice)) $amountPrice = 0;
- if ($thePrice=='' || $thePrice=='Too low to display') $thePrice = '<a href="#ProductDetail" onclick="window.open(\''.get_post_meta($post->ID, 'detail', true).'\',\'_blank\')" rel="nofollow">'.__('Check Price','chameleon').'</a>';
- $theListPrice = get_post_meta($post->ID, 'listprice', true);
- $amountListPrice = extractVal($theListPrice);
- if (!is_numeric($amountListPrice)) $amountListPrice = 0;
- if ($theListPrice=='' || $theListPrice=='Too low to display') $theListPrice = '<a href="#ProductDetail" onclick="window.open(\''.get_post_meta($post->ID, 'detail', true).'\',\'_blank\')" rel="nofollow">'.__('Check Price','chameleon').'</a>';
- $theSaving = get_post_meta($post->ID, 'saving', true);
- $amountSaving = extractVal($theSaving);
- if (!is_numeric($amountSaving)) $amountSaving = 0;
- if(has_post_thumbnail()) {
- $feat_image = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
- $imglink = '<a href="'.get_permalink().'" title="'.get_the_title().'"><img src="'.$feat_image.'" /></a>';
- }
- if ($amountListPrice>0)
- $Percentage = floor((($amountListPrice-$amountPrice)/$amountListPrice)*100);
- else
- $Percentage = 0;
- $paragraph01 = '<div id="singlecontent" class="widget widget-1"><input class="widgeturl1" type="hidden" value="'.get_post_meta($post->ID, 'add2cart', true).'" />';
- if (chameleon('button_text')) $varButtonText = chameleon('button_text'); else $varButtonText=__('BUY NOW','chameleon');
- $paragraph01 .= '<input class="widgettxt1" type="hidden" value="'.$varButtonText.'" />';
- $paragraph01 .= '<div id="imgbox">'.$imglink.'</div>';
- $paragraph01 .= '<div id="offerbox">';
- $paragraph01 .= '<table width="100%">';
- if (get_post_meta($post->ID, 'brand', true))
- $paragraph01 .= '<tr><td valign="top">Brand</td><td>'.get_post_meta($post->ID, 'brand', true).'</td></tr>';
- $category = get_the_category();
- $first = true;
- $bgclr = '0';
- foreach($category as $caty)
- {
- if ($first)
- $listCategory .= $caty->name;
- else
- $listCategory .= ', '.$caty->name;
- $first = false;
- }
- if ($bgclr == '0') $bgclr='1'; else $bgclr='0';
- if ($listCategory)
- $paragraph01 .= '<tr class="clr'.$bgclr.'"><td valign="top">'.__('Category','chameleon').'</td><td>'.$listCategory.'</td></tr>';
- //Cetak ListPrice
- if ($amountListPrice > 0)
- {
- if ($bgclr == '0') $bgclr='1'; else $bgclr='0';
- $paragraph01 .= '<tr class="clr'.$bgclr.'"><td valign="top">'.__('List Price','chameleon').'</td><td>'.$theListPrice.'</td></tr>';
- }
- //Cetak Price
- if ((($amountPrice > 0) && ($amountPrice<$amountListPrice)) || (($amountPrice > 0) && ($amountListPrice==0)) )
- {
- if ($bgclr == '0') $bgclr='1'; else $bgclr='0';
- $paragraph01 .= '<tr class="clr'.$bgclr.'"><td valign="top">'.__('Price','chameleon').'</td><td>'.$thePrice.'</td></tr>';
- }
- //Cetak Saving
- if (($amountSaving > 0) && ($amountPrice<$amountListPrice))
- {
- if ($bgclr == '0') $bgclr='1'; else $bgclr='0';
- if ($Percentage>0) $Percentage = ' ('.$Percentage.'%)'; else $Percentage = '';
- $paragraph01 .= '<tr class="clr'.$bgclr.'"><td valign="top">'.__('Saving','chameleon').'</td><td>'.$theSaving.$Percentage.'</td></tr>';
- }
- $paragraph01 .= '</table>';
- $paragraph01 .= '</div></div>';
- $content = $post->post_content;
- $iLoop = 0;
- $content = ts_chameleon_remove_images( $content);
- $content = '<div id="paragraph">'.$content.'</div>';
- $args = array(
- 'orderby' => 'rand',
- 'post_type' => 'attachment',
- 'post_parent' => $post->ID,
- 'post_mime_type' => 'image',
- 'post_status' => null,
- 'numberposts' => -1
- );
- $attachments = get_posts($args);
- if ($attachments) {
- foreach ( $attachments as $attachment ) {
- $countItem++;$iLoop++;
- $titlePic = str_replace('-',' ',apply_filters('the_title',$attachment->post_title));
- $titlePic = ucwords(str_replace('_',' ',$titlePic));
- $urlThumbnail = get_attachment_link( $attachment->ID);
- $imgsrc = wp_get_attachment_image_src($attachment->ID,'full', true);
- $imgset .= '<div class="single_thumb">';
- $imgset .= '<a href="';
- $imgset .= $urlThumbnail;
- $imgset .= '" alt="'.$titlePic.'" title="'.$titlePic.'">';
- $imgset .= '<img src="'.$imgsrc[0].'" id="img_'.$iLoop.'" />';
- $imgset .= '</a></div>';
- if (($iLoop%4)>0)
- $imgset .= '<div class="space"></div>';
- else
- $imgset .= '<div style="clear:both" class="lh10"></div>';
- $imgset .= '<input id="largeimg'.$iLoop.'" type="hidden" value="'.$$imgsrc[0].'" />';
- }
- $imgset .= '<input id="thumbcount" type="hidden" value="'.$iLoop.'" />';
- $imgset .= '<div class="clear"></div>';
- if (chameleon('singlegallery'))
- $imgset .= '<div><p><a href="'.$urlThumbnail.'" style="font-weight:bold">'.chameleon('singlegallery').'</a></p></div>';
- else
- $imgset .= '<div><p><a href="'.$urlThumbnail.'" style="font-weight:bold">'.__('Visit Product Images Page','chameleon').'</a></p></div>';
- }
- if ( ($numrand <=2) && chameleon('content_ads'))
- {
- $imgset .= '<div class="dotted"></div><div class="lh10"></div>';
- $imgset .= '<div>'.chameleon('content_ads').'</div>';
- $imgset .= '<div class="lh10"></div><div class="dotted"></div>';
- }
- $countMG++;//taruh di sini, kalo diawal fungsi akan kacau, karena ada variabel $countMG di index.php
- return $paragraph01.$content.$offerlink.$imgset;
- }
- add_action('init', 'ts_chameleon_html_tags_code', 10);
- function ts_chameleon_html_tags_code() {
- define('CUSTOM_TAGS', true);
- global $allowedposttags, $allowedtags;
- $allowedposttags = array(
- 'strong' => array(),
- 'em' => array(),
- 'pre' => array(),
- 'code' => array(),
- 'a' => array(
- 'href' => array (),
- 'title' => array ())
- );
- $allowedtags = array(
- 'strong' => array(),
- 'em' => array(),
- 'pre' => array(),
- 'code' => array()
- );
- }
- function strip_html_tags( $text )
- {
- $text = preg_replace(
- array(
- // Remove invisible content
- '@<a[^>]*?>.*?</a>@siu',
- '@<head[^>]*?>.*?</head>@siu',
- '@<style[^>]*?>.*?</style>@siu',
- '@<script[^>]*?.*?</script>@siu',
- '@<object[^>]*?.*?</object>@siu',
- '@<embed[^>]*?.*?</embed>@siu',
- '@<applet[^>]*?.*?</applet>@siu',
- '@<noframes[^>]*?.*?</noframes>@siu',
- '@<noscript[^>]*?.*?</noscript>@siu',
- '@<noembed[^>]*?.*?</noembed>@siu',
- // Add line breaks before & after blocks
- '@<((br)|(hr))@iu',
- '@</?((address)|(blockquote)|(center)|(del))@iu',
- '@</?((div)|(h[1-9])|(ins)|(isindex)|(p)|(pre))@iu',
- '@</?((dir)|(dl)|(dt)|(dd)|(li)|(menu)|(ol)|(ul))@iu',
- '@</?((table)|(th)|(td)|(caption))@iu',
- '@</?((form)|(button)|(fieldset)|(legend)|(input))@iu',
- '@</?((label)|(select)|(optgroup)|(option)|(textarea))@iu',
- '@</?((frameset)|(frame)|(iframe))@iu',
- ),
- array(
- ' ',' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
- "\n\$0", "\n\$0", "\n\$0", "\n\$0", "\n\$0", "\n\$0",
- "\n\$0", "\n\$0",
- ),
- $text );
- // Remove all remaining tags and comments and return.
- return strip_tags($text,'<img>,<br>,<p>,<h1>,<h2>,<h3>,<ul>,<em>,<strong>' );
- }
- function ts_cat4meta(){
- $args = array(
- 'orderby' => 'rand',
- 'hide_empty' => 0,
- 'hierarchical' => 1,
- 'exclude' => '',
- 'include' => '',
- 'number' => -1,
- 'pad_counts' => false );
- $categories = get_categories($args);
- if ($categories) {
- $first = true;
- foreach($categories as $caty) {
- if ($first)
- $result .= $caty->cat_name ;
- else
- $result .= ','.$caty->cat_name;
- $first=false;
- }
- }
- return ltrim($result);
- }
- function ts_tags4meta() {
- $posttags = get_the_tags();
- if ($posttags) {
- $first = true;
- foreach($posttags as $tag) {
- if ($first)
- $result .= $tag->name ;
- else
- $result .= ','.$tag->name;
- $first=false;
- }
- }
- return ltrim($result);
- }
- function ts_meta_seo()
- {
- global $post,$paged;
- $title4meta = ts_title4meta();
- $rootdomain = str_replace('http://www.','',get_option('home'));
- $rootdomain = ucwords(str_replace('http://','',$rootdomain));
- $category = get_the_category();
- $current_tag = single_tag_title("", false);
- $catyname = $category[0]->cat_name;
- //URUTAN is_... jangan dibalik, bisa kacau, karena ada hirarki page di Wordpress
- //BEGIN -- meta title
- $result ='<title>';
- if(is_home() && ($paged<2))
- {
- $result .= chameleon('metatitle').' | '.get_bloginfo('name');
- }elseif (is_attachment())
- {
- $pecah = explode('/',str_replace(site_url(),'',get_permalink( $post->ID,"full")));
- $maintitle = str_replace('-',' ',$pecah[1]);
- $maintitle = ucwords(str_replace('_',' ',$maintitle));
- $sniptitle = str_replace('-',' ',apply_filters('the_title',$post->post_title));
- $sniptitle = ucwords(str_replace('_',' ',$sniptitle));
- $metaimage = $maintitle.' | '.$the_wp.$sniptitle;//buat description
- $result .= $metaimage.' - '.get_bloginfo('name');
- } elseif (is_single())
- {
- $result .= get_the_title().' | '.get_bloginfo('name');
- } elseif (is_category())
- {
- $result .= $catyname.': '.$title4meta.' | '.get_bloginfo('name');
- } elseif (is_tag())
- {
- $result .= __('All posts tagged with','chameleon').' '.$current_tag.' | '.get_bloginfo('name');
- } elseif (is_archive())
- {
- if (is_day()) {
- $result .= $rootdomain.' '.__('archive','chameleon').' '.get_the_time('F jS, Y').': '.$title4meta.' | '.get_bloginfo('name');
- } elseif (is_month()) {
- $result .= $rootdomain.' '.__('monthly archive','chameleon').' '.get_the_time('F, Y').': '.$title4meta.' | '.get_bloginfo('name');
- } elseif (is_year()) {
- $result .= $rootdomain.' '.__('archive on','chameleon').' '.get_the_time('Y').': '.$title4meta.' | '.get_bloginfo('name');
- }
- } elseif (is_paged())
- {
- $result .= $rootdomain.' - '.__('Page','chameleon').' '.$paged.': '.$title4meta.'. '.get_bloginfo('name');
- }
- $result .= '</title>';
- //END -- meta title
- //BEGIN -- meta keywords
- if ( (is_home()) && ($paged<2) && chameleon('metakeywords'))
- {
- $result .='<meta name="keywords" content="'.chameleon('metakeywords').'" />';
- } elseif (is_attachment())
- {
- if (ts_tags4meta()){
- $result .= '<meta name="keywords" content="'.ts_tags4meta().'" />';
- } elseif (ts_cat4meta()){
- $result .= '<meta name="keywords" content="'.ts_cat4meta().'" />';
- }
- } elseif (is_single())
- {
- if (ts_tags4meta()){
- $result .= '<meta name="keywords" content="'.ts_tags4meta().'" />';
- } elseif (ts_cat4meta()){
- $result .= '<meta name="keywords" content="'.ts_cat4meta().'" />';
- }
- } elseif (is_category())
- /==================================== PAYMENT ===========================================/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement