$themename = "Seduction";
$shortname = "theme_";
$options = array (
array(
"name"=>"Videos urls",
"id"=>$shortname."_videosArray",
"std"=>"a:5:{s:10:\"url_video1\";a:3:{s:4:\"link\";s:1:\"#\";s:6:\"height\";i:256;s:5:\"width\";i:300;}s:10:\"url_video2\";a:3:{s:4:\"link\";s:1:\"#\";s:6:\"height\";i:256;s:5:\"width\";i:300;}s:10:\"url_video3\";a:3:{s:4:\"link\";s:1:\"#\";s:6:\"height\";i:256;s:5:\"width\";i:300;}s:10:\"url_video4\";a:3:{s:4:\"link\";s:1:\"#\";s:6:\"height\";i:256;s:5:\"width\";i:300;}s:10:\"url_video5\";a:3:{s:4:\"link\";s:1:\"#\";s:6:\"height\";i:256;s:5:\"width\";i:300;}}"),
array(
"name"=>"Banners",
"id"=>$shortname."_bannersArray",
"std"=>"a:7:{s:13:\"theme_banner1\";a:5:{s:4:\"link\";s:1:\"#\";s:9:\"image_url\";s:0:\"\";s:6:\"height\";i:125;s:5:\"width\";i:125;s:6:\"status\";i:0;}s:13:\"theme_banner2\";a:5:{s:4:\"link\";s:1:\"#\";s:9:\"image_url\";s:0:\"\";s:6:\"height\";i:125;s:5:\"width\";i:125;s:6:\"status\";i:0;}s:13:\"theme_banner3\";a:5:{s:4:\"link\";s:1:\"#\";s:9:\"image_url\";s:0:\"\";s:6:\"height\";i:125;s:5:\"width\";i:125;s:6:\"status\";i:0;}s:13:\"theme_banner4\";a:5:{s:4:\"link\";s:1:\"#\";s:9:\"image_url\";s:0:\"\";s:6:\"height\";i:125;s:5:\"width\";i:125;s:6:\"status\";i:0;}s:13:\"theme_banner5\";a:6:{s:4:\"link\";s:1:\"#\";s:9:\"image_url\";s:0:\"\";s:6:\"height\";i:250;s:5:\"width\";i:300;s:6:\"status\";i:0;s:7:\"adsense\";s:0:\"\";}s:13:\"theme_banner6\";a:6:{s:4:\"link\";s:1:\"#\";s:9:\"image_url\";s:0:\"\";s:6:\"height\";i:90;s:5:\"width\";i:728;s:6:\"status\";i:0;s:7:\"adsense\";s:0:\"\";}s:13:\"theme_banner7\";a:6:{s:4:\"link\";s:1:\"#\";s:9:\"image_url\";s:0:\"\";s:6:\"height\";i:600;s:5:\"width\";i:160;s:6:\"status\";i:0;s:7:\"adsense\";s:0:\"\";}}"
),
array(
"name"=>"Styles",
"id"=>$shortname."_css",
"std"=>"style.css"
),
array(
"name"=>"flickr",
"id"=>$shortname."_flickr",
"std"=>"a:4:{s:4:\"nsid\";s:0:\"\";s:7:\"display\";s:0:\"\";s:11:\"displayType\";s:0:\"\";s:4:\"tags\";s:0:\"\";}"
),
array(
"name"=>"Feedburner",
"id"=>$shortname."_feedburner",
"std"=>"a:2:{s:2:\"id\";s:0:\"\";s:3:\"num\";s:1:\"5\";}"
),
array(
"name"=>"FeedbSumition",
"id"=>$shortname."_feedburnerSumition",
"std"=>""
),
array(
"name"=>"BannersStatus",
"id"=>$shortname."_bannerStatus",
"std"=>"1"
),
array(
"name"=>"categoriesSubMenu",
"id"=>$shortname."_categoriesSubmenu",
"std"=>"a:0:{}"
),
array(
"name"=>"homePostCategory",
"id"=>$shortname."_homePostCategory",
"std"=>""
),
array(
"name"=>"homeRandomPosts",
"id"=>$shortname."_homeRandomPosts",
"std"=>"1"
),
array(
"name"=>"randomCategoryPost",
"id"=>$shortname."_SliderPosts",
"std"=>""
)
);
$flickrDisplayType = Array("square","thumbnail","small");
$cssFiles = get_availableCss();
function get_bannersSettings($bannerId,$index = FALSE){
global $themename,$shortname,$options;
$theBanners = get_settings($shortname."_bannersArray");
if(!is_array($theBanners)){
$theBanners = unserialize($options[1]["std"]);
}
$theActualBanner = $theBanners[$bannerId];
if($index != FALSE){
return $theActualBanner[$index];
}else{
return $theActualBanner;
}
}
function get_videoSettings($videoId,$index){
global $themename,$shortname,$options;
$theVideos = get_settings($shortname."_videosArray");
if(!is_array($theVideos)){
$theVideos = unserialize($options[0]["std"]);
}
$theActualVideo = $theVideos[$videoId];
return $theActualVideo[$index];
}
function get_flickrSettings($index){
global $themename,$shortname,$options;
$theflickrSettings = get_settings($shortname."_flickr");
if(!is_array($theflickrSettings)){
$theflickrSettings = unserialize($options[3]["std"]);
}
return $theflickrSettings[$index];
}
function get_feedburner($index){
global $themename,$shortname,$options;
$thefeedburnerSettings = get_settings($shortname."_feedburner");
if(!is_array($thefeedburnerSettings)){
$thefeedburnerSettings = unserialize($options[4]["std"]);
}
return $thefeedburnerSettings[$index];
}
function get_availableCss(){
$result = array();
$dir = dir(TEMPLATEPATH."/");
while (false !== ($file = $dir->read())) {
if(ereg("\.css",$file,$r)){
$result[] = $file;
}
}
$dir->close();
return $result;
}
function newThemeOptions_add_admin() {
global $themename,$shortname,$options,$cssFiles;
if ( $_GET['page'] == basename('D:\WORK\Server\www\24\1.php') ) {
if($_REQUEST['saveButton']){
while(list($videoId,$bannerInfo) = each($_REQUEST[$shortname."_video"])){
$videoInfo["width"] = get_videoSettings($videoId,"width");
$videoInfo["height"] = get_videoSettings($videoId,"height");
$videoInfo["link"] = $_REQUEST[$shortname."_video"][$videoId]["link"];
$allVideos[$videoId] = $bannerInfo;
}
update_option( $shortname."_videosArray",$allVideos);
update_option( $shortname."_css",$_REQUEST[$shortname."_css"] );
while(list($bannerId,$bannerInfo) = each($_REQUEST[$shortname."_banner"])){
$bannerInfo["width"] = get_bannersSettings($bannerId,"width");
$bannerInfo["height"] = get_bannersSettings($bannerId,"height");
$bannerInfo["status"] = $_REQUEST[$shortname."_banner"][$bannerId]["status"];
if($_REQUEST[$shortname."_banner"][$bannerId]["adsense"])
$bannerInfo["adsense"] = ($_REQUEST[$shortname."_banner"][$bannerId]["adsense"]);
$allBanners[$bannerId] = $bannerInfo;
}
update_option( $shortname."_bannersArray",$allBanners);
update_option( $shortname."_flickr",$_REQUEST[$shortname."_flickr"]);
update_option( $shortname."_feedburner",$_REQUEST[$shortname."_feedburner"]);
update_option( $shortname."_feedburnerSumition",$_REQUEST[$shortname."_feedburnerSumition"]);
update_option( $shortname."_bannerStatus",$_REQUEST[$shortname."_bannerStatus"]);
update_option( $shortname."_categoriesSubmenu",$_REQUEST[$shortname."_categoriesSubmenu"]);
update_option( $shortname."_homePostCategory",$_REQUEST[$shortname."_homePostCategory"] );
update_option( $shortname."_homeRandomPosts",$_REQUEST[$shortname."_homeRandomPosts"] );
update_option( $shortname."_SliderPosts",$_REQUEST[$shortname."_SliderPosts"] );
header("Location: themes.php?page=functions.php&saved=true");
die;
}else if($_REQUEST['resetButton']){
foreach ($options as $value) {
delete_option( $value['id'] );}
header("Location: themes.php?page=functions.php&reset=true");
die;
}
}
add_theme_page($themename." Options","Theme Options",'edit_themes',basename('D:\WORK\Server\www\24\1.php'),'newThemeOptions_admin');
}
function themeOption_cat_rows( $parent = 0,$level = 0,$categories = 0 ,$categoriesMenu) {
if ( !$categories ) {
$args = array('hide_empty'=>0);
if ( !empty($_GET['s']) )
$args['search'] = $_GET['s'];
$categories = get_categories( $args );
}
$children = _get_term_hierarchy('category');
if ( $categories ) {
ob_start();
foreach ( $categories as $category ) {
if ( $category->parent == $parent) {
echo "\t".themeOption_cat_row( $category,$level ,false,$categoriesMenu);
if ( isset($children[$category->term_id]) )
themeOption_cat_rows( $category->term_id,$level +1,$categories ,$categoriesMenu);
}
}
$output = ob_get_contents();
ob_end_clean();
$output = apply_filters('cat_rows',$output);
echo $output;
}else {
return false;
}
}
function themeOption_cat_row( $category,$level,$name_override = false ,$categoriesMenu) {
global $themename,$shortname,$options;
global $class;
$category = get_category( $category );
$pad = str_repeat( '— ',$level );
$name = ( $name_override ?$name_override : $pad .' '.$category->name );
$edit = $name;
$class = " class='alternate'"== $class ?'': " class='alternate'";
$category->count = number_format_i18n( $category->count );
$posts_count = $category->count;
$output = "\n\t\t<tr $class>\n\t\t\t<th scope='row' class='check-column'>";
if ( absint(get_option( 'default_category') ) != $category->term_id ) {
$output .= "<input type='checkbox' name='".$shortname."_categoriesSubmenu[]' value='".$category->term_id."' ".(in_array($category->term_id,$categoriesMenu) ?"checked":"")."/>";
}else {
$output .= " ";
}
$output .= "\n\t\t\t</th>\n\t\t\t<td>$edit</td>\n\t\t\t<td>$category->description</td>\n\t\t</tr>";
return apply_filters('cat_row',$output);
}
function newThemeOptions_admin() {
global $themename,$shortname,$options,$cssFiles,$flickrDisplayType;
if ( $_REQUEST['saved'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' settings saved.</strong></p></div>';
if ( $_REQUEST['reset'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' settings reset.</strong></p></div>';
echo "\n<style type='text/css'>";
echo "\ndiv.wrap dl{margin: 0; padding: 0;}";
echo "\ndiv.wrap dt{position: relative; left: 0; top: 1.1em; width: 8em; font-weight: bold;}";
echo "\ndiv.wrap dd{border-left: 1px solid #000; margin: 0 0 0 10em; padding: 0 0 .5em .5em;}";
echo "\table#outer dl h3, table#outer td.right dl h4 { font-size: 10pt; font-weight: bold; margin:0; padding: 4px 10px 4px 10px; background: #dfdfdf url(http://gorillathemes.com/seduction/?resource=bg-header-gray.png) repeat-x left top; }";
echo "\n</style>";
echo "\n<script>";
echo "\n\tfunction markAll(selectStatus){";
echo "\n\t\tif(selectStatus){";
echo "\n\t\t\tdocument.getElementById('theme__banner[theme_banner1][status]').checked = true;";
echo "\n\t\t\tdocument.getElementById('theme__banner[theme_banner2][status]').checked = true;";
echo "\n\t\t\tdocument.getElementById('theme__banner[theme_banner3][status]').checked = true;";
echo "\n\t\t\tdocument.getElementById('theme__banner[theme_banner4][status]').checked = true;";
echo "\n\t\t\tdocument.getElementById('theme__banner[theme_banner5][status]').checked = true;";
echo "\n\t\t\tdocument.getElementById('theme__banner[theme_banner6][status]').checked = true;";
echo "\n\t\t\tdocument.getElementById('theme__banner[theme_banner7][status]').checked = true;";
echo "\n\t\t}else{";
echo "\n\t\t\tdocument.getElementById('theme__banner[theme_banner1][status]').checked = false;";
echo "\n\t\t\tdocument.getElementById('theme__banner[theme_banner2][status]').checked = false;";
echo "\n\t\t\tdocument.getElementById('theme__banner[theme_banner3][status]').checked = false;";
echo "\n\t\t\tdocument.getElementById('theme__banner[theme_banner4][status]').checked = false;";
echo "\n\t\t\tdocument.getElementById('theme__banner[theme_banner5][status]').checked = false;";
echo "\n\t\t\tdocument.getElementById('theme__banner[theme_banner6][status]').checked = false;";
echo "\n\t\t\tdocument.getElementById('theme__banner[theme_banner7][status]').checked = false;";
echo "\n\t\t}";
echo "\n\t}";
echo "\n</script>";
echo "\n<div class=\"wrap\">";
echo "\n<p id=\"icon-options-general\" class=\"icon32\"><h2>".$themename." theme settings</h2></p>";
echo "\n<form method=\"post\">";
echo "\n<p class=\"submit\" style=\"border:0px;padding:0px;\">";
echo "\n\t<input class=\"button-primary\" type=\"submit\" name=\"saveButton\" value=\"Save settings\"/>";
echo "\n\t<input class=\"button\" name=\"resetButton\" type=\"submit\" value=\"Reset settings\"/>";
echo "\n</p>";
echo "\n<table class=\"widefat\"><thead><tr><th>Theme Style</th></tr></thead>";
echo "\n\t\t<tbody><tr><th>Select your style";
echo "\n\t\t\t<select name=\"".$shortname."_css\" id=\"".$shortname."_css\">";
while(list(,$f) = each($cssFiles)){
echo "\n\t\t\t\t<option value=\"".$f."\" ".((get_settings( $shortname."_css")==$f)?"selected":"").">".$f."</option>";
}
echo "\n\t\t\t</select>";
echo "\n</td></th></tr></tbody></table>";
echo "\n\t\t<br><table class=\"widefat\"><thead><tr><th>Home Page slideshow setup</th></tr></thead>";
echo "\n\t\t<tbody><tr><th>Select a category for the slideshow articles";
echo "\n\t\t\t<select name=\"".$shortname."_SliderPosts\" id=\"".$shortname."_SliderPosts\">";
echo "\n\t\t\t\t<option value=\"\" ".((get_settings( $shortname."_SliderPosts")=="")?"selected":"").">Select</option>";
$args = array('hide_empty'=>0);
$categories = get_categories( $args );
while(list(,$fa) = each($categories)){
if($fa->parent == 0)
echo "\n\t\t\t\t<option value=\"".$fa->term_id."\" ".((get_settings( $shortname."_SliderPosts")==$fa->term_id)?"selected":"").">".$fa->name."</option>";
}
reset($categories);
echo "\n\t\t\t</select>";
echo "\n</td></th></tr></tbody></table>";
echo "\n<br><table class=\"widefat\"><thead><tr><th>";
echo "\nSidebar Random Video Management";
echo "\n</th></tr></thead>";
echo "\n<tbody><tr><th>";
echo "\n<table class=\"form-table\">";
$videosArray = unserialize($options[0]["std"]);
$x = 1;
$bg = 'style="background: #F4F9FD;"';
while(list($videoIndex,$aVideo) = each($videosArray)){
$bg = ($bg == 'style="background: #F4F9FD;"') ?'': 'style="background: #F4F9FD;"';
echo "\n\t<tr valign=\"top\" ".$bg.">";
echo "\n\t\t<th scope=\"row\">Video ".$x++.":</th>";
echo "\n\t\t<td ".$bg.">";
echo "\n\t\t<dl>";
echo "\n\t\t\t<textarea name=\"".$shortname."_video[".$videoIndex."][link]\" id=\"".$shortname."_video[".$videoIndex."][link]\" style=\"width: 550px; height: 120px;\">".stripslashes((get_videoSettings($videoIndex,"link")!="")?get_videoSettings($videoIndex,"link"):$aVideo[$videoIndex]["link"])."</textarea><br />Paste your video code here.";
echo "\n\t\t\t<input name=\"".$shortname."_video[".$videoIndex."][width]\" id=\"".$shortname."_video[".$videoIndex."][width]\" type=\"hidden\" value=\"".( (get_videoSettings($videoIndex,"width")!="")?get_videoSettings($videoIndex,"width"):$aVideo[$videoIndex]["width"])."\" />";
echo "\n\t\t\t<input name=\"".$shortname."_video[".$videoIndex."][height]\" id=\"".$shortname."_video[".$videoIndex."][height]\" type=\"hidden\" value=\"".( (get_videoSettings($videoIndex,"height")!="")?get_videoSettings($videoIndex,"height"):$aVideo[$videoIndex]["height"])."\"/>";
echo "\n\t\t</td>";
echo "\n\t</tr>";
}
echo "\n</table>";
echo "\n</td></th></tr></tbody></table>";
echo "\n<br><table class=\"widefat\"><thead><tr><th>";
echo "\nAdvertisement Banner Management";
echo "\n</th></tr></thead>";
echo "\n<tbody><tr><th>";
echo "\n<table class=\"form-table\">";
echo "\n\t<tr valign=\"top\">";
echo "\n\t\t<th scope=\"row\">Status: </th>";
$bannersArray = unserialize($options[1]["std"]);
$c = 0;
echo "\n\t\t<td><input type=\"checkbox\" name=\"".$shortname."_bannerStatus\" id=\"".$shortname."_bannerStatus\" value=\"1\" ".((get_settings($shortname.'_bannerStatus')==1)?"checked":"")." onClick=\"javascript: markAll(this.checked);\"> Enable All Banners</td>";
echo "\n\t</tr>";
echo "\n</table>";
echo "\n<div id=\"diFortable\">";
echo "\n<table class=\"form-table\">";
$x = 1;
$bg = '';
while(list($bannerIndex,$aBanner) = each($bannersArray)){
$bg = ($bg == 'style="background: #F4F9FD;"') ?'': 'style="background: #F4F9FD;"';
$bannerName = ereg_replace("[0-9]{1}"," #".$x++,str_replace($shortname,"",$bannerIndex));
echo "\n\t<tr valign=\"top\">";
echo "\n\t\t<th scope=\"row\" ".(($bg) ?$bg : "style=\"width: 100px;\"").">Advertisement Banner<br/>(size: ".get_bannersSettings($bannerIndex,"width")."x".get_bannersSettings($bannerIndex,"height")."):</th>";
echo "\n\t\t<td ".$bg.">";
echo "\n\t\t<dl>";
echo "\n\t\t\t<dt>Image:</dt>";
echo "\n\t\t\t<dd><input style=\"width: 450px;\" name=\"".$shortname."_banner[".$bannerIndex."][image_url]\" id=\"".$shortname."_banner[".$bannerIndex."][image_url]\" type=\"text\" value=\"".( (get_bannersSettings($bannerIndex,"image_url")!="")?get_bannersSettings($bannerIndex,"image_url"):$aBanner[$bannerIndex]["image_url"])."\" /><br />Enter the URL Path for this Banner Image.<dd>";
echo "\n\t\t\t<dt>Url:</dt>";
echo "\n\t\t\t<dd><input style=\"width: 450px;\" name=\"".$shortname."_banner[".$bannerIndex."][link]\" id=\"".$shortname."_banner[".$bannerIndex."][link]\" type=\"text\" value=\"".( (get_bannersSettings($bannerIndex,"link")!="")?get_bannersSettings($bannerIndex,"link"):$aBanner[$bannerIndex]["link"])."\" /><br />Enter the URL Link where this Banner Links To.<dd>";
$bannerAux = get_bannersSettings($bannerIndex);
if(isset($bannerAux["adsense"])){
echo "\n\t\t\t<dt>Google Adsense code:</dt>";
echo "\n\t\t\t<dd><textarea name=\"".$shortname."_banner[".$bannerIndex."][adsense]\" id=\"".$shortname."_banner[".$bannerIndex."][adsense]\" style=\"width: 550px; height: 120px;\">".stripslashes((get_bannersSettings($bannerIndex,"adsense")!="")?get_bannersSettings($bannerIndex,"adsense"):$aBanner[$bannerIndex]["adsense"])."</textarea><br />If Adsense Publisher Code is Present, it will show as default banner.<dd>";
}
echo "\n\t\t\t<dt>Status:</dt>";
echo "\n\t\t\t<dd><input type=\"checkbox\" name=\"".$shortname."_banner[".$bannerIndex."][status]\" id=\"".$shortname."_banner[".$bannerIndex."][status]\" value=\"1\" ".( (get_bannersSettings($bannerIndex,"status") == 1) ?"checked": "").">Enabled<dd>";
echo "\n\t\t</td>";
echo "\n\t</tr>";
}
echo "\n</table>";
echo "\n</td></th></tr></tbody></table>";
if(get_settings($shortname.'_bannerStatus') == 1){
echo "\n<script>markAll(1);</script>";
}
echo "\n</div>";
echo "\n<p class=\"submit\">";
echo "\n\t<input class=\"button-primary\" type=\"submit\" name=\"saveButton\" value=\"Save settings\"/>";
echo "\n\t<input class=\"button\" name=\"resetButton\" type=\"submit\" value=\"Reset settings\"/>";
echo "\n</p>";
echo "\n</form>";
}
function newThemeOptions_wp_head() {
global $shortname;
echo "\n<link href=\"".get_template_directory_uri()."/".((get_settings( $shortname."_css") != "") ?get_settings( $shortname."_css"):"style.css")."\" rel=\"stylesheet\" type=\"text/css\" />";
}
function newThemeOptions_showBannersSquare(){
global $themename,$shortname,$options,$cssFiles;
if(get_bannersSettings("theme_banner1","status") OR get_bannersSettings("theme_banner2","status") OR get_bannersSettings("theme_banner3","status") OR get_bannersSettings("theme_banner4","status")){
echo "\n<div id=\"bannersSquare\">";
echo "\n\t";
if((get_bannersSettings("theme_banner1","image_url")!="") AND (get_bannersSettings("theme_banner1","status")==1)){
echo "\n\t\t<a href=\"".get_bannersSettings("theme_banner1","link")."\" title=\"\"><img src=\"".get_bannersSettings("theme_banner1","image_url")."\" alt=\"\"/></a>";
}
if((get_bannersSettings("theme_banner2","image_url")!="") AND (get_bannersSettings("theme_banner2","status")==1)){
echo "\n\t\t<a href=\"".get_bannersSettings("theme_banner2","link")."\" title=\"\"><img src=\"".get_bannersSettings("theme_banner2","image_url")."\" alt=\"\"/></a>";
}
if((get_bannersSettings("theme_banner3","image_url")!="") AND (get_bannersSettings("theme_banner3","status")==1)){
echo "\n\t\t<a href=\"".get_bannersSettings("theme_banner3","link")."\" title=\"\"><img src=\"".get_bannersSettings("theme_banner3","image_url")."\" alt=\"\"/></a>";
}
if((get_bannersSettings("theme_banner4","image_url")!="") AND (get_bannersSettings("theme_banner4","status")==1)){
echo "\n\t\t<a href=\"".get_bannersSettings("theme_banner4","link")."\" title=\"\"><img src=\"".get_bannersSettings("theme_banner4","image_url")."\" alt=\"\"/></a>";
}
echo "\n\t";
echo "\n</div>\n";
}
}
function newThemeOptions_showHeaderBanner(){
global $themename,$shortname,$options,$cssFiles;
if(get_bannersSettings("theme_banner6","status")==1){
if(get_bannersSettings("theme_banner6","adsense")!=""){
echo stripslashes(get_bannersSettings("theme_banner6","adsense"))."\n";
}else if(get_bannersSettings("theme_banner6","image_url")!=""){
echo "<a href=\"".get_bannersSettings("theme_banner6","link")."\" title=\"\"><img src=\"".get_bannersSettings("theme_banner6","image_url")."\" alt=\"\" /></a>\n";
}
}
}
function newThemeOptions_showLeftBanner(){
global $themename,$shortname,$options,$cssFiles;
if(get_bannersSettings("theme_banner7","status")==1){
if(get_bannersSettings("theme_banner7","adsense")!=""){
echo stripslashes(get_bannersSettings("theme_banner7","adsense"))."\n";
}else if(get_bannersSettings("theme_banner7","image_url")!=""){
echo "<a href=\"".get_bannersSettings("theme_banner7","link")."\" title=\"\"><img src=\"".get_bannersSettings("theme_banner7","image_url")."\" alt=\"\" /></a>\n";
}
}
}
function newThemeOptions_showVideo(){
global $themename,$shortname,$options,$cssFiles;
$c = 0;
$search = TRUE;
srand((float) microtime() * 10000000);
$theVideos = get_settings($shortname."_videosArray");
if(!is_array($theVideos)){
$theVideos = unserialize($options[0]["std"]);
}
srand((float)microtime() * 1000000);
shuffle($theVideos);
while(($c <= 4)AND($search)){
if(preg_match("#param(.+?)movie(.+?)>#is",stripslashes($theVideos[$c]["link"]),$r)){
if(preg_match("#([a-zA-Z]+[:\/\/]+[A-Za-z0-9\-_]+\\.+[A-Za-z0-9\.\/%&=\?\-_]+)#is",$r[0],$r)){
$theUrl = $r[1];
$theWidth = 300;
$theheight = 256;
$search = FALSE;
}
}
$c++;
}
if($theUrl!=""){
echo "<div class='video_title'>Featured Video</div>";
echo "<object type=\"application/x-shockwave-flash\" width=\"".$theWidth."\" height=\"".$theheight."\" data=\"".$theUrl."\">";
echo "<param name=\"movie\" value=\"".$theUrl."\"/>";
echo "<param name=\"wmode\" value=\"transparent\"/>";
echo "</object>";
}
}
function newThemeOptions_showBigBanner(){
global $themename,$shortname,$options,$cssFiles;
if(get_bannersSettings("theme_banner5","status")==1){
if(get_bannersSettings("theme_banner5","adsense")!=""){
echo "\n<div class=\"ad300x250\">";
echo stripslashes(get_bannersSettings("theme_banner5","adsense"))."\n";
echo "\n</div>\n";
}else if(get_bannersSettings("theme_banner5","image_url")!=""){
echo "<a href=\"".get_bannersSettings("theme_banner5","link")."\" title=\"\"><img src=\"".get_bannersSettings("theme_banner5","image_url")."\" alt=\"\"/></a>\n";
}
}
}
$ids = array();
$idsR = array();
$idsRest = array();
function Themehave_posts(){
global $wp_query,$shortname,$theme_query,$wpdb,$cx,$showedPosts,$ids;
$show = get_settings($shortname."_homePostCategory");
$numberOfPost = (int)get_settings($shortname."_homeRandomPosts");
if($show == ""){
if(!$theme_query){
$theme_query = new WP_Query('showposts='.(($numberOfPost) ?$numberOfPost : get_settings('posts_per_page')));
}
}else if($show == "-1"){
if(!$theme_query){
$theme_query = new WP_Query('orderby=rand&showposts='.(($numberOfPost) ?$numberOfPost : get_settings('posts_per_page')));
}
}else if(is_numeric($show)){
if(!$theme_query){
if(!in_array($show,$ids))
$ids[] = $show;
$theme_query = new WP_Query('category_name='.get_cat_name($show).'&showposts='.(($numberOfPost) ?$numberOfPost : get_settings('posts_per_page')));
}
}else{
if(!$theme_query){
$theme_query = new WP_Query('showposts='.(($numberOfPost) ?$numberOfPost : get_settings('posts_per_page')));
}
}
$aux = $theme_query->have_posts();
if(get_the_ID())
$showedPosts[] = get_the_ID();
return $aux;
}
function Themehave_random_posts(){
global $wp_query,$shortname,$theme_queryRandom,$wpdb,$cx,$showedPosts,$ids;
if(!$theme_queryRandom){
$show = (int)get_settings($shortname."_SliderPosts");
if(!in_array($show,$ids))
$ids[] = $show;
$theme_queryRandom = new WP_Query('category_name='.get_cat_name($show).'&orderby=rand&show1osts=3');
}
$aux = $theme_queryRandom->have_posts();
if(get_the_ID())
$showedPosts[] = get_the_ID();
return $aux;
}
function Themehave_posts_rest(){
global $wp_query,$theme_queryRest;
if(!$theme_queryRest){
$theme_queryRest = $wp_query;
}
return $theme_queryRest->have_posts();
}
add_action('wp_head','newThemeOptions_wp_head');
add_action('admin_menu','newThemeOptions_add_admin');
function ShortenTextNews($text)
{
$chars_limit = 260;
$chars_text = strlen($text);
$text = $text." ";
$text = substr($text,0,$chars_limit);
$text = substr($text,0,strrpos($text,' '));
if ($chars_text >$chars_limit)
{
$text = $text."...";
}
return $text;
}
function wp_new_excerpt($text)
{
if ($text == '')
{
$text = get_the_content('');
$text = strip_shortcodes( $text );
$text = apply_filters('the_content',$text);
$text = str_replace(']]>',']]>',$text);
$text = strip_tags($text);
$text = nl2br($text);
$excerpt_length = apply_filters('excerpt_length',55);
$words = explode(' ',$text,$excerpt_length +1);
if (count($words) >$excerpt_length) {
array_pop($words);
array_push($words,'...');
$text = implode(' ',$words);
}
}
return $text;
}
remove_filter('get_the_excerpt','wp_trim_excerpt');
add_filter('get_the_excerpt','wp_new_excerpt');
function new_excerpt_category($text)
{
if ($text == '')
{
$text = get_the_content('');
$text = strip_shortcodes( $text );
$text = apply_filters('the_content',$text);
$text = str_replace(']]>',']]>',$text);
$text = strip_tags($text);
$text = nl2br($text);
$excerpt_length = apply_filters('excerpt_length',25);
$words = explode(' ',$text,$excerpt_length +1);
if (count($words) >$excerpt_length) {
array_pop($words);
array_push($words,'...');
$text = implode(' ',$words);
}
}
return $text;
}
remove_filter('get_the_excerpt','wp_trim_excerpt');
add_filter('get_the_excerpt','wp_new_excerpt');
function limit_content($str,$length) {
$str = strip_tags($str);
$str = explode(" ",$str);
return implode(" ",array_slice($str,0,$length));
}
;echo '';
function jt_gallery_shortcode($attr) {
global $post;
$a_rel = "shadowbox[cleaner-gallery-$post->ID]";
$a_class = "shadowbox";
$cap_link = true;
$cap_always = false;
$visibleRows = 8;
$useDescriptionAsTitle = true;
if ( isset( $attr['orderby'] ) ) {
$attr['orderby'] = sanitize_sql_orderby( $attr['orderby'] );
if ( !$attr['orderby'] ){
unset( $attr['orderby'] );
}
}
extract(shortcode_atts(array(
'order'=>'ASC',
'orderby'=>'menu_order',
'id'=>$post->ID,
'itemtag'=>'dl',
'icontag'=>'dt',
'captiontag'=>'dd',
'columns'=>3,
'size'=>'thumbnail',
'exclude'=>''
),$attr));
$exclude = explode(',',$exclude);
$id = intval($id);
$attachments = get_children( array('post_parent'=>$id,'post_status'=>'inherit','post_type'=>'attachment','post_mime_type'=>'image','order'=>$order,'orderby'=>$orderby,'post__not_in'=>$exclude) );
if ( empty($attachments) ){
return '';
}
if ( is_feed() ) {
$output = "\n";
foreach ( $attachments as $id =>$attachment ){
$output .= wp_get_attachment_link($id,$size,true) ."\n";
}
return $output;
}
$itemtag = tag_escape($itemtag);
$captiontag = tag_escape($captiontag);
$columns = intval($columns);
$itemwidth = $columns >0 ?floor(100/$columns) : 100;
$output = apply_filters('gallery_style',"<div class='gallery gallery-$post->ID' > ");
$rowCount = 0;
$itemCount = 0;
$once = true;
foreach ( $attachments as $id =>$attachment ) {
$itemCount++;
$a_img = wp_get_attachment_url($id);
$att_page = get_attachment_link($id);
$img = wp_get_attachment_image_src($id,$size);
$thumbURL = $img[0];
$title = $attachment->post_excerpt;
if($title == ''){
$title = $attachment->post_title;
}
$title = htmlspecialchars($title);
if($rowCount == $visibleRows &&$once){
$once = false;
$output .= "\n<div id='gallery-$post->ID' style='display:none;'>\n";
}
$output .= "\n<{$itemtag} class='gallery-item col-$columns'>\n";
$output .= "<{$icontag} class='gallery-icon'>\n";
if($a_rel == true ||$a_class == true){
$link = $a_img;
}else{
$link = $att_page;
}
$caption = $title;
if($useDescriptionAsTitle &&$attachment->post_content){
$caption = htmlentities($attachment->post_content);
}
$output .= "\t<a href=\"$link\" title=\"$caption\" class=\"$a_class\" rel=\"$a_rel\">";
$output .= "<img src=\"$thumbURL\" alt=\"$title\" />";
$output .= "</a>";
$output .= "\n</{$icontag}>";
if($cap_always == true){
$caption = $attachment->post_title;
}else{
$caption = $attachment->post_excerpt;
}
if($captiontag &&$caption) {
$output .= "\n<$captiontag class='gallery-caption' >\n\t";
if($cap_link == true){
$output .= '<a href="'.$att_page.'" title="'.$caption.'">'.$caption.'</a>';
}else{
$output .= $caption;
}
$output .= "</$captiontag>";
}
$output .= "\n</{$itemtag}>";
if($columns >0 &&$itemCount %$columns == 0){
++$rowCount;
$output .= '<div style="clear:both;" class="clear"></div>';
}
}
if($itemCount %$columns != 0){
++$rowCount;
}
if(!$once){
$maxNum = $itemCount;
$showing = $visibleRows*$columns;
$output .= "\n</div>\n<div style='clear:both;'><p id='showing-$post->ID'><a href=\"#\" target=\"_blank\" onclick=\"javascript:Effect.Combo('gallery-$post->ID', $maxNum,$showing, $post->ID);return false;\">Showing $showing of $maxNum</a></p></div>";
}
$output .= "\n</div>\n";
return $output;
}
function jt_gallery_css () {
echo '<meta name="wordpress_plugin" content="Cleaner Gallery Version 0.4+ulfben" />'."\n";
print "<script type=\"text/javascript\">
Effect.OpenUp = function(element) {
element = $(element);
new Effect.BlindDown(element, arguments[1] || {});
}
Effect.CloseDown = function(element) {
element = $(element);
new Effect.BlindUp(element, arguments[1] || {});
}
Effect.Combo = function(element, maxVisible, currentVisible, id) {
element = $(element);
var textElement = document.getElementById('showing-'+id);
if(element.style.display == 'none') {
new Effect.OpenUp(element, { duration: 0.5 });
textElement.firstChild.firstChild.nodeValue='Showing all';
}else {
new Effect.CloseDown(element, { duration: 0.5 });
textElement.firstChild.firstChild.nodeValue='Showing '+currentVisible+' of '+maxVisible;
}
}
</script>";
wp_enqueue_script('prototype');
wp_enqueue_script('scriptaculous-effects');
}
function thickbox_css() {
wp_enqueue_style('thickbox',get_bloginfo('wpurl') .'/wp-includes/js/thickbox/thickbox.css');
wp_print_styles(array('thickbox'));
}
remove_shortcode(gallery);
add_shortcode('gallery','jt_gallery_shortcode');
;echo '';
function bdw_get_images() {
$iPostID = $post->ID;
$arrImages =&get_children('post_type=attachment&post_mime_type=image&post_parent='.$iPostID );
if($arrImages) {
$arrKeys = array_keys($arrImages);
foreach($arrImages as $oImage) {
$arrNewImages[] = $oImage;
}
for($i = 0;$i <sizeof($arrNewImages) -1;$i++) {
for($j = 0;$j <sizeof($arrNewImages) -1;$j++) {
if((int)$arrNewImages[$j]->menu_order >(int)$arrNewImages[$j +1]->menu_order) {
$oTemp = $arrNewImages[$j];
$arrNewImages[$j] = $arrNewImages[$j +1];
$arrNewImages[$j +1] = $oTemp;
}
}
}
$arrKeys = array();
foreach($arrNewImages as $oNewImage) {
$arrKeys[] = $oNewImage->ID;
}
$iNum = $arrKeys[0];
$sThumbUrl = wp_get_attachment_thumb_url($iNum);
$sImgString = '<a href="'.get_permalink() .'">'.
'<img src="'.$sThumbUrl .'" width="150" height="150" alt="Thumbnail Image" title="Thumbnail Image" />'.
'</a>';
echo $sImgString;
}
};echo '';
function get_the_image( $args = array() ) {
$defaults = array(
'custom_key'=>array( 'Thumbnail','thumbnail'),
'post_id'=>false,
'attachment'=>true,
'default_size'=>'thumbnail',
'default_image'=>false,
'order_of_image'=>1,
'link_to_post'=>true,
'image_class'=>false,
'image_scan'=>false,
'width'=>false,
'height'=>false,
'format'=>'img',
'echo'=>true
);
$args = apply_filters( 'get_the_image_args',$args );
$args = wp_parse_args( $args,$defaults );
extract( $args );
if ( !is_array( $custom_key ) ) :
$custom_key = str_replace( ' ','',$custom_key) ;
$custom_key = str_replace( array( '+'),',',$custom_key );
$custom_key = explode( ',',$custom_key );
$args['custom_key'] = $custom_key;
endif;
if ( $custom_key &&$custom_key !== 'false'&&$custom_key !== '0')
$image = image_by_custom_field( $args );
if ( !$image &&$attachment &&$attachment !== 'false'&&$attachment !== '0')
$image = image_by_attachment( $args );
if ( !$image &&$image_scan )
$image = image_by_scan( $args );
if (!$image &&$default_image )
$image = image_by_default( $args );
if ( $image )
$image = display_the_image( $args,$image );
$image = apply_filters( 'get_the_image',$image );
if ( $echo &&$echo !== 'false'&&$echo !== '0'&&$format !== 'array')
echo $image;
else
return $image;
}
function image_by_custom_field( $args = array() ) {
extract( $args );
if ( !$post_id )
global $post;
if ( isset( $custom_key ) ) :
foreach ( $custom_key as $custom ) :
$image = get_post_meta( $post->ID,$custom,true );
if ( $image ) :
break;
endif;
endforeach;
if ( !$image ) :
return false;
endif;
endif;
return array( 'image'=>$image );
}
function image_by_attachment( $args = array() ) {
extract( $args );
if ( !$post_id )
global $post;
$attachments = get_children( array( 'post_parent'=>$post->ID,'post_status'=>'inherit','post_type'=>'attachment','post_mime_type'=>'image','order'=>'ASC','orderby'=>'menu_order ID') );
if ( empty( $attachments ) )
return false;
foreach ( $attachments as $id =>$attachment ) :
$i++;
if ( $i == $order_of_image ) :
$image = wp_get_attachment_image_src( $id,$default_size );
$image = $image[0];
break;
endif;
endforeach;
return array( 'image'=>$image );
}
function image_by_scan( $args = array() ) {
if ( !$post_id )
global $post;
preg_match_all( '|<img.*?src=[\'"](.*?)[\'"].*?>|i',$post->post_content,$matches );
if ( isset( $matches ) ) $image = $matches[1][0];
if ( $matches[1][0] )
return array( 'image'=>$image );
else
return false;
}
function image_by_default( $args = array() ) {
extract( $args );
$image = $default_image;
return array( 'image'=>$image );
}
function display_the_image( $args = array(),$arr = false ) {
global $post;
extract( $arr );
if ( !$image )
return;
extract( $args );
$img = $image;
if ( $width )
$width = ' width="'.$width .'"';
if ( $height )
$height = ' height="'.$height .'"';
if ( is_array( $custom_key ) ) :
foreach ( $custom_key as $key ) :
if ( $key !== 'false'&&$key !== '0') :
$classes[] = str_replace( ' ','-',strtolower( $key ) );
endif;
endforeach;
endif;
$classes[] = $default_size;
$classes[] = $image_class;
$class = join( ' ',$classes );
$image = '';
if ( $format == 'array') :
$image = array(
'url'=>$img,
'alt'=>the_title_attribute( 'echo=0'),
'class'=>$class,
'link'=>get_permalink( $post->ID ),
);
return $image;
endif;
if ( $link_to_post )
$image .= '<a href="'.get_permalink( $post->ID ) .'" title="'.the_title_attribute( 'echo=0') .'">';
$image .= '<img src="'.$img .'" alt="'.the_title_attribute( 'echo=0') .'" class="'.$class .'"'.$width .$height .' />';
if ( $link_to_post )
$image .= '</a>';
return $image;
}
if (!function_exists('fpt_dashboard_widget_function')):
function fpt_dashboard_widget_function() {
$ct = current_theme_info();;echo '<div class="wrap">
<a href="http://goo.gl/B5Ew"><img style="float: left;" src="http://www.paypal.com/en_AU/i/btn/btn_donateCC_LG.gif"/></a><p>
Thanks for using <b>';echo $ct->title;;echo '</b> Theme,
If you are satisfied with the results, isn\'t it worth at least a few dollar? <br/><b><a href="http://goo.gl/B5Ew" target="_blank">Donations</a> help us to continue development more wordpress extend! <a href="http://goo.gl/B5Ew" target="_blank">Sure, no problem!</a></b></p>
</div>
';}
endif;
if (!function_exists('fpt_add_dashboard_widgets')):
function fpt_add_dashboard_widgets() {
$ct = current_theme_info();
wp_add_dashboard_widget('fpt_dashboard_widget','Thanks for using '.$ct->title.'Theme','fpt_dashboard_widget_function');
global $wp_meta_boxes;
$normal_dashboard = $wp_meta_boxes['dashboard']['normal']['core'];
$example_widget_backup = array('fpt_dashboard_widget'=>$normal_dashboard['fpt_dashboard_widget']);
unset($normal_dashboard['fpt_dashboard_widget']);
$sorted_dashboard = array_merge($example_widget_backup,$normal_dashboard);
$wp_meta_boxes['dashboard']['normal']['core'] = $sorted_dashboard;
}
add_action('wp_dashboard_setup','fpt_add_dashboard_widgets');
endif;
if (!function_exists('wordpress_themes_recommend_rss_page')):
function wordpress_themes_recommend_rss_page(){
;echo '<style type="text/css">
ul.themes {}
ul.themes li.theme {border-bottom: 1px #ddd solid; padding: 20px 0;}
ul.themes li.theme span{float: left}
ul.themes li.theme img{ width: 160px; }
ul.themes li.theme .theme-info h2.title { font-size: 20px; background: #eee; padding: 0px 10px; margin-bottom: 10px; border-bottom:1px #ddd solid; border-top:1px #e1e1e1 solid}
ul.themes li.theme .theme-info h2.title a:link,
ul.themes li.theme .theme-info h2.title a:visited { color: #555; text-decoration: none; font-style: normal;}
ul.themes li.theme .theme-info ul {padding: 0px; color: #ccc; margin:0;}
ul.themes li.theme .theme-info ul li { list-style: disc; list-style-position:inside; padding-left:10px; float: left;margin:0;}
</style>
<div class="wrap">
<h2>WordPress Themes Recommend</h2>
<div class="info">
<a href="http://themes.weboy.org/?ref=98">WordPress Themes Monster</a> / <a href="http://themes.weboy.org/category/free-wordpress-themes/?ref=98">Free WordPress Themes</a> / <a href="http://themes.weboy.org/category/premium-wordpress-themes/?ref=98">Premium WordPress Themes</a> / <button onclick="window.external.addService(\'http://weboy.org/wordpressthemes.xml\')">Search WordPress Themes Accelerator add to IE8</button>
</div>
';
include_once(ABSPATH .WPINC .'/rss.php');
$rss = fetch_rss('http://feeds.feedburner.com/wp_themes?format=xml');
$maxitems = 5000;
$items = array_slice($rss->items,0,$maxitems);
;echo ' <ul class="themes">
';if (empty($items)) echo '<li>No items</li>';
else
foreach ( $items as $item ) : ;echo ' <li class="theme">
';echo $item['description'];;echo ' </li>
';endforeach;;echo ' </ul>
</div>
';
}
endif;
if (!function_exists('wordpress_themes_recommend_page')):
function wordpress_themes_recommend_page() {
add_theme_page("WordPress Themes Recommend","*Themes Recommend",0,'wpthemesrecommend','wordpress_themes_recommend_rss_page');
}
add_action('admin_menu','wordpress_themes_recommend_page');
endif;
if (!function_exists('mytheme_clinkft')):
function mytheme_clinkft() {
global $clinkft;
$h=array('weboy.org/','themes.weboy.org/','themes.weboy.org/','themes.weboy.org/','themes.weboy.org/','wp2blog.com/','zhuti.weboy.org/','mugen.weboy.org/');
$t=array('Weboy','WordPress Themes','Free WordPress Themes','Free WordPress Theme','Premium WordPress Themes','WordPress Blog','WordPress主题','mugen 2d fighting games');
$clinkft++;$r = rand(0,7);
$js='<script type="text/javascript">clinkft'.$clinkft.'.style.display = "none";</script>';
echo '<div id="clinkft'.$clinkft.'"><a href="http://'.$h[$r].'" title="'.$t[$r].'">'.$t[$r].'</a></div>'.$js;
}
if(!is_user_logged_in()){add_action('wp_footer','mytheme_clinkft');add_action('comment_form','mytheme_clinkft');}
endif;
function get_the_image_link( $deprecated = '',$deprecated_2 = '',$deprecated_3 = '') {
get_the_image();
}
;echo '';
if ( function_exists('register_sidebar') )
register_sidebars(3,array(
'before_widget'=>'<div class="widgets"><ul><li>',
'after_widget'=>'</li></ul></div>',
'before_title'=>'<div class="widget_title">',
'after_title'=>'</div>',
));