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' => '
','after_widget' => '
','before_title' => '

','after_title' => '

')); $output = ob_get_contents(); ob_end_clean(); return $output; } // based on the register template from the Hybrid theme, by Justin Tadlock function mystique_register_form($atts){ extract(shortcode_atts(array( 'align' => 'left', 'inline' => 0 ), $atts)); require_once(ABSPATH.WPINC.'/registration.php'); $registration = get_option('users_can_register'); $labels = array( 'user-name' => __('User name (required)', 'mystique'), 'url' => __('Website', 'mystique'), 'pass1' => __('Password (required)', 'mystique'), 'pass2' => __('Verify password (required)', 'mystique'), 'email' => __('E-mail (required)', 'mystique'), 'first-name' => __('First name', 'mystique'), 'last-name' => __('Last name', 'mystique'), 'description' => __('Profile info', 'mystique'), ); /* If user registered, input info. */ if ('POST' == $_SERVER['REQUEST_METHOD'] && !empty($_POST['action']) && $_POST['action'] == 'adduser'): $userdata = array( 'user_pass' => esc_attr($_POST['pass1']), 'user_login' => ($_POST['user-name'] != $labels['user-name']) ? esc_attr($_POST['user-name']) : '', 'user_url' => ($_POST['url'] != $labels['url']) ? esc_attr($_POST['url']) : '', 'user_email' => ($_POST['email'] != $labels['email']) ? esc_attr($_POST['email']) : '', 'first_name' => ($_POST['first-name'] != $labels['first-name']) ? esc_attr($_POST['first-name']) : '', 'last_name' => ($_POST['last-name'] != $labels['last-name']) ? esc_attr($_POST['last-name']) : '', 'description' => ($_POST['description'] != $labels['description']) ? esc_attr($_POST['description']) : '', 'role' => get_option('default_role'), ); $valid = (!username_exists($userdata['user_login']) && !email_exists($userdata['user_email']) && $userdata['user_login']) && ($userdata['user_email']) && ($_POST['pass1']) && ($_POST['pass1'] == $_POST['pass2']); if ($valid): $new_user = wp_insert_user($userdata); else: if (!$userdata['user_login']) $error = __('Please type a user name', 'mystique'); elseif (username_exists($userdata['user_login'])) $error = __('User name already exists','mystique'); elseif (!$userdata['user_email']) $error = __('E-mail address is required.', 'mystique'); elseif (email_exists($userdata['user_email'])) $error = __('E-mail address already in use','mystique'); elseif (!$_POST['pass1']) $error = __('You must enter a password.', 'mystique'); elseif (!$_POST['pass2']) $error = __('Please verify the password', 'mystique'); elseif ($_POST['pass1'] !== $_POST['pass2']) $error = __('Passwords do not match', 'mystique'); else $error = __('User registration failed. Please try again.', 'mystique'); endif; endif; $jquery = get_mystique_option('jquery'); ob_start(); ?>

%2$s. You don\'t need another account :)', 'mystique'), get_author_posts_url($curauth->ID), $user_identity); ?>

'.$_POST['user-name'].''); else printf(__('Thank you for registering, %1$s.', 'mystique'), $_POST['user-name']); ?>

'', 'colors' => '', 'size' => '400x200', 'bg' => 'ffffff', 'title' => '', 'labels' => '', 'advanced' => '', 'type' => 'pie' ), $atts)); switch ($type) { case 'line': $charttype = 'lc'; break; case 'xyline': $charttype = 'lxy'; break; case 'sparkline': $charttype = 'ls'; break; case 'meter': $charttype = 'gom'; break; case 'scatter': $charttype = 's'; break; case 'venn': $charttype = 'v'; break; case 'pie': $charttype = 'p3'; break; case 'pie2d': $charttype = 'p'; break; default: $charttype = $type; break; } if ($title) $string .= '&chtt='.$title.''; if ($labels) $string .= '&chl='.$labels.''; if ($colors) $string .= '&chco='.$colors.''; $string .= '&chs='.$size.''; $string .= '&chd=t:'.$data.''; $string .= '&chf='.$bg.''; return ''.wp_specialchars($title).''; } function mystique_queryposts($atts){ extract(shortcode_atts( array( 'category_id' => '', 'category_name' => '', 'tag' => '', 'day' => '', 'month' => '', 'year' => '', 'count' => '5', 'author_id' => '', 'author_name' => '', 'order_by' => 'date', ), $atts)); $output = ''; $query = array(); if ($category_id != '') $query[] = 'cat=' .$category_id; if ($category_name != '') $query[] = 'category_name=' .$category_name; if ($tag != '') $query[] = 'tag=' . $tag; if ($day != '') $query[] = 'day=' . $day; if ($month != '') $query[] = 'monthnum=' . $month; if ($year != '') $query[] = 'year=' . $year; if ($count) $query[] = 'posts_per_page=' .$count; if ($author_id != '') $query[] = 'author=' . $author_id; if ($author_name != '') $query[] = 'author_name=' . $author_name; if ($order_by) $query[] = 'orderby=' . $order_by; ob_start(); $backup = $post; $posts = new WP_Query(implode('&',$query)); if ($posts->have_posts()): while ($posts->have_posts()): $posts->the_post(); mystique_post(); endwhile; else: echo '

[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.'
'; if(!$inline) $ad = '
'.$ad.'
'; return $ad; else: return '

[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 = '
'; $output.= sprintf(__("PR %s","mystique"), $pagerank); $output.= '
'; $output.= '
'; $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 ?>