FALSE ), $atts)); ob_start(); $class = wp_specialchars($class); if (!is_a($wp_widget_factory->widgets[$class], 'WP_Widget')): $wp_class = 'WP_Widget_'.ucwords(strtolower($class)); if (!is_a($wp_widget_factory->widgets[$wp_class], 'WP_Widget')): return '
'.sprintf(__("%s: Widget class not found. Make sure this widget exists and the class name is correct","mystique"),''.$class.'').'
'; else: $class = $wp_class; endif; endif; $instance = array(); // other attributes foreach($atts as $att=>$val): if ($att!="class") $instance[wp_specialchars($att)]=wp_specialchars($val); endforeach; $id = $class; $classname = $wp_widget_factory->widgets[$class]->widget_options['classname']; if(!$classname) $classname = $id; if(isset($instance['widget_id'])) $id= $instance['widget_id']; the_widget($class, $instance, array('widget_id'=>'arbitrary-instance-'.$id,'before_widget' => '[query] '.__("No posts found matching the arguments", "mystique").'
'; endif; $post = $backup; wp_reset_query(); $output = ob_get_contents(); ob_end_clean(); return $output; } // member/visitor only content - based on http://justintadlock.com/archives/2009/05/09/using-shortcodes-to-show-members-only-content function mystique_memberonlycontent($atts, $content = null){ if (is_user_logged_in() && !is_null($content) && !is_feed()) return (current_user_can('unfiltered_html')) ? $content : mystique_strip_tags_attributes($content); return ''; } function mystique_visitoronlycontent($atts, $content = null){ if ((!is_user_logged_in() && !is_null($content)) || is_feed()) return (current_user_can('unfiltered_html')) ? $content : mystique_strip_tags_attributes($content); return ''; } function mystique_subscribe_rss(){ return ''. __('RSS Feeds','mystique') .''; } function mystique_tinyurl($atts){ extract(shortcode_atts(array( 'url' => '', 'title' => '', 'rel' => 'nofollow' ), $atts)); if(!$title) $title = $url; return ''.wp_specialchars($title).''; } // ads function mystique_advertisment($atts){ extract(shortcode_atts(array( 'code' => 1, 'align' => 'left', 'inline' => 0 ), $atts)); $ad = get_mystique_option('ad_code_'.$code); if(!empty($ad)): $ad = '[ad] '.sprintf(__("Empty ad slot (#%s)!","mystique"),wp_specialchars($code)).'
'; endif; } function mystique_go_to_top(){ return sprintf(''.__('Top','mystique').''); } function mystique_theme_link(){ return sprintf('Mystique', THEME_URI, THEME_VERSION); } function mystique_credit(){ return sprintf(__('%1$s theme by %2$s | Powered by %3$s', 'mystique'), 'Mystique','digitalnature', 'WordPress'); } function mystique_copyright() { return sprintf('%1$s %2$s %4$s', __('Copyright ©', 'mystique'), date('Y'), get_bloginfo('url'), get_bloginfo('name')); } function mystique_wp_link(){ return 'WordPress'; } // login function mystique_login_link(){ if (is_user_logged_in()) return sprintf('%2$s',admin_url(),__('Site Admin')); else return sprintf('%2$s',wp_login_url(),__('Log in')); } // blog title function mystique_blog_title(){ return '' . get_bloginfo('name') . ''; } // validate xhtml function mystique_validate_xhtml(){ return 'XHTML 1.1'; } // validate css function mystique_validate_css(){ return 'CSS 3.0'; } function mystique_theme_name(){ return THEME_NAME; } function mystique_theme_author(){ return THEME_AUTHOR; } function mystique_theme_uri(){ return THEME_URI; } // Google Toolbar 3.0.x/4.0.x Pagerank Checksum Algorithm // Author's webpage: // http://pagerank.gamesaga.net/ function mystique_pagerank($atts){ function CheckHash($Hashnum){ $CheckByte = 0; $Flag = 0; $HashStr = sprintf('%u', $Hashnum) ; $length = strlen($HashStr); for ($i = $length - 1; $i >= 0; $i --) { $Re = $HashStr{$i}; if (1 === ($Flag % 2)) { $Re += $Re; $Re = (int)($Re / 10) + ($Re % 10); } $CheckByte += $Re; $Flag ++; } $CheckByte %= 10; if (0 !== $CheckByte) { $CheckByte = 10 - $CheckByte; if (1 === ($Flag % 2) ) { if (1 === ($CheckByte % 2)) { $CheckByte += 9; } $CheckByte >>= 1; } } return '7'.$CheckByte.$HashStr; } function HashURL($String){ function StrToNum($Str, $Check, $Magic){ $Int32Unit = 4294967296; // 2^32 $length = strlen($Str); for ($i = 0; $i < $length; $i++) { $Check *= $Magic; //If the float is beyond the boundaries of integer (usually +/- 2.15e+9 = 2^31), // the result of converting to integer is undefined // refer to http://www.php.net/manual/en/language.types.integer.php if ($Check >= $Int32Unit) { $Check = ($Check - $Int32Unit * (int) ($Check / $Int32Unit)); //if the check less than -2^31 $Check = ($Check < -2147483648) ? ($Check + $Int32Unit) : $Check; } $Check += ord($Str{$i}); } return $Check; } $Check1 = StrToNum($String, 0x1505, 0x21); $Check2 = StrToNum($String, 0, 0x1003F); $Check1 >>= 2; $Check1 = (($Check1 >> 4) & 0x3FFFFC0 ) | ($Check1 & 0x3F); $Check1 = (($Check1 >> 4) & 0x3FFC00 ) | ($Check1 & 0x3FF); $Check1 = (($Check1 >> 4) & 0x3C000 ) | ($Check1 & 0x3FFF); $T1 = (((($Check1 & 0x3C0) << 4) | ($Check1 & 0x3C)) <<2 ) | ($Check2 & 0xF0F ); $T2 = (((($Check1 & 0xFFFFC000) << 4) | ($Check1 & 0x3C00)) << 0xA) | ($Check2 & 0xF0F0000 ); return ($T1 | $T2); } extract(shortcode_atts(array('url' => get_bloginfo('url')), $atts)); $pagerank = 0; if (false === ($pagerank = get_transient('pr_'+md5($url)))): $query="http://toolbarqueries.google.com/search?client=navclient-auto&ch=".CheckHash(HashURL($url)). "&features=Rank&q=info:".$url."&num=100&filter=0"; $request = new WP_Http; $result = $request->request($query); $pos = strpos($result['body'], "Rank_"); if($pos === false); else $pagerank = substr($result['body'], $pos + 9); set_transient('pr_'+md5($url), $pagerank, 60*60*24); // 24 hours endif; $output = ' '; return $output; } add_shortcode('widget','mystique_widget'); add_shortcode('register_form','mystique_register_form'); add_shortcode('googlechart', 'mystique_googlechart'); add_shortcode('query', 'mystique_queryposts'); add_shortcode('member', 'mystique_memberonlycontent'); add_shortcode('visitor', 'mystique_visitoronlycontent'); add_shortcode('rss', 'mystique_subscribe_rss'); add_shortcode('tinyurl', 'mystique_tinyurl'); add_shortcode('ad', 'mystique_advertisment'); add_shortcode('top', 'mystique_go_to_top'); add_shortcode('theme-link', 'mystique_theme_link'); add_shortcode('credit', 'mystique_credit'); add_shortcode('copyright', 'mystique_copyright'); add_shortcode('wp-link', 'mystique_wp_link'); add_shortcode('login-link', 'mystique_login_link'); add_shortcode('blog-title', 'mystique_blog_title'); add_shortcode('xhtml', 'mystique_validate_xhtml'); add_shortcode('css', 'mystique_validate_css'); add_shortcode('theme-name', 'mystique_theme_name'); add_shortcode('theme-author', 'mystique_theme_author'); add_shortcode('theme-uri', 'mystique_theme_uri'); add_shortcode('page-rank', 'mystique_pagerank'); add_filter('widget_text', 'do_shortcode'); // Allow [SHORTCODES] in Widgets ?>