SHOW:
|
|
- or go back to the newest paste.
| 1 | <?php | |
| 2 | ||
| 3 | if ( ( $pagenow == "themes.php" ) && current_user_can('administrator') && isset( $_GET['activated'] ) && ( $_GET['activated']=='true' ) ) {
| |
| 4 | if (!include_once( get_template_directory() . '/inc/activation.php' )) {
| |
| 5 | $stylesheet = get_option( 'theme_switched' ); | |
| 6 | switch_theme( $stylesheet, $stylesheet ); | |
| 7 | if ( file_exists( get_template_directory() . '/inc/activation.php' ) ) {
| |
| 8 | $error_message[]="PHP hasn't access to file /inc/activation.php. Check the file permissions and try again please."; | |
| 9 | } else {
| |
| 10 | $error_message[]="File /inc/activation.php doesn't exists. Try to upload the theme again."; | |
| 11 | } | |
| 12 | $message="<h2>The theme wasn't activated by following reasons:</h2><ul><li>".implode("</li><li>",$error_message)."</li></ul>"."Your theme was switched back to ".$stylesheet.".";
| |
| 13 | wp_die($message,'',array('back_link'=>"/wp-admin/themes.php"));
| |
| 14 | } | |
| 15 | } | |
| 16 | ||
| 17 | ||
| 18 | ||
| 19 | if (!session_id()) { session_start(); }
| |
| 20 | ||
| 21 | if (!include_once (get_template_directory()."/inc/library.php") )wp_die("Cannot include file /inc/library.php.");
| |
| 22 | $settingsfile='settings'; | |
| 23 | $defparamsfile="defaults"; | |
| 24 | $default='global|slider|layout|seo|translations'; | |
| 25 | ||
| 26 | ||
| 27 | ||
| 28 | if ( function_exists('register_sidebar') ) {
| |
| 29 | $sidebar='default'; | |
| 30 | register_sidebar(array( | |
| 31 | 'name' => 'Right Sidebar', | |
| 32 | 'id' => 'right_sidebar', | |
| 33 | 'description' =>'The right sidebar widget area', | |
| 34 | 'before_widget' => '<div id="%1$s" class="widget %2$s"><div class="inner">', | |
| 35 | 'after_widget' => '</div></div>', | |
| 36 | 'before_title' => '<div class="caption"><h3>', | |
| 37 | 'after_title' => '</h3></div>' | |
| 38 | )); | |
| 39 | register_sidebar(array( | |
| 40 | 'name' => 'Left Sidebar', | |
| 41 | 'id' => 'left_sidebar', | |
| 42 | 'description' =>'The left sidebar widget area', | |
| 43 | 'before_widget' => '<div id="%1$s" class="widget %2$s"><div class="inner">', | |
| 44 | 'after_widget' => '</div></div>', | |
| 45 | 'before_title' => '<div class="caption"><h3>', | |
| 46 | 'after_title' => '</h3></div>' | |
| 47 | )); | |
| 48 | register_sidebar( array( | |
| 49 | 'name' => 'drugi', | |
| 50 | 'id' => 'drugi', | |
| 51 | 'description' => 'Drop here some widgets', | |
| 52 | 'before_widget' => '<div id="%1$s" class="widget %2 $s"><div class="inner">', | |
| 53 | 'after_widget' => '</div></div>', | |
| 54 | 'before_title' => '<div class="caption"></h3>', | |
| 55 | 'after_title' => '</h3></div>' | |
| 56 | ) ); | |
| 57 | $$sidebar='bottom'; | |
| 58 | register_sidebar(array( | |
| 59 | 'name' => 'Footer 1', | |
| 60 | 'id' => 'footer_1', | |
| 61 | 'description' => 'The primary sidebar widget area', | |
| 62 | 'before_widget' => '<div id="%1$s" class="widget %2$s"><div class="inner">', | |
| 63 | 'after_widget' => '</div></div>', | |
| 64 | 'before_title' => '<div class="caption"><h3>', | |
| 65 | 'after_title' => '</h3></div>' | |
| 66 | )); | |
| 67 | register_sidebar(array( | |
| 68 | 'name' => 'Footer 2', | |
| 69 | 'id' => 'footer_2', | |
| 70 | 'description' => 'The primary sidebar widget area', | |
| 71 | 'before_widget' => '<div id="%1$s" class="widget %2$s"><div class="inner">', | |
| 72 | 'after_widget' => '</div></div>', | |
| 73 | 'before_title' => '<div class="caption"><h3>', | |
| 74 | 'after_title' => '</h3></div>' | |
| 75 | )); | |
| 76 | register_sidebar(array( | |
| 77 | 'name' => 'Footer 3', | |
| 78 | 'id' => 'footer_3', | |
| 79 | 'description' => 'The primary sidebar widget area', | |
| 80 | 'before_widget' => '<div id="%1$s" class="widget %2$s"><div class="inner">', | |
| 81 | 'after_widget' => '</div></div>', | |
| 82 | 'before_title' => '<div class="caption"><h3>', | |
| 83 | 'after_title' => '</h3></div>' | |
| 84 | )); | |
| 85 | register_sidebar(array( | |
| 86 | 'name' => 'Tabs', | |
| 87 | 'id' => 'tabs_sidebar', | |
| 88 | 'description' => 'The primary sidebar widget area', | |
| 89 | 'before_widget' => '<div id="%1$s" class="tab_widget %2$s"><div class="inner">', | |
| 90 | 'after_widget' => '</div></div>', | |
| 91 | 'before_title' => '<span class="scaption">', | |
| 92 | 'after_title' => '</span>' | |
| 93 | )); | |
| 94 | ||
| 95 | } | |
| 96 | $settings=$default; | |
| 97 | $SMTheme=new SMTheme; | |
| 98 | include_once get_template_directory()."/inc/widgets/facebook.php"; | |
| 99 | include_once get_template_directory()."/inc/widgets/banners.php"; | |
| 100 | include_once get_template_directory()."/inc/widgets/comments.php"; | |
| 101 | include_once get_template_directory()."/inc/widgets/posts.php"; | |
| 102 | include_once get_template_directory()."/inc/widgets/social-profiles.php"; | |
| 103 | include_once get_template_directory()."/inc/widgets/video.php"; | |
| 104 | include_once get_template_directory()."/inc/widgets/flickr.php"; | |
| 105 | include_once get_template_directory()."/inc/widgets/tabs.php"; | |
| 106 | ||
| 107 | ||
| 108 | if ($_SESSION['commentinput']=='') {
| |
| 109 | $_SESSION['commentinput']=substr(md5(rand(1,234234)),0,5); | |
| 110 | } | |
| 111 | if (isset($_POST[$_SESSION['commentinput']])) {
| |
| 112 | $_POST['comment']=$_POST[$_SESSION['commentinput']]; | |
| 113 | } | |
| 114 | if (function_exists('add_theme_support')) {
| |
| 115 | add_theme_support('automatic-feed-links');
| |
| 116 | add_theme_support('menus');
| |
| 117 | add_theme_support( 'post-thumbnails' ); | |
| 118 | set_post_thumbnail_size( $SMTheme->get( 'layout', 'imgwidth' ), $SMTheme->get( 'layout', 'imgheight' ) , true ); | |
| 119 | } | |
| 120 | ||
| 121 | if ( function_exists( 'register_nav_menu' ) ) {
| |
| 122 | register_nav_menu( 'sec-menu', 'Top Menu' ); | |
| 123 | register_nav_menu( 'main-menu', 'Main Menu' ); | |
| 124 | } | |
| 125 | if ( current_user_can('administrator') ) {
| |
| 126 | include_once (get_template_directory()."/inc/administrator.php"); | |
| 127 | $APage = new AdminPage(); | |
| 128 | } | |
| 129 | ||
| 130 | ||
| 131 | ||
| 132 | ||
| 133 | ||
| 134 | ||
| 135 | function smtheme_excerpt($args='', $postid=''){
| |
| 136 | global $post, $SMTheme; | |
| 137 | if ((int)$postid==0)$p=$post; | |
| 138 | else $p=get_post($postid); | |
| 139 | parse_str($args, $i); | |
| 140 | $echo = isset($i['echo'])?true:false; | |
| 141 | if ( isset($i['maxchar']) ) {
| |
| 142 | $maxchar=(int)trim($i['maxchar']); | |
| 143 | $content = $p->post_content; | |
| 144 | $content = apply_filters('the_content', $content);
| |
| 145 | } else {
| |
| 146 | if ( $p->post_excerpt ) {
| |
| 147 | $content = $p->post_excerpt; | |
| 148 | } else {
| |
| 149 | $content = $p->post_content; | |
| 150 | $content = apply_filters('the_content', $content);
| |
| 151 | $maxchar=($SMTheme->get( 'layout','cuttxton' ))?$SMTheme->get( 'layout','cuttxt' ):0; | |
| 152 | $maxchar=(strpos($content, '<!--more-->'))?strpos(preg_replace('/<.*?>/', '', preg_replace('/<!--more-->/','@smt_readmore_tag',$content)), '@smt_readmore_tag'):$maxchar;
| |
| 153 | } | |
| 154 | } | |
| 155 | if (!$maxchar||strlen(preg_replace('/<.*?>/', '', $content)) <= $maxchar) {
| |
| 156 | if ($echo) print $content; | |
| 157 | else return $content; | |
| 158 | } else {
| |
| 159 | preg_match_all('/(<.+?>)?([^<>]*)/s', $content, $lines, PREG_SET_ORDER);
| |
| 160 | $total_length=0; | |
| 161 | $open_tags = array(); | |
| 162 | $truncate = ''; | |
| 163 | foreach ($lines as $line_matchings) {
| |
| 164 | if (!empty($line_matchings[1])) {
| |
| 165 | if (preg_match('/^<(\s*.+?\/\s*|\s*(img|br|input|hr|area|base|basefont|col|frame|isindex|link|meta|param)(\s.+?)?)>$/is', $line_matchings[1])) {
| |
| 166 | } else if (preg_match('/^<\s*\/([^\s]+?)\s*>$/s', $line_matchings[1], $tag_matchings)) {
| |
| 167 | $pos = array_search($tag_matchings[1], $open_tags); | |
| 168 | if ($pos !== false) {
| |
| 169 | unset($open_tags[$pos]); | |
| 170 | } | |
| 171 | } else if (preg_match('/^<\s*([^\s>!]+).*?>$/s', $line_matchings[1], $tag_matchings)) {
| |
| 172 | array_unshift($open_tags, strtolower($tag_matchings[1])); | |
| 173 | } | |
| 174 | $truncate .= $line_matchings[1]; | |
| 175 | } | |
| 176 | $content_length = strlen(preg_replace('/&[0-9a-z]{2,8};|&#[0-9]{1,7};|&#x[0-9a-f]{1,6};/i', ' ', $line_matchings[2]));
| |
| 177 | ||
| 178 | if ($total_length+$content_length > $maxchar) {
| |
| 179 | ||
| 180 | $left = $maxchar - $total_length; | |
| 181 | $entities_length = 0; | |
| 182 | if (preg_match_all('/&[0-9a-z]{2,8};|&#[0-9]{1,7};|&#x[0-9a-f]{1,6};/i', $line_matchings[2], $entities, PREG_OFFSET_CAPTURE)) {
| |
| 183 | foreach ($entities[0] as $entity) {
| |
| 184 | if ($entity[1]+1-$entities_length <= $left) {
| |
| 185 | $left--; | |
| 186 | $entities_length += strlen($entity[0]); | |
| 187 | } else {
| |
| 188 | break; | |
| 189 | } | |
| 190 | } | |
| 191 | } | |
| 192 | $truncate .= preg_replace('/(.*)\.[^\.]*$/s', "$1",mb_substr($line_matchings[2], 0, $left+$entities_length, 'utf-8'))."...";
| |
| 193 | break; | |
| 194 | } else {
| |
| 195 | $truncate .= $line_matchings[2]; | |
| 196 | $total_length += $content_length; | |
| 197 | } | |
| 198 | if($total_length>= $maxchar) {
| |
| 199 | break; | |
| 200 | } | |
| 201 | } | |
| 202 | ||
| 203 | foreach ($open_tags as $tag) {
| |
| 204 | $truncate .= '</' . $tag . '>'; | |
| 205 | } | |
| 206 | $truncate=preg_replace('/<p([^>])*>( )?<\/p>/', '', $truncate);
| |
| 207 | if ($echo) return print $truncate; | |
| 208 | else return $truncate; | |
| 209 | } | |
| 210 | return; | |
| 211 | } | |
| 212 | function smt_menu($a) {
| |
| 213 | $a=preg_replace("/<ul\sclass='children'>/", "<ul class='children'$2><div class='transparent'></div><div class='inner'>", $a);
| |
| 214 | $a=preg_replace('/<ul\sclass="sub-menu">/', "<ul class='sub-menu'><div class='transparent'></div><div class='inner'>", $a);
| |
| 215 | $a=preg_replace("/<\/ul>/", "</div></ul>", $a);
| |
| 216 | return $a; | |
| 217 | } | |
| 218 | add_filter('wp_list_categories', 'smt_menu');
| |
| 219 | add_filter('wp_list_pages', 'smt_menu');
| |
| 220 | add_filter('wp_nav_menu_items', 'smt_menu');
| |
| 221 | function block_main_menu() {
| |
| 222 | global $SMTheme; | |
| 223 | ?> | |
| 224 | <div class="menu-primary-container"> | |
| 225 | <ul class="menus menu-primary"> | |
| 226 | <li <?php if(is_home() || is_front_page()) { ?>class="current_page_item"<?php } ?>><a href="<?php echo home_url(); ?>/"><?php echo $SMTheme->_( 'homelink' );?></a></li>
| |
| 227 | <?php wp_list_categories('title_li=&'); ?>
| |
| 228 | </ul> | |
| 229 | </div> | |
| 230 | <?php | |
| 231 | } | |
| 232 | ||
| 233 | function block_sec_menu() {
| |
| 234 | ?><div class='menu-topmenu-container'><ul class="menus"> | |
| 235 | <?php wp_list_pages('title_li=&'); ?>
| |
| 236 | </ul></div> | |
| 237 | <?php | |
| 238 | } | |
| 239 | ||
| 240 | function block_sec_menu_mobile() {
| |
| 241 | ?> | |
| 242 | <script> | |
| 243 | jQuery(document).ready(function(){
| |
| 244 | jQuery('.menu-topmenu-container li').each(function() {
| |
| 245 | jQuery('<option />', {
| |
| 246 | 'value':jQuery(this).find('a').attr('href'),
| |
| 247 | 'text':jQuery(this).find('a').html()
| |
| 248 | }).appendTo(jQuery('#mobile-sec-menu'));
| |
| 249 | }); | |
| 250 | }); | |
| 251 | </script> | |
| 252 | <?php | |
| 253 | } | |
| 254 | function block_main_menu_mobile() {
| |
| 255 | ?> | |
| 256 | <script> | |
| 257 | jQuery(document).ready(function(){
| |
| 258 | jQuery('.menu-primary li').each(function() {
| |
| 259 | jQuery('<option />', {
| |
| 260 | 'value':jQuery(this).find('a').attr('href'),
| |
| 261 | 'text':jQuery(this).find('a').html()
| |
| 262 | }).appendTo(jQuery('#mobile-main-menu'));
| |
| 263 | }); | |
| 264 | }); | |
| 265 | </script> | |
| 266 | <?php | |
| 267 | } | |
| 268 | ||
| 269 | function smt_mobile_menu($menu_name) {
| |
| 270 | echo '<select class=\'mobile-menu\' id=\'mobile-'.$menu_name.'\'>'; | |
| 271 | echo '<option value=\'#\'>Go to ...</option>'; | |
| 272 | if ( ( $locations = get_nav_menu_locations() ) && isset( $locations[ $menu_name ] ) ) {
| |
| 273 | $menu = wp_get_nav_menu_object( $locations[ $menu_name ] ); | |
| 274 | if ($menu_items = wp_get_nav_menu_items($menu->term_id)) {
| |
| 275 | $sub=array(); | |
| 276 | foreach ($menu_items as $key => $menu_item ) {
| |
| 277 | if ($menu_item->menu_item_parent==0) $sub[$menu_item->ID]=''; else $sub[$menu_item->ID]=$sub[$menu_item->menu_item_parent].'- '; | |
| 278 | echo '<option value=\''.$menu_item->url . '\'>' .$sub[$menu_item->ID]. $menu_item->title . '</option>'; | |
| 279 | } | |
| 280 | } else {
| |
| 281 | $func='block_'.preg_replace('/-/', '_', $menu_name).'_mobile';
| |
| 282 | if (is_callable($func)) {
| |
| 283 | $func(); | |
| 284 | } | |
| 285 | } | |
| 286 | } else {
| |
| 287 | $func='block_'.preg_replace('/-/', '_', $menu_name).'_mobile';
| |
| 288 | if (is_callable($func)) {
| |
| 289 | $func(); | |
| 290 | } | |
| 291 | } | |
| 292 | echo '</select>'; | |
| 293 | } | |
| 294 | ||
| 295 | ||
| 296 | ||
| 297 | ||
| 298 | ||
| 299 | function addGMap($atts, $content = null) {
| |
| 300 | ||
| 301 | extract(shortcode_atts(array( "addr" => '', "mzoom" => '16' ), $atts)); | |
| 302 | $id='map_canvas'.mktime().rand(0,1000); | |
| 303 | return " | |
| 304 | <div class='googlemap'><div id='".$id."' style='width: 100%; height: 300px;'></div></div> | |
| 305 | <script>jQuery(function(){loadGMap('".$addr."', '".$id."', ".$mzoom.", '".$content."')});</script>
| |
| 306 | "; | |
| 307 | ||
| 308 | } | |
| 309 | add_shortcode('gmap', 'addGMap');
| |
| 310 | ||
| 311 | ||
| 312 | function addYouTube($atts, $content = null) {
| |
| 313 | extract(shortcode_atts(array( "id" => '' ), $atts)); | |
| 314 | return '<p style="text-align:center;display:block;overflow:hidden;clear:left"> | |
| 315 | <a href="http://www.youtube.com/watch?v='.$id.'" target="_blank" alt="'.$id.'" class="youtube"> | |
| 316 | <img src="http://img.youtube.com/vi/'.$id.'/0.jpg" width="90%" height="" /> | |
| 317 | </a></p><script>loadYouTube();</script>'; | |
| 318 | } | |
| 319 | add_shortcode('youtube', 'addYouTube');
| |
| 320 | ||
| 321 | function addVimeo($atts, $content = null) {
| |
| 322 | extract(shortcode_atts(array( "id" => '' ), $atts)); | |
| 323 | $videoinf = unserialize(file_get_contents("http://vimeo.com/api/v2/video/".$id.".php"));
| |
| 324 | return '<p style="text-align:center;display:block;overflow:hidden;"> | |
| 325 | <a href="http://vimeo.com/'.$id.'" target="_blank" alt="'.$id.'" class="vimeo"> | |
| 326 | <img alt="" src="'.$videoinf[0]['thumbnail_large'].'" width="90%"> | |
| 327 | </a></p><script>loadVimeo();</script>'; | |
| 328 | } | |
| 329 | add_shortcode('vimeo', 'addVimeo');
| |
| 330 | ||
| 331 | function addTooltips($atts, $content = "") {
| |
| 332 | extract(shortcode_atts(array( "tiptext" => '' ), $atts)); | |
| 333 | return '<span class="tooltip" title="'.$tiptext.'">'.$content.'<span>'.$tiptext.'</span></span>'; | |
| 334 | } | |
| 335 | add_shortcode('tooltip', 'addTooltips');
| |
| 336 | ||
| 337 | function add_smpanel() {
| |
| 338 | if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') )
| |
| 339 | return; | |
| 340 | if ( get_user_option('rich_editing') == 'true') {
| |
| 341 | add_filter('mce_external_plugins', 'add_smpanel_tinymce_plugin');
| |
| 342 | add_filter('mce_buttons_3', 'register_smpanel');
| |
| 343 | } | |
| 344 | } | |
| 345 | ||
| 346 | add_action('init', 'add_smpanel');
| |
| 347 | function register_smpanel($buttons) {
| |
| 348 | array_push($buttons, "youtube","vimeo","|","btns","cols","tooltips","highlights", "gmap"); | |
| 349 | return $buttons; | |
| 350 | } | |
| 351 | ||
| 352 | function add_smpanel_tinymce_plugin($plugin_array) {
| |
| 353 | $plugin_array['smpanel'] = get_template_directory_uri() .'/js/editor_plugin.js'; | |
| 354 | return $plugin_array; | |
| 355 | } | |
| 356 | ||
| 357 | function my_refresh_mce($ver) {
| |
| 358 | $ver += 3; | |
| 359 | return $ver; | |
| 360 | } | |
| 361 | add_editor_style( 'css/editor.css' ); | |
| 362 | add_filter( 'tiny_mce_version', 'my_refresh_mce'); | |
| 363 | ||
| 364 | ||
| 365 | ||
| 366 | ||
| 367 | if ( ! function_exists('tdav_css') ) {
| |
| 368 | function tdav_css($wp) {
| |
| 369 | $wp .= ','.get_template_directory_uri().'/css/shortcode.css '; | |
| 370 | return $wp; | |
| 371 | } | |
| 372 | } | |
| 373 | add_filter( 'mce_css', 'tdav_css' ); | |
| 374 | function smtheme_topic_count_text($count) {
| |
| 375 | global $SMTheme; | |
| 376 | return sprintf( _n($SMTheme->_( 'altposts' ), $SMTheme->_( 'altpostss' ), $count), number_format_i18n( $count ) ); | |
| 377 | } | |
| 378 | function smtheme_tag_cloud() {
| |
| 379 | $args['topic_count_text_callback']='smtheme_topic_count_text'; | |
| 380 | return $args; | |
| 381 | } | |
| 382 | add_filter('widget_tag_cloud_args', 'smtheme_tag_cloud');
| |
| 383 | ||
| 384 | add_filter( 'gettext', 'theme_change_comment_field_names', 20, 3 ); | |
| 385 | /** | |
| 386 | * Change comment form default field names. | |
| 387 | * | |
| 388 | * @link http://codex.wordpress.org/Plugin_API/Filter_Reference/gettext | |
| 389 | */ | |
| 390 | function theme_change_comment_field_names( $translated_text, $text, $domain ) {
| |
| 391 | global $SMTheme; | |
| 392 | switch ( $translated_text ) {
| |
| 393 | ||
| 394 | case 'View all posts filed under %s' : | |
| 395 | ||
| 396 | $translated_text = $SMTheme->_( 'altcats' ); | |
| 397 | break; | |
| 398 | ||
| 399 | } | |
| 400 | return $translated_text; | |
| 401 | } | |
| 402 | ||
| 403 | ||
| 404 | ||
| 405 | add_action('admin_init', 'single_content_layout', 1);
| |
| 406 | ||
| 407 | function single_content_layout() {
| |
| 408 | add_meta_box( 'single_content_layout', 'Content layout', 'single_content_layout_func', 'post', 'side', 'high' ); | |
| 409 | add_meta_box( 'single_content_layout', 'Content layout', 'single_content_layout_func', 'page', 'side', 'high' ); | |
| 410 | } | |
| 411 | ||
| 412 | function single_content_layout_func($post) {
| |
| 413 | global $APage; | |
| 414 | ||
| 415 | $layouts=$APage->PageOptions['layout']['content']['pagelayout']['params']; | |
| 416 | $selected = get_post_meta($post->ID, 'single_layout', 1); | |
| 417 | ?> | |
| 418 | <select name='single_layout' style='width:100%'> | |
| 419 | <option value='0'>Default</option> | |
| 420 | <?php | |
| 421 | ||
| 422 | foreach ( $layouts as $key=>$value ) {
| |
| 423 | echo "<option value='".$key."' ".selected( $selected, $key ).">".$value."</option>"; | |
| 424 | } | |
| 425 | ?> | |
| 426 | </select> | |
| 427 | <?php | |
| 428 | } | |
| 429 | ||
| 430 | add_action('save_post', 'single_content_layout_update', 0);
| |
| 431 | function single_content_layout_update( $post_id ){
| |
| 432 | ||
| 433 | if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) return false;
| |
| 434 | ||
| 435 | if ( !current_user_can('edit_post', $post_id) ) return false;
| |
| 436 | ||
| 437 | if( !isset($_POST['single_layout']) ) return false; | |
| 438 | ||
| 439 | $_POST['single_layout'] = (int)$_POST['single_layout']; | |
| 440 | update_post_meta($post_id, 'single_layout', $_POST['single_layout']); | |
| 441 | ||
| 442 | ||
| 443 | return $post_id; | |
| 444 | } | |
| 445 | ||
| 446 | ?> |