Advertisement
Guest User

Untitled

a guest
Aug 27th, 2014
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 88.17 KB | None | 0 0
  1. <?php
  2.  
  3. /*============================== TESLA FRAMEWORK ======================================================================================================================*/
  4.  
  5. require_once(get_template_directory() . '/tesla_framework/tesla.php');
  6. require_once TEMPLATEPATH . '/tesla_dev/tt_log.php';
  7.  
  8.  
  9.  
  10. /*============================== THEME FEATURES ======================================================================================================================*/
  11.  
  12. function revoke_theme_features() {
  13.  
  14.     register_nav_menus(array(
  15.         'revoke_menu' => 'Revoke Header Menu'
  16.     ));
  17.  
  18.     if (!isset($content_width))
  19.         $content_width = 960;
  20.  
  21.     if (function_exists('register_sidebar')){
  22.         register_sidebar(array(
  23.             'name' => 'Blog Sidebar',
  24.             'id' => 'blog-sidebar',
  25.             'description' => 'This sidebar is located on the left side of the content on the blog page.',
  26.             'class' => '',
  27.             'before_widget' => '<div id="%1$s" class="widget %2$s font2">',
  28.             'after_widget' => '</div>',
  29.             'before_title' => '<div class="widgetTitle font1 widgettitle">',
  30.             'after_title' => '</div>'
  31.         ));
  32.         register_sidebar(array(
  33.             'name' => 'Footer Sidebar',
  34.             'id' => 'footer-sidebar',
  35.             'description' => 'This sidebar is located in the footer area of the blog page.',
  36.             'class' => '',
  37.             'before_widget' => '<div class="footerColumn"><div id="%1$s" class="widget %2$s">',
  38.             'after_widget' => '</div></div>',
  39.             'before_title' => '<div class="titleContainer titleFooter font1 widgettitle"><div class="title">',
  40.             'after_title' => '</div></div>'
  41.         ));
  42.         register_sidebar(array(
  43.             'name' => 'Page Sidebar',
  44.             'id' => 'page-sidebar',
  45.             'description' => 'This sidebar is located on the left side of the content on user created pages. This is the default sidebar for pages.',
  46.             'class' => '',
  47.             'before_widget' => '<div id="%1$s" class="widget %2$s font2">',
  48.             'after_widget' => '</div>',
  49.             'before_title' => '<div class="widgetTitle font1 widgettitle">',
  50.             'after_title' => '</div>'
  51.         ));
  52.  
  53.         for($i=1;$i<=10;$i++)
  54.             register_sidebar(array(
  55.                 'name' => 'Alternative Sidebar #'.$i,
  56.                 'id' => 'alt-sidebar-'.$i,
  57.                 'description' => 'This sidebar is can be chosen as an alternative for Page Sidebar.',
  58.                 'class' => '',
  59.                 'before_widget' => '<div id="%1$s" class="widget %2$s font2">',
  60.                 'after_widget' => '</div>',
  61.                 'before_title' => '<div class="widgetTitle font1 widgettitle">',
  62.                 'after_title' => '</div>'
  63.             ));
  64.     }
  65.  
  66.     add_theme_support('post-thumbnails');
  67.  
  68.     add_theme_support( 'automatic-feed-links' );
  69. }
  70.  
  71. revoke_theme_features();
  72.  
  73.  
  74.  
  75. /*============================== LANGUAGE SETUP ======================================================================================================================*/
  76.  
  77. function my_theme_setup(){
  78.     load_theme_textdomain('revoke', get_template_directory() . '/language');
  79. }
  80. add_action('after_setup_theme', 'my_theme_setup');
  81.  
  82.  
  83.  
  84. /*============================== SCRIPTS & STYLES ======================================================================================================================*/
  85.  
  86. function revoke_scripts() {
  87.  
  88.     wp_enqueue_style('revoke-style', get_template_directory_uri() . '/css/style.css',false,null);
  89.     wp_enqueue_style('revoke-bootstrap', get_template_directory_uri() . '/css/bootstrap.min.css',array('revoke-style'),null);
  90.     wp_enqueue_style('revoke-style-wp', get_stylesheet_uri(),false,null);
  91.  
  92.     //wp_enqueue_script('revoke-gmap', 'https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&libraries=places',array('jquery'),null,false);
  93.  
  94.     wp_enqueue_script('jquery');
  95.  
  96.     wp_enqueue_script('revoke-plugins', get_template_directory_uri() . '/js/plugins.js',array('jquery'),null);
  97.     wp_enqueue_script('revoke-main-script', get_template_directory_uri() . '/js/script.js',array('jquery','revoke-plugins'),null);
  98.  
  99.     $list_view_mobile = _go('list_view_mobile');
  100.     $list_view_mobile = isset($list_view_mobile);
  101.     $list_view_desktop = _go('list_view_desktop');
  102.     $list_view_desktop = isset($list_view_desktop);
  103.  
  104.     wp_localize_script( "revoke-main-script", "revoke_main", array( "ajaxurl" => admin_url( "admin-ajax.php" ), "listviewmobile" => $list_view_mobile, "listviewdesktop" => $list_view_desktop ) );
  105.  
  106.     if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) wp_enqueue_script( "comment-reply", array('jquery') );
  107.  
  108.     $protocol = is_ssl() ? 'https' : 'http';
  109.  
  110.     if(_go('logo_text_font')){
  111.         $font = str_replace(' ', '+', _go('logo_text_font'));
  112.         wp_enqueue_style( 'tesla-custom-font', "$protocol://fonts.googleapis.com/css?family=$font");
  113.     }
  114.  
  115. }
  116.  
  117. function revoke_admin_scripts($hook_suffix) {
  118.     if ('widgets.php' == $hook_suffix) {
  119.         wp_enqueue_media();
  120.         wp_enqueue_script('revoke-widget-script', get_template_directory_uri() . '/js/revoke_admin_widgets.js', array('media-upload', 'media-views'),null);
  121.     }
  122.     if ($hook_suffix == 'post-new.php' || $hook_suffix == 'post.php') {
  123.         wp_enqueue_script('revoke-post-script', get_template_directory_uri() . '/js/revoke_admin_post.js',array('jquery'),null);
  124.     }
  125. }
  126.  
  127. if(!is_admin())
  128.     add_action('wp_enqueue_scripts', 'revoke_scripts');
  129. else
  130.     add_action('admin_enqueue_scripts', 'revoke_admin_scripts');
  131.  
  132. function revoke_header(){
  133.     $background_image = _go('bg_image');
  134.     $background_position = _go('bg_image_position');
  135.     $background_repeat = _go('bg_image_repeat');
  136.     $background_attachment = _go('bg_image_attachment');
  137.     $background_color = _go('bg_color');
  138.     echo '<style type="text/css">';
  139.     echo '.revoke_custom_background{';
  140.     if(!empty($background_image))
  141.         echo 'background-image: url('.$background_image.');';
  142.     if(!empty($background_position)){
  143.         echo 'background-position: ';
  144.         switch($background_position){
  145.             case 'Left':
  146.                 echo 'top left';
  147.                 break;
  148.             case 'Center':
  149.                 echo 'top center';
  150.                 break;
  151.             case 'Right':
  152.                 echo 'top right';
  153.                 break;
  154.             default:
  155.                 break;
  156.         }
  157.         echo ';';
  158.     }
  159.     if(!empty($background_repeat)){
  160.         echo 'background-repeat: ';
  161.         switch($background_repeat){
  162.             case 'No Repeat':
  163.                 echo 'no-repeat';
  164.                 break;
  165.             case 'Tile':
  166.                 echo 'repeat';
  167.                 break;
  168.             case 'Tile Horizontally':
  169.                 echo 'repeat-x';
  170.                 break;
  171.             case 'Tile Vertically':
  172.                 echo 'repeat-y';
  173.                 break;
  174.             default:
  175.                 break;
  176.         }
  177.         echo ';';
  178.     }
  179.     if(!empty($background_attachment)){
  180.         echo 'background-attachment: ';
  181.         switch($background_attachment){
  182.             case 'Scroll':
  183.                 echo 'scroll';
  184.                 break;
  185.             case 'Fixed':
  186.                 echo 'fixed';
  187.                 break;
  188.             default:
  189.                 break;
  190.         }
  191.         echo ';';
  192.     }
  193.     if(!empty($background_color))
  194.         echo 'background-color: '.$background_color.';';
  195.     echo '}';
  196.     $default = _go('site_color');
  197.     if(empty($default))
  198.         $default = '#fe5113';
  199.     ?>
  200.     .textcolor{
  201.         color: <?php echo $default; ?>;
  202.     }
  203.     .textcolor_hover:hover{
  204.         color: <?php echo $default; ?>;
  205.     }
  206.     .bgcolor{
  207.         background-color: <?php echo $default; ?>;
  208.     }
  209.     .bgcolor_hover:hover{
  210.         background-color: <?php echo $default; ?>;
  211.     }
  212.     .bordercolor{
  213.         border-color: <?php echo $default; ?>;
  214.     }
  215.     .social a:hover img{
  216.         background-color: <?php echo $default; ?>;
  217.     }
  218.     .menuContainer>ul.menu>li.menuactive>a,
  219.     .menuContainer>ul.menu>li>a:hover{
  220.         background-color: <?php echo $default; ?>;
  221.     }
  222.     .menuContainer div.menuLevel>ul.menuDrop>li:hover>a{
  223.         background-color: <?php echo $default; ?>;
  224.     }
  225.     .menuContainer div.menuLevel>ul.menuDrop>li>div.menuDropArrow{
  226.         background-color: <?php echo $default; ?>;
  227.     }
  228.     .titleContainer{
  229.         border-bottom-color: <?php echo $default; ?>;
  230.     }
  231.     .titleContainer .title{
  232.         border-bottom-color: <?php echo $default; ?>;
  233.     }
  234.     .titleContainer .clientsNav .clientsNavPrev{
  235.         background-color: <?php echo $default; ?>;
  236.     }
  237.     .titleContainer .clientsNav .clientsNavNext{
  238.         background-color: <?php echo $default; ?>;
  239.     }
  240.     .widgetFlickr .widgetFlickrImg:hover{
  241.         border-color: <?php echo $default; ?>;
  242.     }
  243.     .contact .contactForm fieldset.contactFormButtons input[type="submit"]:hover,
  244.     .contactForm fieldset.contactFormButtons input[type="submit"]:hover,
  245.     .contact .contactForm fieldset.contactFormButtons input[type="reset"]:hover,
  246.     .contactForm fieldset.contactFormButtons input[type="reset"]:hover{
  247.         background-color: <?php echo $default; ?>;
  248.     }
  249.     .pageSlider ul.pageSliderNav li.active,
  250.     .pageSlider ul.pageSliderNav li:hover{
  251.         background-color: <?php echo $default; ?>;
  252.     }
  253.     .widgetCategories ul li a span{
  254.         background-color: <?php echo $default; ?>;
  255.     }
  256.     .widgetCategories ul li a:hover{
  257.         color: <?php echo $default; ?>;
  258.     }
  259.     .widgetGallery .widgetGalleryImg a:hover img{
  260.         border-color: <?php echo $default; ?>;
  261.     }
  262.     .widgetWorks .widgetWorksEntry .widgetWorksEntryImg a span{
  263.         background-color: <?php echo $default; ?>;
  264.     }
  265.     .widgetWorks .widgetWorksEntry .widgetWorksEntryImg a:hover img{
  266.         border-color: <?php echo $default; ?>;
  267.     }
  268.     .works .worksFilter ul.worksFilterCategories li.worksFilterCategoriesActive div,
  269.     .works .worksFilter ul.worksFilterCategories li:hover div{
  270.         background-color: <?php echo $default; ?>;
  271.     }
  272.     .works .worksViews .worksViewsOption.worksViewsOptionActive,
  273.     .works .worksViews .worksViewsOption:hover{
  274.         border-color: <?php echo $default; ?>;
  275.     }
  276.     .works .worksContainer.worksContainerView1 .worksEntry .worksEntryContainer .worksEntryInfo .worksEntryInfoMore:hover{
  277.         background-color: <?php echo $default; ?>;
  278.     }
  279.     .works .worksContainer.worksContainerView2 .worksEntry .worksEntryContainer .worksEntryInfo .worksEntryInfoTitle a:hover{
  280.         color: <?php echo $default; ?>;
  281.     }
  282.     .blog .blogEntry .blogEntryTitle a:hover{
  283.         color: <?php echo $default; ?>;
  284.     }
  285.     .blog .blogEntry .blogEntryFooter .blogEntryFooterComments a{
  286.         color: <?php echo $default; ?>;
  287.         border-color: <?php echo $default; ?>;
  288.     }
  289.     .blogNav a.blogNavActive,
  290.     .blogNav a:hover{
  291.         color: <?php echo $default; ?>;
  292.     }
  293.     .post .postForm .postFormButtons input:hover{
  294.         background-color: <?php echo $default; ?>;
  295.     }
  296.     .project .projectInfo .projectInfoDetails .projectInfoDetailsEntry .projectInfoDetailsEntryBody a{
  297.         color: <?php echo $default; ?>;
  298.     }
  299.     .footer .footerColumn .widget .widgetBody a:hover{
  300.         color: <?php echo $default; ?>;
  301.     }
  302.     .sidebar .widget_revoke_categories ul li a span{
  303.         background-color: <?php echo $default; ?>;
  304.     }
  305.     ul.page-numbers a:hover,
  306.     ul.page-numbers span.current{
  307.         color: <?php echo $default; ?>;
  308.     }
  309.     #postForm p.form-submit #submit:hover{
  310.         background-color: <?php echo $default; ?>;
  311.     }
  312.     #reply-title a:hover{
  313.         color: <?php echo $default; ?>;
  314.     }
  315.     .sidebar .widget table tfoot tr td a:hover{
  316.         color: <?php echo $default; ?>;
  317.     }
  318.     .sidebar .widget table tbody tr td a:hover{
  319.         background-color: <?php echo $default; ?>;
  320.     }
  321.     .sidebar .widget .tagcloud a:hover,
  322.     .sidebar .widget .textwidget a:hover{
  323.         color: <?php echo $default; ?>;
  324.     }
  325.     .sidebar .widget .widgetTitle a:hover{
  326.         color: <?php echo $default; ?>;
  327.     }
  328.     .sidebar .widget #searchform #searchsubmit:hover{
  329.         background-color: <?php echo $default; ?>;
  330.     }
  331.     .sidebar .widgetWorks .widgetWorksEntry .widgetWorksEntryImg a:hover{
  332.         border-color: <?php echo $default; ?>;
  333.     }
  334.     .searchNoResults form input#searchsubmit:hover{
  335.         background-color: <?php echo $default; ?>;
  336.     }
  337.     .footerColumn a:hover{
  338.         color: <?php echo $default; ?>;
  339.     }
  340.     .footerColumn .widget_search #searchsubmit:hover{
  341.         background-color: <?php echo $default; ?>;
  342.     }
  343.     .menuContainer > ul.menu > li.current_page_item > a,
  344.     .menuContainer > ul.menu > li.current-menu-item > a,
  345.     .menuContainer > ul.menu > li.current-menu-ancestor > a,
  346.     .menuContainer > ul.menu > li.current_page_ancestor > a{
  347.         background-color: <?php echo $default; ?>;
  348.     }
  349.     .post-numbers{
  350.         color: <?php echo $default; ?>;
  351.     }
  352.     .post-numbers a:hover,
  353.     .postFooter a:hover,
  354.     .pingback a:hover,
  355.     .postCommentsEntryBodyMessage a:hover,
  356.     .post .postBody a:hover,
  357.     .pageContents a:hover,
  358.     .postCommentsEntryBodyUser a:hover,
  359.     .trackback a:hover{
  360.         color: <?php echo $default; ?>;
  361.     }
  362.     .pageContents input[type="submit"]:hover,
  363.     .pageContents input[type="reset"]:hover{
  364.         background-color: <?php echo $default; ?>;
  365.     }
  366.     .sidebar .widget ul li a:hover, .sidebar .widget_revoke_categories ul li a:hover{
  367.         color: <?php echo $default; ?>;
  368.     }
  369.     .contactResult{
  370.         color: <?php echo $default; ?>;
  371.     }
  372.     .revoke-read-more{
  373.         color: <?php echo $default; ?>;
  374.     }
  375.     <?php
  376.     echo _go('custom_css');
  377.     echo '</style>';
  378. }
  379. add_action('wp_head','revoke_header',1000);
  380.  
  381. function revoke_footer(){
  382.     echo _go('tracking_code');
  383. }
  384. add_action('wp_footer','revoke_footer',1000);
  385.  
  386.  
  387.  
  388. /*============================== WIDGETS ======================================================================================================================*/
  389.  
  390. class Revoke_contact_widget extends WP_Widget {
  391.  
  392.     function __construct() {
  393.         parent::__construct(
  394.                 'revoke_contact',
  395.                 'Revoke - Contact',
  396.                 array(
  397.             'description' => __('Contact details', 'revoke'),
  398.             'classname' => 'widget_revoke_contact',
  399.                 ),
  400.                 array('width' => 400, 'height' => 350)
  401.         );
  402.     }
  403.  
  404.     function widget( $args, $instance ) {
  405.         extract($args);
  406.         $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __('Contact','revoke') : $instance['title'], $instance, $this->id_base );
  407.         $company = empty( $instance['company'] ) ? 'Company' : $instance['company'];
  408.         $text = empty( $instance['text'] ) ? "Address\nCity, State Zip\n+123 456 7890\n+123 456 7890\nemail@address.com" : $instance['text'];
  409.         echo $before_widget;
  410.         if ( !empty( $title ) ) { echo $before_title . $title . $after_title; } ?>
  411.             <div class="widgetBody">
  412.                 <div class="widgetAddress">
  413.                     <div class="widgetAddressCompany"><?php echo $company; ?></div>
  414.                     <?php echo !empty( $instance['filter'] ) ? wpautop( $text ) : $text; ?>
  415.                 </div>
  416.             </div>
  417.         <?php
  418.         echo $after_widget;
  419.     }
  420.  
  421.     function update( $new_instance, $old_instance ) {
  422.         $instance = $old_instance;
  423.         $instance['title'] = strip_tags($new_instance['title']);
  424.         $instance['company'] = strip_tags($new_instance['company']);
  425.         if ( current_user_can('unfiltered_html') )
  426.             $instance['text'] =  $new_instance['text'];
  427.         else
  428.             $instance['text'] = stripslashes( wp_filter_post_kses( addslashes($new_instance['text']) ) );
  429.         $instance['filter'] = isset($new_instance['filter']);
  430.         return $instance;
  431.     }
  432.  
  433.     function form( $instance ) {
  434.         $instance = wp_parse_args( (array) $instance, array( 'title' => 'Contact', 'text' => "Address\nCity, State Zip\n+123 456 7890\n+123 456 7890\nemail@address.com", 'company' => 'Company', 'filter' => 1 ) );
  435.         $title = strip_tags($instance['title']);
  436.         $text = esc_textarea($instance['text']);
  437.         $company = strip_tags($instance['company']);
  438.         $filter = $instance['filter'];
  439. ?>
  440.         <p>
  441.             <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:','revoke'); ?></label>
  442.             <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" />
  443.         </p>
  444.  
  445.         <p>
  446.             <label for="<?php echo $this->get_field_id('company'); ?>"><?php _e('Company:','revoke'); ?></label>
  447.             <input class="widefat" id="<?php echo $this->get_field_id('company'); ?>" name="<?php echo $this->get_field_name('company'); ?>" type="text" value="<?php echo esc_attr($company); ?>" />
  448.         </p>
  449.  
  450.         <p>
  451.             <label for="<?php echo $this->get_field_id('text'); ?>"><?php _e('Contact details:','revoke'); ?></label>
  452.             <textarea class="widefat" rows="16" cols="20" id="<?php echo $this->get_field_id('text'); ?>" name="<?php echo $this->get_field_name('text'); ?>"><?php echo $text; ?></textarea>
  453.         </p>
  454.  
  455.         <p>
  456.             <input id="<?php echo $this->get_field_id('filter'); ?>" name="<?php echo $this->get_field_name('filter'); ?>" type="checkbox" <?php checked($filter); ?> />&nbsp;
  457.             <label for="<?php echo $this->get_field_id('filter'); ?>"><?php _e('Automatically add line breaks','revoke'); ?></label>
  458.         </p>
  459. <?php
  460.     }
  461.  
  462. }
  463.  
  464. class Revoke_categories_widget extends WP_Widget {
  465.  
  466.     function __construct() {
  467.         parent::__construct(
  468.                 'revoke_categories',
  469.                 'Revoke - Categories',
  470.                 array(
  471.             'description' => __('A list of categories', 'revoke'),
  472.             'classname' => 'widget_revoke_categories',
  473.                 )
  474.         );
  475.     }
  476.  
  477.     function widget($args, $instance) {
  478.         extract($args);
  479.         $title = apply_filters('widget_title', empty($instance['title']) ? __('Categories','revoke') : $instance['title'], $instance, $this->id_base);
  480.  
  481.         echo $before_widget;
  482.         if (!empty($title))
  483.             echo $before_title . $title . $after_title;
  484.         ?>
  485.         <ul>
  486.             <?php
  487.             $cat_args['title_li'] = '';
  488.             wp_list_categories(apply_filters('widget_revoke_categories_args', $cat_args));
  489.             ?>
  490.         </ul>
  491.         <?php
  492.         echo $after_widget;
  493.     }
  494.  
  495.     function update($new_instance, $old_instance) {
  496.         $instance = array();
  497.         $instance['title'] = strip_tags($new_instance['title']);
  498.  
  499.         return $instance;
  500.     }
  501.  
  502.     function form($instance) {
  503.         $instance = wp_parse_args((array) $instance, array('title' => ''));
  504.         $title = esc_attr($instance['title']);
  505.         ?>
  506.         <p>
  507.             <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:','revoke'); ?></label>
  508.             <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" />
  509.         </p>
  510.         <?php
  511.     }
  512.  
  513. }
  514.  
  515. class Revoke_twitter_widget extends WP_Widget {
  516.  
  517.     function __construct() {
  518.         parent::__construct(
  519.                 'revoke_twitter',
  520.                 'Revoke - Twitter',
  521.                 array(
  522.             'description' => __('A list of latest tweets', 'revoke'),
  523.             'classname' => 'widget_revoke_twitter',
  524.                 )
  525.         );
  526.     }
  527.  
  528.     function widget($args, $instance) {
  529.         extract($args);
  530.         $title = apply_filters('widget_title', empty($instance['title']) ? __('Twitter','revoke') : $instance['title'], $instance, $this->id_base);
  531.         $user = empty($instance['user']) ? 'teslathemes' : $instance['user'];
  532.         if (empty($instance['number']) || !$number = absint($instance['number']))
  533.             $number = 3;
  534.  
  535.         echo $before_widget;
  536.         if (!empty($title))
  537.             echo $before_title . $title . $after_title;
  538.  
  539.         // echo twitter_generate_output($user, $number);
  540.         echo twitter_generate_output($user, $number, '', array($this, 'tweet_output'),'','');
  541.  
  542.         echo $after_widget;
  543.     }
  544.  
  545.     function update($new_instance, $old_instance) {
  546.         $instance = array();
  547.         $instance['title'] = strip_tags($new_instance['title']);
  548.         $instance['user'] = strip_tags($new_instance['user']);
  549.         $instance['number'] = (int)strip_tags($new_instance['number']);
  550.  
  551.         return $instance;
  552.     }
  553.  
  554.     function form($instance) {
  555.         $instance = wp_parse_args((array) $instance, array('title' => ''));
  556.         $title = isset($instance['title']) ? esc_attr($instance['title']) : '';
  557.         $user = isset($instance['user']) ? esc_attr($instance['user']) : 'TeslaThemes';
  558.         $number = isset($instance['number']) ? absint($instance['number']) : 3;
  559.         ?>
  560.         <p>
  561.             <label><?php _e('Title:','revoke'); ?><input class="widefat" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></label>
  562.             <label><?php _e('Twitter user:','revoke'); ?><input class="widefat" name="<?php echo $this->get_field_name('user'); ?>" type="text" value="<?php echo esc_attr($user); ?>" /></label>
  563.             <label for="<?php echo $this->get_field_id('number'); ?>">
  564.                 <?php _e('Number of posts to show:','revoke'); ?>
  565.                 <input id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="text" value="<?php echo $number; ?>" size="3" />
  566.             </label>
  567.         </p>
  568.         <?php
  569.     }
  570.  
  571.     public function tweet_output($i, $text, $date){
  572.         if($i)
  573.             $output = '<div class="widgetPostsEntryDelimiter widgetPostsEntryDelimiterSmall"></div>';
  574.         else
  575.             $output = '';
  576.         $output .= '<div class="widgetTwitterPost"><div class="widgetTwitterPostText">'.$text.'</div><div class="widgetTwitterPostDate textcolor8">'.$date.'</div></div>';
  577.         return $output;
  578.     }
  579. }
  580.  
  581. class Revoke_flickr_widget extends WP_Widget {
  582.  
  583.     function __construct() {
  584.         parent::__construct(
  585.                 'revoke_flickr',
  586.                 'Revoke - Flickr',
  587.                 array(
  588.             'description' => __('A list of Flickr images', 'revoke'),
  589.             'classname' => 'widget_revoke_flickr',
  590.                 )
  591.         );
  592.     }
  593.  
  594.     function widget($args, $instance) {
  595.         extract($args);
  596.         $title = apply_filters('widget_title', empty($instance['title']) ? __('Flickr widget','revoke') : $instance['title'], $instance, $this->id_base);
  597.         $user = empty($instance['user']) ? '97073871@N04' : $instance['user'];
  598.         if (empty($instance['number']) || !$number = absint($instance['number']))
  599.             $number = 12;
  600.  
  601.         echo $before_widget;
  602.         if (!empty($title))
  603.             echo $before_title . $title . $after_title;
  604.         ?>
  605.         <div class="widgetBody widgetFlickr" data-user="<?php echo $user; ?>" data-images="<?php echo $number; ?>"></div>
  606.         <?php
  607.         echo $after_widget;
  608.     }
  609.  
  610.     function update($new_instance, $old_instance) {
  611.         $instance = array();
  612.         $instance['title'] = strip_tags($new_instance['title']);
  613.         $instance['user'] = strip_tags($new_instance['user']);
  614.         $instance['number'] = (int)strip_tags($new_instance['number']);
  615.  
  616.         return $instance;
  617.     }
  618.  
  619.     function form($instance) {
  620.         $instance = wp_parse_args((array) $instance, array('title' => ''));
  621.         $title = isset($instance['title']) ? esc_attr($instance['title']) : '';
  622.         $user = isset($instance['user']) ? esc_attr($instance['user']) : '97073871@N04';
  623.         $number = isset($instance['number']) ? absint($instance['number']) : 12;
  624.         ?>
  625.         <p>
  626.             <label><?php _e('Title:','revoke'); ?><input class="widefat" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></label>
  627.             <label><?php _e('Flickr user id:','revoke'); ?><input class="widefat" name="<?php echo $this->get_field_name('user'); ?>" type="text" value="<?php echo esc_attr($user); ?>" /></label>
  628.             <label for="<?php echo $this->get_field_id('number'); ?>">
  629.                 <?php _e('Number of posts to show:','revoke'); ?>
  630.                 <input id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="text" value="<?php echo $number; ?>" size="3" />
  631.             </label>
  632.         </p>
  633.         <?php
  634.     }
  635.  
  636. }
  637.  
  638. class Revoke_latest_posts_widget extends WP_Widget {
  639.  
  640.     function __construct() {
  641.         parent::__construct(
  642.                 'revoke_latest_posts',
  643.                 'Revoke - Latest Posts',
  644.                 array(
  645.             'description' => __('A list of the latest posts', 'revoke'),
  646.             'classname' => 'widget_revoke_latest_posts',
  647.                 )
  648.         );
  649.         $this->alt_option_name = 'widget_revoke_latest_posts_entries';
  650.  
  651.         add_action('save_post', array($this, 'flush_widget_cache'));
  652.         add_action('deleted_post', array($this, 'flush_widget_cache'));
  653.         add_action('switch_theme', array($this, 'flush_widget_cache'));
  654.     }
  655.  
  656.     function widget($args, $instance) {
  657.         $cache = wp_cache_get('widget_revoke_latest_posts_cache', 'widget');
  658.  
  659.         if (!is_array($cache))
  660.             $cache = array();
  661.  
  662.         if (!isset($args['widget_id']))
  663.             $args['widget_id'] = $this->id;
  664.  
  665.         if (isset($cache[$args['widget_id']])) {
  666.             echo $cache[$args['widget_id']];
  667.             return;
  668.         }
  669.  
  670.         ob_start();
  671.         extract($args);
  672.  
  673.         $title = apply_filters('widget_title', empty($instance['title']) ? __('Latest Posts','revoke') : $instance['title'], $instance, $this->id_base);
  674.         if (empty($instance['number']) || !$number = absint($instance['number']))
  675.             $number = 10;
  676.  
  677.         $r = new WP_Query(apply_filters('widget_posts_args', array('posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true)));
  678.         if ($r->have_posts()) :
  679.             ?>
  680.             <?php echo $before_widget; ?>
  681.             <?php if ($title) echo $before_title . $title . $after_title; ?>
  682.             <?php if($args['id']==='footer-sidebar'): ?>
  683.                 <div class="widgetBody widgetPosts">
  684.                     <?php
  685.                     while ($r->have_posts()) : $r->the_post(); ?>
  686.                         <div class="widgetPostsEntry">
  687.                             <?php if (has_post_thumbnail()): ?>
  688.                                 <div class="widgetPostsEntryAvatar">
  689.                                     <?php the_post_thumbnail(); ?>
  690.                                 </div>
  691.                             <?php endif; ?>
  692.                             <div class="widgetPostsEntryBody">
  693.                                 <div class="widgetPostsEntryBodyTitle">
  694.                                     <a class="textcolor7" href="<?php the_permalink(); ?>">
  695.                                         <?php the_title(); ?>
  696.                                     </a>
  697.                                 </div>
  698.                                 <div class="widgetPostsEntryBodyText">
  699.                                     <?php echo get_the_excerpt().'&nbsp;<a class="widgetPostsEntryBodyTextMore bgcolor" href="'.get_permalink().'"></a>'; ?>
  700.                                 </div>
  701.                             </div>
  702.                         </div>
  703.                         <?php if($r->have_posts()): ?>
  704.                             <div class="widgetPostsEntryDelimiter"></div>
  705.                         <?php else: break; endif; ?>
  706.                     <?php endwhile; ?>
  707.                 </div>
  708.             <?php else: ?>
  709.             <ul>
  710.                 <?php while ($r->have_posts()) : $r->the_post(); ?>
  711.                     <li>
  712.                         <span class="post-date"><?php echo get_the_date('d M'); ?></span>
  713.                         <a href="<?php the_permalink() ?>" title="<?php echo esc_attr(get_the_title() ? get_the_title() : get_the_ID() ); ?>"><?php
  714.                             if (get_the_title())
  715.                                 the_title();
  716.                             else
  717.                                 the_ID();
  718.                             ?></a>
  719.                     </li>
  720.                 <?php endwhile; ?>
  721.             </ul>
  722.             <?php endif; ?>
  723.             <?php echo $after_widget; ?>
  724.             <?php
  725.             wp_reset_postdata();
  726.  
  727.         endif;
  728.  
  729.         $cache[$args['widget_id']] = ob_get_flush();
  730.         wp_cache_set('widget_revoke_latest_posts_cache', $cache, 'widget');
  731.     }
  732.  
  733.     function update($new_instance, $old_instance) {
  734.         $instance = $old_instance;
  735.         $instance['title'] = strip_tags($new_instance['title']);
  736.         $instance['number'] = (int) $new_instance['number'];
  737.         $this->flush_widget_cache();
  738.  
  739.         $alloptions = wp_cache_get('alloptions', 'options');
  740.         if (isset($alloptions['widget_revoke_latest_posts_entries']))
  741.             delete_option('widget_revoke_latest_posts_entries');
  742.  
  743.         return $instance;
  744.     }
  745.  
  746.     function flush_widget_cache() {
  747.         wp_cache_delete('widget_revoke_latest_posts_cache', 'widget');
  748.     }
  749.  
  750.     function form($instance) {
  751.         $title = isset($instance['title']) ? esc_attr($instance['title']) : '';
  752.         $number = isset($instance['number']) ? absint($instance['number']) : 5;
  753.         ?>
  754.         <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:','revoke'); ?></label>
  755.             <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" />
  756.         </p>
  757.         <p>
  758.             <label for="<?php echo $this->get_field_id('number'); ?>"><?php _e('Number of posts to show:','revoke'); ?></label>
  759.             <input id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="text" value="<?php echo $number; ?>" size="3" />
  760.         </p>
  761.         <?php
  762.     }
  763.  
  764. }
  765.  
  766. class Revoke_sidebar_gallery_widget extends WP_Widget {
  767.  
  768.     function __construct() {
  769.         parent::__construct(
  770.                 'revoke_sidebar_gallery',
  771.                 'Revoke - Sidebar Gallery',
  772.                 array(
  773.             'description' => __('A gallery of images', 'revoke'),
  774.             'classname' => 'widget_revoke_sidebar_gallery',
  775.                 )
  776.         );
  777.     }
  778.  
  779.     function widget($args, $instance) {
  780.         extract($args);
  781.         $title = apply_filters('widget_title', empty($instance['title']) ? __('Sidebar Gallery','revoke') : $instance['title'], $instance, $this->id_base);
  782.         $category = $instance['category'];
  783.  
  784.         echo $before_widget;
  785.         if (!empty($title))
  786.             echo $before_title . $title . $after_title;
  787.         ?>
  788.         <div class="widgetGallery">
  789.             <?php
  790.             if(isset($instance['category'])&&$instance['category']!==''){
  791.                 $args = array(
  792.                     'numberposts' => $instance['number'],
  793.                     'category' => $instance['category'],
  794.                     'orderby' => 'post_date',
  795.                     'order' => 'DESC',
  796.                     'meta_key' => '_thumbnail_id',
  797.                     'post_type' => 'post',
  798.                     'post_status' => 'publish',
  799.                     'suppress_filters' => true
  800.                 );
  801.                 $query = get_posts($args);
  802.                 foreach($query as $q){
  803.                     echo '<div class="widgetGalleryImg">';
  804.                     echo '<a href="'.get_permalink($q->ID).'">';
  805.                     echo get_the_post_thumbnail($q->ID);
  806.                     echo '</a>';
  807.                     echo '</div>';
  808.                 }
  809.             }
  810.             ?>
  811.         </div>
  812.         <?php
  813.         echo $after_widget;
  814.     }
  815.  
  816.     function update($new_instance, $old_instance) {
  817.         $instance = array();
  818.         $instance['title'] = strip_tags($new_instance['title']);
  819.         $instance['category'] = $new_instance['category']===''?NULL:(int)strip_tags($new_instance['category']);
  820.         $instance['number'] = (int)strip_tags($new_instance['number']);
  821.  
  822.         return $instance;
  823.     }
  824.  
  825.     function form($instance) {
  826.         $instance = wp_parse_args((array) $instance, array('title' => '', 'category' => ''));
  827.         $title = esc_attr($instance['title']);
  828.         $category = esc_attr($instance['category']);
  829.         $number = isset($instance['number']) ? absint($instance['number']) : 9;
  830.         ?>
  831.         <p>
  832.             <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:','revoke'); ?></label>
  833.             <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" />
  834.         </p>
  835.         <p>
  836.             <label for="<?php echo $this->get_field_id('number'); ?>"><?php _e('Number of images to show:','revoke'); ?></label>
  837.             <input id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="text" value="<?php echo $number; ?>" size="3" />
  838.         </p>
  839.         <p>
  840.             <select class="widefat" id="<?php echo $this->get_field_id('category'); ?>" name="<?php echo $this->get_field_name('category'); ?>">
  841.                 <?php
  842.                 $term = term_exists($instance['category'], 'category');
  843.                 if ($instance['category'] === '' || $term === 0 || $term === null)
  844.                     echo '<option value=""> - Choose a category - </option>';
  845.                 $cats = get_categories();
  846.                 foreach ($cats as $c) {
  847.                     $option = '<option value="' . $c->cat_ID . '"' . selected($instance['category'], $c->cat_ID, false) . '>';
  848.                     $option .= $c->cat_name;
  849.                     $option .= '</option>';
  850.                     echo $option;
  851.                 }
  852.                 ?>
  853.             </select>
  854.         </p>
  855.         <?php
  856.     }
  857.  
  858. }
  859.  
  860. class Revoke_recent_works_widget extends WP_Widget {
  861.  
  862.     function __construct() {
  863.         parent::__construct(
  864.                 'revoke_recent_works',
  865.                 'Revoke - Recent Works',
  866.                 array(
  867.             'description' => __('A list of recent works', 'revoke'),
  868.             'classname' => 'widget_revoke_recent_works',
  869.                 )
  870.         );
  871.     }
  872.  
  873.     function widget($args, $instance) {
  874.         extract($args);
  875.         $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Works','revoke') : $instance['title'], $instance, $this->id_base);
  876.         $category = $instance['category'];
  877.  
  878.         echo $before_widget;
  879.         if (!empty($title))
  880.             echo $before_title . $title . $after_title;
  881.         ?>
  882.         <div class="widgetWorks">
  883.             <?php
  884.             if(isset($instance['category'])&&$instance['category']!==''){
  885.                 $cat_args['title_li'] = '';
  886.                 $args = array(
  887.                     'numberposts' => $instance['number'],
  888.                     'category' => $instance['category'],
  889.                     'orderby' => 'post_date',
  890.                     'order' => 'DESC',
  891.                     'meta_key' => '_thumbnail_id',
  892.                     'post_type' => 'post',
  893.                     'post_status' => 'publish',
  894.                     'suppress_filters' => true
  895.                 );
  896.                 $query = get_posts($args);
  897.                 foreach($query as $q){
  898.                     echo '<div class="widgetWorksEntry">';
  899.                     echo '<div class="widgetWorksEntryImg">';
  900.                     echo '<a href="'.get_permalink($q->ID).'">';
  901.                     echo '<span></span>';
  902.                     echo get_the_post_thumbnail($q->ID);
  903.                     echo '</a>';
  904.                     echo '</div>';
  905.                     echo '<div class="widgetWorksEntryInfo">';
  906.                     echo $q->post_excerpt;
  907.                     echo '</div>';
  908.                     echo '</div>';
  909.                 }
  910.             }
  911.             ?>
  912.         </div>
  913.         <?php
  914.         echo $after_widget;
  915.     }
  916.  
  917.     function update($new_instance, $old_instance) {
  918.         $instance = array();
  919.         $instance['title'] = strip_tags($new_instance['title']);
  920.         $instance['category'] = $new_instance['category']===''?NULL:(int)strip_tags($new_instance['category']);
  921.         $instance['number'] = (int)strip_tags($new_instance['number']);
  922.  
  923.         return $instance;
  924.     }
  925.  
  926.     function form($instance) {
  927.         $instance = wp_parse_args((array) $instance, array('title' => '', 'category' => ''));
  928.         $title = esc_attr($instance['title']);
  929.         $category = esc_attr($instance['category']);
  930.         $number = isset($instance['number']) ? absint($instance['number']) : 5;
  931.         ?>
  932.         <p>
  933.             <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:','revoke'); ?></label>
  934.             <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" />
  935.         </p>
  936.         <p>
  937.             <label for="<?php echo $this->get_field_id('number'); ?>"><?php _e('Number of works to show:','revoke'); ?></label>
  938.             <input id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="text" value="<?php echo $number; ?>" size="3" />
  939.         </p>
  940.         <p>
  941.             <select class="widefat" id="<?php echo $this->get_field_id('category'); ?>" name="<?php echo $this->get_field_name('category'); ?>">
  942.                 <?php
  943.                 $term = term_exists($instance['category'], 'category');
  944.                 if ($instance['category'] === '' || $term === 0 || $term === null)
  945.                     echo '<option value=""> - Choose a category - </option>';
  946.                 $cats = get_categories();
  947.                 foreach ($cats as $c) {
  948.                     $option = '<option value="' . $c->cat_ID . '"' . selected($instance['category'], $c->cat_ID, false) . '>';
  949.                     $option .= $c->cat_name;
  950.                     $option .= '</option>';
  951.                     echo $option;
  952.                 }
  953.                 ?>
  954.             </select>
  955.         </p>
  956.         <?php
  957.     }
  958.  
  959. }
  960.  
  961. function revoke_register_widgets() {
  962.     register_widget('Revoke_categories_widget');
  963.     register_widget('Revoke_latest_posts_widget');
  964.     register_widget('Revoke_sidebar_gallery_widget');
  965.     register_widget('Revoke_recent_works_widget');
  966.     register_widget('Revoke_twitter_widget');
  967.     register_widget('Revoke_flickr_widget');
  968.     register_widget('Revoke_contact_widget');
  969. }
  970.  
  971. add_action('widgets_init', 'revoke_register_widgets');
  972.  
  973. class Walker_Category_revoke extends Walker_Category {
  974.  
  975.     function start_el(&$output, $category, $depth = 0, $args = array(), $id = 0) {
  976.         extract($args);
  977.  
  978.         $cat_name = esc_attr($category->name);
  979.         $cat_name = apply_filters('list_cats', $cat_name, $category);
  980.         $link = '<a href="' . esc_url(get_term_link($category)) . '" ';
  981.         if ($use_desc_for_title == 0 || empty($category->description))
  982.             $link .= 'title="' . esc_attr(sprintf(__('View all posts filed under %s'), $cat_name)) . '"';
  983.         else
  984.             $link .= 'title="' . esc_attr(strip_tags(apply_filters('category_description', $category->description, $category))) . '"';
  985.         $link .= '><span></span>';
  986.         $link .= $cat_name . '</a>';
  987.  
  988.         if (!empty($feed_image) || !empty($feed)) {
  989.             $link .= ' ';
  990.  
  991.             if (empty($feed_image))
  992.                 $link .= '(';
  993.  
  994.             $link .= '<a href="' . esc_url(get_term_feed_link($category->term_id, $category->taxonomy, $feed_type)) . '"';
  995.  
  996.             if (empty($feed)) {
  997.                 $alt = ' alt="' . sprintf(__('Feed for all posts filed under %s'), $cat_name) . '"';
  998.             } else {
  999.                 $title = ' title="' . $feed . '"';
  1000.                 $alt = ' alt="' . $feed . '"';
  1001.                 $tax = $feed;
  1002.                 $link .= $title;
  1003.             }
  1004.  
  1005.             $link .= '>';
  1006.  
  1007.             if (empty($feed_image))
  1008.                 $link .= $tax;
  1009.             else
  1010.                 $link .= "<img src='$feed_image'$alt$title" . ' />';
  1011.  
  1012.             $link .= '</a>';
  1013.  
  1014.             if (empty($feed_image))
  1015.                 $link .= ')';
  1016.         }
  1017.  
  1018.         if (!empty($show_count))
  1019.             $link .= ' (' . intval($category->count) . ')';
  1020.  
  1021.         if ('list' == $args['style']) {
  1022.             $output .= "\t<li";
  1023.             $class = 'cat-item cat-item-' . $category->term_id;
  1024.             if (!empty($current_category)) {
  1025.                 $_current_category = get_term($current_category, $category->taxonomy);
  1026.                 if ($category->term_id == $current_category)
  1027.                     $class .= ' current-cat';
  1028.                 elseif ($category->term_id == $_current_category->parent)
  1029.                     $class .= ' current-cat-parent';
  1030.             }
  1031.             $output .= ' class="' . $class . '"';
  1032.             $output .= ">$link\n";
  1033.         } else {
  1034.             $output .= "\t$link<br />\n";
  1035.         }
  1036.     }
  1037.  
  1038. }
  1039.  
  1040.  
  1041.  
  1042. /*============================== FILTERS ======================================================================================================================*/
  1043.  
  1044. function widget_revoke_categories_args_filter() {
  1045.     $args = func_get_args();
  1046.     $args[0]['walker'] = new Walker_Category_revoke;
  1047.     return $args[0];
  1048. }
  1049.  
  1050. function revoke_read_more_filter() {
  1051.     return '';
  1052. }
  1053.  
  1054. add_filter('widget_revoke_categories_args', 'widget_revoke_categories_args_filter');
  1055. add_filter('excerpt_more', 'revoke_read_more_filter');
  1056.  
  1057. function revoke_excerpt_filter($excerpt) {
  1058.     $revoke_read_more = _go('read_more');
  1059.     if($revoke_read_more){
  1060.         global $revoke_blog_page;
  1061.         if($revoke_blog_page){
  1062.             global $post;
  1063.             $link = '<a class="revoke-read-more" href="'.get_permalink($post).'">'.$revoke_read_more.'</a>';
  1064.             $excerpt_after = ' '.$link;
  1065.         }else{
  1066.             $excerpt_after = '';
  1067.         }
  1068.     }else{
  1069.         $excerpt_after = '';
  1070.     }
  1071.    
  1072.     return $excerpt.$excerpt_after;;
  1073. }
  1074.  
  1075. add_filter('get_the_excerpt','revoke_excerpt_filter');
  1076.  
  1077.  
  1078.  
  1079. /*============================== COMMENTS ======================================================================================================================*/
  1080.  
  1081. function revoke_comment($comment, $args, $depth) {
  1082.     $GLOBALS['comment'] = $comment;
  1083.     switch ($comment->comment_type) :
  1084.         case 'pingback' :
  1085.         case 'trackback' :
  1086.             ?>
  1087.             <div <?php comment_class(); ?> id="comment-<?php comment_ID(); ?>">
  1088.                 <p><?php _e('Pingback:', 'revoke'); ?> <?php comment_author_link(); ?> <?php edit_comment_link(__('(Edit)', 'revoke'), '<span class="edit-link">', '</span>'); ?></p>
  1089.                 <?php
  1090.                 break;
  1091.             default :
  1092.                 global $post;
  1093.                 ?>
  1094.  
  1095.                 <div <?php comment_class(array('postCommentsEntry')); ?>>
  1096.  
  1097.                 <div class="postCommentsEntryAvatar">
  1098.                     <?php echo get_avatar($comment, 50); ?>
  1099.                 </div>
  1100.  
  1101.                 <div class="postCommentsEntryBody">
  1102.  
  1103.                 <div class="postCommentsEntryBodyUser">
  1104.                     <?php echo get_comment_author_link(); ?>
  1105.                 </div>
  1106.                 <div class="postCommentsEntryBodyDate">
  1107.                     <?php comment_date('F jS, Y'); ?> <?php _e('at','revoke'); ?> <?php comment_time('g:i a'); ?>
  1108.                 </div>
  1109.                 <div class="postCommentsEntryBodyMessage">
  1110.                     <?php if ('0' == $comment->comment_approved) : ?>
  1111.                         <p class="comment-awaiting-moderation"><?php _e('Your comment is awaiting moderation.', 'revoke'); ?></p>
  1112.                     <?php endif; ?>
  1113.                     <?php comment_text(); ?>
  1114.                 </div>
  1115.                 <div class="postCommentsEntryBodyButton" id="comment-<?php comment_ID(); ?>">
  1116.                     <?php comment_reply_link(array_merge($args, array('reply_text' => __('Reply', 'revoke'), 'depth' => $depth, 'max_depth' => $args['max_depth']))); ?>
  1117.                     <?php edit_comment_link(__('Edit', 'revoke')); ?>
  1118.                 </div>
  1119.                 <div class="postCommentsEntryBodyReplies">
  1120.  
  1121.             <?php
  1122.             break;
  1123.     endswitch;
  1124. }
  1125.  
  1126. function revoke_comment_end($comment, $args, $depth) {
  1127.     $GLOBALS['comment'] = $comment;
  1128.     switch ($comment->comment_type) :
  1129.         case 'pingback' :
  1130.         case 'trackback' :
  1131.             ?>
  1132.                 </div>
  1133.             <?php
  1134.             break;
  1135.         default :
  1136.             ?>
  1137.                 </div></div></div>
  1138.             <?php
  1139.             break;
  1140.     endswitch;
  1141. }
  1142.  
  1143.  
  1144.  
  1145. /*============================== META BOXES ======================================================================================================================*/
  1146.  
  1147. function revoke_featured_video($post) {
  1148.     wp_nonce_field(-1, 'revoke_featured_video_nonce');
  1149.     $value = get_post_meta($post->ID, 'revoke_featured_video_id', true);
  1150.     $enabled = get_post_meta($post->ID, 'revoke_featured_video_enabled', true);
  1151.     ?>
  1152.     <label><input <?php if ($enabled === '1') echo 'checked="checked" '; ?>value="" type="checkbox" name="revoke_featured_video_input_check_name" id="revoke_featured_video_input_check_id"> <?php _e('Enable featured video', 'revoke'); ?></label>
  1153.     <br/>
  1154.     <?php
  1155.     echo '<input ' . ($enabled === '0' || $enabled === '' ? 'style="display:none;" ' : '') . 'type="text" id="revoke_featured_video_input_id" name="revoke_featured_video_input_name" value="' . esc_attr($value) . '" size="25" />';
  1156. }
  1157.  
  1158. function revoke_featured_video_save($post_id) {
  1159.     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
  1160.         return;
  1161.  
  1162.     if (!isset($_POST['revoke_featured_video_nonce']) || !wp_verify_nonce($_POST['revoke_featured_video_nonce']))
  1163.         return;
  1164.  
  1165.     if (!current_user_can('edit_post', $post_id))
  1166.         return;
  1167.  
  1168.     if (wp_is_post_revision($post_id) === false) {
  1169.  
  1170.         $video = $_POST['revoke_featured_video_input_name'];
  1171.         $enabled = $_POST['revoke_featured_video_input_check_name'] === NULL ? '0' : '1';
  1172.  
  1173.         add_post_meta($post_id, 'revoke_featured_video_id', $video, true) or
  1174.                 update_post_meta($post_id, 'revoke_featured_video_id', $video);
  1175.         add_post_meta($post_id, 'revoke_featured_video_enabled', $enabled, true) or
  1176.                 update_post_meta($post_id, 'revoke_featured_video_enabled', $enabled);
  1177.     }
  1178. }
  1179.  
  1180. function revoke_disable_title($post) {
  1181.     wp_nonce_field(-1, 'revoke_disable_title_nonce');
  1182.     $enabled = get_post_meta($post->ID, 'revoke_disable_title_check', true);
  1183.     ?>
  1184.     <label>
  1185.         <input <?php checked($enabled); ?> type="checkbox" name="revoke_disable_title_input_check">
  1186.         <?php _e('Disable Page Title', 'revoke'); ?>
  1187.     </label>
  1188.     <?php
  1189. }
  1190.  
  1191. function revoke_disable_sidebar($post) {
  1192.     wp_nonce_field(-1, 'revoke_disable_sidebar_nonce');
  1193.     $enabled = get_post_meta($post->ID, 'revoke_disable_sidebar_check', true);
  1194.     ?>
  1195.     <label>
  1196.         <input <?php checked($enabled); ?> type="checkbox" name="revoke_disable_sidebar_input_check">
  1197.         <?php _e('Disable Page Sidebar', 'revoke'); ?>
  1198.     </label>
  1199.     <?php
  1200. }
  1201.  
  1202. function revoke_alternative_sidebar($post) {
  1203.  
  1204.     global $wp_registered_sidebars;  
  1205.      
  1206.     $custom = get_post_custom($post->ID);
  1207.      
  1208.     if(isset($custom['custom_sidebar']))  
  1209.         $val = $custom['custom_sidebar'][0];  
  1210.     else  
  1211.         $val = "default";  
  1212.  
  1213.     wp_nonce_field(-1,'custom_sidebar_nonce' );  
  1214.  
  1215.     $output = '<p>'.__("Choose a sidebar to be displayed", 'revoke' ).'</p>';  
  1216.     $output .= "<select name='custom_sidebar'>";  
  1217.  
  1218.     $output .= "<option";  
  1219.     if($val == "default")  
  1220.         $output .= " selected='selected'";  
  1221.     $output .= " value='default'>".__('default', 'revoke')."</option>";  
  1222.      
  1223.     foreach($wp_registered_sidebars as $sidebar_id => $sidebar)  
  1224.     {  
  1225.         $output .= "<option";  
  1226.         if($sidebar_id == $val)  
  1227.             $output .= " selected='selected'";  
  1228.         $output .= " value='".$sidebar_id."'>".$sidebar['name']."</option>";  
  1229.     }  
  1230.    
  1231.     $output .= "</select>";  
  1232.      
  1233.     echo $output;
  1234. }
  1235.  
  1236. function revoke_disable_padding($post) {
  1237.     wp_nonce_field(-1, 'revoke_disable_padding_nonce');
  1238.     $enabled = get_post_meta($post->ID, 'revoke_disable_padding_check', true);
  1239.     ?>
  1240.     <label>
  1241.         <input <?php checked($enabled); ?> type="checkbox" name="revoke_disable_padding_input_check">
  1242.         <?php _e('Revome the spacing at the bottom of the page', 'revoke'); ?>
  1243.     </label>
  1244.     <?php
  1245. }
  1246.  
  1247. function revoke_disable_title_save($post_id) {
  1248.     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
  1249.         return;
  1250.  
  1251.     if (!isset($_POST['revoke_disable_title_nonce']) || !wp_verify_nonce($_POST['revoke_disable_title_nonce']))
  1252.         return;
  1253.  
  1254.     if (!current_user_can('edit_post', $post_id))
  1255.         return;
  1256.  
  1257.     if (wp_is_post_revision($post_id) === false) {
  1258.  
  1259.         $enabled = $_POST['revoke_disable_title_input_check'] === NULL ? false : true;
  1260.  
  1261.         add_post_meta($post_id, 'revoke_disable_title_check', $enabled, true) or
  1262.                 update_post_meta($post_id, 'revoke_disable_title_check', $enabled);
  1263.     }
  1264. }
  1265.  
  1266. function revoke_disable_sidebar_save($post_id) {
  1267.     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
  1268.         return;
  1269.  
  1270.     if (!isset($_POST['revoke_disable_sidebar_nonce']) || !wp_verify_nonce($_POST['revoke_disable_sidebar_nonce']))
  1271.         return;
  1272.  
  1273.     if (!current_user_can('edit_post', $post_id))
  1274.         return;
  1275.  
  1276.     if (wp_is_post_revision($post_id) === false) {
  1277.  
  1278.         $enabled = $_POST['revoke_disable_sidebar_input_check'] === NULL ? false : true;
  1279.  
  1280.         add_post_meta($post_id, 'revoke_disable_sidebar_check', $enabled, true) or
  1281.                 update_post_meta($post_id, 'revoke_disable_sidebar_check', $enabled);
  1282.     }
  1283. }
  1284.  
  1285. function revoke_alternative_sidebar_save($post_id) {
  1286.  
  1287.     if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )  
  1288.       return;  
  1289.  
  1290.     if (!isset($_POST['custom_sidebar_nonce']) || !wp_verify_nonce($_POST['custom_sidebar_nonce']))
  1291.         return;
  1292.  
  1293.     if ( !current_user_can( 'edit_page', $post_id ) )  
  1294.         return;  
  1295.  
  1296.     if (wp_is_post_revision($post_id) === false) {
  1297.         $data = $_POST['custom_sidebar'];
  1298.  
  1299.         add_post_meta($post_id, "custom_sidebar", $data,true) or
  1300.             update_post_meta($post_id, "custom_sidebar", $data);
  1301.     }
  1302. }
  1303.  
  1304. function revoke_disable_padding_save($post_id) {
  1305.     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
  1306.         return;
  1307.  
  1308.     if (!isset($_POST['revoke_disable_padding_nonce']) || !wp_verify_nonce($_POST['revoke_disable_padding_nonce']))
  1309.         return;
  1310.  
  1311.     if (!current_user_can('edit_post', $post_id))
  1312.         return;
  1313.  
  1314.     if (wp_is_post_revision($post_id) === false) {
  1315.  
  1316.         $enabled = $_POST['revoke_disable_padding_input_check'] === NULL ? false : true;
  1317.  
  1318.         add_post_meta($post_id, 'revoke_disable_padding_check', $enabled, true) or
  1319.                 update_post_meta($post_id, 'revoke_disable_padding_check', $enabled);
  1320.     }
  1321. }
  1322.  
  1323. function revoke_meta_boxes() {
  1324.     add_meta_box('revoke_featured_video_id', 'Featured Video', 'revoke_featured_video', 'post', 'side', 'low');
  1325.     add_meta_box('revoke_featured_video_id', 'Featured Video', 'revoke_featured_video', 'page', 'side', 'low');
  1326.     add_meta_box('revoke_disable_title_id', 'Disable Title', 'revoke_disable_title', 'page', 'side', 'low');
  1327.     add_meta_box('revoke_disable_sidebar', 'Disable Sidebar', 'revoke_disable_sidebar', 'page', 'side', 'low');
  1328.     add_meta_box('revoke_alternative_sidebar', 'Alternative Sidebar', 'revoke_alternative_sidebar', 'page', 'side', 'low');
  1329.     add_meta_box('revoke_disable_padding', 'Disable Page Bottom Padding', 'revoke_disable_padding', 'page', 'side', 'low');
  1330. }
  1331.  
  1332. add_action('add_meta_boxes', 'revoke_meta_boxes');
  1333. add_action('save_post', 'revoke_featured_video_save');
  1334. add_action('save_post', 'revoke_disable_title_save');
  1335. add_action('save_post', 'revoke_disable_sidebar_save');
  1336. add_action('save_post', 'revoke_alternative_sidebar_save');
  1337. add_action('save_post', 'revoke_disable_padding_save');
  1338.  
  1339.  
  1340.  
  1341. /*============================== MENU ======================================================================================================================*/
  1342.  
  1343. class Revoke_Nav_Menu_Walker extends Walker_Nav_Menu {
  1344.  
  1345.     function start_lvl( &$output, $depth = 0, $args = array() ) {
  1346.         $indent = str_repeat("\t", $depth);
  1347.         $output .= "\n$indent<div class=\"menuLevel\"><ul class=\"sub-menu menuDrop font3\">\n";
  1348.     }
  1349.  
  1350.     function end_lvl( &$output, $depth = 0, $args = array() ) {
  1351.         $indent = str_repeat("\t", $depth);
  1352.         $output .= "$indent</ul></div>\n";
  1353.     }
  1354.  
  1355.     function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
  1356.         $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
  1357.  
  1358.         $class_names = $value = '';
  1359.  
  1360.         $classes = empty( $item->classes ) ? array() : (array) $item->classes;
  1361.         $classes[] = 'menu-item-' . $item->ID;
  1362.  
  1363.         $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args ) );
  1364.         $class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';
  1365.  
  1366.         $id = apply_filters( 'nav_menu_item_id', 'menu-item-'. $item->ID, $item, $args );
  1367.         $id = $id ? ' id="' . esc_attr( $id ) . '"' : '';
  1368.  
  1369.         $output .= $indent . '<li' . $id . $value . $class_names .'>'.($depth?'<div class="menuDropArrow"></div>':'');
  1370.  
  1371.         $attributes  = ! empty( $item->attr_title ) ? ' title="'  . esc_attr( $item->attr_title ) .'"' : '';
  1372.         $attributes .= ! empty( $item->target )     ? ' target="' . esc_attr( $item->target     ) .'"' : '';
  1373.         $attributes .= ! empty( $item->xfn )        ? ' rel="'    . esc_attr( $item->xfn        ) .'"' : '';
  1374.         $attributes .= ! empty( $item->url )        ? ' href="'   . esc_attr( $item->url        ) .'"' : '';
  1375.  
  1376.         $item_output = $args->before;
  1377.         $item_output .= '<a'. $attributes .'>';
  1378.         $item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;
  1379.         $item_output .= '</a>';
  1380.         $item_output .= $args->after;
  1381.  
  1382.         $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
  1383.     }
  1384. }
  1385.  
  1386. class Revoke_List_Pages_Walker extends Walker_Page {
  1387.  
  1388.     function start_lvl( &$output, $depth = 0, $args = array() ) {
  1389.         $indent = str_repeat("\t", $depth);
  1390.         $output .= "\n$indent<div class=\"menuLevel\"><ul class='children menuDrop font3'>\n";
  1391.     }
  1392.  
  1393.     function end_lvl( &$output, $depth = 0, $args = array() ) {
  1394.         $indent = str_repeat("\t", $depth);
  1395.         $output .= "$indent</ul></div>\n";
  1396.     }
  1397.  
  1398.     function start_el( &$output, $page, $depth = 0, $args = array(), $current_page = 0 ) {
  1399.         if ( $depth )
  1400.             $indent = str_repeat("\t", $depth);
  1401.         else
  1402.             $indent = '';
  1403.  
  1404.         extract($args, EXTR_SKIP);
  1405.         $css_class = array('page_item', 'page-item-'.$page->ID);
  1406.         if ( !empty($current_page) ) {
  1407.             $_current_page = get_post( $current_page );
  1408.             if ( in_array( $page->ID, $_current_page->ancestors ) )
  1409.                 $css_class[] = 'current_page_ancestor';
  1410.             if ( $page->ID == $current_page )
  1411.                 $css_class[] = 'current_page_item';
  1412.             elseif ( $_current_page && $page->ID == $_current_page->post_parent )
  1413.                 $css_class[] = 'current_page_parent';
  1414.         } elseif ( $page->ID == get_option('page_for_posts') ) {
  1415.             $css_class[] = 'current_page_parent';
  1416.         }
  1417.  
  1418.         $css_class = implode( ' ', apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page ) );
  1419.  
  1420.         $output .= $indent . '<li class="' . $css_class . '">'.($depth?'<div class="menuDropArrow"></div>':'').'<a href="' . get_permalink($page->ID) . '">' . $link_before . apply_filters( 'the_title', $page->post_title, $page->ID ) . $link_after . '</a>';
  1421.  
  1422.         if ( !empty($show_date) ) {
  1423.             if ( 'modified' == $show_date )
  1424.                 $time = $page->post_modified;
  1425.             else
  1426.                 $time = $page->post_date;
  1427.  
  1428.             $output .= " " . mysql2date($date_format, $time);
  1429.         }
  1430.     }
  1431. }
  1432.  
  1433. class Revoke_Nav_Menu_Select_Walker extends Walker_Nav_Menu {
  1434.  
  1435.     function start_lvl( &$output, $depth = 0, $args = array() ) {
  1436.  
  1437.     }
  1438.  
  1439.     function end_lvl( &$output, $depth = 0, $args = array() ) {
  1440.  
  1441.     }
  1442.  
  1443.     function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0 ) {
  1444.         $pad = str_repeat('&nbsp;', $depth * 3);
  1445.  
  1446.         $output .= "\t<option class=\"level-$depth\" value=\"".$item->url."\"";
  1447.         if ( isset($args->selected) && $item->url == $args->selected )
  1448.             $output .= ' selected="selected"';
  1449.         $output .= '>';
  1450.         $title = $item->title;
  1451.         $output .= $pad . esc_html( $title );
  1452.     }
  1453.  
  1454.     function end_el( &$output, $item, $depth = 0, $args = array() ) {
  1455.         $output .= "</option>\n";
  1456.     }
  1457. }
  1458.  
  1459. class Revoke_List_Pages_Select_Walker extends Walker_Page {
  1460.  
  1461.     function start_lvl( &$output, $depth = 0, $args = array() ) {
  1462.        
  1463.     }
  1464.  
  1465.     function end_lvl( &$output, $depth = 0, $args = array() ) {
  1466.        
  1467.     }
  1468.  
  1469.     function start_el(&$output, $page, $depth = 0, $args = array(), $id = 0 ) {
  1470.         $pad = str_repeat('&nbsp;', $depth * 3);
  1471.  
  1472.         $url = get_permalink($page->ID);
  1473.  
  1474.         $output .= "\t<option class=\"level-$depth\" value=\"".$url."\"";
  1475.         if ( isset($args->selected) && $url == $args->selected )
  1476.             $output .= ' selected="selected"';
  1477.         $output .= '>';
  1478.         $title = $page->post_title;
  1479.         $output .= $pad . esc_html( $title );
  1480.     }
  1481.  
  1482.     function end_el( &$output, $page, $depth = 0, $args = array() ) {
  1483.         $output .= "</option>\n";
  1484.     }
  1485. }
  1486.  
  1487.  
  1488.  
  1489. /*============================== SHORTCODES ======================================================================================================================*/
  1490.  
  1491. function revoke_column_first_shortcode( $atts, $content = null ){
  1492.     extract(shortcode_atts(array(
  1493.             'size' => 4,
  1494.             'style' => '',
  1495.         ), $atts));
  1496.     $size = (int)$size;
  1497.     return '<div class="row-fluid"><div class="span'.$size.'" style="'.$style.'">'.do_shortcode($content).'</div>';
  1498. }
  1499. function revoke_column_shortcode( $atts, $content = null ){
  1500.     extract(shortcode_atts(array(
  1501.             'size' => 4,
  1502.             'style' => '',
  1503.         ), $atts));
  1504.     $size = (int)$size;
  1505.     return '<div class="span'.$size.'" style="'.$style.'">'.do_shortcode($content).'</div>';
  1506. }
  1507. function revoke_column_last_shortcode( $atts, $content = null ){
  1508.     extract(shortcode_atts(array(
  1509.             'size' => 4,
  1510.             'style' => '',
  1511.         ), $atts));
  1512.     $size = (int)$size;
  1513.     return '<div class="span'.$size.'" style="'.$style.'">'.do_shortcode($content).'</div></div>';
  1514. }
  1515. add_shortcode( 'revoke_column_first', 'revoke_column_first_shortcode' );
  1516. add_shortcode( 'revoke_column', 'revoke_column_shortcode' );
  1517. add_shortcode( 'revoke_column_last', 'revoke_column_last_shortcode' );
  1518. add_shortcode( 'tesla_column_first', 'revoke_column_first_shortcode' );
  1519. add_shortcode( 'tesla_column', 'revoke_column_shortcode' );
  1520. add_shortcode( 'tesla_column_last', 'revoke_column_last_shortcode' );
  1521.  
  1522. function revoke_map_shortcode( $atts, $content = null ){
  1523.     extract(shortcode_atts(array(
  1524.             'height' => '384px',
  1525.             'width' => '100%',
  1526.             'address' => 'London, UK',
  1527.             'style' => ''
  1528.         ), $atts));
  1529.     return '<iframe style="height:'.$height.';width:'.$width.';'.$style.'" src="http://maps.google.com/maps?q=' . urlencode($address) . '&amp;output=embed&amp;iwloc" class="revoke_map"></iframe>';
  1530. }
  1531. add_shortcode( 'revoke_map', 'revoke_map_shortcode' );
  1532.  
  1533. function tesla_map_shortcode( $atts, $content = null ){
  1534.     extract(shortcode_atts(array(
  1535.             'height' => '384px',
  1536.             'width' => '100%',
  1537.             'address' => 'London, UK',
  1538.             'style' => ''
  1539.         ), $atts));
  1540.     return tt_gmap('contact_map', 'map-canvas','revoke_map\' style=\'height:'.$height.';width:'.$width.';'.$style,'true',false);
  1541. }
  1542. add_shortcode( 'tesla_map', 'tesla_map_shortcode' );
  1543.  
  1544. function revoke_contact_shortcode( $atts, $content = null ){
  1545.     extract(shortcode_atts(array(
  1546.             'title' => '',
  1547.             'style' => ''
  1548.         ), $atts));
  1549.     if(empty($title))
  1550.         $title = _go('form_title');
  1551.     if(empty($title))
  1552.         $title = 'Don\'t Be Shy, Come Along & Say Hi';
  1553.     $output = '<form class="contactForm" action="" style="'.$style.'">
  1554.            <div class="contactFormTitle font1">
  1555.                '.$title.'
  1556.                <input name="action" type="hidden" value="revoke_contact" />
  1557.            </div>
  1558.            <fieldset class="contactFormDetails">
  1559.                <input type="text" name="input-name" value="" placeholder="'.__('Name','revoke').'">
  1560.                <input type="text" name="input-email" value="" placeholder="'.__('E-mail','revoke').'">
  1561.            </fieldset>
  1562.            <fieldset class="contactFormMessage">
  1563.                <textarea rows="" cols="" name="input-message" placeholder="'.__('Type your message here','revoke').'"></textarea>
  1564.            </fieldset>
  1565.            <fieldset class="contactFormButtons">
  1566.                <input type="submit" value="'.__('Send','revoke').'">
  1567.            </fieldset>
  1568.        </form>
  1569.        <div class="contactResult"></div>';
  1570.     return $output;
  1571. }
  1572. add_shortcode( 'revoke_contact', 'revoke_contact_shortcode' );
  1573. add_shortcode( 'tesla_contact', 'revoke_contact_shortcode' );
  1574. function revoke_contact_ajax(){
  1575.     $receiver_mail = _go('email_contact');
  1576.     if(!empty($receiver_mail))
  1577.     {
  1578.         $mail_title_prefix = _go('email_prefix');
  1579.         if(empty($mail_title_prefix))
  1580.             $mail_title_prefix = '';
  1581.         if( !empty($_POST['input-name']) && !empty($_POST['input-email']) && !empty($_POST['input-message']) ){
  1582.                 $subject = $mail_title_prefix.__(' message from ','revoke').$_POST['input-name'].' ('.$_POST['input-email'].')';
  1583.             $reply_to = is_email($_POST['input-email']);
  1584.             if(false!==$reply_to){
  1585.                 $reply_to = $_POST['input-name'] . '<' . $reply_to . '>';
  1586.                 $headers = '';
  1587.                 $headers .= 'MIME-Version: 1.0' . "\r\n";
  1588.                 $headers .= 'Content-type: text/plain; charset=utf-8' . "\r\n";
  1589.                 $headers .= 'Reply-to: ' . $reply_to . "\r\n";
  1590.                 $message = 'Name: '.$_POST['input-name']."\r\n".'E-mail: '.$_POST['input-email']."\r\n".'Message: '.$_POST['input-message'];
  1591.                 if ( wp_mail($receiver_mail, $subject, $message, $headers) ){
  1592.                     $result = __("Your message was successfully sent.",'revoke');
  1593.                     $result_error = false;
  1594.                 }else{
  1595.                     $result = __("Operation could not be completed.",'revoke');
  1596.                     $result_error = true;
  1597.                 }
  1598.             }else{
  1599.                 $result = __("You have provided an invalid e-mail address.",'revoke');
  1600.                 $result_error = true;
  1601.             }
  1602.         }else{
  1603.             $result = __("Please fill in all the required fields.",'revoke');
  1604.             $result_error = true;
  1605.         }
  1606.     }else{
  1607.         $result = __('Error! There is no e-mail configured to receive the messages.','revoke');
  1608.         $result_error = true;
  1609.     }
  1610.     echo json_encode(array(
  1611.         'message' => $result,
  1612.         'error' => $result_error
  1613.     ));
  1614.     die;
  1615. }
  1616. add_action( "wp_ajax_revoke_contact", "revoke_contact_ajax" );
  1617. add_action( "wp_ajax_nopriv_revoke_contact", "revoke_contact_ajax" );
  1618.  
  1619. function revoke_post_slider_shortcode( $atts, $content = null ){
  1620.     extract(shortcode_atts(array(
  1621.             'style' => '',
  1622.             'speed' => 4,
  1623.             'pause' => 8
  1624.         ), $atts));
  1625.     $speed = (int)$speed;
  1626.     $pause = (int)$pause;
  1627.     $before = '
  1628.    <div class="pageSlider" style="'.$style.'" data-speed="'.($speed*1000).'" data-pause="'.($pause*1000).'">
  1629.        <div class="pageSliderItems">
  1630.            <ul>
  1631.    ';
  1632.     $after = '
  1633.            </ul>
  1634.        </div>
  1635.    </div>
  1636.    ';
  1637.     return $before.do_shortcode(str_replace('<br />','',shortcode_unautop($content))).$after;
  1638. }
  1639. add_shortcode( 'revoke_secondary_slider', 'revoke_post_slider_shortcode' );
  1640. function revoke_post_slider_item_shortcode( $atts, $content = null ){
  1641.     extract(shortcode_atts(array(
  1642.             'image' => '',
  1643.             'style' => ''
  1644.         ), $atts));
  1645.     $output = '<li><img src="'.$image.'" alt="" /></li>';
  1646.     return $output;
  1647. }
  1648. add_shortcode( 'revoke_secondary_slider_item', 'revoke_post_slider_item_shortcode' );
  1649.  
  1650. function revoke_clients_slider_shortcode( $atts, $content = null ){
  1651.     extract(shortcode_atts(array(
  1652.             'title' => 'our clients',
  1653.             'style' => ''
  1654.         ), $atts));
  1655.     $before = '
  1656.    <div class="clients" style="'.$style.'">
  1657.        <div class="titleContainer font1">
  1658.            <div class="title">
  1659.                '.$title.'
  1660.            </div>
  1661.            <div class="clientsNav">
  1662.                <div class="clientsNavPrev"></div>
  1663.                <div class="clientsNavNext"></div>
  1664.            </div>
  1665.        </div>
  1666.        <ul>
  1667.    ';
  1668.     $after = '
  1669.        </ul>
  1670.    </div>
  1671.    ';
  1672.     return $before.do_shortcode(str_replace('<br />','',shortcode_unautop($content))).$after;
  1673. }
  1674. add_shortcode( 'revoke_clients_slider', 'revoke_clients_slider_shortcode' );
  1675. function revoke_clients_slider_item_shortcode( $atts, $content = null ){
  1676.     extract(shortcode_atts(array(
  1677.             'style' => '',
  1678.             'image' => ''
  1679.         ), $atts));
  1680.     $output = '<li><img src="'.$image.'" alt="" /></li>';
  1681.     return $output;
  1682. }
  1683. add_shortcode( 'revoke_clients_slider_item', 'revoke_clients_slider_item_shortcode' );
  1684.  
  1685. function revoke_testimonial_shortcode( $atts, $content = null ){
  1686.     extract(shortcode_atts(array(
  1687.             'image' => '',
  1688.             'author' => '',
  1689.             'wide' => 'false',
  1690.             'style' => ''
  1691.         ), $atts));
  1692.     $output = '
  1693.    <div class="testimonialbg'.($wide==='true'?' testimonialbgwide':'').'" style="'.$style.'">
  1694.        <div class="testimonial">
  1695.            <div class="testimonialImg bordercolor">
  1696.                <img src="'.$image.'" alt="" />
  1697.            </div>
  1698.            <div class="testimonialContent font4">
  1699.                <div class="testimonialContentText textcolor4">
  1700.                    '.do_shortcode($content).'
  1701.                </div>
  1702.                <div class="testimonialContentAuthor textcolor5">
  1703.                    &HorizontalLine; '.$author.'
  1704.                </div>
  1705.            </div>
  1706.        </div>
  1707.    </div>
  1708.    ';
  1709.     return $output;
  1710. }
  1711. add_shortcode( 'revoke_testimonial', 'revoke_testimonial_shortcode' );
  1712.  
  1713. global $revoke_main_slider_toggle_caption;
  1714. function revoke_main_slider_shortcode( $atts, $content = null ){
  1715.     extract(shortcode_atts(array(
  1716.             'style' => '',
  1717.             'speed' => 4,
  1718.             'pause' => 8,
  1719.             'toggle_caption' => true
  1720.         ), $atts));
  1721.     $speed = (int)$speed;
  1722.     $pause = (int)$pause;
  1723.     $toggle_caption = (bool)$toggle_caption;
  1724.     global $revoke_main_slider_toggle_caption;
  1725.     $revoke_main_slider_toggle_caption = $toggle_caption;
  1726.     $before = '<div class="mainSlider" style="'.$style.'" data-speed="'.($speed*1000).'" data-pause="'.($pause*1000).'">
  1727.        <div class="mainSliderItemsWrapper">
  1728.            <div class="mainSliderItems">';
  1729.     $after = '</div>
  1730.        </div>
  1731.        <div class="mainSliderNav">
  1732.            <div class="mainSliderNavBar bgcolor"></div>
  1733.        </div>
  1734.    </div>';
  1735.     return $before.do_shortcode(str_replace('<br />','',shortcode_unautop($content))).$after;
  1736. }
  1737. add_shortcode( 'revoke_main_slider', 'revoke_main_slider_shortcode' );
  1738. function revoke_main_slider_item_shortcode( $atts, $content = null ){
  1739.     extract(shortcode_atts(array(
  1740.             'title' => '',
  1741.             'image' => '',
  1742.             'style' => ''
  1743.         ), $atts));
  1744.     global $revoke_main_slider_toggle_caption;
  1745.     $before = '
  1746.        <div class="mainSliderItemsEntry">
  1747.            <img src="'.$image.'" class="mainSliderItemsEntryImg" alt="" />
  1748.            <div class="mainSliderItemsEntryBox bgcolor2'.($revoke_main_slider_toggle_caption?' mainSliderItemsEntryBoxToggle':'').'">
  1749.                <div class="mainSliderItemsEntryBoxBorder"></div>
  1750.                <div class="mainSliderItemsEntryBoxTitle textcolor2 font3">
  1751.                    '.$title.'
  1752.                </div>
  1753.                <div class="mainSliderItemsEntryBoxContent textcolor3">
  1754.                    ';
  1755.     $after = '
  1756.                </div>
  1757.                <div class="mainSliderItemsEntryBoxButtons">
  1758.                    <div class="mainSliderItemsEntryBoxButtonsPrev bgcolor3 bgcolor_hover"></div>
  1759.                    <div class="mainSliderItemsEntryBoxButtonsNext bgcolor3 bgcolor_hover"></div>
  1760.                </div>
  1761.            </div>
  1762.        </div>
  1763.        ';
  1764.     return $before.do_shortcode(str_replace('<br />','',shortcode_unautop($content))).$after;
  1765. }
  1766. add_shortcode( 'revoke_main_slider_item', 'revoke_main_slider_item_shortcode' );
  1767.  
  1768.  
  1769. function revoke_portofolio_shortcode( $atts, $content = null ){
  1770.     extract(shortcode_atts(array(
  1771.         ), $atts));
  1772.     $before = '<div class="works">';
  1773.     $after = '</div>';
  1774.     return $before.do_shortcode(str_replace('<br />','',shortcode_unautop($content))).$after;
  1775. }
  1776. add_shortcode( 'revoke_portofolio', 'revoke_portofolio_shortcode' );
  1777. add_shortcode( 'revoke_portfolio', 'revoke_portofolio_shortcode' );
  1778. function revoke_portofolio_categories_shortcode( $atts, $content = null ){
  1779.     extract(shortcode_atts(array(
  1780.         ), $atts));
  1781.     $before = '<div class="worksFilter">
  1782.                        <div class="worksFilterText textcolor6">
  1783.                            '.__('Featured Work:','revoke').'
  1784.                        </div>
  1785.                        <ul class="worksFilterCategories">
  1786.                            <li class="textcolor6 worksFilterCategoriesActive bordercolor3" data-category="all">
  1787.                                <div class="bordercolor3">
  1788.                                    '.__('all','revoke').'
  1789.                                </div>
  1790.                            </li>';
  1791.     $after = '</ul>
  1792.                    </div>
  1793.                    <div class="worksViews">
  1794.                        <div class="worksViewsOption bordercolor3 worksViewsOptionActive" data-class="worksContainerView1">
  1795.                            <img src="'.get_template_directory_uri().'/images/options/sort_opt1.png" alt="" />
  1796.                        </div>
  1797.                        <div class="worksViewsOption bordercolor3" data-class="worksContainerView2">
  1798.                            <img src="'.get_template_directory_uri().'/images/options/sort_opt2.png" alt="" />
  1799.                        </div>
  1800.                    </div>';
  1801.     return $before.do_shortcode(str_replace('<br />','',shortcode_unautop($content))).$after;
  1802. }
  1803. add_shortcode( 'revoke_portofolio_categories', 'revoke_portofolio_categories_shortcode' );
  1804. add_shortcode( 'revoke_portfolio_categories', 'revoke_portofolio_categories_shortcode' );
  1805. function revoke_portofolio_category_shortcode( $atts, $content = null ){
  1806.     extract(shortcode_atts(array(
  1807.             'slug' => ''
  1808.         ), $atts));
  1809.     $before = '<li class="textcolor6 bordercolor3" data-category="'.($slug===''?$content:$slug).'">
  1810.                                <div class="bordercolor3">';
  1811.     $after = '</div>
  1812.                            </li>';
  1813.     return $before.do_shortcode(str_replace('<br />','',shortcode_unautop($content))).$after;
  1814. }
  1815. add_shortcode( 'revoke_portofolio_category', 'revoke_portofolio_category_shortcode' );
  1816. add_shortcode( 'revoke_portfolio_category', 'revoke_portofolio_category_shortcode' );
  1817. function revoke_portofolio_items_shortcode( $atts, $content = null ){
  1818.     extract(shortcode_atts(array(
  1819.         ), $atts));
  1820.     $before = '<div class="worksContainer worksContainerView1">';
  1821.     $after = '</div>';
  1822.     return $before.do_shortcode(str_replace('<br />','',shortcode_unautop($content))).$after;
  1823. }
  1824. add_shortcode( 'revoke_portofolio_items', 'revoke_portofolio_items_shortcode' );
  1825. add_shortcode( 'revoke_portfolio_items', 'revoke_portofolio_items_shortcode' );
  1826. function revoke_portofolio_item_shortcode( $atts, $content = null ){
  1827.     extract(shortcode_atts(array(
  1828.             'categories' => '',
  1829.             'image_small' => '',
  1830.             'image_big' => '',
  1831.             'url' => '',
  1832.             'title' => '',
  1833.             'no_more' => false
  1834.         ), $atts));
  1835.     $no_more = (bool)$no_more;
  1836.     $before = '<div class="worksEntry" data-categories="'.$categories.'">
  1837.        <div class="worksEntryContainer">
  1838.            <div class="worksEntryInfo">
  1839.                <div class="worksEntryInfoTitle">
  1840.                    <a href="'.$url.'">
  1841.                        '.$title.'
  1842.                    </a>
  1843.                </div>';
  1844.     $after = (!$no_more?'<div class="worksEntryInfoMore"><a href="'.$url.'">'.__('read more','revoke').'</a></div>':'').
  1845.             '</div>
  1846.            <a href="'.$url.'"><img class="worksEntryImg" src="'.$image_small.'" alt="" /></a>
  1847.            <img class="worksEntryImgBig" src="'.$image_big.'" alt="" />
  1848.        </div>
  1849.    </div>';
  1850.     return $before.do_shortcode(str_replace('<br />','',shortcode_unautop($content))).$after;
  1851. }
  1852. add_shortcode( 'revoke_portofolio_item', 'revoke_portofolio_item_shortcode' );
  1853. add_shortcode( 'revoke_portfolio_item', 'revoke_portofolio_item_shortcode' );
  1854. function revoke_portofolio_item_description_small_shortcode( $atts, $content = null ){
  1855.     extract(shortcode_atts(array(
  1856.             'category' => '',
  1857.         ), $atts));
  1858.     $before = '<div  class="worksEntryInfoExcerpt">';
  1859.     $after = '</div>';
  1860.     return $before.do_shortcode(str_replace('<br />','',shortcode_unautop($content))).$after;
  1861. }
  1862. add_shortcode( 'revoke_portofolio_item_description_small', 'revoke_portofolio_item_description_small_shortcode' );
  1863. add_shortcode( 'revoke_portfolio_item_description_small', 'revoke_portofolio_item_description_small_shortcode' );
  1864. function revoke_portofolio_item_description_big_shortcode( $atts, $content = null ){
  1865.     extract(shortcode_atts(array(
  1866.             'category' => '',
  1867.         ), $atts));
  1868.     $before = '<div  class="worksEntryInfoExcerptBig">';
  1869.     $after = '</div>';
  1870.     return $before.do_shortcode(str_replace('<br />','',shortcode_unautop($content))).$after;
  1871. }
  1872. add_shortcode( 'revoke_portofolio_item_description_big', 'revoke_portofolio_item_description_big_shortcode' );
  1873. add_shortcode( 'revoke_portfolio_item_description_big', 'revoke_portofolio_item_description_big_shortcode' );
  1874.  
  1875. function revoke_project_shortcode( $atts, $content = null ){
  1876.     extract(shortcode_atts(array(
  1877.             'style' => '',
  1878.         ), $atts));
  1879.     $before = '<div class="project">';
  1880.     $after = '</div>';
  1881.     return $before.do_shortcode(str_replace('<br />','',shortcode_unautop($content))).$after;
  1882. }
  1883. add_shortcode( 'revoke_project', 'revoke_project_shortcode' );
  1884. function revoke_project_slider_shortcode( $atts, $content = null ){
  1885.     extract(shortcode_atts(array(
  1886.             'style' => '',
  1887.             'speed' => 4,
  1888.             'pause' => 8
  1889.         ), $atts));
  1890.     $speed = (int)$speed;
  1891.     $pause = (int)$pause;
  1892.     $before = '
  1893.    <div class="pageSlider" style="'.$style.'" data-speed="'.($speed*1000).'" data-pause="'.($pause*1000).'">
  1894.        <div class="pageSliderItems">
  1895.            <ul>
  1896.    ';
  1897.     $after = '
  1898.            </ul>
  1899.        </div>
  1900.    </div>';
  1901.     return $before.do_shortcode(str_replace('<br />','',shortcode_unautop($content))).$after;
  1902. }
  1903. add_shortcode( 'revoke_project_slider', 'revoke_project_slider_shortcode' );
  1904. function revoke_project_slider_item_shortcode( $atts, $content = null ){
  1905.     extract(shortcode_atts(array(
  1906.             'style' => '',
  1907.             'image' => ''
  1908.         ), $atts));
  1909.     $output = '<li><img src="'.$image.'" alt="" /></li>';
  1910.     return $output;
  1911. }
  1912. add_shortcode( 'revoke_project_slider_item', 'revoke_project_slider_item_shortcode' );
  1913. function revoke_project_info_shortcode( $atts, $content = null ){
  1914.     extract(shortcode_atts(array(
  1915.             'style' => '',
  1916.             'title' => '',
  1917.             'description' => '',
  1918.             'categories' => '',
  1919.             'skills' => '',
  1920.             'url' => '',
  1921.         ), $atts));
  1922.     $output = '
  1923.    <div class="projectInfo">
  1924.        <div class="projectInfoTitle font1">
  1925.            '.$title.'
  1926.        </div>
  1927.        <div class="projectInfoDescription">
  1928.            '.$description.'
  1929.        </div>
  1930.        <div class="projectInfoDetails">
  1931.            <div class="projectInfoDetailsTitle font1">
  1932.                '.__('Project Details','revoke').'
  1933.            </div>
  1934.            <div class="projectInfoDetailsEntry">
  1935.                <div class="projectInfoDetailsEntryTitle">
  1936.                    '.__('Categories','revoke').'
  1937.                </div>
  1938.                <div class="projectInfoDetailsEntryBody">
  1939.                    '.$categories.'
  1940.                </div>
  1941.            </div>
  1942.            <div class="projectInfoDetailsEntry">
  1943.                <div class="projectInfoDetailsEntryTitle">
  1944.                    '.__('Skills','revoke').'
  1945.                </div>
  1946.                <div class="projectInfoDetailsEntryBody">
  1947.                    '.$skills.'
  1948.                </div>
  1949.            </div>
  1950.            <div class="projectInfoDetailsEntry">
  1951.                <div class="projectInfoDetailsEntryTitle">
  1952.                    '.__('Project url','revoke').'
  1953.                </div>
  1954.                <div class="projectInfoDetailsEntryBody">
  1955.                    <a href="'.$url.'">'.__('Project link','revoke').'</a>
  1956.                </div>
  1957.            </div>
  1958.        </div>
  1959.    </div>
  1960.    ';
  1961.     return $output;
  1962. }
  1963. add_shortcode( 'revoke_project_info', 'revoke_project_info_shortcode' );
  1964. function revoke_project_related_shortcode( $atts, $content = null ){
  1965.     extract(shortcode_atts(array(
  1966.             'style' => '',
  1967.         ), $atts));
  1968.     $before = '
  1969.    <div class="projectRelated">
  1970.        <div class="titleContainer font1">
  1971.            <div class="title">
  1972.                '.__('related projects','revoke').'
  1973.            </div>
  1974.            <div class="clientsNav">
  1975.                <div class="clientsNavPrev"></div>
  1976.                <div class="clientsNavNext"></div>
  1977.            </div>
  1978.        </div>
  1979.        <ul>
  1980.    ';
  1981.     $after = '</ul>
  1982.    </div>';
  1983.     return $before.do_shortcode(str_replace('<br />','',shortcode_unautop($content))).$after;
  1984. }
  1985. add_shortcode( 'revoke_project_related', 'revoke_project_related_shortcode' );
  1986. function revoke_project_related_item_shortcode( $atts, $content = null ){
  1987.     extract(shortcode_atts(array(
  1988.             'style' => '',
  1989.             'title' => '',
  1990.             'description' => '',
  1991.             'image' => '',
  1992.             'url' => '',
  1993.         ), $atts));
  1994.     $output = '
  1995.    <li>
  1996.        <a href="'.$url.'">
  1997.            <img src="'.$image.'" alt="" />
  1998.        </a>
  1999.        <div class="title">
  2000.            <a href="'.$url.'">
  2001.                '.$title.'
  2002.            </a>
  2003.        </div>
  2004.        <div class="description">
  2005.            '.$description.'
  2006.        </div>
  2007.    </li>
  2008.    ';
  2009.     return $output;
  2010. }
  2011. add_shortcode( 'revoke_project_related_item', 'revoke_project_related_item_shortcode' );
  2012.  
  2013.  
  2014.  
  2015. /*============================== CUSTOM TAXONOMY FIELDS ======================================================================================================================*/
  2016.  
  2017. define("TT_TAX_ORDER", "revoke_portfolio");
  2018.  
  2019. function tt_taxonomy_add_fields() {
  2020.     ?>
  2021.     <div class="form-field">
  2022.         <label for="tt_tax_order_input"><?php _ex( 'Order', 'portfolio category order', 'revoke' ); ?></label>
  2023.         <input type="text" name="tt_tax_order_input" id="tt_tax_order_input" value="">
  2024.         <p class="description"><?php _ex( 'Set the order in which the categories should be displayed.', 'portfolio category order', 'revoke' ); ?></p>
  2025.     </div>
  2026.     <?php
  2027. }
  2028.  
  2029. add_action( TT_TAX_ORDER.'_tax_add_form_fields', 'tt_taxonomy_add_fields', 10, 2 );
  2030.  
  2031. function tt_taxonomy_edit_fields($term) {
  2032.  
  2033.     $term_id = $term->term_id;
  2034.     $term_meta = tt_taxonomy_order($term_id);
  2035.  
  2036.     ?>
  2037.     <tr class="form-field">
  2038.     <th scope="row" valign="top"><label for="tt_tax_order_input"><?php _ex( 'Order', 'portfolio category order', 'revoke' ); ?></label></th>
  2039.         <td>
  2040.             <input type="text" name="tt_tax_order_input" id="tt_tax_order_input" value="<?php echo esc_attr( $term_meta ); ?>">
  2041.             <p class="description"><?php _ex( 'Set the order in which the categories should be displayed.', 'portfolio category order', 'revoke' ); ?></p>
  2042.         </td>
  2043.     </tr>
  2044.     <?php
  2045. }
  2046.  
  2047. add_action( TT_TAX_ORDER.'_tax_edit_form_fields', 'tt_taxonomy_edit_fields', 10, 2 );
  2048.  
  2049. function tt_taxonomy_save_fields( $term_id ) {
  2050.     if ( isset( $_POST['tt_tax_order_input'] ) ) {
  2051.         $term_meta_array = tt_taxonomy_order();
  2052.         $term_meta = $_POST['tt_tax_order_input'];
  2053.         $term_meta_array[$term_id] = $term_meta;
  2054.         update_option(TT_TAX_ORDER."_taxonomy_order", $term_meta_array);
  2055.     }
  2056. }
  2057.  
  2058. add_action( 'edited_'.TT_TAX_ORDER.'_tax', 'tt_taxonomy_save_fields', 10, 2 );
  2059. add_action( 'create_'.TT_TAX_ORDER.'_tax', 'tt_taxonomy_save_fields', 10, 2 );
  2060.  
  2061. function tt_taxonomy_columns_head($columns) {
  2062.     $columns['order']  = _x( 'Order', 'portfolio category order column', 'revoke' );
  2063.     return $columns;
  2064. }
  2065.  
  2066. add_filter('manage_edit-'.TT_TAX_ORDER.'_tax_columns', 'tt_taxonomy_columns_head');
  2067.  
  2068. function tt_taxonomy_order($term_id = null){
  2069.  
  2070.     $term_meta_array = get_option(TT_TAX_ORDER."_taxonomy_order", array());
  2071.  
  2072.     if(is_null($term_id)){
  2073.  
  2074.         return $term_meta_array;
  2075.  
  2076.     }else{
  2077.  
  2078.         $term_meta = (int) ( array_key_exists($term_id, $term_meta_array) ? $term_meta_array[$term_id] : 0 );
  2079.         return $term_meta;
  2080.  
  2081.     }
  2082.  
  2083. }
  2084.  
  2085. function tt_terms_ordered_compare($a, $b){
  2086.  
  2087.     $a_order = tt_taxonomy_order($a->term_id);
  2088.     $b_order = tt_taxonomy_order($b->term_id);
  2089.  
  2090.     if ($a_order === $b_order)
  2091.         return strcmp($a->name, $b->name);
  2092.     else
  2093.         return ($a_order < $b_order) ? -1 : 1;
  2094.  
  2095. }
  2096.  
  2097. function tt_terms_ordered($tax_array){
  2098.  
  2099.     usort($tax_array, 'tt_terms_ordered_compare');
  2100.     return $tax_array;
  2101.  
  2102. }
  2103.  
  2104. add_filter('tesla_slide_categories_'.TT_TAX_ORDER, 'tt_terms_ordered', 10, 2);
  2105.  
  2106. function tt_taxonomy_columns_content($empty, $column_name, $term_id) {
  2107.     if ($column_name == 'order') {
  2108.         $term_meta = tt_taxonomy_order($term_id);
  2109.         echo $term_meta;
  2110.     }
  2111. }
  2112.  
  2113. add_filter('manage_'.TT_TAX_ORDER.'_tax_custom_column', 'tt_taxonomy_columns_content', 10, 3);
  2114.  
  2115. function tt_taxonomy_columns_quick_edit($column_name, $screen, $tax){
  2116.  
  2117.     if($tax !== TT_TAX_ORDER.'_tax' || $column_name !== 'order')
  2118.         return false;
  2119.  
  2120.     ?>
  2121.     <fieldset>
  2122.         <div id="my-custom-content" class="inline-edit-col">
  2123.             <label>
  2124.                 <span class="title">Order</span>
  2125.                 <span class="input-text-wrap"><input type="text" name="tt_tax_order_input" class="ptitle" value=""></span>
  2126.             </label>
  2127.         </div>
  2128.     </fieldset>
  2129.     <?php
  2130. }
  2131.  
  2132. if('edit-tags.php'===$pagenow)
  2133.     add_action('quick_edit_custom_box', 'tt_taxonomy_columns_quick_edit', 10, 3);
  2134.  
  2135. function tt_taxonomy_columns_scripts($hook_suffix) {
  2136.     if ('edit-tags.php' === $hook_suffix && isset($_GET['taxonomy']) && TT_TAX_ORDER.'_tax' === $_GET['taxonomy'] && !isset($_GET['action'])){
  2137.         wp_enqueue_script('tt-tax-quickedit', get_template_directory_uri() . '/admin/quickedit.js',array('inline-edit-tax'),null,true);
  2138.     }
  2139. }
  2140.  
  2141. if(is_admin())
  2142.     add_action('admin_enqueue_scripts', 'tt_taxonomy_columns_scripts');
  2143.  
  2144.  
  2145.  
  2146. /*============================== THEME VERSION COMPATIBILITY ======================================================================================================================*/
  2147.  
  2148. function revoke_compatibility($meta, $id, $context){
  2149.     if(is_string($meta)){
  2150.         $meta_json = json_decode($meta, true);
  2151.         if(is_array($meta_json)){
  2152.             $meta = $meta_json;
  2153.         }else{
  2154.             $meta_serialize = unserialize($meta);
  2155.             if(is_array($meta_serialize)){
  2156.                 $meta = $meta_serialize;
  2157.             }else{
  2158.                 $meta = array();
  2159.             }
  2160.         }
  2161.     }
  2162.     $post_type = get_post_type($id);
  2163.     switch($post_type){
  2164.         case 'revoke_main':
  2165.             break;
  2166.  
  2167.         case 'revoke_clients':
  2168.             break;
  2169.  
  2170.         case 'revoke_secondary':
  2171.             break;
  2172.  
  2173.         case 'revoke_portfolio':
  2174.             if(isset($meta['image_slider'])&&!isset($meta['slider'])){
  2175.                 if(count($meta['image_slider'])){
  2176.                     $meta['slider'] = array();
  2177.                     foreach ($meta['image_slider'] as $key => $value) {
  2178.                         array_push($meta['slider'], array( 'image' => $value ));
  2179.                     }
  2180.                 }
  2181.                 unset($meta['image_slider']);
  2182.             }
  2183.             if(isset($meta['categories'])&&isset($meta['skills'])&&isset($meta['url'])&&isset($meta['full_description'])&&!isset($meta['info'])){
  2184.  
  2185.                 $title = __('Project Details','revoke');
  2186.                 if('Project Details'!==$title)
  2187.                     $title = 'Details';
  2188.  
  2189.                 if(true||''===$meta['categories']){
  2190.                     $terms = get_the_terms($id, $post_type.'_tax');
  2191.                     if(false===$terms)
  2192.                         $terms = array();
  2193.                     $categories = array();
  2194.                     foreach ($terms as $key => $value) {
  2195.                         array_push($categories, $value->name);
  2196.                     }
  2197.                     $categories = implode(', ', $categories);
  2198.                 }else{
  2199.                     $categories = $meta['categories'];
  2200.                 }
  2201.  
  2202.                 $categories_title = __('Categories','revoke');
  2203.  
  2204.                 $skills_title = __('Skills','revoke');
  2205.  
  2206.                 $url_title = __('Project url','revoke');
  2207.                 if('Project url'!==$url_title)
  2208.                     $url_title = 'URL';
  2209.  
  2210.                 $meta['info'] = array(
  2211.                     array(
  2212.                         'title' => 'Description',
  2213.                         'content' => array(
  2214.                             'text' => $meta['full_description']
  2215.                         )
  2216.                     ),
  2217.                     array(
  2218.                         'title' => $title,
  2219.                         'content' => array(
  2220.                             'fields' => array(
  2221.                                 array(
  2222.                                     'name' => $categories_title,
  2223.                                     'value' => $categories
  2224.                                 ),
  2225.                                 array(
  2226.                                     'name' => $skills_title,
  2227.                                     'value' => $meta['skills']
  2228.                                 ),
  2229.                                 array(
  2230.                                     'name' => $url_title,
  2231.                                     'value' => '<a target="_blank" href="'.esc_attr($meta['url']).'">'.__('Project link','revoke').'</a>'
  2232.                                 )
  2233.                             )
  2234.                         )
  2235.                     )
  2236.                 );
  2237.                 unset($meta['categories']);
  2238.                 unset($meta['skills']);
  2239.                 unset($meta['url']);
  2240.                 unset($meta['full_description']);
  2241.             }
  2242.             break;
  2243.  
  2244.         case 'revoke_testimonial':
  2245.             break;
  2246.  
  2247.         default:
  2248.             break;
  2249.     }
  2250.     return $meta;
  2251. }
  2252.  
  2253. add_filter('tesla_slide_options', 'revoke_compatibility', 10, 3);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement