Advertisement
pixedelic

pix_functions.3.2.0.php

Nov 3rd, 2011
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 82.12 KB | None | 0 0
  1. <?php
  2. add_filter( 'show_admin_bar', '__return_false' );
  3.  
  4. /*=========================================================================================*/
  5.  
  6. load_theme_textdomain( 'delight', TEMPLATEPATH . '/languages' );
  7.  
  8.     $locale = get_locale();
  9.     $locale_file = TEMPLATEPATH . "/languages/$locale.php";
  10.     if ( is_readable( $locale_file ) )
  11.         require_once( $locale_file );
  12.  
  13. /*=========================================================================================*/
  14.  
  15. $content_width = 710;
  16.  
  17. /*=========================================================================================*/
  18.  
  19. add_action('login_head', 'my_custom_login_logo');
  20.  
  21. function my_custom_login_logo() {
  22.     echo '<style type="text/css">
  23.        h1 a { background-image:url('.get_bloginfo('template_directory').'/images/custom-login-logo.png) !important; height:128px; background-position:center!important; margin-bottom:30px; }
  24.    </style>';
  25. }
  26.  
  27. /*=========================================================================================*/
  28.  
  29. add_action('admin_head', 'my_custom_logo');
  30.  
  31. function my_custom_logo() {
  32.     if( get_bloginfo('version') < 3.2 ) {
  33.         echo '
  34.             <style type="text/css">
  35.                  #header-logo { background-image: url('.get_bloginfo('template_directory').'/images/custom_logo.png) !important; }
  36.             </style>';
  37.     } else {
  38.         echo '
  39.             <style type="text/css">
  40.                  #header-logo {
  41.                     background-image: url('.get_bloginfo('template_directory').'/images/delight-icon.png) !important;
  42.                     background-position: 0 -6px;
  43.                  }
  44.             </style>';
  45.     }
  46. }
  47.  
  48. /*=========================================================================================*/
  49.  
  50. add_filter('admin_body_class', 'google_font_load', 1);
  51.  
  52. function google_font_load( $classes ) {
  53.     global $wpdb, $post;
  54.     $post_type = get_post_type( $post->ID );
  55.     if ( is_admin() && get_pix_option('pix_google_prevent') != '0' ) {
  56.         $classes .= 'google_font_loaded';
  57.     }
  58.     return $classes;
  59. }
  60. /*=========================================================================================*/
  61.  
  62. if (function_exists('register_nav_menus')) {
  63.     add_action( 'init', 'register_my_menus' );
  64.     function register_my_menus() {
  65.         register_nav_menus(
  66.             array(
  67.                 'primary_menu' => __( 'Primary menu' ),
  68.                 'secondary_menu' => __( 'Secondary menu' )
  69.             )
  70.         );
  71.     }
  72. }
  73.  
  74. /*=========================================================================================*/
  75.  
  76. function menuCount($menu_name){
  77. $menu_to_count = wp_nav_menu(array(
  78.                     'echo' => false,
  79.                     'theme_location' => $menu_name
  80.                 ));
  81. $menu_items = substr_count($menu_to_count,'class="menu-item ');
  82. return $menu_items;
  83. }
  84.            
  85. /*=========================================================================================*/
  86.  
  87. add_theme_support( 'post-thumbnails' );
  88. set_post_thumbnail_size( 75, 75, true ); // hard crop mode true
  89.  
  90. if ( function_exists( 'add_image_size' ) ) {
  91.     add_image_size('slideTh', 34, 34, true);
  92.     add_image_size('exTh', 50, 50, true);
  93.     add_image_size('wideCol', 708, 0, true);
  94.     add_image_size('narrowCol', 427, 0, true);
  95.     add_image_size('floatPort', 350, 350, false);
  96. }
  97.  
  98. /*=========================================================================================*/
  99.  
  100. /*=========================================================================================*/
  101.  
  102. if ( !function_exists('fb_AddThumbColumn') && function_exists('add_theme_support') ) {
  103.  
  104.     function fb_AddThumbColumn($cols) {
  105.         $cols['description'] = __('Description');
  106.         $cols['thumbnail'] = __('Thumbnail');
  107.         $cols['galleries'] = __('Galleries');
  108.         return $cols;
  109.     }
  110.  
  111.     function fb_AddThumbValue($column_name, $post_id) {
  112.        
  113.             $width = (int) 75;
  114.             $height = (int) 75;
  115.  
  116.  
  117.             if ( 'thumbnail' == $column_name ) {
  118.                 $thumbnail_id = get_post_meta( $post_id, '_thumbnail_id', true );
  119.                 $attachments = get_children( array('post_parent' => $post_id, 'post_type' => 'attachment', 'post_mime_type' => 'image') );
  120.                 if ($thumbnail_id)
  121.                     $thumb = wp_get_attachment_image( $thumbnail_id, array($width, $height), true );
  122.                 elseif ($attachments) {
  123.                     foreach ( $attachments as $attachment_id => $attachment ) {
  124.                         $thumb = wp_get_attachment_image( $attachment_id, array($width, $height), true );
  125.                     }
  126.                 }
  127.                     if ( isset($thumb) && $thumb ) {
  128.                         echo $thumb;
  129.                     } else {
  130.                         echo __('None');
  131.                     }
  132.             }
  133.            
  134.        
  135.             if ( 'description' == $column_name ) {
  136.                 echo get_the_excerpt();
  137.             }
  138.  
  139.             if ( 'galleries' == $column_name ) {
  140.                 $_taxonomy = 'gallery';
  141.                 $categories = get_the_terms( $post_id, $_taxonomy );
  142.                 if ( !empty( $categories ) ) {
  143.                     $out = array();
  144.                     foreach ( $categories as $c )
  145.                         $out[] = "<a href='edit.php?gallery=$c->term_id&post_type=portfolio'> " . esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'category', 'display')) . "</a>";
  146.                     echo join( ', ', $out );
  147.                 }
  148.                 else {
  149.                     _e('Uncategorized');
  150.                 }
  151.             }
  152.     }
  153.  
  154.     add_filter( 'manage_posts_columns', 'fb_AddThumbColumn' );
  155.     add_action( 'manage_posts_custom_column', 'fb_AddThumbValue', 10, 2 );
  156.  
  157. }
  158.  
  159. /*=========================================================================================*/
  160.  
  161. function get_content($url)
  162. {
  163.     $ch = curl_init();
  164.  
  165.     curl_setopt ($ch, CURLOPT_URL, $url);
  166.     curl_setopt ($ch, CURLOPT_HEADER, 0);
  167.  
  168.     ob_start();
  169.  
  170.     curl_exec ($ch);
  171.     curl_close ($ch);
  172.     $string = ob_get_contents();
  173.  
  174.     ob_end_clean();
  175.    
  176.     return $string;    
  177. }
  178.            
  179. /*=========================================================================================*/
  180.  
  181. function pix_admin_styles() {
  182.     wp_enqueue_style('thickbox');
  183.     wp_enqueue_style( 'farbtastic' );
  184.     if(get_pix_option('pix_google_prevent') != '0') { wp_enqueue_style("lobster", "http://fonts.googleapis.com/css?family=Lobster", false, "1.0", "all"); }
  185.     if(get_pix_option('pix_google_prevent') != '0') { wp_enqueue_style("cabin", "http://fonts.googleapis.com/css?family=Cabin", false, "1.0", "all"); }
  186.     wp_enqueue_style("functions", get_bloginfo('template_directory')."/functions/css/functions.css", false, "1.0", "all");
  187. }
  188. add_action('admin_print_styles', 'pix_admin_styles');
  189.  
  190. /*=========================================================================================*/
  191.  
  192. function addTinyMCELinkClasses( $wp ) {
  193.     $wp .= ',' . get_bloginfo('stylesheet_directory') . '/functions/css/tinymce.css';
  194.     return $wp;
  195. }
  196.  
  197. add_filter( 'mce_css', 'addTinyMCELinkClasses' );
  198.            
  199. /*=========================================================================================*/
  200.  
  201. add_action( 'admin_head', 'html5_comp' );
  202. function html5_comp() {
  203.     echo '<!--[if lt IE 9]>
  204.    <script src="'.get_bloginfo('stylesheet_directory').'/scripts/html5.js"></script>
  205.    <![endif]-->';
  206. }
  207.  
  208.  
  209.            
  210. /*=========================================================================================*/
  211.  
  212. add_action( 'admin_head', 'template_path' );
  213. function template_path() {
  214.     echo '<link id="template_path" data-url="'.get_bloginfo('stylesheet_directory').'" />';
  215. }
  216.            
  217. /*=========================================================================================*/
  218.  
  219. function pix_admin_enqueue_scripts() {
  220.         wp_enqueue_script('media-upload');
  221.         wp_enqueue_script('thickbox');
  222.         wp_enqueue_script( 'thickbox' );
  223.         wp_register_script( 'pix-tb', get_bloginfo('template_directory')."/functions/scripts/pix_thickbox.js", array('thickbox') );
  224.         wp_enqueue_script( 'pix-tb' );
  225.         wp_enqueue_script( 'jquery-ui-core' );
  226.         wp_enqueue_script( 'jquery-ui-tabs' );
  227.         wp_enqueue_script( 'jquery-ui-sortable' );
  228.         wp_enqueue_script( 'farbtastic' );
  229.         wp_enqueue_script('jquery-ui-mouse', get_bloginfo('template_directory')."/scripts/jquery.ui.mouse.js", array('jquery-ui-core'));
  230.         wp_enqueue_script('jquery-ui-widget', get_bloginfo('template_directory')."/scripts/jquery.ui.widget.js", array('jquery-ui-core'));
  231.         wp_enqueue_script('jquery-ui-slider', get_bloginfo('template_directory')."/scripts/jquery.ui.slider.js", array('jquery-ui-core','jquery-ui-mouse','jquery-ui-widget'));
  232.     if($_GET['page']=='admin_general'){
  233.         wp_enqueue_script('modernizr', get_bloginfo( 'stylesheet_directory' )."/scripts/modernizr-1.7.min.js");
  234.         wp_enqueue_script('jquery-cookie', get_bloginfo('template_directory')."/functions/scripts/biscuit.js", array('jquery'));
  235.         wp_enqueue_script('jquery-cluetip', get_bloginfo('template_directory')."/scripts/jquery.qtip.min.js", array('jquery'));
  236.         wp_enqueue_script("colorBox", get_bloginfo( 'stylesheet_directory' )."/scripts/jquery.colorbox-min.js", array('jquery'));
  237.         if(get_pix_option('pix_google_prevent') != '0') { wp_enqueue_script('google-font', "https://www.google.com/jsapi"); }
  238.     }
  239.     wp_enqueue_script('pix-scripts', get_bloginfo('template_directory')."/functions/scripts/pix_scripts.js", array('jquery','jquery-ui-tabs'));
  240. }
  241. add_action('admin_enqueue_scripts', 'pix_admin_enqueue_scripts');
  242.            
  243. function plugin_prevent_scripts() {
  244.     if($_GET['page']=='admin_general'){
  245.         wp_deregister_script( 'yak-ui' );
  246.         wp_deregister_script( 'yak-admin-ui' );
  247.     }
  248. }
  249. add_action('admin_enqueue_scripts', 'plugin_prevent_scripts');
  250.  
  251. /*=========================================================================================*/
  252.  
  253. if ( (strpos($_SERVER['SCRIPT_NAME'], 'wp-admin/admin.php'))) {
  254.     if( get_bloginfo('version') < 3.2 ) {
  255.         add_filter('admin_head','myplugin_tinymce');
  256.     }
  257.     add_filter('tiny_mce_before_init', 'remove_mce_showcase');
  258.     add_action("admin_print_scripts", "js_libs");
  259. }
  260.  
  261. function js_libs() {
  262.      wp_enqueue_script('tiny_mce');
  263. }
  264.  
  265. function myplugin_tinymce()
  266. {
  267.   wp_enqueue_script('common');
  268.   wp_enqueue_script('jquery-color');
  269.   wp_admin_css('thickbox');
  270.   wp_print_scripts('post');
  271.   wp_print_scripts('media-upload');
  272.   wp_print_scripts('jquery');
  273.   wp_print_scripts('jquery-ui-core');
  274.   wp_print_scripts('jquery-ui-tabs');
  275.   wp_print_scripts('tiny_mce');
  276.   wp_print_scripts('editor');
  277.   wp_print_scripts('editor-functions');
  278.   add_thickbox();
  279.   wp_tiny_mce();
  280.   wp_admin_css();
  281.   wp_enqueue_script('utils');
  282.   wp_enqueue_script('link');
  283.   do_action("admin_print_styles-post-php");
  284.   do_action('admin_print_styles');
  285.   remove_all_filters('mce_external_plugins');
  286. }
  287.  
  288. function remove_mce_showcase($initArray) {
  289.     global $post_type;
  290.     $initArray['theme_advanced_disable'] = 'strikethrough,wp_more,spellchecker,fullscreen,underline,undo,redo,wp_help';
  291.     return $initArray;
  292. }
  293.  
  294. /*=========================================================================================*/
  295.  
  296. $custom_slideshow = new WPAlchemy_MetaBox(array
  297. (
  298.     'id' => '_custom_slideshow',
  299.     'types' => array('page', 'post','portfolio'),
  300.     'title' => 'Slideshow shortcode',
  301.     'context' => 'normal',
  302.     'priority' => 'high',
  303.     'template' => TEMPLATEPATH .'/custom/custom_slideshow.php'
  304. ));
  305.  
  306. $custom_googlemap = new WPAlchemy_MetaBox(array
  307. (
  308.     'id' => '_custom_googlemap',
  309.     'types' => array('page', 'post','portfolio'),
  310.     'title' => 'Googlemap shortcode',
  311.     'context' => 'normal',
  312.     'priority' => 'high',
  313.     'template' => TEMPLATEPATH .'/custom/custom_googlemap.php'
  314. ));
  315.  
  316. $custom_contactform = new WPAlchemy_MetaBox(array
  317. (
  318.     'id' => '_custom_contactform',
  319.     'types' => array('page', 'post','portfolio'),
  320.     'title' => 'Contact form shortcode',
  321.     'context' => 'normal',
  322.     'priority' => 'high',
  323.     'template' => TEMPLATEPATH .'/custom/custom_contactform.php'
  324. ));
  325.  
  326. $custom_tooltip = new WPAlchemy_MetaBox(array
  327. (
  328.     'id' => '_custom_tooltip',
  329.     'types' => array('page', 'post','portfolio'),
  330.     'title' => 'Tooltip shortcode',
  331.     'context' => 'normal',
  332.     'priority' => 'high',
  333.     'template' => TEMPLATEPATH .'/custom/custom_tooltip.php'
  334. ));
  335.  
  336. $custom_options = new WPAlchemy_MetaBox(array
  337. (
  338.     'id' => '_custom_options',
  339.     'types' => array('page', 'post','portfolio'),
  340.     'title' => 'Page options',
  341.     'context' => 'normal',
  342.     'priority' => 'high',
  343.     'template' => TEMPLATEPATH .'/custom/custom_options.php'
  344. ));
  345.  
  346. $custom_payoff = new WPAlchemy_MetaBox(array
  347. (
  348.     'id' => '_custom_payoff',
  349.     'types' => array('page', 'post','portfolio'),
  350.     'title' => 'Custom titles',
  351.     'context' => 'normal',
  352.     'priority' => 'high',
  353.     'template' => TEMPLATEPATH .'/custom/custom_payoff.php'
  354. ));
  355.  
  356. $custom_seo = new WPAlchemy_MetaBox(array
  357. (
  358.     'id' => '_custom_seo',
  359.     'types' => array('page', 'post','portfolio'),
  360.     'title' => 'SEO',
  361.     'context' => 'normal',
  362.     'priority' => 'high',
  363.     'template' => TEMPLATEPATH .'/custom/custom_seo.php'
  364. ));
  365.  
  366. $custom_destination = new WPAlchemy_MetaBox(array
  367. (
  368.     'id' => '_custom_destination',
  369.     'types' => array('portfolio'),
  370.     'title' => 'Display a video in the gallery page',
  371.     'context' => 'side',
  372.     'priority' => 'low',
  373.     'template' => TEMPLATEPATH .'/custom/custom_destination.php'
  374. ));
  375.  
  376. $custom_url = new WPAlchemy_MetaBox(array
  377. (
  378.     'id' => '_custom_url',
  379.     'types' => array('portfolio'),
  380.     'title' => 'Point your featured image to an external URL',
  381.     'context' => 'side',
  382.     'priority' => 'low',
  383.     'template' => TEMPLATEPATH .'/custom/custom_url.php'
  384. ));
  385.  
  386. $custom_video = new WPAlchemy_MetaBox(array
  387. (
  388.     'id' => '_custom_video',
  389.     'types' => array('page', 'post','portfolio'),
  390.     'title' => 'Insert a video',
  391.     'context' => 'normal',
  392.     'priority' => 'high',
  393.     'template' => TEMPLATEPATH .'/custom/custom_video.php'
  394. ));
  395.  
  396. $custom_audio = new WPAlchemy_MetaBox(array
  397. (
  398.     'id' => '_custom_audio',
  399.     'types' => array('page', 'post','portfolio'),
  400.     'title' => 'Insert a audio',
  401.     'context' => 'normal',
  402.     'priority' => 'high',
  403.     'template' => TEMPLATEPATH .'/custom/custom_audio.php'
  404. ));
  405.  
  406. $custom_accordion = new WPAlchemy_MetaBox(array
  407. (
  408.     'id' => '_custom_accordion',
  409.     'types' => array('page', 'post','portfolio'),
  410.     'title' => 'Insert an accordion',
  411.     'context' => 'normal',
  412.     'priority' => 'high',
  413.     'template' => TEMPLATEPATH .'/custom/custom_accordion.php'
  414. ));
  415.  
  416. $custom_tab = new WPAlchemy_MetaBox(array
  417. (
  418.     'id' => '_custom_tab',
  419.     'types' => array('page', 'post','portfolio'),
  420.     'title' => 'Insert a tab',
  421.     'context' => 'normal',
  422.     'priority' => 'high',
  423.     'template' => TEMPLATEPATH .'/custom/custom_tab.php'
  424. ));
  425.  
  426. $custom_columns = new WPAlchemy_MetaBox(array
  427. (
  428.     'id' => '_custom_columns',
  429.     'types' => array('page', 'post','portfolio'),
  430.     'title' => 'Insert columns',
  431.     'context' => 'normal',
  432.     'priority' => 'high',
  433.     'template' => TEMPLATEPATH .'/custom/custom_columns.php'
  434. ));
  435.  
  436. $custom_box = new WPAlchemy_MetaBox(array
  437. (
  438.     'id' => '_custom_box',
  439.     'types' => array('page', 'post','portfolio'),
  440.     'title' => 'Insert a box',
  441.     'context' => 'normal',
  442.     'priority' => 'high',
  443.     'template' => TEMPLATEPATH .'/custom/custom_box.php'
  444. ));
  445.  
  446. $custom_list = new WPAlchemy_MetaBox(array
  447. (
  448.     'id' => '_custom_list',
  449.     'types' => array('page', 'post','portfolio'),
  450.     'title' => 'Insert a custom list',
  451.     'context' => 'normal',
  452.     'priority' => 'high',
  453.     'template' => TEMPLATEPATH .'/custom/custom_list.php'
  454. ));
  455.  
  456. $custom_dropcap = new WPAlchemy_MetaBox(array
  457. (
  458.     'id' => '_custom_dropcap',
  459.     'types' => array('page', 'post','portfolio'),
  460.     'title' => 'Insert a drop cap',
  461.     'context' => 'normal',
  462.     'priority' => 'high',
  463.     'template' => TEMPLATEPATH .'/custom/custom_dropcap.php'
  464. ));
  465.  
  466. $custom_button = new WPAlchemy_MetaBox(array
  467. (
  468.     'id' => '_custom_button',
  469.     'types' => array('page', 'post','portfolio'),
  470.     'title' => 'Insert a drop cap',
  471.     'context' => 'normal',
  472.     'priority' => 'high',
  473.     'template' => TEMPLATEPATH .'/custom/custom_button.php'
  474. ));
  475.  
  476. $custom_pricetable = new WPAlchemy_MetaBox(array
  477. (
  478.     'id' => '_custom_pricetable',
  479.     'types' => array('page', 'post','portfolio'),
  480.     'title' => 'Insert a drop cap',
  481.     'context' => 'normal',
  482.     'priority' => 'high',
  483.     'template' => TEMPLATEPATH .'/custom/custom_pricetable.php'
  484. ));
  485.  
  486. $custom_span = new WPAlchemy_MetaBox(array
  487. (
  488.     'id' => '_custom_span',
  489.     'types' => array('page', 'post','portfolio'),
  490.     'title' => 'Insert a drop cap',
  491.     'context' => 'normal',
  492.     'priority' => 'high',
  493.     'template' => TEMPLATEPATH .'/custom/custom_span.php'
  494. ));
  495.  
  496. $custom_blog = new WPAlchemy_MetaBox(array
  497. (
  498.     'id' => '_custom_blog',
  499.     'types' => array('page'),
  500.     'title' => 'Display your posts',
  501.     'context' => 'normal',
  502.     'priority' => 'high',
  503.     'template' => TEMPLATEPATH .'/custom/custom_blog.php'
  504. ));
  505.  
  506. add_action('admin_print_footer_scripts','my_admin_print_footer_scripts',99);
  507. function my_admin_print_footer_scripts()
  508. {
  509.     ?><script type="text/javascript">/* <![CDATA[ */
  510.         jQuery(function($)
  511.         {
  512.             var i=1;
  513.             $('.customEditor textarea').each(function(e)
  514.             {
  515.                 var id = $(this).attr('id');
  516.  
  517.                 if (!id)
  518.                 {
  519.                     id = 'customEditor-' + i++;
  520.                     $(this).attr('id',id);
  521.                 }
  522.  
  523.                 tinyMCE.execCommand('mceAddControl', false, id);
  524.  
  525.             });
  526.         });
  527.     /* ]]> */</script><?php
  528. }
  529.  
  530. /*=========================================================================================*/
  531.  
  532. function ajax_sidebar_rm() {   
  533.     global $shortname, $wpdb;
  534.     $sidebar = $_POST['sidebar'];
  535.     $sidebar_id = $_POST['sidebar_id'];
  536.     $sidebar_name = $_POST['sidebar_name'];
  537.     $pieces = explode(",", $sidebar);
  538.  
  539.     foreach ($pieces as $key => $value) {
  540.         if($value != '')
  541.             $options_sidebar_rm[ $value ] = $value;
  542.         }
  543.         update_option( $shortname.'_sidebar_generator', $options_sidebar_rm);
  544.         ajax_update_widgets($sidebar_id);
  545.  
  546.         $sidebar_meta = $wpdb->get_results("SELECT post_id FROM $wpdb->postmeta WHERE meta_value = '$sidebar_name'", ARRAY_A);
  547.         if ( is_array($sidebar_meta) ){
  548.             foreach ($sidebar_meta as $key => $value) {
  549.                 delete_post_meta($value['post_id'], 'selected_sidebar');
  550.         }
  551.     }
  552. }
  553.  
  554. add_action('wp_ajax_sidebar_rm', 'ajax_sidebar_rm');
  555.  
  556. function pix_admin_print_scripts($hook) {
  557.     $nonce = wp_create_nonce( 'sidebar_rm' );
  558.        
  559.     echo '<script type="text/javascript">
  560.     //<![CDATA[
  561.     var $rmSidebarAjaxUrl = "' .admin_url('admin-ajax.php'). '";
  562.     var $ajaxNonce = "' .$nonce. '";
  563.     //]]></script>';
  564. }
  565.  
  566. add_action('admin_print_scripts', 'pix_admin_print_scripts');
  567.  
  568. /*=========================================================================================*/
  569.  
  570. add_action('admin_menu', 'select_sidebar');
  571.  
  572. function select_sidebar() {
  573.     add_meta_box('sidebar_selected', 'Select a sidebar', 'custom_sidebar_selected', 'post', 'side', 'high');
  574.     add_meta_box('sidebar_selected', 'Select a sidebar', 'custom_sidebar_selected', 'page', 'side', 'high');
  575.     add_meta_box('sidebar_selected', 'Select a sidebar', 'custom_sidebar_selected', 'portfolio', 'side', 'high');
  576. }
  577.  
  578. function custom_sidebar_selected() {
  579.     global $post;
  580.     ?>
  581.     <fieldset id="mycustom-div">
  582.     <div>
  583.     <p>
  584.     <label for="pix_select_sidebar" >Dropdown Options:</label><br />
  585.     <select name="pix_select_sidebar" id="pix_select_sidebar">
  586.         <option<?php selected( get_post_meta($post->ID, 'pix_select_sidebar', true), 'None'); ?>>No sidebar</option>
  587.     <?php
  588.     $sidebars = sidebar_generator_pix::get_sidebars();
  589.     if(is_array($sidebars) && !empty($sidebars)){
  590.         foreach($sidebars as $sidebar){ ?>
  591.             <option<?php selected( get_post_meta($post->ID, 'pix_select_sidebar', true), $sidebar ); ?>><?php echo $sidebar; ?></option>
  592.         <?php }
  593.     }
  594.     ?>
  595.     </select>
  596.     </p>
  597.     </div>
  598.     </fieldset>
  599.     <?php
  600. }
  601.  
  602. add_action('save_post', 'custom_sidebar_save');
  603. function custom_sidebar_save($postID){
  604.     if($parent_id = wp_is_post_revision($postID)) {
  605.         $postID = $parent_id;
  606.     }
  607.    
  608.     if ($_POST['pix_select_sidebar']) {
  609.         update_custom_meta($postID, $_POST['pix_select_sidebar'], 'pix_select_sidebar');
  610.     }
  611. }
  612.  
  613. function update_custom_meta($postID, $newvalue, $field_name) {
  614.     if(!get_post_meta($postID, $field_name)){
  615.         add_post_meta($postID, $field_name, $newvalue);
  616.     }else{
  617.         update_post_meta($postID, $field_name, $newvalue);
  618.     }
  619. }
  620.  
  621. /*=========================================================================================*/
  622.  
  623.  
  624. function custom_the_excerpt($length, $more, $end_char = '&#8230;'){
  625.     global $post;
  626.     if (function_exists('has_excerpt') && has_excerpt()) {
  627.         the_excerpt();
  628.     } else {
  629.         $content = strip_tags($post->post_content);
  630.         $content = preg_replace( '|\[(.+?)\](.+?\[/\\1\])?|s', '', $content);
  631.         preg_match('/^\s*+(?:\S++\s*+){1,' .$length . '}/', $content, $matches);
  632.         $no = count(explode(" ",$content));
  633.         $no2 = count(explode(" ",$matches[0]));
  634.         $excerpt = preg_replace("/\n/", " ", $matches[0]);
  635.         if($no>$no2) {
  636.             echo "<p class='".$no." ".$no2."'>" . $excerpt . $end_char . "</p>";
  637.         } else {
  638.             echo "<p class='".$no." ".$no2."'>" . $excerpt . "</p>";
  639.         }
  640.     }
  641.         if($more!=''){
  642.             echo '<a class="button small alignleft" href="'. get_permalink($post->ID) .'">'. $more .'</a>';
  643.         }
  644. }
  645.  
  646. add_filter( 'the_content_more_link', 'pix_more_link', 10, 2 );
  647.  
  648. function pix_more_link( $more_link, $more_link_text ) {
  649.     return str_replace( $more_link_text, '<a href="' . get_permalink() . '" class="more-link button small alignleft">'.$more_link_text.'</a>', $more_link );
  650. }
  651.  
  652. /*=========================================================================================*/
  653.  
  654. function remove_something($something,$content)
  655. {
  656.     $str = str_replace($something, '', $content);
  657.  
  658.     return $str;
  659. }
  660.  
  661. /*=========================================================================================*/
  662.  
  663. function add_space_brackets($pattern)
  664. {
  665.     $str = str_replace('][', '] [', $pattern);
  666.  
  667.     return $str;
  668. }
  669.  
  670. /*=========================================================================================*/
  671.  
  672. function pix_comment($comment, $args, $depth) {
  673.     $GLOBALS['comment'] = $comment;
  674.     ?>
  675.     <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
  676.         <div class="comment-text">
  677.             <div id="comment-<?php comment_ID(); ?>" class="span_in">
  678.                 <span class="comment-author vcard">
  679.                     <?php
  680.                         if($depth == 1) {
  681.                             echo get_avatar( $comment, '50' );
  682.                         }
  683.                         else {
  684.                             echo get_avatar( $comment, '34' );
  685.                         }
  686.                     ?>
  687.                 </span><!-- .comment-author-avatar -->
  688.                 <span class="head-comment"><?php comment_author_link(); ?>, <span><?php printf( __( '%1$s at %2$s', 'delight' ), get_comment_date(),  get_comment_time() ); ?></span></span><!-- .head-comment -->
  689.                 <br />
  690.                 <?php echo get_comment_text(); ?>
  691.                 <?php if ( $comment->comment_approved == '0' ) : ?>
  692.                 <em><?php _e('Your comment is awaiting moderation','delight'); ?></em>
  693.                 <?php edit_comment_link( __('Edit','delight')); ?>
  694.                 <?php endif; ?>
  695.        
  696.                 <?php edit_comment_link( __( '(Edit)', 'delight' ), ' ' ); ?>
  697.        
  698.                 <div class="reply buttonspan small">
  699.                     <?php comment_reply_link( array_merge( array( 'reply_text' => __('Reply','delight')), array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
  700.                 </div><!-- .reply -->
  701.             </div><!-- #comment-##  -->
  702.        </div><!-- .comment-text -->
  703.  
  704.     <?php
  705.        }
  706.  
  707. /*=========================================================================================*/
  708.  
  709. function pix_search_form($form) {
  710. $form = '
  711.     <form method="get" id="search" action="' . get_pix_option('home') . '/" >
  712.         <fieldset>
  713.             <input type="text" class="typeText" value="" name="s" id="s"><input type="submit" class="typeSubmit" id="searchsubmit" value="&nbsp;">
  714.             <span class="icons">S</span>
  715.         </fieldset>
  716.     </form>';
  717. return $form;
  718. }
  719. add_filter('get_search_form', 'pix_search_form');
  720.  
  721. /*=========================================================================================*/
  722.  
  723. function curPageURL() {
  724.     $pageURL = 'http';
  725.     if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
  726.     $pageURL .= "://";
  727.     if ($_SERVER["SERVER_PORT"] != "80") {
  728.     $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
  729.     } else {
  730.     $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
  731.     }
  732.     return $pageURL;
  733. }
  734.  
  735. /*=========================================================================================*/
  736.  
  737. function get_attachment_id_from_src($image_src) {
  738.     global $wpdb;
  739.     $query = "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_value='$image_src'";
  740.     $id = $wpdb->get_var($query);
  741.     return $id;
  742. }
  743.  
  744. function get_pix_thumb($image_src, $thumb_size) {
  745.     $upload_dir = wp_upload_dir();
  746.     $image_id = get_attachment_id_from_src(str_replace($upload_dir['baseurl'].'/','',$image_src));  
  747.     if($image_id=='') {
  748.         if(strpos(substr( $image_src, -10 ), 'x')&&strpos(substr( $image_src, -15 ), '-')) {
  749.             $pos = strrpos($image_src, '-');
  750.             $image_src = substr($image_src, 0, $pos) . substr($image_src, -4);
  751.         }
  752.         $image_id = get_attachment_id_from_src(str_replace($upload_dir['baseurl'].'/','',$image_src));  
  753.     }
  754.     $url_thumb = wp_get_attachment_image_src($image_id,$thumb_size);  
  755.     $url_thumb2 = $url_thumb[0];
  756.     if($url_thumb2==''){
  757.         $url_thumb2=$url_thumb;
  758.     }
  759.     if($url_thumb2==''){
  760.         $url_thumb2= get_bloginfo('stylesheet_directory').'/scripts/timthumb.php?src='.pix_image_path($image_src).'&amp;h=50&amp;w=50';
  761.     }
  762.     return $url_thumb2;
  763. }
  764.  
  765. function get_pix_content($image_src) {
  766.     global $wpdb;
  767.     $upload_dir = wp_upload_dir();
  768.     $image_id = get_attachment_id_from_src(str_replace($upload_dir['baseurl'].'/','',$image_src));
  769.     if($image_id=='') {
  770.         if(strpos(substr( $image_src, -10 ), 'x')&&strpos(substr( $image_src, -15 ), '-')) {
  771.             $pos = strrpos($image_src, '-');
  772.             $image_src = substr($image_src, 0, $pos) . substr($image_src, -4);
  773.         }
  774.         $image_id = get_attachment_id_from_src(str_replace($upload_dir['baseurl'].'/','',$image_src));  
  775.     }
  776.     $query = "SELECT post_content FROM {$wpdb->posts} WHERE ID='$image_id'";
  777.     $content = $wpdb->get_var($query);
  778.     $img_content = replace_something('"', '\'', $content);
  779.     if($img_content == '') {
  780.         $img_content = __('Sorry, there are no info for this photograph','delight');
  781.     }
  782.     return $img_content;
  783. }
  784.  
  785. /*=========================================================================================*/
  786.  
  787. function replace_something($something,$else,$content) {
  788.     $str = str_replace($something, $else, $content);
  789.     return $str;
  790. }
  791.  
  792.  
  793. /*=========================================================================================*/
  794.  
  795. function explode_something($something,$content,$return) {
  796.     $str = explode($something, $content);
  797.     return $str[$return];
  798. }
  799.  
  800. /*=========================================================================================*/
  801.  
  802. function pix_breadcrumbs() {
  803.  
  804.     global $custom_payoff; $meta_title = get_post_meta(get_the_ID(), $custom_payoff->get_the_id(), TRUE);
  805.     if($meta_title['payoff']!='') {
  806.         $the_title = $meta_title['payoff'];
  807.     } else {
  808.         $the_title = get_the_title();
  809.     }
  810.  
  811.   $delimiter = '</li><li> / </li>';
  812.   $name = __( 'Home', 'delight');
  813.   $currentBefore = '<li class="current">';
  814.   $currentAfter = '</li>';
  815.    
  816.   if ( get_pix_option('pix_breadcrumbs_show')=='show' && ( !is_home() && !is_front_page() || is_paged() && !is_search())) {
  817.  
  818.     echo '<ul id="breadcrumbs">';
  819.  
  820.     global $post;
  821.     $home = get_bloginfo('url');
  822.     echo '<li><a href="' . $home . '">' . $name . '</a> ' . $delimiter . ' ';
  823.  
  824.     if ( is_category() && !is_search()) {
  825.       global $wp_query;
  826.       $cat_obj = $wp_query->get_queried_object();
  827.       $thisCat = $cat_obj->term_id;
  828.       $thisCat = get_category($thisCat);
  829.       $parentCat = get_category($thisCat->parent);
  830.       if ($thisCat->parent != 0) echo('<li>'.get_category_parents($parentCat, TRUE, ' ' . $delimiter . ' '));
  831.       echo $currentBefore;
  832.       single_cat_title();
  833.       echo $currentAfter;
  834.  
  835.     } elseif ( is_day() && !is_search()) {
  836.       echo '<li><a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a> ' . $delimiter . ' ';
  837.       echo '<li><a href="' . get_month_link(get_the_time('Y'),get_the_time('m')) . '">' . get_the_time('F') . '</a> ' . $delimiter . ' ';
  838.       echo $currentBefore . get_the_time('d') . $currentAfter;
  839.  
  840.     } elseif ( is_month() && !is_search()) {
  841.       echo '<li><a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a> ' . $delimiter . ' ';
  842.       echo $currentBefore . get_the_time('F') . $currentAfter;
  843.  
  844.     } elseif ( is_year() && !is_search()) {
  845.       echo $currentBefore . get_the_time('Y') . $currentAfter;
  846.  
  847.     } elseif ( is_tax() && !is_search()) {
  848.         $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); $current_term = $term->term_id; $taxonomy = $term->taxonomy;
  849.         $cus_terms = get_ancestors( $current_term, $taxonomy );
  850.         foreach ( $cus_terms as $cus_term ) {
  851.             $the_term = get_term_by( 'id', $cus_term, $taxonomy );
  852.             echo "<li><a href='".get_term_link( $the_term->name, $taxonomy )."'>".$the_term->name."</a></li><li> / </li>";
  853.         }
  854.         echo "<li class='current'>".$term->name."</li>";
  855.     } elseif ( 'portfolio' == get_post_type() && !is_search()) {
  856.         echo get_the_term_list( $post->ID, 'gallery', '<li>', '</li><li> / </li><li>', '</li><li> / </li>');
  857.         echo $currentBefore;
  858.         echo $the_title;
  859.         echo $currentAfter;
  860.     }elseif ( is_single() && !is_search()) {
  861.       $cat = get_the_category(); $cat = $cat[0];
  862.       echo '<li>'.get_category_parents($cat, TRUE, '</li><li> / </li><li>');
  863.       echo $currentBefore;
  864.       echo $the_title;
  865.       echo $currentAfter;
  866.  
  867.     } elseif ( is_page() && !$post->post_parent && !is_search()) {
  868.       echo $currentBefore;
  869.       echo $the_title;
  870.       echo $currentAfter;
  871.  
  872.     } elseif ( is_page() && $post->post_parent && !is_search()) {
  873.       $parent_id  = $post->post_parent;
  874.       $breadcrumbs = array();
  875.       while ($parent_id) {
  876.         $page = get_page($parent_id);
  877.         $breadcrumbs[] = '<li><a href="' . get_permalink($page->ID) . '">' . get_the_title($page->ID) . '</a>';
  878.         $parent_id  = $page->post_parent;
  879.       }
  880.       $breadcrumbs = array_reverse($breadcrumbs);
  881.       foreach ($breadcrumbs as $crumb) echo $crumb . ' ' . $delimiter . ' ';
  882.       echo $currentBefore;
  883.       echo $the_title;
  884.       echo $currentAfter;
  885.  
  886.     } elseif ( is_tag() && !is_search()) {
  887.       echo $currentBefore .  __( 'Tag &#39;','delight');
  888.       single_tag_title();
  889.       echo '&#39;' . $currentAfter;
  890.  
  891.     } elseif ( is_author() && !is_search()) {
  892.        global $author;
  893.       $userdata = get_userdata($author);
  894.       echo $currentBefore .  __( 'Posts by ','delight') . $userdata->display_name . $currentAfter;
  895.  
  896.     } elseif ( is_404() && !is_search() ) {
  897.       echo $currentBefore .  __( 'Error 404 ','delight') . $currentAfter;
  898.      
  899.     } elseif ( is_search() ) {
  900.        
  901.       echo $currentBefore .sprintf( __( 'Results for &#39%s&#39','delight'), get_search_query()) . $currentAfter;
  902.  
  903.     }
  904.  
  905.     if ( get_query_var('paged') ) {
  906.       if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() || is_tax() ) echo '<li class="current" style="padding-left:0"> (';
  907.       echo __('Page','delight') . ' ' . get_query_var('paged');
  908.       if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() || is_tax() ) echo ')</li>';
  909.     }
  910.  
  911.     echo '</ul>';
  912.  
  913.   }
  914. }
  915.  
  916. /*=========================================================================================*/
  917.  
  918. function pix_pagenavi($numposts='') {
  919.     global $request, $posts_per_page, $wpdb, $paged;
  920.      $pages_to_show = 10;
  921.      $always_show = false;
  922.     $half_pages_to_show = round($pages_to_show/2);
  923.     if (!is_single()) {
  924.         if(!is_category()&&!is_tag()&&!is_tax()) {
  925.             preg_match('#FROM\s(.*)\sORDER BY#siU', $request, $matches);
  926.         }
  927.         else {
  928.             preg_match('#FROM\s(.*)\sGROUP BY#siU', $request, $matches);  
  929.         }
  930.     $fromwhere = $matches[1];
  931.     if($numposts==''){
  932.         $numposts = $wpdb->get_var("SELECT COUNT(DISTINCT ID) FROM $fromwhere");
  933.     }
  934.     $max_page = ceil($numposts / $posts_per_page);
  935.     if(empty($paged)) {
  936.         $paged = 1;
  937.     }
  938.     if($max_page > 1 || $always_show) {
  939.         echo "<div class='pix_pagenavi'><ul>";
  940.         if ($paged >= ($pages_to_show-2)) {
  941.             echo '<li><a href="'.esc_url( get_pagenum_link()).'">1</a></li><li>...</li>';
  942.         } elseif ($paged == ($pages_to_show-3)) {
  943.             echo '<li><a href="'.esc_url( get_pagenum_link()).'">1</a></li>';
  944.         }
  945.         for($i = $paged - $half_pages_to_show; $i <= $paged + $half_pages_to_show; $i++) {  
  946.             if ($i >= 1 && $i <= $max_page) {
  947.                 if($i == $paged) {
  948.                     echo "<li class='on'>$i</li> ";
  949.                 }
  950.                 else {
  951.                     echo '<li><a href="'.esc_url( get_pagenum_link($i)).'">'.$i.'</a></li> ';  
  952.                 }
  953.             }
  954.         }
  955.         if (($paged+$half_pages_to_show) < ($max_page-1) ) {
  956.             echo ' <li>...</li><li><a href="'.get_pagenum_link($max_page).'">'.$max_page.'</a></li> ';
  957.         } elseif  (($paged+$half_pages_to_show) == ($max_page-1)) {
  958.             echo ' <li><a href="'.get_pagenum_link($max_page).'">'.$max_page.'</a></li> ';
  959.         }
  960.         echo "</ul></div>";
  961.     }
  962. }
  963. }
  964.  
  965. /*=========================================================================================*/
  966.  
  967. function reduce_string($start, $end, $original) {
  968.     $original = strrchr($original, $start);
  969.     $trimmed = strrchr($original, $end);
  970.     return substr($original, strlen($start), -strlen($trimmed));
  971. }
  972.  
  973. /*=========================================================================================*/
  974.  
  975. function html5autop($pee, $br = 1) {
  976.    if ( trim($pee) === '' )
  977.       return '';
  978.    $pee = $pee . "\n"; // just to make things a little easier, pad the end
  979.    $pee = preg_replace('|<br />\s*<br />|', "\n\n", $pee);
  980.    // Space things out a little
  981. // *insertion* of section|article|aside|header|footer|hgroup|figure|details|figcaption|summary
  982.    $allblocks = '(?:table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|map|area|blockquote|address|math|style|input|p|h[1-6]|hr|fieldset|legend|section|article|aside|header|footer|hgroup|figure|details|figcaption|summary)';
  983.    $pee = preg_replace('!(<' . $allblocks . '[^>]*>)!', "\n$1", $pee);
  984.    $pee = preg_replace('!(</' . $allblocks . '>)!', "$1\n\n", $pee);
  985.    $pee = str_replace(array("\r\n", "\r"), "\n", $pee); // cross-platform newlines
  986.    if ( strpos($pee, '<object') !== false ) {
  987.       $pee = preg_replace('|\s*<param([^>]*)>\s*|', "<param$1>", $pee); // no pee inside object/embed
  988.       $pee = preg_replace('|\s*</embed>\s*|', '</embed>', $pee);
  989.    }
  990.    $pee = preg_replace("/\n\n+/", "\n\n", $pee); // take care of duplicates
  991.    // make paragraphs, including one at the end
  992.    $pees = preg_split('/\n\s*\n/', $pee, -1, PREG_SPLIT_NO_EMPTY);
  993.    $pee = '';
  994.    foreach ( $pees as $tinkle )
  995.       $pee .= '<p>' . trim($tinkle, "\n") . "</p>\n";
  996.    $pee = preg_replace('|<p>\s*</p>|', '', $pee); // under certain strange conditions it could create a P of entirely whitespace
  997. // *insertion* of section|article|aside
  998.    $pee = preg_replace('!<p>([^<]+)</(div|address|form|section|article|aside)>!', "<p>$1</p></$2>", $pee);
  999.    $pee = preg_replace('!<p>\s*(</?' . $allblocks . '[^>]*>)\s*</p>!', "$1", $pee); // don't pee all over a tag
  1000.    $pee = preg_replace("|<p>(<li.+?)</p>|", "$1", $pee); // problem with nested lists
  1001.    $pee = preg_replace('|<p><blockquote([^>]*)>|i', "<blockquote$1><p>", $pee);
  1002.    $pee = str_replace('</blockquote></p>', '</p></blockquote>', $pee);
  1003.    $pee = preg_replace('!<p>\s*(</?' . $allblocks . '[^>]*>)!', "$1", $pee);
  1004.    $pee = preg_replace('!(</?' . $allblocks . '[^>]*>)\s*</p>!', "$1", $pee);
  1005.    if ($br) {
  1006.       $pee = preg_replace_callback('/<(script|style).*?<\/\\1>/s', create_function('$matches', 'return str_replace("\n", "<WPPreserveNewline />", $matches[0]);'), $pee);
  1007.       $pee = preg_replace('|(?<!<br />)\s*\n|', "<br />\n", $pee); // optionally make line breaks
  1008.       $pee = str_replace('<WPPreserveNewline />', "\n", $pee);
  1009.    }
  1010.    $pee = preg_replace('!(</?' . $allblocks . '[^>]*>)\s*<br />!', "$1", $pee);
  1011. // *insertion* of img|figcaption|summary
  1012.    $pee = preg_replace('!<br />(\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol|img|figcaption|summary)[^>]*>)!', '$1', $pee);
  1013.    if (strpos($pee, '<pre') !== false)
  1014.       $pee = preg_replace_callback('!(<pre[^>]*>)(.*?)</pre>!is', 'clean_pre', $pee );
  1015.    $pee = preg_replace( "|\n</p>$|", '</p>', $pee );
  1016.    $pee = preg_replace( "|\]\[|", '] [', $pee );
  1017.  
  1018.    return $pee;
  1019. }
  1020.  
  1021.  
  1022. function my_shortcode($pee) {
  1023.  
  1024.    $pee = preg_replace( "| />|", '>', $pee );
  1025.    $pee = preg_replace( "|/>|", '>', $pee );
  1026.    $pee = preg_replace( "|<p><div|", '<div', ($pee) );
  1027.    $pee = preg_replace( "|div></p>|", 'div>', ($pee) );
  1028.    $pee = preg_replace( "|--></p>|", '-->', ($pee) );
  1029.    $pee = preg_replace( "|/li><br>|", '/li>', ($pee) );
  1030.    $pee = preg_replace( "|ul><br>|", 'ul>', ($pee) );
  1031.    $pee = preg_replace( "|</div><br>|", '</div>', ($pee) );
  1032.    $pee = preg_replace('!<p>\s*(</?' . $allblocks . '[^>]*>)!', "$1", ($pee));
  1033.    $pee = preg_replace('!(</?' . $allblocks . '[^>]*>)\s*</p>!', "$1", ($pee));
  1034.    $pee = preg_replace( "|--><br>|", '-->', ($pee) );
  1035.  
  1036.         return $pee;
  1037.  
  1038. }
  1039.  
  1040.  
  1041. // remove the original wpautop function
  1042. remove_filter('the_excerpt', 'wpautop');
  1043. remove_filter('the_content', 'wpautop');
  1044.  
  1045. // add our new html5autop function
  1046. add_filter('the_excerpt', 'html5autop');
  1047. add_filter('the_content', 'html5autop');
  1048.  
  1049.  
  1050. add_filter('the_content', 'my_shortcode', 100);
  1051.  
  1052. /*=========================================================================================*/
  1053.  
  1054. function extend_valid_html5($init) {
  1055.     // Standard attributes
  1056.     $atts = 'role|accesskey|class|contenteditable|contextmenu|dir|draggable|hidden|id|item|itemprop|lang|spellcheck|style|subject|tabindex|title';
  1057.     $html5Elements = array(
  1058.         'article[#|cite|pubdate]',
  1059.         'aside[#]',
  1060.         'audio[#]',
  1061.         'canvas[#]',
  1062.         'command[#]',
  1063.         'datalist[#]',
  1064.         'details[#]',
  1065.         'figure[#]',
  1066.         'figcaption[#]',
  1067.         'footer[#]',
  1068.         'header[#]',
  1069.         'hgroup[#]',
  1070.         'mark[#]',
  1071.         'meter[#]',
  1072.         'nav[#]',
  1073.         'output[#]',
  1074.         'progress[#]',
  1075.         'section[#]',
  1076.         'summary[#]',
  1077.         'time[#|datetime]',
  1078.         'video[#]'
  1079.     );
  1080.     if(!isset($init['extended_valid_elements'])) {
  1081.         $init['extended_valid_elements'] = '';
  1082.     }
  1083.     $init['extended_valid_elements'] .= str_replace('#',$atts,implode(',',$html5Elements));
  1084.     return $init;
  1085. }
  1086.  
  1087. add_filter('tiny_mce_before_init', 'extend_valid_html5');
  1088.  
  1089. /*=========================================================================================*/
  1090.  
  1091. function set_contenttype($content_type){
  1092.     return 'text/html';
  1093. }
  1094. add_filter('wp_mail_content_type','set_contenttype');
  1095.  
  1096. /*=========================================================================================*/
  1097.  
  1098. function hex2RGB($hexStr, $returnAsString = false, $seperator = ',') {
  1099.     $hexStr = preg_replace("/[^0-9A-Fa-f]/", '', $hexStr); // Gets a proper hex string
  1100.     $rgbArray = array();
  1101.     if (strlen($hexStr) == 6) { //If a proper hex code, convert using bitwise operation. No overhead... faster
  1102.         $colorVal = hexdec($hexStr);
  1103.         $rgbArray['red'] = 0xFF & ($colorVal >> 0x10);
  1104.         $rgbArray['green'] = 0xFF & ($colorVal >> 0x8);
  1105.         $rgbArray['blue'] = 0xFF & $colorVal;
  1106.     } elseif (strlen($hexStr) == 3) { //if shorthand notation, need some string manipulations
  1107.         $rgbArray['red'] = hexdec(str_repeat(substr($hexStr, 0, 1), 2));
  1108.         $rgbArray['green'] = hexdec(str_repeat(substr($hexStr, 1, 1), 2));
  1109.         $rgbArray['blue'] = hexdec(str_repeat(substr($hexStr, 2, 1), 2));
  1110.     } else {
  1111.         return false; //Invalid hex color code
  1112.     }
  1113.     return $returnAsString ? implode($seperator, $rgbArray) : $rgbArray; // returns the rgb string or the associative array
  1114. }
  1115.  
  1116. /*=========================================================================================*/
  1117.  
  1118. function opacHex($opacity){
  1119.     if($opacity=='0'){
  1120.         return '00';
  1121.     } elseif($opacity=='0.05'){
  1122.         return '0d';
  1123.     } elseif($opacity=='0.1' || $opacity=='0.10'){
  1124.         return '19';
  1125.     } elseif($opacity=='0.15'){
  1126.         return '26';
  1127.     } elseif($opacity=='0.2' || $opacity=='0.20'){
  1128.         return '32';
  1129.     } elseif($opacity=='0.25'){
  1130.         return '3f';
  1131.     } elseif($opacity=='0.3' || $opacity=='0.30'){
  1132.         return '4b';
  1133.     } elseif($opacity=='0.35'){
  1134.         return '58';
  1135.     } elseif($opacity=='0.4' || $opacity=='0.40'){
  1136.         return '64';
  1137.     } elseif($opacity=='0.45'){
  1138.         return '72';
  1139.     } elseif($opacity=='0.5' || $opacity=='0.50'){
  1140.         return '7d';
  1141.     } elseif($opacity=='0.55'){
  1142.         return '8b';
  1143.     } elseif($opacity=='0.6' || $opacity=='0.60'){
  1144.         return '96';
  1145.     } elseif($opacity=='0.65'){
  1146.         return 'a4';
  1147.     } elseif($opacity=='0.7' || $opacity=='0.70'){
  1148.         return 'af';
  1149.     } elseif($opacity=='0.75'){
  1150.         return 'bd';
  1151.     } elseif($opacity=='0.8' || $opacity=='0.80'){
  1152.         return 'c8';
  1153.     } elseif($opacity=='0.85'){
  1154.         return 'd7';
  1155.     } elseif($opacity=='0.9' || $opacity=='0.90'){
  1156.         return 'e3';
  1157.     } elseif($opacity=='0.95'){
  1158.         return 'f0';
  1159.     } elseif($opacity=='1'){
  1160.         return 'ff';
  1161.     }
  1162. }
  1163.  
  1164. /*=========================================================================================*/
  1165.  
  1166. function listFont($name, $name2, $label, $label2, $preview) {
  1167.     $out = '<label for="'.$name.'">'.$label.'</label>';
  1168.    
  1169.     $out .= '
  1170.                        <select id="'.$name.'" name="'.$name.'" class="font_select">
  1171.                            <optgroup label="Web safe">
  1172.                                <option value="Arial"'; if (get_pix_option($name) == 'Arial') { $out .= ' selected="selected"'; } $out .='>Arial</option>
  1173.                                <option value="Verdana"'; if (get_pix_option($name) == 'Verdana') { $out .= ' selected="selected"'; } $out .='>Verdana</option>
  1174.                                <option value="Georgia"'; if (get_pix_option($name) == 'Georgia') { $out .= ' selected="selected"'; } $out .='>Georgia</option>
  1175.                                <option value="Courier New"'; if (get_pix_option($name) == 'Courier New') { $out .= ' selected="selected"'; } $out .='>Courier New</option>
  1176.                                <option value="Tahoma"'; if (get_pix_option($name) == 'Tahoma') { $out .= ' selected="selected"'; } $out .='>Tahoma</option>
  1177.                                <option value="Trebuchet MS"'; if (get_pix_option($name) == 'Trebuchet MS') { $out .= ' selected="selected"'; } $out .='>Trebuchet</option>
  1178.                                <option value="Arial Black"'; if (get_pix_option($name) == 'Arial Black') { $out .= ' selected="selected"'; } $out .='>Arial Black</option>
  1179.                                <option value="Times New Roman"'; if (get_pix_option($name) == 'Times New Roman') { $out .= ' selected="selected"'; } $out .='>Times</option>
  1180.                                <option value="Palatino Linotype"'; if (get_pix_option($name) == 'Palatino Linotype') { $out .= ' selected="selected"'; } $out .='>Palatino Linotype</option>
  1181.                                <option value="Lucida Sans Unicode"'; if (get_pix_option($name) == 'Lucida Sans Unicode') { $out .= ' selected="selected"'; } $out .='>Lucida</option>
  1182.                                <option value="Comic Sans MS"'; if (get_pix_option($name) == 'Comic Sans MS') { $out .= ' selected="selected"'; } $out .='>Comic Sans MS</option>
  1183.                           </optgroup>
  1184.                            <optgroup label="Sans serif">
  1185.                                <option value="Allerta"'; if (get_pix_option($name) == 'Allerta') { $out .= ' selected="selected"'; } $out .='>Allerta</option>
  1186.                                <option value="Amaranth"'; if (get_pix_option($name) == 'Amaranth') { $out .= ' selected="selected"'; } $out .='>Amaranth</option>
  1187.                                <option value="Arimo"'; if (get_pix_option($name) == 'Arimo') { $out .= ' selected="selected"'; } $out .='>Arimo</option>
  1188.                                <option value="Bowlby One"'; if (get_pix_option($name) == 'Bowlby One') { $out .= ' selected="selected"'; } $out .='>Bowlby One</option>
  1189.                                <option value="Cabin"'; if (get_pix_option($name) == 'Cabin') { $out .= ' selected="selected"'; } $out .='>Cabin</option>
  1190.                                <option value="Candal"'; if (get_pix_option($name) == 'Candal') { $out .= ' selected="selected"'; } $out .='>Candal</option>
  1191.                                <option value="Cantarell"'; if (get_pix_option($name) == 'Cantarell') { $out .= ' selected="selected"'; } $out .='>Cantarell</option>
  1192.                                <option value="Carter One"'; if (get_pix_option($name) == 'Carter One') { $out .= ' selected="selected"'; } $out .='>Carter One</option>
  1193.                                <option value="Coda:800"'; if (get_pix_option($name) == 'Coda:800') { $out .= ' selected="selected"'; } $out .='>Coda</option>
  1194.                                <option value="Didact Gothic"'; if (get_pix_option($name) == 'Didact Gothic') { $out .= ' selected="selected"'; } $out .='>Didact Gothic</option>
  1195.                                <option value="Droid Sans"'; if (get_pix_option($name) == 'Droid Sans') { $out .= ' selected="selected"'; } $out .='>Droid Sans</option>
  1196.                                <option value="Expletus Sans"'; if (get_pix_option($name) == 'Expletus Sans') { $out .= ' selected="selected"'; } $out .='>Expletus Sans</option>
  1197.                                <option value="Francois One"'; if (get_pix_option($name) == 'Francois One') { $out .= ' selected="selected"'; } $out .='>Francois One</option>
  1198.                                <option value="Gruppo"'; if (get_pix_option($name) == 'Gruppo') { $out .= ' selected="selected"'; } $out .='>Gruppo</option>
  1199.                                <option value="Hammersmith One"'; if (get_pix_option($name) == 'Hammersmith One') { $out .= ' selected="selected"'; } $out .='>Hammersmith One</option>
  1200.                                <option value="Istok Web"'; if (get_pix_option($name) == 'Istok Web') { $out .= ' selected="selected"'; } $out .='>Istok Web</option>
  1201.                                <option value="Josefin Sans"'; if (get_pix_option($name) == 'Josefin Sans') { $out .= ' selected="selected"'; } $out .='>Josefin Sans</option>
  1202.                                <option value="Jura"'; if (get_pix_option($name) == 'Jura') { $out .= ' selected="selected"'; } $out .='>Jura</option>
  1203.                                <option value="Lato"'; if (get_pix_option($name) == 'Lato') { $out .= ' selected="selected"'; } $out .='>Lato</option>
  1204.                                <option value="Lekton"'; if (get_pix_option($name) == 'Lekton') { $out .= ' selected="selected"'; } $out .='>Lekton</option>
  1205.                                <option value="Limelight"'; if (get_pix_option($name) == 'Limelight') { $out .= ' selected="selected"'; } $out .='>Limelight</option>
  1206.                                <option value="Mako"'; if (get_pix_option($name) == 'Mako') { $out .= ' selected="selected"'; } $out .='>Mako</option>
  1207.                                <option value="Maven Pro"'; if (get_pix_option($name) == 'Maven Pro') { $out .= ' selected="selected"'; } $out .='>Maven Pro</option>
  1208.                                <option value="Michroma"'; if (get_pix_option($name) == 'Michroma') { $out .= ' selected="selected"'; } $out .='>Michroma</option>
  1209.                                <option value="Metrophobic"'; if (get_pix_option($name) == 'Metrophobic') { $out .= ' selected="selected"'; } $out .='>Metrophobic</option>
  1210.                                <option value="Molengo"'; if (get_pix_option($name) == 'Molengo') { $out .= ' selected="selected"'; } $out .='>Molengo</option>
  1211.                                <option value="Muli"'; if (get_pix_option($name) == 'Muli') { $out .= ' selected="selected"'; } $out .='>Muli</option>
  1212.                                <option value="News Cycle"'; if (get_pix_option($name) == 'News Cycle') { $out .= ' selected="selected"'; } $out .='>News Cycle</option>
  1213.                                <option value="Nova Flat"'; if (get_pix_option($name) == 'Nova Flat') { $out .= ' selected="selected"'; } $out .='>Nova Flat</option>
  1214.                                <option value="Nunito"'; if (get_pix_option($name) == 'Nunito') { $out .= ' selected="selected"'; } $out .='>Nunito</option>
  1215.                                <option value="Oswald"'; if (get_pix_option($name) == 'Oswald') { $out .= ' selected="selected"'; } $out .='>Oswald</option>
  1216.                                <option value="Play"'; if (get_pix_option($name) == 'Play') { $out .= ' selected="selected"'; } $out .='>Play</option>
  1217.                                <option value="Paytone One"'; if (get_pix_option($name) == 'Paytone One') { $out .= ' selected="selected"'; } $out .='>Paytone One</option>
  1218.                                <option value="PT Sans"'; if (get_pix_option($name) == 'PT Sans') { $out .= ' selected="selected"'; } $out .='>PT Sans</option>
  1219.                                <option value="Puritan"'; if (get_pix_option($name) == 'Puritan') { $out .= ' selected="selected"'; } $out .='>Puritan</option>
  1220.                                <option value="Raleway:100"'; if (get_pix_option($name) == 'Raleway:100') { $out .= ' selected="selected"'; } $out .='>Raleway</option>
  1221.                                <option value="Shanti"'; if (get_pix_option($name) == 'Shanti') { $out .= ' selected="selected"'; } $out .='>Shanti</option>
  1222.                                <option value="Tenor Sans"'; if (get_pix_option($name) == 'Tenor Sans') { $out .= ' selected="selected"'; } $out .='>Tenor Sans</option>
  1223.                                <option value="Terminal Dosis Light"'; if (get_pix_option($name) == 'Terminal Dosis Light') { $out .= ' selected="selected"'; } $out .='>Terminal Dosis Light</option>
  1224.                                <option value="Ubuntu"'; if (get_pix_option($name) == 'Ubuntu') { $out .= ' selected="selected"'; } $out .='>Ubuntu</option>
  1225.                                <option value="Varela"'; if (get_pix_option($name) == 'Varela') { $out .= ' selected="selected"'; } $out .='>Varela</option>
  1226.                                <option value="Varela Round"'; if (get_pix_option($name) == 'Varela Round') { $out .= ' selected="selected"'; } $out .='>Varela Round</option>
  1227.                                <option value="Wire One"'; if (get_pix_option($name) == 'Wire One') { $out .= ' selected="selected"'; } $out .='>Wire One</option>
  1228.                                <option value="Yanone Kaffeesatz"'; if (get_pix_option($name) == 'Yanone Kaffeesatz') { $out .= ' selected="selected"'; } $out .='>Yanone Kaffeesatz</option>
  1229.                            </optgroup>
  1230.                            <optgroup label="Serif">
  1231.                                <option value="Asset"'; if (get_pix_option($name) == 'Asset') { $out .= ' selected="selected"'; } $out .='>Asset</option>
  1232.                                <option value="Bentham"'; if (get_pix_option($name) == 'Bentham') { $out .= ' selected="selected"'; } $out .='>Bentham</option>
  1233.                                <option value="Bigshot One"'; if (get_pix_option($name) == 'Bigshot One') { $out .= ' selected="selected"'; } $out .='>Bigshot One</option>
  1234.                                <option value="Brawler"'; if (get_pix_option($name) == 'Brawler') { $out .= ' selected="selected"'; } $out .='>Brawler</option>
  1235.                                <option value="Buda:300"'; if (get_pix_option($name) == 'Buda:300') { $out .= ' selected="selected"'; } $out .='>Buda</option>
  1236.                                <option value="Cardo"'; if (get_pix_option($name) == 'Cardo') { $out .= ' selected="selected"'; } $out .='>Cardo</option>
  1237.                                <option value="Caudex"'; if (get_pix_option($name) == 'Caudex') { $out .= ' selected="selected"'; } $out .='>Caudex</option>
  1238.                                <option value="Corben:bold"'; if (get_pix_option($name) == 'Corben:bold') { $out .= ' selected="selected"'; } $out .='>Corben</option>
  1239.                                <option value="Crimson Text"'; if (get_pix_option($name) == 'Crimson Text') { $out .= ' selected="selected"'; } $out .='>Crimson Text</option>
  1240.                                <option value="Droid Serif"'; if (get_pix_option($name) == 'Droid Serif') { $out .= ' selected="selected"'; } $out .='>Droid Serif</option>
  1241.                                <option value="EB Garamond"'; if (get_pix_option($name) == 'EB Garamond') { $out .= ' selected="selected"'; } $out .='>EB Garamond</option>
  1242.                                <option value="Forum"'; if (get_pix_option($name) == 'Forum') { $out .= ' selected="selected"'; } $out .='>Forum</option>
  1243.                                <option value="Gravitas One"'; if (get_pix_option($name) == 'Gravitas One') { $out .= ' selected="selected"'; } $out .='>Gravitas One</option>
  1244.                                <option value="Goblin One"'; if (get_pix_option($name) == 'Goblin One') { $out .= ' selected="selected"'; } $out .='>Goblin One</option>
  1245.                                <option value="IM Fell DW Pica"'; if (get_pix_option($name) == 'IM Fell DW Pica') { $out .= ' selected="selected"'; } $out .='>IM Fell</option>
  1246.                                <option value="Judson"'; if (get_pix_option($name) == 'Judson') { $out .= ' selected="selected"'; } $out .='>Judson</option>
  1247.                                <option value="Merriweather"'; if (get_pix_option($name) == 'Merriweather') { $out .= ' selected="selected"'; } $out .='>Merriweather</option>
  1248.                                <option value="Modern Antiqua"'; if (get_pix_option($name) == 'Modern Antiqua') { $out .= ' selected="selected"'; } $out .='>Modern Antiqua</option>
  1249.                                <option value="Neuton"'; if (get_pix_option($name) == 'Neuton') { $out .= ' selected="selected"'; } $out .='>Neuton</option>
  1250.                                <option value="OFL Sorts Mill Goudy TT"'; if (get_pix_option($name) == 'OFL Sorts Mill Goudy TT') { $out .= ' selected="selected"'; } $out .='>OFL Sorts Mill Goudy TT</option>
  1251.                                <option value="Old Standard TT"'; if (get_pix_option($name) == 'Old Standard TT') { $out .= ' selected="selected"'; } $out .='>Old Standard TT</option>
  1252.                                <option value="Playfair Display"'; if (get_pix_option($name) == 'Playfair Display') { $out .= ' selected="selected"'; } $out .='>Playfair Display</option>
  1253.                                <option value="Philosopher"'; if (get_pix_option($name) == 'Philosopher') { $out .= ' selected="selected"'; } $out .='>Philosopher</option>
  1254.                                <option value="PT Serif"'; if (get_pix_option($name) == 'PT Serif') { $out .= ' selected="selected"'; } $out .='>PT Serif</option>
  1255.                                <option value="Quattrocento"'; if (get_pix_option($name) == 'Quattrocento') { $out .= ' selected="selected"'; } $out .='>Quattrocento</option>
  1256.                                <option value="Radley"'; if (get_pix_option($name) == 'Radley') { $out .= ' selected="selected"'; } $out .='>Radley</option>
  1257.                                <option value="Stardos Stencil"'; if (get_pix_option($name) == 'Stardos Stencil') { $out .= ' selected="selected"'; } $out .='>Stardos Stencil</option>
  1258.                                <option value="Tinos"'; if (get_pix_option($name) == 'Tinos') { $out .= ' selected="selected"'; } $out .='>Tinos</option>
  1259.                                <option value="Ultra"'; if (get_pix_option($name) == 'Ultra') { $out .= ' selected="selected"'; } $out .='>Ultra</option>
  1260.                                <option value="Vollkorn"'; if (get_pix_option($name) == 'Vollkorn') { $out .= ' selected="selected"'; } $out .='>Vollkorn</option>
  1261.                                <option value="Yeseva One"'; if (get_pix_option($name) == 'Yeseva One') { $out .= ' selected="selected"'; } $out .='>Yeseva One</option>
  1262.                            </optgroup>
  1263.                            <optgroup label="Slab">
  1264.                                <option value="Anton"'; if (get_pix_option($name) == 'Anton') { $out .= ' selected="selected"'; } $out .='>Anton</option>
  1265.                                <option value="Arvo"'; if (get_pix_option($name) == 'Arvo') { $out .= ' selected="selected"'; } $out .='>Arvo</option>
  1266.                                <option value="Holtwood One SC"'; if (get_pix_option($name) == 'Holtwood One SC') { $out .= ' selected="selected"'; } $out .='>Holtwood One SC</option>
  1267.                                <option value="Josefin Slab"'; if (get_pix_option($name) == 'Josefin Slab') { $out .= ' selected="selected"'; } $out .='>Josefin Slab</option>
  1268.                                <option value="Kreon"'; if (get_pix_option($name) == 'Kreon') { $out .= ' selected="selected"'; } $out .='>Kreon</option>
  1269.                                <option value="Podkova"'; if (get_pix_option($name) == 'Podkova') { $out .= ' selected="selected"'; } $out .='>Podkova</option>
  1270.                                <option value="Rokkitt"'; if (get_pix_option($name) == 'Rokkitt') { $out .= ' selected="selected"'; } $out .='>Rokkitt</option>
  1271.                            </optgroup>
  1272.                            <optgroup label="Script">
  1273.                                <option value="Annie Use Your Telescope"'; if (get_pix_option($name) == 'Annie Use Your Telescope') { $out .= ' selected="selected"'; } $out .='>Annie Use Your Telescope</option>
  1274.                                <option value="Architects Daughter"'; if (get_pix_option($name) == 'Architects Daughter') { $out .= ' selected="selected"'; } $out .='>Architects Daughter</option>
  1275.                                <option value="Calligraffitti"'; if (get_pix_option($name) == 'Calligraffitti') { $out .= ' selected="selected"'; } $out .='>Calligraffitti</option>
  1276.                                <option value="Damion"'; if (get_pix_option($name) == 'Damion') { $out .= ' selected="selected"'; } $out .='>Damion</option>
  1277.                                <option value="Dancing Script"'; if (get_pix_option($name) == 'Dancing Script') { $out .= ' selected="selected"'; } $out .='>Dancing Script</option>
  1278.                                <option value="Homemade Apple"'; if (get_pix_option($name) == 'Homemade Apple') { $out .= ' selected="selected"'; } $out .='>Homemade Apple</option>
  1279.                                <option value="Kristi"'; if (get_pix_option($name) == 'Kristi') { $out .= ' selected="selected"'; } $out .='>Kristi</option>
  1280.                                <option value="Indie Flower"'; if (get_pix_option($name) == 'Indie Flower') { $out .= ' selected="selected"'; } $out .='>Indie Flower</option>
  1281.                                <option value="Lobster"'; if (get_pix_option($name) == 'Lobster') { $out .= ' selected="selected"'; } $out .='>Lobster</option>
  1282.                                <option value="Lobster Two"'; if (get_pix_option($name) == 'Lobster Two') { $out .= ' selected="selected"'; } $out .='>Lobster Two</option>
  1283.                                <option value="Meddon"'; if (get_pix_option($name) == 'Meddon') { $out .= ' selected="selected"'; } $out .='>Meddon</option>
  1284.                                <option value="Over the Rainbow"'; if (get_pix_option($name) == 'Over the Rainbow') { $out .= ' selected="selected"'; } $out .='>Over the Rainbow</option>
  1285.                                <option value="Pacifico"'; if (get_pix_option($name) == 'Pacifico') { $out .= ' selected="selected"'; } $out .='>Pacifico</option>
  1286.                                <option value="Redressed"'; if (get_pix_option($name) == 'Redressed') { $out .= ' selected="selected"'; } $out .='>Redressed</option>
  1287.                                <option value="Swanky and Moo Moo"'; if (get_pix_option($name) == 'Swanky and Moo Moo') { $out .= ' selected="selected"'; } $out .='>Swanky and Moo Moo</option>
  1288.                                <option value="Tangerine"'; if (get_pix_option($name) == 'Tangerine') { $out .= ' selected="selected"'; } $out .='>Tangerine</option>
  1289.                                <option value="The Girl Next Door"'; if (get_pix_option($name) == 'The Girl Next Door') { $out .= ' selected="selected"'; } $out .='>The Girl Next Door</option>
  1290.                                <option value="Vibur"'; if (get_pix_option($name) == 'Vibur') { $out .= ' selected="selected"'; } $out .='>Vibur</option>
  1291.                            </optgroup>
  1292.                            <optgroup label="Monospaced">
  1293.                                <option value="Anonymous Pro"'; if (get_pix_option($name) == 'Anonymous Pro') { $out .= ' selected="selected"'; } $out .='>Anonymous Pro</option>
  1294.                                <option value="Cousine"'; if (get_pix_option($name) == 'Cousine') { $out .= ' selected="selected"'; } $out .='>Cousine</option>
  1295.                                <option value="Droid Sans Mono"'; if (get_pix_option($name) == 'Droid Sans Mono') { $out .= ' selected="selected"'; } $out .='>Droid Sans Mono</option>
  1296.                                <option value="Inconsolata"'; if (get_pix_option($name) == 'Inconsolata') { $out .= ' selected="selected"'; } $out .='>Inconsolata</option>
  1297.                                <option value="VT323"'; if (get_pix_option($name) == 'VT323') { $out .= ' selected="selected"'; } $out .='>VT323</option>
  1298.                            </optgroup>
  1299.                            <optgroup label="Square">
  1300.                                <option value="Geo"'; if (get_pix_option($name) == 'Geo') { $out .= ' selected="selected"'; } $out .='>Geo</option>
  1301.                                <option value="Orbitron"'; if (get_pix_option($name) == 'Orbitron') { $out .= ' selected="selected"'; } $out .='>Orbitron</option>
  1302.                            </optgroup>
  1303.                            <optgroup label="Comic">
  1304.                                <option value="Coming Soon"'; if (get_pix_option($name) == 'Coming Soon') { $out .= ' selected="selected"'; } $out .='>Coming Soon</option>
  1305.                                <option value="Chewy"'; if (get_pix_option($name) == 'Chewy') { $out .= ' selected="selected"'; } $out .='>Chewy</option>
  1306.                                <option value="Luckiest Guy"'; if (get_pix_option($name) == 'Luckiest Guy') { $out .= ' selected="selected"'; } $out .='>Luckiest Guy</option>
  1307.                                <option value="Neucha"'; if (get_pix_option($name) == 'Neucha') { $out .= ' selected="selected"'; } $out .='>Neucha</option>
  1308.                                <option value="Sunshiney"'; if (get_pix_option($name) == 'Sunshiney') { $out .= ' selected="selected"'; } $out .='>Sunshiney</option>
  1309.                                <option value="Walter Turncoat"'; if (get_pix_option($name) == 'Walter Turncoat') { $out .= ' selected="selected"'; } $out .='>Walter Turncoat</option>
  1310.                            </optgroup>
  1311.                            <optgroup label="Hand writing">
  1312.                                <option value="Crafty Girls"'; if (get_pix_option($name) == 'Crafty Girls') { $out .= ' selected="selected"'; } $out .='>Crafty Girls</option>
  1313.                                <option value="Just Another Hand"'; if (get_pix_option($name) == 'Just Another Hand') { $out .= ' selected="selected"'; } $out .='>Just Another Hand</option>
  1314.                                <option value="Just Me Again Down Here"'; if (get_pix_option($name) == 'Just Me Again Down Here') { $out .= ' selected="selected"'; } $out .='>Just Me Again Down Here</option>
  1315.                                <option value="Patrick Hand"'; if (get_pix_option($name) == 'Patrick Hand') { $out .= ' selected="selected"'; } $out .='>Patrick Hand</option>
  1316.                                <option value="Reenie Beanie"'; if (get_pix_option($name) == 'Reenie Beanie') { $out .= ' selected="selected"'; } $out .='>Reenie Beanie</option>
  1317.                                <option value="Schoolbell"'; if (get_pix_option($name) == 'Schoolbell') { $out .= ' selected="selected"'; } $out .='>Schoolbell</option>
  1318.                            </optgroup>
  1319.                        </select>
  1320.                        
  1321.                         ';
  1322.    
  1323.     $out .= '<label for="'.$name2.'">'.$label2.'</label>
  1324.             <input name="'.$name2.'" class="font_your_own" type="text" value="'.get_pix_option($name2).'">
  1325.                        
  1326.             <input type="text" class="preview_font" value="'. $preview.'" />';
  1327.     echo $out;
  1328. }  
  1329.  
  1330. /*=========================================================================================*/
  1331.  
  1332. function findCoords ($str) {
  1333.     $str = str_replace('(', '', $str);
  1334.     $str = str_replace(')', '', $str);
  1335.     $str = explode(",", $str);
  1336.     return $str;
  1337. }
  1338.  
  1339. /*=========================================================================================*/
  1340.  
  1341. function getTheWideVideo($video,$start,$loop) {
  1342.     if(detectMobile()){
  1343.         return '<video id="wide_flash" class="projekktor" data-position="fixed" data-top="0" data-bottom="not" data-height="100" controls>
  1344.             <source src="'.remove_something('.flv',$video).'.ogg" type="video/ogg">
  1345.             <source src="'.remove_something('.flv',$video).'.mp4" type="video/mp4">
  1346.             <source src="'.remove_something('.flv',$video).'.webm" type="video/mp4">
  1347.         </video>';
  1348.        
  1349.        
  1350.         $out .= '<script type="text/javascript">
  1351.         jQuery(window).one("load",function() {
  1352.             projekktor("#wide_flash");
  1353.         });
  1354.         </script>';
  1355.     } else {
  1356.         if($start==''){
  1357.             $start = 'false';
  1358.         } elseif($start=='auto'){
  1359.             $start = 'true';
  1360.         }
  1361.    
  1362.         if($loop==''){
  1363.             $loop = 'false';
  1364.         } elseif($loop=='loop'){
  1365.             $loop = 'true';
  1366.         }
  1367.         $wmode;
  1368.         $os = strtolower($_SERVER['HTTP_USER_AGENT']);
  1369.        
  1370.         if (strpos($os,'chrome')!==false||strpos($os,'msie')!==false||strpos($os,'linux')!==false||(strpos($os,'windows')!==false && strpos($os,'safari')!==false)) {
  1371.             $wmode = 'wmode:"opaque",';
  1372.         } elseif ((strpos($os,'windows')!==false && strpos($os,'mozilla/5')!==false)) {
  1373.             $wmode = 'wmode:"transparent",';
  1374.         }
  1375.        
  1376.         return '<script type="text/javascript">
  1377.      
  1378.             var flashvars = {fileSource:"'.$video.'",fileStart:"'.$start.'",fileLoop:"'.$loop.'"};
  1379.             var params = {'.$wmode.'scale:"noscale",allowfullscreen:"true",allowscriptaccess:"always",salign:"tl"};
  1380.             var attributes = {id: "wide_flash"};
  1381.              
  1382.             swfobject.embedSWF("'. get_bloginfo( 'stylesheet_directory' ) .'/scripts/fullbg.swf", "wide_flash", "100%", "100%", "10.0.0","'.get_bloginfo( 'stylesheet_directory' ).'/scripts/expressInstall.swf", flashvars, params, attributes);
  1383.            
  1384.             jQuery(window).one("load",function(){
  1385.                 if(jQuery("#pix_credits_pictures").length!=0){
  1386.                     jQuery("#pix_credits_pictures").html("'.$credits.'");
  1387.                 }
  1388.             });
  1389.    
  1390.              
  1391.             </script>
  1392.             <div class="pix_overlay_pattern"></div>';
  1393.     }
  1394. }
  1395.  
  1396. /*=========================================================================================*/
  1397.  
  1398. add_filter( 'pre_get_posts', 'number_of_posts' );
  1399. function number_of_posts( $wp_query = '' ) {
  1400.     remove_filter( 'pre_get_posts', 'number_of_posts' );
  1401.     global $wp_query;
  1402.     $query_obj = $wp_query->get_queried_object();
  1403.     global $wpdb;
  1404.        
  1405.         if ( $wp_query->is_tax ) {
  1406.             $term_id = $query_obj->term_id;
  1407.             $wp_query->query_vars['posts_per_page'] = get_pix_option('pix_array_term_ppp_'.$term_id);
  1408.         }
  1409.  
  1410.         if ( $wp_query->is_home ) {
  1411.             if(get_pix_option('pix_frontpage_galleries_ppp')!=''){         
  1412.                 $wp_query->query_vars['posts_per_page'] = get_pix_option('pix_frontpage_galleries_ppp');
  1413.             }
  1414.         }
  1415.  
  1416.     return $wp_query;
  1417. }
  1418.  
  1419. /*=========================================================================================*/
  1420.  
  1421. function getTinyUrl($url) {
  1422.     $tinyurl = get_content("http://tinyurl.com/api-create.php?url=".$url);
  1423.     return $tinyurl;
  1424. }
  1425.  
  1426. /*=========================================================================================*/
  1427.  
  1428. function splitFont($str, $str2) {
  1429.     if($str2!=''){
  1430.         $str = $str2;
  1431.     }
  1432.     if (strpos($str,':')==true){
  1433.         $str = explode(':', $str);
  1434.         return $str[0];
  1435.     } else {
  1436.         return $str;
  1437.     }
  1438. }
  1439.  
  1440. /*=========================================================================================*/
  1441.  
  1442. function delight_comments_on($text) {
  1443.     if(get_pix_option('pix_postmetadata_comments')!='0') {
  1444.         return '<span>|&nbsp;<a href="'.get_comments_link().'">'.$text.'</a></span>';
  1445.     }
  1446. }
  1447.  
  1448. /*=========================================================================================*/
  1449.  
  1450. function delight_posted_on() {
  1451.     $numb = number_format_i18n( get_comments_number() );
  1452.     if($numb == 0) {
  1453.         $get_comm = __( '0 comments', 'delight' );
  1454.     } elseif ($numb == 1) {
  1455.         $get_comm = __( '1 comment', 'delight' );
  1456.     } else {
  1457.         $get_comm = __( $numb.' comments', 'delight' );
  1458.     }
  1459.     printf( __( '<span>|&nbsp;Posted by %1$s in %2$s</span>'.delight_comments_on('%3$s'), 'delight' ),
  1460.         sprintf( '<a href="%1$s" title="%2$s">%3$s</a>',
  1461.             get_author_posts_url( get_the_author_meta( 'ID' ) ),
  1462.             sprintf( esc_attr__( 'View all posts by %s', 'delight' ), get_the_author() ),
  1463.             get_the_author()
  1464.         ),
  1465.         my_category_list( ', ' ),
  1466.         $get_comm
  1467.     );
  1468. }
  1469.  
  1470. /*=========================================================================================*/
  1471.  
  1472. function get_pix_option($record) {
  1473.     global $current_user;
  1474.  
  1475.     get_currentuserinfo();
  1476.    
  1477.     if ($current_user->display_name == 'pix_test' || $current_user->display_name == 'manu_test') {
  1478.         if($_SESSION[$record]=='') {
  1479.             $_SESSION[$record]=get_option($record);
  1480.         }
  1481.         return $_SESSION[$record];
  1482.     } else {
  1483.         return get_option($record);
  1484.     }
  1485. }
  1486.  
  1487. /*=========================================================================================*/
  1488.  
  1489. add_filter('img_caption_shortcode', 'my_img_caption_shortcode_filter',10,3);
  1490.  
  1491. function my_img_caption_shortcode_filter($val, $attr, $content = null)
  1492. {
  1493.     extract(shortcode_atts(array(
  1494.         'id'    => '',
  1495.         'align' => '',
  1496.         'width' => '',
  1497.         'caption' => ''
  1498.     ), $attr));
  1499.    
  1500.     if ( 1 > (int) $width || empty($caption) )
  1501.         return $val;
  1502.  
  1503.     $capid = '';
  1504.     if ( $id ) {
  1505.         $id = esc_attr($id);
  1506.         $capid = 'id="figcaption_'. $id . '" ';
  1507.         $id = 'id="' . $id . '" aria-labelledby="figcaption_' . $id . '" ';
  1508.     }
  1509.  
  1510.     return '<figure ' . $id . 'class="wp-caption ' . esc_attr($align) . '" style="width: '
  1511.     . (2 + (int) $width) . 'px">' . do_shortcode( $content ) . '<figcaption ' . $capid
  1512.     . 'class="wp-caption-text">' . $caption . '</figcaption></figure>';
  1513. }
  1514.  
  1515. /*=========================================================================================*/
  1516.  
  1517. function my_category_list( $separator = '', $parents='', $post_id = false ) {
  1518.  
  1519.     global $wp_rewrite;
  1520.  
  1521.     $categories = get_the_category( $post_id );
  1522.  
  1523.     if ( !is_object_in_taxonomy( get_post_type( $post_id ), 'category' ) )
  1524.  
  1525.         return apply_filters( 'the_category', '', $separator, $parents );
  1526.  
  1527.     if ( empty( $categories ) )
  1528.  
  1529.         return apply_filters( 'the_category', __( 'Uncategorized' ), $separator, $parents );
  1530.  
  1531.     $rel = ( is_object( $wp_rewrite ) && $wp_rewrite->using_permalinks() ) ? 'data-rel="category tag"' : 'data-rel="category"';
  1532.  
  1533.     $thelist = '';
  1534.  
  1535.     if ( '' == $separator ) {
  1536.  
  1537.         $thelist .= '<ul class="post-categories">';
  1538.  
  1539.         foreach ( $categories as $category ) {
  1540.  
  1541.             $thelist .= "\n\t<li>";
  1542.  
  1543.             switch ( strtolower( $parents ) ) {
  1544.  
  1545.                 case 'multiple':
  1546.  
  1547.                     if ( $category->parent )
  1548.  
  1549.                         $thelist .= get_category_parents( $category->parent, true, $separator );
  1550.  
  1551.                     $thelist .= '<a href="' . get_category_link( $category->term_id ) . '" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $category->name ) ) . '" ' . $rel . '>' . $category->name.'</a></li>';
  1552.  
  1553.                     break;
  1554.  
  1555.                 case 'single':
  1556.  
  1557.                     $thelist .= '<a href="' . get_category_link( $category->term_id ) . '" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $category->name ) ) . '" ' . $rel . '>';
  1558.  
  1559.                     if ( $category->parent )
  1560.  
  1561.                         $thelist .= get_category_parents( $category->parent, false, $separator );
  1562.  
  1563.                     $thelist .= $category->name.'</a></li>';
  1564.  
  1565.                     break;
  1566.  
  1567.                 case '':
  1568.  
  1569.                 default:
  1570.  
  1571.                     $thelist .= '<a href="' . get_category_link( $category->term_id ) . '" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $category->name ) ) . '" ' . $rel . '>' . $category->name.'</a></li>';
  1572.  
  1573.             }
  1574.  
  1575.         }
  1576.  
  1577.         $thelist .= '</ul>';
  1578.  
  1579.     } else {
  1580.  
  1581.         $i = 0;
  1582.  
  1583.         foreach ( $categories as $category ) {
  1584.  
  1585.             if ( 0 < $i )
  1586.  
  1587.                 $thelist .= $separator;
  1588.  
  1589.             switch ( strtolower( $parents ) ) {
  1590.  
  1591.                 case 'multiple':
  1592.  
  1593.                     if ( $category->parent )
  1594.  
  1595.                         $thelist .= get_category_parents( $category->parent, true, $separator );
  1596.  
  1597.                     $thelist .= '<a href="' . get_category_link( $category->term_id ) . '" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $category->name ) ) . '" ' . $rel . '>' . $category->name.'</a>';
  1598.  
  1599.                     break;
  1600.  
  1601.                 case 'single':
  1602.  
  1603.                     $thelist .= '<a href="' . get_category_link( $category->term_id ) . '" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $category->name ) ) . '" ' . $rel . '>';
  1604.  
  1605.                     if ( $category->parent )
  1606.  
  1607.                         $thelist .= get_category_parents( $category->parent, false, $separator );
  1608.  
  1609.                     $thelist .= "$category->name</a>";
  1610.  
  1611.                     break;
  1612.  
  1613.                 case '':
  1614.  
  1615.                 default:
  1616.  
  1617.                     $thelist .= '<a href="' . get_category_link( $category->term_id ) . '" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $category->name ) ) . '" ' . $rel . '>' . $category->name.'</a>';
  1618.  
  1619.             }
  1620.  
  1621.             ++$i;
  1622.  
  1623.         }
  1624.  
  1625.     }
  1626.  
  1627.     return apply_filters( 'the_category', $thelist, $separator, $parents );
  1628.  
  1629. }
  1630.  
  1631. /*=========================================================================================*/
  1632.  
  1633. function add_video_wmode_transparent($html, $url, $attr) {
  1634.    if (strpos($html, "<embed src=" ) !== false) {
  1635.         $html = str_replace('</param><embed', '</param><param name="wmode" value="transparent"></param><embed wmode="transparent" ', $html);
  1636.         return $html;
  1637.    } else {
  1638.         return $html;
  1639.    }
  1640. }
  1641. add_filter('embed_oembed_html', 'add_video_wmode_transparent', 10, 3);
  1642.  
  1643. /*=========================================================================================*/
  1644.  
  1645. remove_action( 'wp_head', 'feed_links_extra', 3 );
  1646. remove_action( 'wp_head', 'feed_links', 2 );
  1647. remove_action( 'wp_head', 'rsd_link' );
  1648. remove_action( 'wp_head', 'wlwmanifest_link' );
  1649. remove_action( 'wp_head', 'index_rel_link' );
  1650. remove_action( 'wp_head', 'parent_post_rel_link', 10, 0 );
  1651. remove_action( 'wp_head', 'start_post_rel_link', 10, 0 );
  1652. remove_action( 'wp_head', 'adjacent_posts_rel_link', 10, 0 );
  1653. remove_action( 'wp_head', 'wp_generator' );
  1654. remove_action( 'wp_head', 'rel_canonical' );
  1655. remove_action( 'wp_head', 'rel_canonical' );
  1656.  
  1657. /*=========================================================================================*/
  1658.  
  1659. function detectMobile(){
  1660.     $mobile_browser = '0';
  1661.      
  1662.     if (preg_match('/(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone|android|pad)/i', strtolower($_SERVER['HTTP_USER_AGENT']))) {
  1663.         $mobile_browser++;
  1664.     }
  1665.      
  1666.     if ((strpos(strtolower($_SERVER['HTTP_ACCEPT']),'application/vnd.wap.xhtml+xml') > 0) or ((isset($_SERVER['HTTP_X_WAP_PROFILE']) or isset($_SERVER['HTTP_PROFILE'])))) {
  1667.         $mobile_browser++;
  1668.     }    
  1669.      
  1670.     $mobile_ua = strtolower(substr($_SERVER['HTTP_USER_AGENT'], 0, 4));
  1671.     $mobile_agents = array(
  1672.         'w3c ','acs-','alav','alca','amoi','audi','avan','benq','bird','blac',
  1673.         'blaz','brew','cell','cldc','cmd-','dang','doco','eric','hipt','inno',
  1674.         'ipaq','java','jigs','kddi','keji','leno','lg-c','lg-d','lg-g','lge-',
  1675.         'maui','maxo','midp','mits','mmef','mobi','mot-','moto','mwbp','nec-',
  1676.         'newt','noki','palm','pana','pant','phil','play','port','prox',
  1677.         'qwap','sage','sams','sany','sch-','sec-','send','seri','sgh-','shar',
  1678.         'sie-','siem','smal','smar','sony','sph-','symb','t-mo','teli','tim-',
  1679.         'tosh','tsm-','upg1','upsi','vk-v','voda','wap-','wapa','wapi','wapp',
  1680.         'wapr','webc','winw','winw','xda ','xda-');
  1681.      
  1682.     if (in_array($mobile_ua,$mobile_agents)) {
  1683.         $mobile_browser++;
  1684.     }
  1685.      
  1686.     if (strpos(strtolower($_SERVER['ALL_HTTP']),'OperaMini') > 0) {
  1687.         $mobile_browser++;
  1688.     }
  1689.      
  1690.     if (strpos(strtolower($_SERVER['HTTP_USER_AGENT']),'windows') > 0) {
  1691.         $mobile_browser = 0;
  1692.     }
  1693.      
  1694.     if ($mobile_browser > 0) {
  1695.        return true;
  1696.     }
  1697. }
  1698.  
  1699. function detectIOS(){
  1700.     $ios5 = '0';
  1701.     if (preg_match('/(os 5_0)/i', strtolower($_SERVER['HTTP_USER_AGENT']))) {
  1702.         $ios5++;
  1703.     }
  1704.      
  1705.     if ($ios5 > 0) {
  1706.        return true;
  1707.     }
  1708. }
  1709.  
  1710. /*=========================================================================================*/
  1711.  
  1712. function dontChangePw(){
  1713.     global $current_user, $page;
  1714.  
  1715.     get_currentuserinfo();
  1716.     if ('admin.php' != basename($_SERVER['SCRIPT_NAME']) && ($current_user->display_name == 'pix_test' || $current_user->display_name == 'manu_test') )
  1717.     wp_die(__('<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US">
  1718. <head>
  1719.     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  1720.     <title>WordPress &rsaquo; Error</title>
  1721.     <link rel="stylesheet" href="http://www.pixedelic.com/themes/delight/wp-admin/css/install.css" type="text/css" />
  1722. </head>
  1723. <body id="error-page" style="height:auto">
  1724.     <p>You do not have sufficient permissions to access this page.</p>
  1725. </body>
  1726. </html> '));
  1727. }
  1728.  
  1729.  
  1730. add_action('admin_head', 'dontChangePw');
  1731.  
  1732. /*=========================================================================================*/
  1733.  
  1734. add_filter('the_posts', 'pix_enq_accordion');
  1735. function pix_enq_accordion($posts){
  1736.     if ( empty($posts) ) return $posts;
  1737.  
  1738.     $shortcode_found = false;
  1739.     foreach ( $posts as $post ){
  1740.         if ( stripos($post->post_content, 'pix_accordion') ){
  1741.             $shortcode_found = true;
  1742.             break;
  1743.         }
  1744.     }
  1745.  
  1746.     if ( $shortcode_found ){
  1747.         wp_enqueue_script("jquery-ui-core");
  1748.         wp_enqueue_script("ui-widget", get_bloginfo( 'stylesheet_directory' )."/scripts/jquery.ui.widget.js", array('jquery-ui-core'));
  1749.         wp_enqueue_script("ui-accordion", get_bloginfo( 'stylesheet_directory' )."/scripts/jquery.ui.accordion.js", array('ui-widget'));
  1750.     }
  1751.  
  1752.     return $posts;
  1753. }
  1754.  
  1755. /*=========================================================================================*/
  1756.  
  1757. add_filter('the_posts', 'pix_enq_tabs');
  1758. function pix_enq_tabs($posts){
  1759.     if ( empty($posts) ) return $posts;
  1760.  
  1761.     $shortcode_found = false;
  1762.     foreach ( $posts as $post ){
  1763.         if ( stripos($post->post_content, 'pix_tabs') ){
  1764.             $shortcode_found = true;
  1765.             break;
  1766.         }
  1767.     }
  1768.  
  1769.     if ( $shortcode_found ){
  1770.         wp_enqueue_script("jquery-ui-core");
  1771.         wp_enqueue_script("ui-widget", get_bloginfo( 'stylesheet_directory' )."/scripts/jquery.ui.widget.js", array('jquery-ui-core'));
  1772.         wp_enqueue_script("ui-tabs", get_bloginfo( 'stylesheet_directory' )."/scripts/jquery.ui.tabs.js", array('ui-widget'));
  1773.     }
  1774.  
  1775.     return $posts;
  1776. }
  1777.  
  1778. /*=========================================================================================*/
  1779.  
  1780. add_filter('the_posts', 'pix_enq_datePicker');
  1781. function pix_enq_datePicker($posts){
  1782.     global $print_datepicker;
  1783.     if ( empty($posts) ) return $posts;
  1784.  
  1785.     foreach ( $posts as $post ){
  1786.         if ( stripos($post->post_content, 'pix_period') ){
  1787.             $print_datepicker = true;
  1788.             break;
  1789.         }
  1790.     }
  1791.  
  1792.     return $posts;
  1793. }
  1794.  
  1795. /*=========================================================================================*/
  1796.  
  1797. add_filter('the_posts', 'pix_enq_cycle');
  1798. function pix_enq_cycle($posts){
  1799.     if ( empty($posts) ) return $posts;
  1800.  
  1801.     $shortcode_found = false;
  1802.     foreach ( $posts as $post ){
  1803.         if ( stripos($post->post_content, 'slideshow') ){
  1804.             $shortcode_found = true;
  1805.             break;
  1806.         }
  1807.     }
  1808.  
  1809.     if ( $shortcode_found ){
  1810.         wp_enqueue_script("cycle", get_bloginfo( 'stylesheet_directory' )."/scripts/jquery.cycle.all.min.js", array('jquery'));
  1811.     }
  1812.  
  1813.     return $posts;
  1814. }
  1815.  
  1816. /*=========================================================================================*/
  1817.  
  1818. add_action('init', 'register_pix_datepciker');
  1819. add_action('wp_footer', 'print_pix_datepicker');
  1820.  
  1821. function register_pix_datepciker() {
  1822.         wp_register_script("ui-widget", get_bloginfo( 'stylesheet_directory' )."/scripts/jquery.ui.widget.js", array('jquery-ui-core'));
  1823.         wp_register_script("ui-datepicker", get_bloginfo( 'stylesheet_directory' )."/scripts/jquery.ui.datepicker.js", array('ui-widget'));
  1824. }
  1825.  
  1826. function print_pix_datepicker() {
  1827.     global $print_datepicker;
  1828.     if (!$print_datepicker) return;
  1829.         wp_print_scripts("jquery-ui-core");
  1830.         wp_print_scripts("ui-widget");
  1831.         wp_print_scripts("ui-datepicker");
  1832. }
  1833.  
  1834. /*=========================================================================================*/
  1835.  
  1836. add_action('init', 'register_pix_isotope');
  1837. add_action('wp_footer', 'print_pix_isotope');
  1838.  
  1839. function register_pix_isotope() {
  1840.         wp_register_script("isotope", get_bloginfo( 'stylesheet_directory' )."/scripts/jquery.isotope.min.js", array('jquery'));
  1841. }
  1842.  
  1843. function print_pix_isotope() {
  1844.     global $print_isotope;
  1845.     if (!$print_isotope) return;
  1846.         wp_print_scripts("isotope");
  1847. }
  1848.  
  1849. /*=========================================================================================*/
  1850.  
  1851. add_action('init', 'register_pix_infinite');
  1852. add_action('wp_footer', 'print_pix_infinite');
  1853.  
  1854. function register_pix_infinite() {
  1855.         wp_register_script("infinitescroll", get_bloginfo( 'stylesheet_directory' )."/scripts/jquery.infinitescroll.min.js", array('jquery'));
  1856. }
  1857.  
  1858. function print_pix_infinite() {
  1859.     global $print_infinite;
  1860.     if (!$print_infinite) return;
  1861.         wp_print_scripts("infinitescroll");
  1862. }
  1863.  
  1864. /*=========================================================================================*/
  1865.  
  1866. add_filter('widget_text', 'do_shortcode');
  1867.  
  1868. /*=========================================================================================*/
  1869.  
  1870. function pix_remove_item_by_value($array, $val = '', $preserve_keys = true) {
  1871.     if (empty($array) || !is_array($array)) return false;
  1872.     if (!in_array($val, $array)) return $array;
  1873.  
  1874.     foreach($array as $key => $value) {
  1875.         if ($value == $val) unset($array[$key]);
  1876.     }
  1877.  
  1878.     return ($preserve_keys === true) ? $array : array_values($array);
  1879. }
  1880.  
  1881.  
  1882. /*=========================================================================================*/
  1883.  
  1884. add_action('restrict_manage_posts','restrict_portfolio_by_gallery');
  1885. function restrict_portfolio_by_gallery() {
  1886.     global $typenow;
  1887.     $args=array( 'public' => true, '_builtin' => false );
  1888.     $post_types = get_post_types($args);
  1889.     if ( in_array($typenow, $post_types) ) {
  1890.     $filters = get_object_taxonomies($typenow);
  1891.         foreach ($filters as $tax_slug) {
  1892.             $tax_obj = get_taxonomy($tax_slug);
  1893.             wp_dropdown_categories(array(
  1894.                 'show_option_all' => __('Show All '.$tax_obj->label ),
  1895.                 'taxonomy' => $tax_slug,
  1896.                 'name' => $tax_obj->name,
  1897.                 'orderby' => 'term_order',
  1898.                 'selected' => $_GET[$tax_obj->query_var],
  1899.                 'hierarchical' => $tax_obj->hierarchical,
  1900.                 'show_count' => false,
  1901.                 'hide_empty' => true
  1902.             ));
  1903.         }
  1904.     }
  1905. }
  1906.  
  1907.  
  1908. add_filter('parse_query','convert_portfolio_id_to_taxonomy_term_in_query');
  1909. function convert_portfolio_id_to_taxonomy_term_in_query($query) {
  1910.     global $typenow;
  1911.     global $pagenow;
  1912.     if ($pagenow=='edit.php') {
  1913.         $filters = get_object_taxonomies($typenow);
  1914.         foreach ($filters as $tax_slug) {
  1915.             $var = &$query->query_vars[$tax_slug];
  1916.             if ( isset($var) ) {
  1917.                 $term = get_term_by('id',$var,$tax_slug);
  1918.                 $var = $term->slug;
  1919.             }
  1920.         }
  1921.     }
  1922. }
  1923.  
  1924. /*=========================================================================================*/
  1925.  
  1926. function pix_image_path($img) {
  1927.     global $blog_id;
  1928.     if (isset($blog_id) && $blog_id > 1) {
  1929.         $img = explode('/files/', $img);
  1930.         if (isset($img[1])) {
  1931.             $img = '/blogs.dir/' . $blog_id . '/files/' . $img[1];
  1932.         }
  1933.     }
  1934.     return $img;
  1935. }
  1936.  
  1937. /*=========================================================================================*/
  1938.  
  1939.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement