Advertisement
pixedelic

functions.shortcodelic.2.4.4.php

Feb 28th, 2015
291
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 123.67 KB | None | 0 0
  1. <?php
  2.  
  3. class ShortCodelic{
  4.  
  5.     /**
  6.      * @since   2.4.4
  7.      *
  8.      * @var     string
  9.      */
  10.     protected $version = '2.4.4';
  11.  
  12.     /**
  13.      * @since    1.0.0
  14.      *
  15.      * @var      string
  16.      */
  17.     protected $plugin_slug = 'shortcodelic';
  18.  
  19.     /**
  20.      * @since    1.0.0
  21.      *
  22.      * @var      string
  23.      */
  24.     protected $plugin_name = 'ShortCodelic';
  25.  
  26.     /**
  27.      * @since    1.0.0
  28.      *
  29.      * @var      object
  30.      */
  31.     protected static $instance = null;
  32.  
  33.     /**
  34.      * @since    2.1.0
  35.      *
  36.      * @var      object
  37.      */
  38.     public function __construct() {
  39.         add_action( 'init', array( &$this, 'load_plugin_textdomain' ) );
  40.         add_action( 'admin_footer', array( &$this, 'check_version' ) );
  41.         add_action( 'admin_footer', array( &$this, 'iframe_post_urls' ) );
  42.         add_action( 'admin_menu', array( &$this, 'add_menu' ) );
  43.         add_filter( 'tiny_mce_version', array( &$this, 'shortcodelic_refresh_mce' ) );
  44.         add_action( 'init', array( &$this, 'add_shortcodelic_buttons' ) );
  45.         add_filter( 'mce_css', array( &$this, 'add_tinymce_css' ) );
  46.         add_action( 'admin_enqueue_scripts', array( &$this, 'admin_styles' ) );
  47.         add_action( 'admin_enqueue_scripts', array( &$this, 'admin_scripts' ) );
  48.         add_action( 'add_meta_boxes', array( &$this, 'add_meta' ) );
  49.         add_action( 'save_post', array( &$this, 'content_save' ) );
  50.         add_action( 'wp_ajax_shortocodelic_data_save', array( &$this, 'save_via_ajax' ) );
  51.         add_action( 'wp_ajax_css_shortcodelic_ajax', array( &$this, 'compile_css_ajax' ) );
  52.         add_action( 'admin_head', array( &$this, 'remove_subpages' ) );
  53.         add_action( 'admin_head', array( &$this, 'js_vars' ) );
  54.         //add_action( 'loop_start', array( &$this, 'shortcodelic_remove_sharedaddy' ) );
  55.  
  56.         add_action( 'wp_ajax_shortcodelic_update_meta', array( &$this, 'ajax_update_meta' ) );
  57.         add_action( 'wp_ajax_shortcodelic_get_thumb', array( &$this, 'ajax_get_thumb' ) );
  58.         add_action( 'wp_ajax_shortcodelic_sanitize', array( &$this, 'sanitize_ajax' ) );
  59.         add_action( 'wp_ajax_download_css', array( &$this, 'download_css' ) );
  60.  
  61.         add_action( 'wp_enqueue_scripts', array( &$this, 'front_scripts' ) );
  62.         add_action( 'wp_enqueue_scripts', array( &$this, 'front_styles' ) );
  63.         add_action( 'wp_head', array( &$this, 'css_inline' ) );
  64.         add_action( 'wp_head', array( &$this, 'conditional_scripts' ) );
  65.         add_filter( 'body_class', array( &$this, 'body_class' ) );
  66.  
  67.         add_filter( 'the_content', array( &$this, 'filter_content' ), 10 );
  68.         //add_action( 'the_content', array( &$this, 'shortcodelic_append_sharedaddy' ));
  69.  
  70.         add_shortcode('shortcodelic-fontlist', array( &$this, 'fontIconPreview') );
  71.         add_shortcode('shortcodelic-slideshow', array( &$this, 'shortcodelicSlideshowSC') );
  72.         add_shortcode('shortcodelic-tabs', array( &$this, 'shortcodelicTabsSC') );
  73.         add_shortcode('shortcodelic-tables', array( &$this, 'shortcodelicTablesSC') );
  74.         add_shortcode('shortcodelic-maps', array( &$this, 'shortcodelicMapsSC') );
  75.         add_shortcode('shortcodelic-carousel', array( &$this, 'shortcodelicCarouselsSC') );
  76.         add_shortcode('shortcodelic-postcarousel', array( &$this, 'shortcodelicPostCarouselsSC') );
  77.         add_shortcode('shortcodelic-woocarousel', array( &$this, 'shortcodelicWooCarouselsSC') );
  78.         add_shortcode('shortcodelic-progress', array( &$this, 'shortcodelicProgressSC') );
  79.         add_shortcode('shortcodelic-box', array( &$this, 'shortcodelicBoxSC') );
  80.  
  81.         add_filter( 'manage_posts_columns', array( &$this, 'add_pp_col' ) );
  82.         add_action( 'manage_posts_custom_column', array( &$this, 'add_pp_value' ), 100, 2 );
  83.         add_filter( 'manage_page_posts_columns', array( &$this, 'add_pp_col' )  );
  84.         add_action( 'manage_page_posts_custom_column', array( &$this, 'add_pp_value' ), 100, 2 );
  85.  
  86.         add_filter( 'pre_set_site_transient_update_plugins', array( &$this, 'check_for_plugin_update' ));
  87.         add_filter( 'plugins_api', array( &$this, 'plugin_api_call' ), 10, 3);
  88.  
  89.     }
  90.  
  91.     /**
  92.      * Return an instance of this class.
  93.      *
  94.      * @since     1.0.0
  95.      *
  96.      * @return    object    A single instance of this class.
  97.      */
  98.     public static function get_instance() {
  99.  
  100.         // If the single instance hasn't been set, set it now.
  101.         if ( null == self::$instance ) {
  102.             self::$instance = new self;
  103.         }
  104.  
  105.         return self::$instance;
  106.     }
  107.  
  108.     /**
  109.      * Fired when the plugin is activated.
  110.      *
  111.      * @since    1.0.0
  112.      *
  113.      * @param    boolean    $network_wide    True if WPMU superadmin uses "Network Activate" action, false if WPMU is disabled or plugin is activated on an individual blog.
  114.      */
  115.     public static function activate( $network_wide ) {
  116.         self::add_general();
  117.         self::compile_css();
  118.     }
  119.  
  120.     /**
  121.      * Check last version and add new options and styles if necessary.
  122.      *
  123.      * @since    2.0.0
  124.      */
  125.     public function check_version() {
  126.         if ( get_option('shortcodelic_info_update')!=$this->version ) {
  127.             update_option('shortcodelic_info_update',$this->version);
  128.             self::add_general();
  129.             self::compile_css();
  130.         }
  131.     }
  132.  
  133.     /**
  134.      * Fired when the plugin is uninstall.
  135.      *
  136.      * @since    1.0.0
  137.      *
  138.      * @param    boolean    $network_wide    True if WPMU superadmin uses "Network Deactivate" action, false if WPMU is disabled or plugin is deactivated on an individual blog.
  139.      */
  140.     public static function uninstall( $network_wide ) {
  141.  
  142.         global $wpdb;
  143.         $options = self::register_options();
  144.         foreach ($options as $key => $value) {
  145.             $shortcodelic_id = $value['id'];
  146.             delete_option($shortcodelic_id);
  147.             $wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE '%shortcodelic_array%'");
  148.             $wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE '%shortcodelic_security%'");
  149.             $wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE '%shortcodelic_hidden%'");
  150.         }
  151.  
  152.         $results = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_content LIKE '%shortcodelic%' AND post_name NOT LIKE '%autosave%' AND post_name NOT LIKE '%revision%'");
  153.         foreach ( $results as $result )
  154.         {
  155.             $id = $result->ID;
  156.             $content = $result->post_content;
  157.             $content = preg_replace('/\[ *shortcodelic-slideshow([^\]])*\]/', '', $content);
  158.             $content = preg_replace('/\<(.*?) class=[\'"]scicon-(.*?)><\/(.*?)>/', '', $content);
  159.             $content = preg_replace('/\[ *shortcodelic-tabs([^\]])*\]/', '', $content);
  160.             $content = preg_replace('/\[ *shortcodelic-tables([^\]])*\]/', '', $content);
  161.             $content = preg_replace('/\[ *shortcodelic-maps([^\]])*\]/', '', $content);
  162.             $content = preg_replace('/\[ *shortcodelic-carousel([^\]])*\]/', '', $content);
  163.             $content = preg_replace('/\[ *shortcodelic-postcarousel([^\]])*\]/', '', $content);
  164.             $content = preg_replace('/\<span(.*?)data-tooltip(.*?)>(.*?)<\/span>/', '$3', $content);
  165.             $content = preg_replace('/\<(.*?)data-tooltip=[\'"](.*?)[\'"]([^\>])*\>(.*?)<\/(.*?)>/', '<$1$3>$4</$5>', $content);
  166.             $content = preg_replace('/\<(.*?)data-ttopts=[\'"](.*?)[\'"]([^\>])*\>(.*?)<\/(.*?)>/', '<$1$3>$4</$5>', $content);
  167.             $content = preg_replace('/\<span(.*?)buttonelic(.*?)>(.*?)<\/span>/', '$3', $content);
  168.             $content = preg_replace('/\<(.*?)buttonelic(.*?)>(.*?)<\/(.*?)>/', '<$1$2>$3</$4>', $content);
  169.             $content = preg_replace('/\<(.*?)data-style=[\'"](.*?)[\'"]([^\>])*\>(.*?)<\/(.*?)>/', '<$1$3>$4</$5>', $content);
  170.             $content = preg_replace('/\<(.*?)data-fontsize=[\'"](.*?)[\'"]([^\>])*\>(.*?)<\/(.*?)>/', '<$1$3>$4</$5>', $content);
  171.             $content = preg_replace('/\[ *shortcodelic-progress([^\]])*\](.*?)\[\/shortcodelic-progress\]/', '', $content);
  172.            
  173.             $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET post_content = %s WHERE ID = $id", $content ) );
  174.         }
  175.  
  176.         $post_types = get_post_types(array( 'public' => true ));  
  177.         $args = array(
  178.         'numberposts' => -1,
  179.         'post_type' => $post_types );
  180.  
  181.         $allposts = get_posts( $args );
  182.         foreach( $allposts as $postinfo ) {
  183.             delete_post_meta( $postinfo->ID, 'shortcodelic_slideshows' );
  184.             delete_post_meta( $postinfo->ID, 'shortcodelic_tabs' );
  185.             delete_post_meta( $postinfo->ID, 'shortcodelic_tables' );
  186.             delete_post_meta( $postinfo->ID, 'shortcodelic_maps' );
  187.             delete_post_meta( $postinfo->ID, 'shortcodelic_carousels' );
  188.             delete_post_meta( $postinfo->ID, 'shortcodelic_postcarousels' );
  189.             delete_post_meta( $postinfo->ID, 'shortcodelic_woocarousels' );
  190.         }
  191.     }
  192.  
  193.     /**
  194.      * Load text domain for translation.
  195.      *
  196.      * @since    1.0.0
  197.      */
  198.     public function load_plugin_textdomain() {
  199.  
  200.         $domain = $this->plugin_slug;
  201.         $locale = apply_filters( 'plugin_locale', get_locale(), $domain );
  202.  
  203.         load_textdomain( $domain, WP_LANG_DIR . '/' . $domain . '/' . $locale . '.mo' );
  204.         load_plugin_textdomain( $domain, FALSE, dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
  205.     }
  206.  
  207.     /**
  208.      * Register and enqueue front-end style sheets.
  209.      *
  210.      * @since    2.3.3
  211.      */
  212.     public function front_styles() {
  213.         global $post,
  214.             $sc_slideshine,
  215.             $blog_id;
  216.  
  217.         wp_register_style( $this->plugin_slug .'-fontello', SHORTCODELIC_URL.'css/shortcodelic-fontello.css' );
  218.         wp_register_style( $this->plugin_slug . '-tabs', SHORTCODELIC_URL.'css/tabs.css' );
  219.         wp_register_style( $this->plugin_slug . '-tables', SHORTCODELIC_URL.'css/tables.css' );
  220.         wp_register_style( $this->plugin_slug . '-maps', SHORTCODELIC_URL.'css/maps.css' );
  221.         wp_register_style( $this->plugin_slug . '-slideshine', SHORTCODELIC_URL.'css/slideshine.css' );
  222.         wp_register_style( $this->plugin_slug . '-carousel', SHORTCODELIC_URL.'css/carousel.css' );
  223.         wp_register_style( $this->plugin_slug . '-tooltipster', SHORTCODELIC_URL.'css/tooltipster.css' );
  224.         wp_register_style( $this->plugin_slug . '-progress', SHORTCODELIC_URL.'css/progress.css' );
  225.         wp_register_style( $this->plugin_slug . '-box', SHORTCODELIC_URL.'css/box.css' );
  226.  
  227.         wp_enqueue_style( $this->plugin_slug . '-fontello' );
  228.  
  229.         if ( get_option('shortcodelic_load_css_inline')!='true' ) {
  230.             if ( is_multisite() && $blog_id > 1 ) {
  231.                 $upload_dir = wp_upload_dir();
  232.                 $css_file = $upload_dir['baseurl'] .'/shortcodelic/shortcodelic_compiled.css';
  233.             } else {
  234.                 $css_file = SHORTCODELIC_URL.'css/shortcodelic_compiled.css';
  235.             }
  236.         }
  237.  
  238.         if ( get_option('shortcodelic_load_css_inline')!='true' && isset($css_file) ) {
  239.             wp_enqueue_style( $this->plugin_slug, $css_file, array(), $this->version );
  240.         } else {
  241.             $compile_style = self::inline_css();
  242.             $compile_style = str_replace(array("\r", "\n", "\t"), '', $compile_style);
  243.             wp_add_inline_style( $this->plugin_slug . '-fontello', $compile_style );
  244.         }
  245.  
  246.         if ( !$post )
  247.             return;
  248.  
  249.         $content = $post->post_content;
  250.         if ( preg_match( '#\[ *shortcodelic-slideshow([^\]])*\]#i', $content ) || preg_match( '#\[ *gallery([^\]])*\]#i', $content ) ) {
  251.             wp_enqueue_style( $this->plugin_slug . '-fontello' );
  252.             wp_enqueue_style( $this->plugin_slug . '-slideshine' );
  253.         }
  254.  
  255.         if ( preg_match( '#\[ *shortcodelic-tabs([^\]])*\]#i', $content ) ) {
  256.             wp_enqueue_style( $this->plugin_slug . '-box' );
  257.             wp_enqueue_style( $this->plugin_slug . '-progress' );
  258.             wp_enqueue_style( $this->plugin_slug . '-tooltipster' );
  259.             wp_enqueue_style( $this->plugin_slug . '-tables' );
  260.             wp_enqueue_style( $this->plugin_slug . '-maps' );
  261.             wp_enqueue_style( $this->plugin_slug . '-tabs' );
  262.         }
  263.  
  264.         if ( preg_match( '#\[ *shortcodelic-tables([^\]])*\]#i', $content ) ) {
  265.             wp_enqueue_style( $this->plugin_slug . '-tables' );
  266.             wp_enqueue_style( $this->plugin_slug . '-box' );
  267.             wp_enqueue_style( $this->plugin_slug . '-progress' );
  268.             wp_enqueue_style( $this->plugin_slug . '-tooltipster' );
  269.             wp_enqueue_style( $this->plugin_slug . '-maps' );
  270.             wp_enqueue_style( $this->plugin_slug . '-tabs' );
  271.         }
  272.  
  273.         if ( preg_match( '#\[ *shortcodelic-maps([^\]])*\]#i', $content ) ) {
  274.             wp_enqueue_style( $this->plugin_slug . '-maps' );
  275.         }
  276.  
  277.         if ( preg_match( '#\[ *shortcodelic-carousel([^\]])*\]#i', $content ) || preg_match( '#\[ *shortcodelic-postcarousel([^\]])*\]#i', $content ) ) {
  278.             wp_enqueue_style( $this->plugin_slug . '-carousel' );
  279.         }
  280.  
  281.         if ( preg_match( '#data-tooltip#i', $content ) ) {
  282.             wp_enqueue_style( $this->plugin_slug . '-tooltipster' );
  283.         }
  284.  
  285.         if ( preg_match( '#\[ *shortcodelic-progress([^\]])*\]#i', $content ) ) {
  286.             wp_enqueue_style( $this->plugin_slug . '-progress' );
  287.         }
  288.  
  289.         if ( preg_match( '#\[ *shortcodelic-box([^\]])*\]#i', $content ) ) {
  290.             wp_enqueue_style( $this->plugin_slug . '-box' );
  291.         }
  292.  
  293.     }
  294.  
  295.     /**
  296.      * Register and enqueue front-end scripts.
  297.      *
  298.      * @since    2.3.4
  299.      */
  300.     public function front_scripts() {
  301.         global $post,
  302.             $sc_slideshine;
  303.    
  304.         wp_register_script( 'pix-modernizr', SHORTCODELIC_URL.'scripts/modernizr.pix.js', array(), '2.6.2' );
  305.         wp_register_script( 'jquery-easing', SHORTCODELIC_URL.'scripts/jquery.easing.min.js', array('jquery') );
  306.        
  307.         wp_register_script( $this->plugin_slug . '-kinetic', SHORTCODELIC_URL.'scripts/jquery.kinetic.min.js', array('jquery'), '1.8.2' );
  308.         wp_register_script( $this->plugin_slug . '-transit', SHORTCODELIC_URL.'scripts/jquery.transit.js', array('jquery'), '0.9.9' );
  309.         wp_register_script( $this->plugin_slug . '-google-maps-api', '//maps.google.com/maps/api/js?sensor=true', $this->version );
  310.         wp_register_script( $this->plugin_slug . '-gmaps', SHORTCODELIC_URL.'scripts/gmaps.min.js', array('jquery', $this->plugin_slug . '-google-maps-api'), '0.4.5' );
  311.         wp_register_script( $this->plugin_slug . '-maps', SHORTCODELIC_URL.'scripts/maps.js', array('pix-modernizr','jquery',$this->plugin_slug.'-gmaps'));
  312.         wp_register_script( $this->plugin_slug . '-imagesloaded', SHORTCODELIC_URL.'scripts/imagesloaded.min.js', array('jquery'), '3.1.4');
  313.         wp_register_script( $this->plugin_slug . '-bxslider', SHORTCODELIC_URL.'scripts/jquery.bxslider.min.js', array('jquery',$this->plugin_slug.'-imagesloaded'), '4.1.1' );
  314.         wp_register_script( $this->plugin_slug . '-carousel', SHORTCODELIC_URL.'scripts/carousel.js', array('pix-modernizr','jquery',$this->plugin_slug.'-bxslider'));
  315.         wp_register_script( $this->plugin_slug . '-tooltipster', SHORTCODELIC_URL.'scripts/jquery.tooltipster.min.js', array('jquery'), '2.1.4' );
  316.         wp_register_script( $this->plugin_slug . '-tabs', SHORTCODELIC_URL.'scripts/tabs.js', array('pix-modernizr','jquery','jquery-easing',$this->plugin_slug . '-transit',$this->plugin_slug . '-plugins'));
  317.         wp_register_script( $this->plugin_slug . '-chart', SHORTCODELIC_URL.'scripts/Chart.js', array('jquery'), '' );
  318.         wp_register_script( $this->plugin_slug . '-cookie', SHORTCODELIC_URL.'scripts/jquery.cookie.js', array('jquery'), '1.4.0' );
  319.         wp_register_script( $this->plugin_slug . '-tooltips', SHORTCODELIC_URL.'scripts/tooltips.js', array('pix-modernizr','jquery',$this->plugin_slug.'-tooltipster'));
  320.         wp_register_script( $this->plugin_slug . '-slideshine', SHORTCODELIC_URL.'scripts/slideshine.js', array('pix-modernizr','jquery','jquery-ui-core','jquery-easing',$this->plugin_slug . '-transit',$this->plugin_slug . '-kinetic',$this->plugin_slug . '-plugins','jquery-ui-draggable'));
  321.         wp_enqueue_script( $this->plugin_slug . '-plugins', SHORTCODELIC_URL.'scripts/plugins.js', array('jquery'), $this->version );
  322.  
  323.         if ( !$post )
  324.             return;
  325.         $content = $post->post_content;
  326.  
  327.         if ( preg_match( '#\[ *shortcodelic-slideshow([^\]])*\]#i', $content ) || preg_match( '#\[ *gallery([^\]])*\]#i', $content ) ) {
  328.             wp_enqueue_script( $this->plugin_slug . '-slideshine' );
  329.         }
  330.  
  331.         if ( preg_match( '#\[ *shortcodelic-tabs([^\]])*\]#i', $content ) ) {
  332.             wp_enqueue_script( $this->plugin_slug . '-tabs' );
  333.         }
  334.  
  335.         if ( preg_match( '#\[ *shortcodelic-tables([^\]])*\]#i', $content ) ) {
  336.             wp_enqueue_script( $this->plugin_slug . '-tables', SHORTCODELIC_URL.'scripts/tables.js', array('pix-modernizr','jquery', $this->plugin_slug . '-tooltips'));
  337.         }
  338.  
  339.         if ( preg_match( '#\[ *shortcodelic-maps([^\]])*\]#i', $content ) ) {
  340.             wp_enqueue_script( $this->plugin_slug . '-maps' );
  341.         }
  342.  
  343.         if ( preg_match( '#\[ *shortcodelic-carousel([^\]])*\]#i', $content ) || preg_match( '#\[ *shortcodelic-postcarousel([^\]])*\]#i', $content ) ) {
  344.             wp_enqueue_script( $this->plugin_slug . '-carousel' );
  345.         }
  346.  
  347.         if ( preg_match( '#data-tooltip#i', $content ) ) {
  348.             wp_enqueue_script( $this->plugin_slug . '-tooltips' );
  349.         }
  350.  
  351.         if ( preg_match( '#\[ *shortcodelic-progress([^\]])*\]#i', $content ) ) {
  352.             wp_enqueue_script( $this->plugin_slug . '-progress', SHORTCODELIC_URL.'scripts/progress.js', array($this->plugin_slug.'-chart','pix-modernizr','jquery','jquery-easing',$this->plugin_slug . '-transit',$this->plugin_slug . '-plugins'));
  353.         }
  354.  
  355.         if ( preg_match( '#\[ *shortcodelic-box([^\]])*\]#i', $content ) ) {
  356.             wp_enqueue_script( $this->plugin_slug . '-box', SHORTCODELIC_URL.'scripts/box.js', array('pix-modernizr','jquery',$this->plugin_slug.'-cookie'));
  357.         }
  358.  
  359.     }
  360.  
  361.     /**
  362.      * Conditional scripts
  363.      *
  364.      * @since    1.0.0
  365.      */
  366.     public function conditional_scripts() {
  367.         echo '<!--[if lte IE 8]>
  368.     <script type="text/javascript" src="'.SHORTCODELIC_URL.'scripts/excanvas.js"></script>
  369. <![endif]-->
  370. ';
  371.     }
  372.  
  373.     /**
  374.      * Register and enqueue admin-specific style sheet.
  375.      *
  376.      * @since    1.0.0
  377.      */
  378.     public function admin_styles() {
  379.         global $pagenow;
  380.         if ( $pagenow == 'post.php' || $pagenow == 'post-new.php' ) {
  381.             wp_enqueue_style( 'wp-jquery-ui-dialog' );
  382.             wp_enqueue_style( 'wp-pointer' );
  383.             wp_enqueue_style( 'farbtastic' );
  384.             wp_enqueue_style( $this->plugin_slug .'-fontello', SHORTCODELIC_URL.'css/shortcodelic-fontello.css', array(), $this->version );
  385.             wp_enqueue_style( $this->plugin_slug .'-open-sans', SHORTCODELIC_URL.'css/open_sans.css', array(), $this->version );
  386.             wp_enqueue_style( $this->plugin_slug .'-meta', SHORTCODELIC_URL.'css/meta.css', array(), $this->version );
  387.         } elseif ( $pagenow == 'edit.php' ) {
  388.             wp_enqueue_style( $this->plugin_slug .'-fontello', SHORTCODELIC_URL.'css/shortcodelic-fontello.css', array(), $this->version );
  389.             wp_enqueue_style( $this->plugin_slug .'-columns', SHORTCODELIC_URL.'css/columns.css', array(), $this->version );
  390.         } elseif ('admin.php' == $pagenow && isset($_GET['page']) && $_GET['page']=='shortcodelic_admin') {
  391.             wp_enqueue_style( 'farbtastic' );
  392.             wp_enqueue_style( 'wp-jquery-ui-dialog' );
  393.             wp_enqueue_style( $this->plugin_slug .'-codemirror', SHORTCODELIC_URL.'css/codemirror.css', array(), $this->version );
  394.             wp_enqueue_style( $this->plugin_slug .'-codemirror-skin', SHORTCODELIC_URL.'css/codemirror-skin.css', array(), $this->version );
  395.             wp_enqueue_style( $this->plugin_slug .'-fontello', SHORTCODELIC_URL.'css/shortcodelic-fontello.css', array(), $this->version );
  396.             wp_enqueue_style( $this->plugin_slug .'-open-sans', SHORTCODELIC_URL.'css/open_sans.css', array(), $this->version );
  397.             wp_enqueue_style( $this->plugin_slug .'-admin', SHORTCODELIC_URL.'css/admin.css', array(), $this->version );
  398.         }
  399.     }
  400.  
  401.     /**
  402.      * Register and enqueue admin-specific scripts.
  403.      *
  404.      * @since    2.4.2
  405.      */
  406.     public function admin_scripts() {
  407.         global $pagenow;
  408.         if ( $pagenow == 'post.php' || $pagenow == 'post-new.php' ) {
  409.             wp_enqueue_script( 'wp-pointer' );
  410.             wp_enqueue_script( 'farbtastic' );
  411.             wp_enqueue_script( 'pix-modernizr', SHORTCODELIC_URL.'scripts/modernizr.pix.js', array(), '2.6.2' );
  412.             wp_enqueue_script( $this->plugin_slug . '-ui-touch-punch', SHORTCODELIC_URL.'scripts/jquery.ui.touch-punch.min.js', array('jquery-ui-mouse'), '0.2.2', false );
  413.             wp_enqueue_script( $this->plugin_slug . '-meta', SHORTCODELIC_URL.'scripts/meta.js', array('pix-modernizr','farbtastic','jquery','jquery-ui-core','wp-pointer',$this->plugin_slug.'-ui-touch-punch','jquery-ui-slider','jquery-ui-sortable','jquery-ui-resizable','jquery-ui-dialog','jquery-ui-draggable') );
  414.         } elseif ('admin.php' == $pagenow && isset($_GET['page']) && $_GET['page']=='shortcodelic_admin') {
  415.             wp_enqueue_script( 'farbtastic' );
  416.             wp_enqueue_script( 'pix-modernizr', SHORTCODELIC_URL.'scripts/modernizr.pix.js', array(), '2.6.2' );
  417.             wp_enqueue_script( $this->plugin_slug . '-ui-touch-punch', SHORTCODELIC_URL.'scripts/jquery.ui.touch-punch.min.js', array('jquery-ui-mouse'), '0.2.2', false );
  418.             //wp_enqueue_script( $this->plugin_slug . '-ui-slider', SHORTCODELIC_URL.'scripts/jquery.ui.slider.js', array('jquery-ui-core','jquery-ui-mouse','jquery-ui-widget') );
  419.             wp_enqueue_script( $this->plugin_slug . '-codemirror', SHORTCODELIC_URL.'scripts/codemirror.js', array('jquery'), '3.14', false );
  420.             wp_enqueue_script( $this->plugin_slug . '-css-mode', SHORTCODELIC_URL.'scripts/css.js', array($this->plugin_slug.'-codemirror'), '3.14', false );
  421.             wp_enqueue_script( $this->plugin_slug . '-livequery', SHORTCODELIC_URL.'scripts/jquery.livequery.js', array('jquery'), '1.1.1', false );
  422.             wp_enqueue_script( $this->plugin_slug . '-easing', SHORTCODELIC_URL.'scripts/jquery.easing.min.js', array('jquery'), '1.3', false );
  423.             wp_enqueue_script( $this->plugin_slug . '-admin', SHORTCODELIC_URL.'scripts/admin.js', array('pix-modernizr','jquery','jquery-ui-core',$this->plugin_slug.'-ui-touch-punch','jquery-ui-sortable','jquery-ui-draggable','jquery-ui-droppable','jquery-ui-slider',$this->plugin_slug.'-css-mode',$this->plugin_slug . '-livequery', $this->plugin_slug.'-easing','jquery-ui-dialog'));
  424.         }
  425.     }
  426.  
  427.     /**
  428.      * Add the class "shortcodelic" to the front-end body
  429.      *
  430.      * @since    1.0.0
  431.      */
  432.     public function body_class($classes) {
  433.         $classes[] = 'shortcodelic';
  434.         return $classes;
  435.     }
  436.  
  437.  
  438.     /**
  439.      * Add the metaboxes: the grid builder and its tabs to switch between builder and preview.
  440.      *
  441.      * @since    1.0.0
  442.      */
  443.     public function add_meta() {
  444.         global $post;
  445.         $typenow = get_post_type();
  446.  
  447.         if (!function_exists('shortcodelic_shortcode_generator')) {
  448.             add_meta_box( 'shortcodelic_shortcode_generator', 'ShortCodelic Shortcode Generator', 'shortcodelic_shortcode_generator', $typenow, 'normal', 'low' );
  449.             function shortcodelic_shortcode_generator( $post, $display ) {
  450.                 require_once( SHORTCODELIC_PATH.'lib/shortcode_generator.php' );
  451.             }
  452.         }
  453.  
  454.     }
  455.  
  456.     /**
  457.      * Save the data sent thorugh metaboxes.
  458.      *
  459.      * @since    1.0.0
  460.      */
  461.     public function content_save( $post_id ) {
  462.         if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;
  463.  
  464.         foreach ($_POST as $key => $value) {
  465.             if ( preg_match("/shortcodelic_(.+)_nonce/", $key) ) {
  466.                 if( !isset( $_POST[$key] ) || !wp_verify_nonce( $_POST[$key], $key ) ) return;
  467.  
  468.                 if( !current_user_can( 'edit_post', $post_id ) ) return;
  469.  
  470.                 $meta_key = str_replace("_nonce", "", $key);
  471.  
  472.                 $meta_value = $_POST[$meta_key];
  473.                 $meta_value = preg_replace_callback('/s:(\d+):"(.*?)\[(.*?)\]";/s', 'shortcodelic_preg_callback_meta_value_json_quotes', $meta_value);
  474.                
  475.                 if( isset( $_POST[$meta_key] ) )
  476.                     update_post_meta( $post_id, $meta_key, $meta_value );
  477.             }
  478.         }
  479.            
  480.     }
  481.  
  482.     /**
  483.      * Replace the html comments in the post content to create the grid
  484.      *
  485.      * @since    1.0.0
  486.      *
  487.      */
  488.     public function filter_content($content) {
  489.  
  490.         if (!function_exists('shortcodelic_match_quotes')) {
  491.             function shortcodelic_match_quotes($matches) {
  492.                 return preg_replace('/&quot;/','"',$matches[0]);
  493.                 $icopts = json_decode($matches[0]);
  494.             }
  495.         }
  496.  
  497.         if (!function_exists('shortcodelic_match_quotes_2')) {
  498.             function shortcodelic_match_quotes_2($matches) {
  499.                 $icopts = json_decode($matches[1]);
  500.                 $icoin = '';
  501.                 $icoout = '';
  502.                 if ( isset($icopts->style) ) {
  503.                     $icoout .= 'data-style="'.$icopts->style.'" ';
  504.                 }
  505.                 if ( isset($icopts->size) ) {
  506.                     $icoin .= 'font-size:'.$icopts->size.'px;';
  507.                 }
  508.                 if ( isset($icopts->color) ) {
  509.                     $icoin .= 'color:'.$icopts->color.';';
  510.                 }
  511.                 if ( isset($icopts->bg) ) {
  512.                     if ( isset($icopts->style) && $icopts->style=='disc' ) {
  513.                         $icoin .= 'background-color:'.$icopts->bg.';';
  514.                     } elseif ( isset($icopts->style) && $icopts->style=='circle' ) {
  515.                         $icoin .= 'border-color:'.$icopts->color.';';
  516.                     }
  517.                 }
  518.                 if ( $icoin!='' ) {
  519.                     $icoout .= 'style="'.$icoin.'"';
  520.                 }
  521.                 return $icoout;
  522.             }
  523.         }
  524.  
  525.         /*$content = preg_replace('/\"\{\"(.*?)\"\}\"/', '\'{"$1"}\'', $content);
  526.         $content = preg_replace('/<p>\[shortcodelic-(.*?)\]<\/p>/', '[shortcodelic-$1]', $content);
  527.         $content = preg_replace('/<p>\[\/shortcodelic-(.*?)\]<\/p>/', '[shortcodelic-$1]', $content);
  528.         $content = preg_replace('/<span (.*?)><\/p>/', '<span $1>', $content);
  529.         $content = preg_replace('/<div (.*?)><\/p>/', '<div $1>', $content);
  530.         $content = preg_replace('/<p><\/span>/', '</span>', $content);
  531.         $content = preg_replace('/<p><\/div>/', '</div>', $content);
  532.         $content = preg_replace('/<p>\[shortcodelic-(.*?)\]<\/p>/', '[shortcodelic-$1]', $content);
  533.         $content = preg_replace('/\[shortcodelic-(.*?)\]<\/p>/', '</p>[shortcodelic-$1]', $content);
  534.         $content = preg_replace('/<p>\[\/shortcodelic-(.*?)\]<\/p>/', '[/shortcodelic-$1]', $content);
  535.         $content = preg_replace('/<p>\[shortcodelic-(.*?)\]/', '[shortcodelic-$1]', $content);
  536.         $content = preg_replace('/\[\/shortcodelic-(.*?)\]<\/p>/', '[/shortcodelic-$1]', $content);*/
  537.         $content = preg_replace('/<p>\[shortcodelic-box(.*?)\](.*?)\[\/shortcodelic-box\]<\/p>/s', '[shortcodelic-box$1]$2[/shortcodelic-box]', $content);
  538.         $content = preg_replace('/<p>\[shortcodelic-slideshow(.*?)\]<\/p>/', '[shortcodelic-slideshow$1]', $content);
  539.         $content = preg_replace('/<p>\[shortcodelic-tabs(.*?)\]<\/p>/', '[shortcodelic-tabs$1]', $content);
  540.         $content = preg_replace('/<p>\[shortcodelic-tables(.*?)\]<\/p>/', '[shortcodelic-tables$1]', $content);
  541.         $content = preg_replace('/<p>\[shortcodelic-maps(.*?)\]<\/p>/', '[shortcodelic-maps$1]', $content);
  542.         $content = preg_replace('/<p>\[shortcodelic-carousel(.*?)\]<\/p>/', '[shortcodelic-carousel$1]', $content);
  543.         $content = preg_replace('/<p>\[shortcodelic-postcarousel(.*?)\]<\/p>/', '[shortcodelic-postcarousel$1]', $content);
  544.         $content = preg_replace('/<p>\[shortcodelic-woocarousel(.*?)\]<\/p>/', '[shortcodelic-woocarousel$1]', $content);
  545.         $content = preg_replace('/<p>\[shortcodelic-progress(.*?)\]<\/p>/', '[shortcodelic-progress$1]', $content);
  546.         $content = preg_replace('/\<(.*?) class=([\'|"])scicon-(.*?)>(.*?)<\/(.*?)>/', '<$1 class=$2scicon-$3></$5>', $content);
  547.         $content = preg_replace_callback(
  548.             '/data-icopts=([\'|"]){(.*?)}([\'|"])/',
  549.             'shortcodelic_match_quotes',
  550.             $content
  551.         );
  552.         $content = preg_replace('/data-icopts=([\'|"]){(.*?)}([\'|"])/', 'data-icopts=\'{$2}\'', $content);
  553.         $content = preg_replace_callback(
  554.             '/data-icopts=\'(.*?)\'/',
  555.             'shortcodelic_match_quotes_2',
  556.             $content
  557.         );
  558.  
  559.         return $content;
  560.     }
  561.  
  562.     /**
  563.      * Add plugin menu.
  564.      *
  565.      * @since    1.0.0
  566.      */
  567.     public function add_menu() {
  568.         if (function_exists('add_options_page')) {
  569.             add_menu_page($this->plugin_name, $this->plugin_name, 'activate_plugins', 'shortcodelic_admin', array( $this, 'register_options' ));
  570.             add_submenu_page('shortcodelic_admin', 'Very general', 'Very general', 'activate_plugins', 'shortcodelic_verygeneral', array( $this, 'register_options' ));
  571.             add_submenu_page('shortcodelic_admin', 'Register', 'Register', 'activate_plugins', 'shortcodelic_register', array( $this, 'register_options' ));
  572.             add_submenu_page('shortcodelic_admin', 'Slideshows', 'Slideshows', 'activate_plugins', 'shortcodelic_slideshows', array( $this, 'register_options' ));
  573.             add_submenu_page('shortcodelic_admin', 'Tabs', 'Tabs', 'activate_plugins', 'shortcodelic_tabs', array( $this, 'register_options' ));
  574.             add_submenu_page('shortcodelic_admin', 'Tables', 'Tables', 'activate_plugins', 'shortcodelic_tables', array( $this, 'register_options' ));
  575.             add_submenu_page('shortcodelic_admin', 'Carousels', 'Carousels', 'activate_plugins', 'shortcodelic_carousels', array( $this, 'register_options' ));
  576.             add_submenu_page('shortcodelic_admin', 'Tooltips', 'Tooltips', 'activate_plugins', 'shortcodelic_tooltips', array( $this, 'register_options' ));
  577.             add_submenu_page('shortcodelic_admin', 'Progress bars', 'Progress bars', 'activate_plugins', 'shortcodelic_progress', array( $this, 'register_options' ));
  578.             add_submenu_page('shortcodelic_admin', 'Buttons', 'Buttons', 'activate_plugins', 'shortcodelic_buttons', array( $this, 'register_options' ));
  579.             add_submenu_page('shortcodelic_admin', 'Text boxes', 'Text boxes', 'activate_plugins', 'shortcodelic_boxes', array( $this, 'register_options' ));
  580.             add_submenu_page('shortcodelic_admin', 'Compile CSS file', 'Compile CSS file', 'activate_plugins', 'shortcodelic_css', array( $this, 'register_options' ));
  581.         }
  582.     }
  583.  
  584.     /**
  585.      * Options.
  586.      *
  587.      * @since    1.0.0
  588.      */
  589.     public static function register_options() {
  590.         global $options;
  591.  
  592.         $shortCodelic = new ShortCodelic();
  593.         $version = $shortCodelic->version;
  594.  
  595.         $page_template = locate_template( array( 'page.php' ) );
  596.         $shortcodelic_post_type = (!empty($page_template)) ? array("page" => "page") : '';
  597.  
  598.         if (!empty($page_template)) {
  599.             $shortcodelic_page_template['default'] = 'default';
  600.         }
  601.         $templates = get_page_templates();
  602.         $shortcodelic_page_template = array();
  603.         foreach ( $templates as $template_name => $template_filename ) {
  604.             $shortcodelic_page_template[$template_filename] = $template_filename;
  605.         }
  606.  
  607.         $options = array (
  608.             array( "id" => "shortcodelic_info_update",
  609.                 "std" => $version),
  610.             array( "id" => "shortcodelic_allow_ajax",
  611.                 "std" => "true"),
  612.             array( "id" => "shortcodelic_no_trace",
  613.                 "std" => "0"),
  614.             array( "id" => "shortcodelic_user_name",
  615.                 "std" => ""),
  616.             array( "id" => "shortcodelic_license_key",
  617.                 "std" => ""),
  618.             array( "id" => "shortcodelic_slideshow_main_color",
  619.                 "std" => "#ffffff"),
  620.             array( "id" => "shortcodelic_slideshow_bg_color",
  621.                 "std" => "#000000"),
  622.             array( "id" => "shortcodelic_slideshow_opacity",
  623.                 "std" => "0.2"),
  624.             array( "id" => "shortcodelic_slide_bg_color",
  625.                 "std" => "#ffffff"),
  626.             array( "id" => "shortcodelic_slide_opacity",
  627.                 "std" => "0"),
  628.             array( "id" => "shortcodelic_tab_border_color",
  629.                 "std" => "#eeeeee"),
  630.             array( "id" => "shortcodelic_tab_bg_color",
  631.                 "std" => "#fafafa"),
  632.             array( "id" => "shortcodelic_tab_color",
  633.                 "std" => "#21759b"),
  634.             array( "id" => "shortcodelic_tab_border_width",
  635.                 "std" => "1"),
  636.             array( "id" => "shortcodelic_panel_bg_color",
  637.                 "std" => "#ffffff"),
  638.             array( "id" => "shortcodelic_panel_text_color",
  639.                 "std" => "#444444"),
  640.             array( "id" => "shortcodelic_heading_border_color",
  641.                 "std" => "#ed7c57"),
  642.             array( "id" => "shortcodelic_heading_background_color",
  643.                 "std" => "#d94839"),
  644.             array( "id" => "shortcodelic_heading_border_width",
  645.                 "std" => "1"),
  646.             array( "id" => "shortcodelic_heading_text_color",
  647.                 "std" => "#ffffff"),
  648.             array( "id" => "shortcodelic_pricing_border_color",
  649.                 "std" => "#d94839"),
  650.             array( "id" => "shortcodelic_pricing_background_color",
  651.                 "std" => "#b32516"),
  652.             array( "id" => "shortcodelic_pricing_border_width",
  653.                 "std" => "1"),
  654.             array( "id" => "shortcodelic_pricing_text_color",
  655.                 "std" => "#ffffff"),
  656.             array( "id" => "shortcodelic_pricetable_border_color",
  657.                 "std" => "#dddddd"),
  658.             array( "id" => "shortcodelic_pricetable_background_color",
  659.                 "std" => "#ffffff"),
  660.             array( "id" => "shortcodelic_pricetable_text_color",
  661.                 "std" => "#252525"),
  662.             array( "id" => "shortcodelic_pricetable_border_color_alt",
  663.                 "std" => "#dddddd"),
  664.             array( "id" => "shortcodelic_pricetable_border_width",
  665.                 "std" => "1"),
  666.             array( "id" => "shortcodelic_pricetable_background_color_alt",
  667.                 "std" => "#fafafa"),
  668.             array( "id" => "shortcodelic_pricetable_text_color_alt",
  669.                 "std" => "#252525"),
  670.             array( "id" => "shortcodelic_pricetable_gutter",
  671.                 "std" => "30"),
  672.             array( "id" => "shortcodelic_table_border_color",
  673.                 "std" => "#dddddd"),
  674.             array( "id" => "shortcodelic_table_background_color",
  675.                 "std" => "#ffffff"),
  676.             array( "id" => "shortcodelic_table_text_color",
  677.                 "std" => "#252525"),
  678.             array( "id" => "shortcodelic_table_border_color_alt",
  679.                 "std" => "#dddddd"),
  680.             array( "id" => "shortcodelic_table_border_width",
  681.                 "std" => "1"),
  682.             array( "id" => "shortcodelic_table_background_color_alt",
  683.                 "std" => "#fafafa"),
  684.             array( "id" => "shortcodelic_table_text_color_alt",
  685.                 "std" => "#252525"),
  686.             array( "id" => "shortcodelic_carousel_commands_fore",
  687.                 "std" => "#ffffff"),
  688.             array( "id" => "shortcodelic_carousel_commands_bg",
  689.                 "std" => "#000000"),
  690.             array( "id" => "shortcodelic_carousel_commands_opacity",
  691.                 "std" => "0.2"),
  692.             array( "id" => "shortcodelic_carousel_nav",
  693.                 "std" => "#eeeeee"),
  694.             array( "id" => "shortcodelic_tooltip_color",
  695.                 "std" => "#eeeeee"),
  696.             array( "id" => "shortcodelic_tooltip_link",
  697.                 "std" => "#56d8f5"),
  698.             array( "id" => "shortcodelic_tooltip_bg",
  699.                 "std" => "#333333"),
  700.             array( "id" => "shortcodelic_tooltip_radius",
  701.                 "std" => "2"),
  702.             array( "id" => "shortcodelic_tooltip_border",
  703.                 "std" => "2"),
  704.             array( "id" => "shortcodelic_tooltip_border_color",
  705.                 "std" => "#222222"),
  706.             array( "id" => "shortcodelic_tooltip_shadow_size",
  707.                 "std" => "5"),
  708.             array( "id" => "shortcodelic_tooltip_shadow_color",
  709.                 "std" => "#000000"),
  710.             array( "id" => "shortcodelic_tooltip_shadow_opacity",
  711.                 "std" => "0.3"),
  712.             array( "id" => "shortcodelic_progress_tooltip_bg",
  713.                 "std" => "#222222"),
  714.             array( "id" => "shortcodelic_progress_tooltip_color",
  715.                 "std" => "#eeeeee"),
  716.             array( "id" => "shortcodelic_css_code",
  717.                 "std" => '\/* Shortcodelic custom stylesheet *\/'),
  718.             array( "id" => "shortcodelic_load_css_inline",
  719.                 "std" => 'true')
  720.         );
  721.        
  722.         self::shortcodelic_admin( array( &$this, 'register_options' ) );
  723.         self::shortcodelic_verygeneral( array( &$this, 'register_options' ) );
  724.         self::shortcodelic_register( array( &$this, 'register_options' ) );
  725.         self::shortcodelic_slideshows( array( &$this, 'register_options' ) );
  726.         self::shortcodelic_tabs( array( &$this, 'register_options' ) );
  727.         self::shortcodelic_tables( array( &$this, 'register_options' ) );
  728.         self::shortcodelic_carousels( array( &$this, 'register_options' ) );
  729.         self::shortcodelic_tooltips( array( &$this, 'register_options' ) );
  730.         self::shortcodelic_progress( array( &$this, 'register_options' ) );
  731.         self::shortcodelic_buttons( array( &$this, 'register_options' ) );
  732.         self::shortcodelic_boxes( array( &$this, 'register_options' ) );
  733.         self::shortcodelic_css( array( &$this, 'register_options' ) );
  734.  
  735.         return $options;
  736.     }
  737.  
  738.     /**
  739.      * Display the menu for admin panel.
  740.      *
  741.      * @since    1.0.0
  742.      */
  743.     public static function shortcodelic_admin() {
  744.         require_once( SHORTCODELIC_PATH . 'lib/admin/panel.php' );
  745.     }
  746.  
  747.     /**
  748.      * Display the general admin page.
  749.      *
  750.      * @since    1.0.0
  751.      */
  752.     public static function shortcodelic_verygeneral() {
  753.         require_once( SHORTCODELIC_PATH . 'lib/admin/general.php' );
  754.     }
  755.  
  756.     /**
  757.      * Display the slideshow default options.
  758.      *
  759.      * @since    1.0.0
  760.      */
  761.     public static function shortcodelic_slideshows() {
  762.         require_once( SHORTCODELIC_PATH . 'lib/admin/slideshows.php' );
  763.     }
  764.  
  765.     /**
  766.      * Display the tab default options.
  767.      *
  768.      * @since    1.0.0
  769.      */
  770.     public static function shortcodelic_tabs() {
  771.         require_once( SHORTCODELIC_PATH . 'lib/admin/tabs.php' );
  772.     }
  773.  
  774.     /**
  775.      * Display the table default options.
  776.      *
  777.      * @since    1.0.0
  778.      */
  779.     public static function shortcodelic_tables() {
  780.         require_once( SHORTCODELIC_PATH . 'lib/admin/tables.php' );
  781.     }
  782.  
  783.     /**
  784.      * Display the carousel default options.
  785.      *
  786.      * @since    1.0.0
  787.      */
  788.     public static function shortcodelic_carousels() {
  789.         require_once( SHORTCODELIC_PATH . 'lib/admin/carousels.php' );
  790.     }
  791.  
  792.     /**
  793.      * Display the tooltip default options.
  794.      *
  795.      * @since    1.0.0
  796.      */
  797.     public static function shortcodelic_tooltips() {
  798.         require_once( SHORTCODELIC_PATH . 'lib/admin/tooltips.php' );
  799.     }
  800.  
  801.     /**
  802.      * Display the progress bar default options.
  803.      *
  804.      * @since    1.0.0
  805.      */
  806.     public static function shortcodelic_progress() {
  807.         require_once( SHORTCODELIC_PATH . 'lib/admin/progress.php' );
  808.     }
  809.  
  810.     /**
  811.      * Display the buttons default options.
  812.      *
  813.      * @since    1.0.0
  814.      */
  815.     public static function shortcodelic_buttons() {
  816.         require_once( SHORTCODELIC_PATH . 'lib/admin/buttons.php' );
  817.     }
  818.  
  819.     /**
  820.      * Display the text boxes default options.
  821.      *
  822.      * @since    1.0.0
  823.      */
  824.     public static function shortcodelic_boxes() {
  825.         require_once( SHORTCODELIC_PATH . 'lib/admin/boxes.php' );
  826.     }
  827.  
  828.     /**
  829.      * Display the register form.
  830.      *
  831.      * @since    1.0.0
  832.      */
  833.     public static function shortcodelic_register() {
  834.         require_once( SHORTCODELIC_PATH . 'lib/admin/register.php' );
  835.     }
  836.  
  837.     /**
  838.      * Display the CSS compiler.
  839.      *
  840.      * @since    1.0.0
  841.      */
  842.     public static function shortcodelic_css() {
  843.         require_once( SHORTCODELIC_PATH . 'lib/admin/css.php' );
  844.     }
  845.  
  846.     /**
  847.      * Register options in the database.
  848.      *
  849.      * @since    1.0.0
  850.      */
  851.     public static function add_general() {
  852.         global $options;
  853.         self::register_options();
  854.        
  855.         foreach ($options as $value) :
  856.             if(!get_option($value['id'])){
  857.                 add_option($value['id'], $value['std']);
  858.             }
  859.         endforeach;
  860.     }
  861.  
  862.     /**
  863.      * Save the options on the admin panel via AJAX.
  864.      *
  865.      * @since    1.0.0
  866.      */
  867.     public function save_via_ajax() {
  868.         global $options;
  869.         check_ajax_referer('shortcodelic_data', 'shortcodelic_security');
  870.  
  871.         $data = $_POST;
  872.         unset($data['shortcodelic_security'], $data['action']);
  873.  
  874.         foreach ($_REQUEST as $key => $value) {
  875.             if ( preg_match("/shortcodelic_array/", $key) ) {
  876.                 delete_option($key);
  877.                 if(!get_option($key)) {
  878.                     add_option($key, $value);
  879.                 } else {
  880.                     update_option($key, $value);
  881.                 }
  882.             }
  883.         }
  884.        
  885.         foreach ($_REQUEST as $key => $value) {
  886.             if( isset($_REQUEST[$key]) ) {
  887.                 update_option($key, $value);
  888.             }
  889.         }      
  890.     }
  891.  
  892.     /**
  893.      * Remove the subpages via CSS.
  894.      *
  895.      * @since    1.0.0
  896.      */
  897.     public function remove_subpages() { ?>
  898.         <style type="text/css" media="screen">
  899.             #toplevel_page_shortcodelic_admin ul, #toplevel_page_shortcodelic_admin .wp-menu-toggle, #toplevel_page_shortcodelic_admin .wp-submenu, #toplevel_page_shortcodelic_admin.wp-not-current-submenu .wp-menu-arrow {
  900.                 display: none!important;
  901.             }
  902.         </style>
  903.     <?php }
  904.  
  905.     /**
  906.      * Set the content width as JS var.
  907.      *
  908.      * @since    1.0.0
  909.      */
  910.     public function js_vars() {
  911.         global $content_width, $post, $pagenow;
  912.  
  913.         if ( ! isset( $content_width ) ) $content_width = 1280;
  914.  
  915.         if ( $pagenow == 'post.php' || $pagenow == 'post-new.php' ) {
  916.  
  917.         ?>
  918.  
  919.         <script type="text/javascript">
  920.         //<![CDATA[
  921.             var shortcodelic_content_width = "<?php echo $content_width; ?>", shortcodelic_url = "<?php echo SHORTCODELIC_URL; ?>", pix_post_id = "<?php echo $post->ID; ?>", pix_referer = "<?php echo wp_get_referer(); ?>", shortcodelic_modal = "close", shortcodelic_video_icon = "<?php echo SHORTCODELIC_URL; ?>images/video-icon.svg";
  922.         //]]>
  923.         </script>
  924.  
  925.         <?php
  926.         }
  927.     }
  928.  
  929.     /**
  930.      * Style loader for the slideshow preview.
  931.      *
  932.      * @since    2.1.0
  933.      */
  934.     public function iframe_post_urls() {
  935.  
  936.         $wpload = get_home_path().'/wp-load.php';
  937.  
  938.         echo '<form name="shortcodelic_send_url" id="shortcodelic_send_url" method="post" target="shortcodelic_preview_iframe" action="' . SHORTCODELIC_URL . 'lib/slideshow-preview.php" style="display:none">
  939.             <input type="hidden" name="wpload" value="' . $wpload . '">
  940.             <input type="submit">
  941.         </form>';
  942.  
  943.     }
  944.  
  945.     /**
  946.      * The inline css compiler.
  947.      *
  948.      * @since    3.2.0
  949.      */
  950.     public static function css_inline() {
  951.  
  952.         $target_file = SHORTCODELIC_PATH.'lib/push.php';
  953.  
  954.         ob_start();
  955.         require($target_file);
  956.         $css = ob_get_clean();
  957.  
  958.         if ( get_option('shortcodelic_load_css_inline')=='true' )
  959.             echo '<style>'.$css.'</style>';
  960.  
  961.     }
  962.  
  963.  
  964.     /**
  965.      * The css compiler.
  966.      *
  967.      * @since    2.0.0
  968.      */
  969.     public static function compile_css() {
  970.  
  971.         do_action('schortcodelic_css_compiling');
  972.  
  973.         WP_Filesystem();
  974.         global $wp_filesystem, $blog_id;
  975.  
  976.         if ( is_multisite() && $blog_id > 1 ) {
  977.             $upload_dir = wp_upload_dir();
  978.             $dir = $upload_dir['basedir'] .'/shortcodelic/';
  979.             if (!is_dir($dir))
  980.                 @mkdir($dir);
  981.            
  982.             $css_file = $dir . '/shortcodelic_compiled.css';
  983.         } else {
  984.             $css_file = SHORTCODELIC_PATH . 'css/shortcodelic_compiled.css';
  985.         }
  986.         $target_file = SHORTCODELIC_PATH.'lib/push.php';
  987.  
  988.         ob_start();
  989.         require($target_file);
  990.         $css = ob_get_clean();
  991.  
  992.         $wp_filesystem->put_contents( $css_file, $css, FS_CHMOD_FILE );
  993.  
  994.     }
  995.  
  996.  
  997.     /**
  998.      * The css compiler via AJAX.
  999.      *
  1000.      * @since    2.0.0
  1001.      */
  1002.     public function compile_css_ajax() {
  1003.  
  1004.         do_action('schortcodelic_css_ajax_compiling');
  1005.  
  1006.         WP_Filesystem();
  1007.         global $wp_filesystem, $blog_id;
  1008.  
  1009.         if ( is_multisite() && $blog_id > 1 ) {
  1010.             $upload_dir = wp_upload_dir();
  1011.             $dir = $upload_dir['basedir'] .'/shortcodelic/';
  1012.             if (!is_dir($dir))
  1013.                 @mkdir($dir);
  1014.            
  1015.             $css_file = $dir . '/shortcodelic_compiled.css';
  1016.         } else {
  1017.             $css_file = SHORTCODELIC_PATH . 'css/shortcodelic_compiled.css';
  1018.         }
  1019.         $target_file = SHORTCODELIC_PATH.'lib/push.php';
  1020.  
  1021.         ob_start();
  1022.         require($target_file);
  1023.         $css = ob_get_clean();
  1024.  
  1025.         $wp_filesystem->put_contents( $css_file, $css, FS_CHMOD_FILE );
  1026.  
  1027.         die();
  1028.     }
  1029.  
  1030.     /**
  1031.      * Add custom stylesheet to tinyMCE.
  1032.      *
  1033.      * @since    1.0.0
  1034.      */
  1035.     public static function add_tinymce_css($wp) {
  1036.         $wp .= ',' . SHORTCODELIC_URL . 'css/tinymce.css,' . SHORTCODELIC_URL . 'css/shortcodelic-fontello.css';
  1037.         return $wp;
  1038.     }
  1039.  
  1040.     /**
  1041.      * Sanitize titles via AJAX.
  1042.      *
  1043.      * @since    1.0.0
  1044.      */
  1045.     public static function sanitize_ajax() {
  1046.         $title = sanitize_title($_POST['title']);
  1047.         echo $title;
  1048.         die();
  1049.     }
  1050.  
  1051.     /**
  1052.      * Download custom CSS.
  1053.      *
  1054.      * @since    1.0.0
  1055.      */
  1056.     public static function download_css() {
  1057.         $target_file = SHORTCODELIC_PATH.'lib/push.php';
  1058.         ob_start();
  1059.         require($target_file);
  1060.         $css = ob_get_clean();
  1061.         echo $css;
  1062.         die();
  1063.     }
  1064.  
  1065.     /**
  1066.      * Download custom CSS.
  1067.      *
  1068.      * @since    1.0.0
  1069.      */
  1070.     public static function inline_css() {
  1071.         $target_file = SHORTCODELIC_PATH.'lib/push.php';
  1072.         ob_start();
  1073.         require($target_file);
  1074.         $css = ob_get_clean();
  1075.         return $css;
  1076.     }
  1077.  
  1078. /*=========================================================================================*/
  1079.  
  1080.     /**
  1081.      * Set the button on tinyMCE editor.
  1082.      *
  1083.      * @since    2.1.0
  1084.      */
  1085.     /**
  1086.      * Set the button on tinyMCE editor.
  1087.      *
  1088.      * @since    1.0.0
  1089.      */
  1090.     function add_shortcodelic_buttons() {
  1091.  
  1092.         global $post, $pagenow;
  1093.  
  1094.         if ( $pagenow == 'post.php' || $pagenow == 'post-new.php' ) {
  1095.             if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') )
  1096.                 return;
  1097.             if ( get_user_option('rich_editing') == 'true' ) {
  1098.                 add_filter('mce_external_plugins', array( &$this, 'add_shortcodelic_js' ) );
  1099.                 add_filter('mce_buttons', array( &$this, 'register_shortcodelic_buttons_page' ) );
  1100.             }
  1101.  
  1102.         }
  1103.  
  1104.     }
  1105.  
  1106.     function add_shortcodelic_js($plugin_array) {
  1107.         $plugin_array['shortcodelic'] = SHORTCODELIC_URL.'scripts/sc_buttons.js';
  1108.         return $plugin_array;
  1109.     }
  1110.  
  1111.     function register_shortcodelic_buttons_page($buttons) {
  1112.         array_push(
  1113.             $buttons,
  1114.             "shortcodelic_sc",
  1115.             "shortcodelic_fonticon",
  1116.             "shortcodelic_tooltip",
  1117.             "shortcodelic_removetooltip",
  1118.             "shortcodelic_progress",
  1119.             "shortcodelic_buttons",
  1120.             "shortcodelic_removebutton",
  1121.             "shortcodelic_box",
  1122.             "shortcodelic_removespan"
  1123.         );
  1124.         return $buttons;
  1125.     }
  1126.  
  1127.     function shortcodelic_refresh_mce($ver) {
  1128.         $ver += 3;
  1129.         return $ver;
  1130.     }
  1131.  
  1132.     /**
  1133.      * Set the button on tinyMCE editor.
  1134.      *
  1135.      * @since    1.0.0
  1136.      */
  1137.  
  1138.     public static function ajax_update_meta() {
  1139.  
  1140.         check_ajax_referer('shortcodelic_'.$_POST['type'].'_nonce', 'security');
  1141.  
  1142.         //print_r($_POST); /*to test with an alert on ajax success*/
  1143.  
  1144.         $meta_key = $_POST['meta_key'];
  1145.         $post_id = $_POST['post_id'];
  1146.  
  1147.         $values = get_post_custom( $post_id );
  1148.         if ( isset($_POST['from']) ) {
  1149.             $from = stripslashes($_POST['from']);
  1150.             $meta_size = $_POST['meta_size'];
  1151.             $key = str_replace('shortcodelic_', "", $meta_key);
  1152.             $from = str_replace($key, "key", $from);
  1153.             preg_match_all('/postid=["|\'](.*?)["|\']/', $from, $id);
  1154.             $from_id = $id[1][0];
  1155.             $from = preg_replace('/postid=["|\'](.*?)["|\']/', '', $from);
  1156.             preg_match_all('/=["|\'](.*?)["|\']/', $from, $key);
  1157.             $key = $key[1][0];
  1158.             $get_from_meta = get_post_meta( $from_id, $meta_key );
  1159.             $data[$meta_key.'_'.$meta_size] = $get_from_meta[0][$meta_key.'_'.$key];
  1160.         } else {
  1161.             wp_parse_str( $_POST['content'], $data );
  1162.         }
  1163.  
  1164.         if ( isset($values[$meta_key]) ) {
  1165.             $values = $values[$meta_key][0];
  1166.             $values = maybe_unserialize($values);
  1167.             if ( isset($_POST['slideshow']) ) {
  1168.                 $slideshow = $_POST['slideshow'];
  1169.                 $values[$slideshow] = '';
  1170.             } elseif ( isset($_POST['tabs']) ) {
  1171.                 $tabs = $_POST['tabs'];
  1172.                 $values[$tabs] = '';
  1173.             } elseif ( isset($_POST['tables']) ) {
  1174.                 $tables = $_POST['tables'];
  1175.                 $values[$tables] = '';
  1176.             } elseif ( isset($_POST['maps']) ) {
  1177.                 $maps = $_POST['maps'];
  1178.                 $values[$maps] = '';
  1179.             } elseif ( isset($_POST['carousels']) ) {
  1180.                 $carousels = $_POST['carousels'];
  1181.                 $values[$carousels] = '';
  1182.             } elseif ( isset($_POST['postcarousels']) ) {
  1183.                 $postcarousels = $_POST['postcarousels'];
  1184.                 $values[$postcarousels] = '';
  1185.             } elseif ( isset($_POST['woocarousels']) ) {
  1186.                 $woocarousels = $_POST['woocarousels'];
  1187.                 $values[$woocarousels] = '';
  1188.             }
  1189.             $data = array_merge($values, $data);
  1190.         }
  1191.         update_post_meta( $post_id, $meta_key, $data );
  1192.  
  1193.         die();
  1194.     }  
  1195.  
  1196.     /**
  1197.      * Return a thumbnail
  1198.      *
  1199.      * @since    1.0.0
  1200.      */
  1201.  
  1202.     public static function ajax_get_thumb() {
  1203.  
  1204.         check_ajax_referer('shortcodelic_slideshows_nonce', 'security');
  1205.  
  1206.         //echo $_POST['content'];
  1207.  
  1208.         $attachment_id = $_POST['content'];
  1209.         $attachment_bg = wp_get_attachment_image_src( $attachment_id, 'thumbnail' );
  1210.         echo $attachment_bg[0];
  1211.  
  1212.         die();
  1213.     }  
  1214.  
  1215.     public static function add_pp_col($cols) {
  1216.  
  1217.         global $post;
  1218.         //$post_type = $post->post_type;
  1219.  
  1220.         $cols['shortcodelic'] = __('SCE','shortcodelic');
  1221.  
  1222.         /*if ( $typenow != 'testimonial' ) {
  1223.             $cols['template'] = __('Template');
  1224.         }
  1225.         if ( $typenow == 'portfolio' ) {
  1226.             $cols['galleries'] = __('Galleries');
  1227.             $cols['portfolio_tag'] = __('Tags');
  1228.         }*/
  1229.         return $cols;
  1230.     }
  1231.  
  1232.     public static function add_pp_value($column_name) {
  1233.  
  1234.         global $post;
  1235.                
  1236.         switch ( $column_name ) {
  1237.             case 'shortcodelic':
  1238.                 $values = get_post_custom( $post->ID );
  1239.                 $out = '<i class="scicon-awesome-cancel-circled" style="color:#bbbbbb; font-size:14px"></i>';
  1240.                 foreach ($values as $key => $value) {
  1241.                     if ( preg_match("/shortcodelic_(.+)/", $key, $match) ) {
  1242.                         $shortcodelic = isset( $values[$match[0]] ) ? $values[$match[0]][0] : '';
  1243.                         $shortcodelic = maybe_unserialize($shortcodelic);
  1244.                         if (is_array($shortcodelic)) {
  1245.                             $pluginSize = sizeof($shortcodelic)+1;
  1246.                             for ($key = 1; $key <= sizeof($shortcodelic); $key++) {
  1247.                                 if ( !empty($shortcodelic[$match[0].'_'.$key]) ) {
  1248.                                     $out = '<i class="scicon-awesome-ok-circled" style="color:#1abc9c; font-size:14px"></i>';
  1249.                                 }
  1250.                             }
  1251.                         }
  1252.                     }
  1253.                 }
  1254.                 echo $out;
  1255.                 break;
  1256.         }
  1257.     }
  1258.  
  1259.     /**
  1260.      * HEX to RGB (http://bavotasan.com/2011/convert-hex-color-to-rgb-using-php/).
  1261.      *
  1262.      * @since    1.0.0
  1263.      */
  1264.  
  1265.     public static function hex2rgb($hex) {
  1266.        $hex = str_replace("#", "", $hex);
  1267.  
  1268.        if(strlen($hex) == 3) {
  1269.           $r = hexdec(substr($hex,0,1).substr($hex,0,1));
  1270.           $g = hexdec(substr($hex,1,1).substr($hex,1,1));
  1271.           $b = hexdec(substr($hex,2,1).substr($hex,2,1));
  1272.        } else {
  1273.           $r = hexdec(substr($hex,0,2));
  1274.           $g = hexdec(substr($hex,2,2));
  1275.           $b = hexdec(substr($hex,4,2));
  1276.        }
  1277.        $rgb = array($r, $g, $b);
  1278.        //return implode(",", $rgb); // returns the rgb values separated by commas
  1279.        return $rgb; // returns an array with the rgb values
  1280.     }
  1281.  
  1282.     /**
  1283.      * Display font list for preview scopes.
  1284.      *
  1285.      * @since    2.1.0
  1286.      */
  1287.     public function fontIconPreview($atts, $content = null) {
  1288.         extract(shortcode_atts(array(
  1289.             'font' => 'awesome'
  1290.         ), $atts));
  1291.  
  1292.         $out = '<div class="shortcodelic_font_list cf">';
  1293.  
  1294.         ob_start();
  1295.  
  1296.         include_once(SHORTCODELIC_PATH."/font/scicon-$font.php");
  1297.  
  1298.         $out .= ob_get_clean();
  1299.  
  1300.         $out .= '</div><!-- .shortcodelic_font_list.cf -->';
  1301.  
  1302.         return $out;
  1303.     }
  1304.  
  1305.  
  1306.     /**
  1307.      * Slideshow shortcode.
  1308.      *
  1309.      * @since    2.0.0
  1310.      */
  1311.  
  1312.     public function shortcodelicSlideshowSC($atts) {
  1313.  
  1314.         global $post;
  1315.  
  1316.         extract(shortcode_atts(array(
  1317.             'postid' => '',
  1318.             'slideshow' => ''
  1319.         ), $atts));
  1320.  
  1321.         $postid = $postid == '' ? $post->ID : $postid;
  1322.  
  1323.         wp_enqueue_style( $this->plugin_slug . '-fontello' );
  1324.         wp_enqueue_style( $this->plugin_slug . '-slideshine' );
  1325.         wp_enqueue_script( $this->plugin_slug . '-slideshine' );
  1326.  
  1327.         if (!function_exists('shortcodelic_match_quotes')) {
  1328.             function shortcodelic_match_quotes($matches) {
  1329.                 return preg_replace('/&quot;/','"',$matches[0]);
  1330.                 $icopts = json_decode($matches[0]);
  1331.             }
  1332.         }
  1333.  
  1334.         if (!function_exists('shortcodelic_match_quotes_3')) {
  1335.             function shortcodelic_match_quotes_3($matches) {
  1336.                 return preg_replace('/"/','&quot;',$matches[0]);
  1337.                 $icopts = json_decode($matches[0]);
  1338.             }
  1339.         }
  1340.  
  1341.         global $wp_embed;
  1342.         $out = '';
  1343.  
  1344.         $values = get_post_custom( $postid );
  1345.         $shortcodelic_slideshows = isset( $values['shortcodelic_slideshows'] ) ? $values['shortcodelic_slideshows'][0] : '';
  1346.         $shortcodelic_slideshows = maybe_unserialize($shortcodelic_slideshows);
  1347.         $slideshowSize = $slideshow;
  1348.  
  1349.         if (is_array($shortcodelic_slideshows)) {
  1350.  
  1351.             $skin = esc_attr($shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['skin']);
  1352.             $skinrgb = $this->hex2rgb($skin);
  1353.             $skinbg = esc_attr($shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['skinbg']);
  1354.             $skinbgrgb = $this->hex2rgb($skinbg);
  1355.             $skinopacity = esc_attr($shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['skinopacity']);
  1356.  
  1357.             $slide_h = esc_attr($shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['height']);
  1358.             $slide_w = esc_attr($shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['width']);
  1359.  
  1360.             $out .= "<div class='pix_slideshine pix_slideshine-post-id-$postid pix_slideshine-$slideshow' data-opts='{";
  1361.                 $out .= "\"layout\":\"".esc_attr($shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['layout'])."\",";
  1362.                 $out .= "\"height\":\"$slide_h\",";
  1363.                 $out .= "\"width\":\"$slide_w\",";
  1364.                 $out .= "\"fx\":\"".implode(",", $shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['fx'])."\",";
  1365.                 $out .= "\"mobfx\":\"".implode(",", $shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['mobfx'])."\",";
  1366.                 $out .= "\"longfx\":\"".esc_attr($shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['longfx'])."\",";
  1367.                 $out .= "\"timeout\":\"".esc_attr($shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['timeout'])."\",";
  1368.                 $out .= "\"speed\":\"".esc_attr($shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['speed'])."\",";
  1369.                 $out .= "\"easing\":\"".esc_attr($shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['easing'])."\",";
  1370.                 $out .= "\"fxslide\":\"".esc_attr($shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['fxslide'])."\",";
  1371.                 $out .= "\"autoplay\":\"".esc_attr($shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['autoplay'])."\",";
  1372.                 $out .= "\"hover\":\"".esc_attr($shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['hover'])."\",";
  1373.                 $out .= "\"thumbnails\":\"".esc_attr($shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['thumbnails'])."\",";
  1374.                 $out .= "\"bullets\":\"".esc_attr($shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['bullets'])."\",";
  1375.                 $out .= "\"rows\":\"".esc_attr($shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['rows'])."\",";
  1376.                 $out .= "\"cols\":\"".esc_attr($shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['cols'])."\",";
  1377.                 $out .= "\"gridrows\":\"".esc_attr($shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['gridrows'])."\",";
  1378.                 $out .= "\"gridcols\":\"".esc_attr($shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['gridcols'])."\",";
  1379.                 $out .= "\"skin\":\"$skin\",";
  1380.                 $out .= "\"skinrgb\":\"$skinrgb[0],$skinrgb[1],$skinrgb[2]\",";
  1381.                 $out .= "\"skinbg\":\"$skinbg\",";
  1382.                 $out .= "\"skinbgrgb\":\"$skinbgrgb[0],$skinbgrgb[1],$skinbgrgb[2]\",";
  1383.                 $out .= "\"skinopacity\":\"$skinopacity\"";
  1384.             $out .= "}'>";
  1385.  
  1386.             if (isset($shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['slide']) && is_array($shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['slide'])) {
  1387.                 $i = 1; foreach ($shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['slide'] as $key => &$slide) {
  1388.  
  1389.                     $attachment_bg = isset($shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['slide'][$key]['bg']) ? esc_attr($shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['slide'][$key]['bg']) : '';
  1390.                     $attachment_id = $this->attachment_meta_by_url($attachment_bg);
  1391.                     $attachment_size = isset($shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['slide'][$key]['size']) ? esc_attr($shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['slide'][$key]['size']): '';
  1392.                     $attachment_bg_pos = isset($shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['slide'][$key]['bg_pos']) ? esc_attr($shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['slide'][$key]['bg_pos']): 'center';
  1393.                     $attachment_timeout = isset($shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['slide'][$key]['timeout']) ? esc_attr($shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['slide'][$key]['timeout']): '';
  1394.                     $attachment_speed = isset($shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['slide'][$key]['speed']) ? esc_attr($shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['slide'][$key]['speed']): '';
  1395.                     $attachment_effect = isset($shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['slide'][$key]['effect']) ? esc_attr($shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['slide'][$key]['effect']): '';
  1396.                     $attachment_mobfx = isset($shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['slide'][$key]['mobfx']) ? esc_attr($shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['slide'][$key]['mobfx']): '';
  1397.                     $attachment_longfx = isset($shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['slide'][$key]['longfx']) ? esc_attr($shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['slide'][$key]['longfx']): '';
  1398.                     $attachment_easing = isset($shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['slide'][$key]['easing']) ? esc_attr($shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['slide'][$key]['easing']): '';
  1399.                     $attachment_fxslide = isset($shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['slide'][$key]['fxslide']) ? esc_attr($shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['slide'][$key]['fxslide']): '';
  1400.                     $attachment_link = isset($shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['slide'][$key]['link']) ? esc_attr($shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['slide'][$key]['link']): '';
  1401.                     $attachment_target = isset($shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['slide'][$key]['target']) ? esc_attr($shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['slide'][$key]['target']): '';
  1402.                     $attachment_video = isset($shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['slide'][$key]['video']) ? $shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['slide'][$key]['video']: '';
  1403.                     $attachment_stop = isset($shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['slide'][$key]['stop']) ? esc_attr($shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['slide'][$key]['stop']): '';
  1404.                     $attachment_elements = isset($shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['slide'][$key]['elements']) ? esc_attr($shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['slide'][$key]['elements']): '';
  1405.                     $attachment_elements = preg_replace('/\"\{\"(.*?)\"\}\"/', '\'{"$1"}\'', $attachment_elements);
  1406.  
  1407.                     $attachment_url = wp_get_attachment_url( $attachment_id );
  1408.                     $cover = '';
  1409.                     if ( $attachment_id != '' ) {
  1410.                         $attachment_bg = wp_get_attachment_image_src( $attachment_id, 'thumbnail' );
  1411.                         $attachment_bg = 'url('.$attachment_bg[0].')';
  1412.                         $attachment_url = wp_get_attachment_image_src( $attachment_id, $attachment_size );
  1413.                         $attachment_url = $attachment_url[0];
  1414.                     } else {
  1415.                         $attachment_url = $attachment_bg;
  1416.                         $attachment_bg = 'url('.$attachment_bg.')';
  1417.                     }
  1418.  
  1419.                     $attachment_bg_video = $attachment_video != '' ? 'url('.SHORTCODELIC_URL.'images/video-icon.svg)' : '';
  1420.  
  1421.                     $out .= "<div>
  1422.                         <div data-opts='{";
  1423.                             $out .= "\"src\":\"$attachment_url\",";
  1424.                             $out .= "\"thumb\":\"$attachment_bg\",";
  1425.                             $out .= "\"thumb2\":\"$attachment_bg_video\",";
  1426.                             $out .= "\"bg_pos\":\"$attachment_bg_pos\",";
  1427.                             $out .= "\"timeout\":\"$attachment_timeout\",";
  1428.                             $out .= "\"speed\":\"$attachment_speed\",";
  1429.                             $out .= "\"fx\":\"$attachment_effect\",";
  1430.                             $out .= "\"mobfx\":\"$attachment_mobfx\",";
  1431.                             $out .= "\"longfx\":\"$attachment_longfx\",";
  1432.                             $out .= "\"fxslide\":\"$attachment_fxslide\",";
  1433.                             $out .= "\"stop\":\"$attachment_stop\",";
  1434.                             $out .= "\"link\":\"$attachment_link\",";
  1435.                             $out .= "\"target\":\"$attachment_target\"";
  1436.                     $out .= "}'>";
  1437.                         if ( $attachment_video != '' ) {
  1438.                             $out .= do_shortcode($wp_embed->autoembed(wp_specialchars_decode($attachment_video, ENT_QUOTES)));
  1439.                         }
  1440.  
  1441.                         $out .= "</div>";
  1442.  
  1443.                         if ( $attachment_elements != '' ) {
  1444.                             $attachment_elements = html_entity_decode($attachment_elements);
  1445.                             $attachment_elements = preg_replace("/\"\{/", "{", $attachment_elements);
  1446.                             $attachment_elements = preg_replace("/\}\"/", "}", $attachment_elements);
  1447.                             $attachment_elements = preg_replace("/\;quot\;/", "&quot;", $attachment_elements);
  1448.                             $attachment_elements = preg_replace("/\&quot\;(top|left)\&quot\;/", "\"$1\"", $attachment_elements);
  1449.                             $attachment_elements = preg_replace_callback(
  1450.                                 '/data-(.+?)=&quot;\{(.+?)\}&quot;/',
  1451.                                 'shortcodelic_match_quotes_3',
  1452.                                 $attachment_elements
  1453.                             );
  1454.                             $attachment_elements = preg_replace_callback(
  1455.                                 '/data-(.+?)=\{(.+?)\}/',
  1456.                                 'shortcodelic_match_quotes_3',
  1457.                                 $attachment_elements
  1458.                             );
  1459.                             $attachment_elements = preg_replace_callback(
  1460.                                 '/data-(.+?)=[\'"]\{(.+?)\}[\'"]/',
  1461.                                 'shortcodelic_match_quotes_3',
  1462.                                 $attachment_elements
  1463.                             );
  1464.                             $attachment_elements = preg_replace("/data-(.+?)=&quot;\{(.+?)\}&quot;/", "data-$1='$2'", $attachment_elements);
  1465.                             $attachment_elements = preg_replace("/data-(.+?)=(\'\")\{(.+?)\}(\'\")/", "data-$1='$2'", $attachment_elements);
  1466.                             $attachment_elements = preg_replace("/data-(.+?)=\{(.+?)\}/", "data-$1='$2'", $attachment_elements);
  1467.                             $attachment_elements = json_decode($attachment_elements);
  1468.                             $element = array();
  1469.  
  1470.                             if (!empty($attachment_elements)) {
  1471.                                 foreach ($attachment_elements as $key => $value) {
  1472.                                     $i = preg_replace("/slide_elements\[elements\]\[(.*?)\]\[(.*?)\]/", "$1", $attachment_elements[$key]->name);
  1473.                                     $k = preg_replace("/slide_elements\[elements\]\[(.*?)\]\[(.*?)\]/", "$2", $attachment_elements[$key]->name);
  1474.                                     $v = $attachment_elements[$key]->value;
  1475.                                     $element[$i][$k] = $v;
  1476.                                 }
  1477.  
  1478.                                 foreach ($element as $key => $value) {
  1479.                                     if ( isset($key) ) {
  1480.                                         $elements = $element[$key];
  1481.                                         if ( !empty($elements['caption']) ) {
  1482.                                             $out .= "<div class='slideshine_caption slideshine_caption_".($key-1)."' style='
  1483.                                                     max-width:".$elements['width']."%;
  1484.                                                     left:".(($elements['position']->left / $slide_w) * 100)."%;
  1485.                                                     top:".(($elements['position']->top / $slide_h) * 100)."%;'
  1486.                                                 data-caption='{";
  1487.                                                 $out .= "\"wider\":\"".$elements['wider']."\",";
  1488.                                                 $out .= "\"narrower\":\"".$elements['narrower']."\",";
  1489.                                                 $out .= "\"bg\":\"".$elements['bg']."\",";
  1490.                                                 $data_rgb = $this->hex2rgb($elements['bg']);
  1491.                                                 $out .= "\"rgb\":\"rgba($data_rgb[0],$data_rgb[1],$data_rgb[2],".$elements['opacity'].")\",";
  1492.                                                 $out .= "\"entering\":\"".$elements['entering']."\",";
  1493.                                                 $out .= "\"from\":\"".$elements['from']."\",";
  1494.                                                 $out .= "\"fromduration\":\"".$elements['fromduration']."\",";
  1495.                                                 $out .= "\"fromeasing\":\"".$elements['fromeasing']."\",";
  1496.                                                 $out .= "\"leaving\":\"".$elements['leaving']."\",";
  1497.                                                 $out .= "\"to\":\"".$elements['to']."\",";
  1498.                                                 $out .= "\"toduration\":\"".$elements['toduration']."\",";
  1499.                                                 $out .= "\"toeasing\":\"".$elements['toeasing']."\"";
  1500.                                             $out .= "}'>";
  1501.                                             $the_content = $elements['caption'];
  1502.                                             $the_content = preg_replace("/data-(.+?)=\'\"(.+?)\"\'/", "data-$1='{\"$2\"}'", $the_content);
  1503.                                             $the_content = preg_replace("/data-(.+?)=\'&quot;(.+?)&quot;\'/", "data-$1='{\"$2\"}'", $the_content);
  1504.                                             $the_content = preg_replace_callback(
  1505.                                                 '/data-(.+?)=\'\{(.+?)\}\'/',
  1506.                                                 'shortcodelic_match_quotes',
  1507.                                                 $the_content
  1508.                                             );
  1509.                                             $the_content = wp_specialchars_decode($the_content, ENT_QUOTES); $the_content = $wp_embed->autoembed(apply_filters('the_content', $the_content));
  1510.                                             $out .= $the_content;
  1511.                                             $out .= "</div>";
  1512.                                         }
  1513.                                     }
  1514.                                 }
  1515.                             }
  1516.  
  1517.                         }
  1518.  
  1519.  
  1520.                     $out .= "</div>";
  1521.                 }
  1522.             }
  1523.  
  1524.                 if ( isset($shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['loading_bar']) && $shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['loading_bar']!='true' ) {
  1525.                     $slideshine_hidden = "slideshine_hidden";
  1526.                 } else {
  1527.                     $slideshine_hidden = "";                   
  1528.                 }
  1529.                 $out .= "<div class='slideshine_loader $slideshine_hidden' style='background: $skin;'></div><!-- .slideshine_loader -->";
  1530.                 if ( isset($shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['loading_pie']) && $shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['loading_pie']=='true' ) {
  1531.                     $out .= "<div class='slideshine_pie slideshine_fontsized $slideshine_hidden'><canvas id='canvas_$postid-$slideshow'></canvas></div><!-- .slideshine_pie -->";
  1532.                     $bordered = "";
  1533.                     $bged = "";
  1534.                 } else {
  1535.                     $bordered = " bordered";
  1536.                     $bged = " background: rgba($skinbgrgb[0],$skinbgrgb[1],$skinbgrgb[2],$skinopacity);";
  1537.                 }
  1538.  
  1539.                 if ( isset($shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['play_pause']) && $shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['play_pause']=='true' ) {
  1540.                     $out .= "<div class='slideshine_play scicon-entypo-play' style='color: $skin;'></div><!-- .slideshine_play --><div class='slideshine_pause scicon-entypo-pause' style='color: $skin;'></div><!-- .slideshine_pause -->";
  1541.                     $out .= "<div class='slideshine_pie_bg slideshine_fontsized slideshine_skinbg$bordered' style='color: $skin; border-color: $skin; background: $skinbg; background: rgba($skinbgrgb[0],$skinbgrgb[1],$skinbgrgb[2],$skinopacity);'></div>";
  1542.                 }
  1543.  
  1544.                 if ( isset($shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['prev_next']) && $shortcodelic_slideshows['shortcodelic_slideshows_'.$slideshowSize]['prev_next']=='true' ) {
  1545.                     $out .= "<div class='slideshine_prev slideshine_fontsized scicon-entypo-left-open-big' style='color: $skin; border-color: $skin; background: $skinbg; background: rgba($skinbgrgb[0],$skinbgrgb[1],$skinbgrgb[2],$skinopacity);'></div><!-- .slideshine_prev --><div class='slideshine_next slideshine_fontsized scicon-entypo-right-open-big' style='color: $skin; border-color: $skin; background: $skinbg; background: rgba($skinbgrgb[0],$skinbgrgb[1],$skinbgrgb[2],$skinopacity);'></div><!-- .slideshine_next -->";
  1546.                 }
  1547.  
  1548.                 $out .= "<div class='slideshine_waiter hiddenspinner'>
  1549.                     <div class='spinner slideshine_fontsized' style='border-top-color: $skin;$bged'></div>
  1550.                 </div>";
  1551.  
  1552.             $out .= "</div><!-- .pix_slideshine.pix_slideshine-post-id-$postid.pix_slideshine-$slideshow -->";
  1553.  
  1554.             $out .= "<div class='slideshine_margin slideshine_margin-id-$postid-slideshow-$slideshow'></div>";
  1555.  
  1556.         }
  1557.  
  1558.         return $out;
  1559.  
  1560.     }  
  1561.  
  1562.     /**
  1563.      * Tabs/accordion shortcode.
  1564.      *
  1565.      * @since    2.0.0
  1566.      */
  1567.     public function shortcodelicTabsSC($atts) {
  1568.  
  1569.         wp_enqueue_style( $this->plugin_slug . '-tabs' );
  1570.         wp_enqueue_script( $this->plugin_slug . '-tabs', SHORTCODELIC_URL.'scripts/tabs.js', array('pix-modernizr','jquery','jquery-easing',$this->plugin_slug . '-transit',$this->plugin_slug . '-plugins'));
  1571.  
  1572.         global $post;
  1573.  
  1574.         if (!function_exists('shortcodelic_match_quotes')) {
  1575.             function shortcodelic_match_quotes($matches) {
  1576.                 return preg_replace('/&quot;/','"',$matches[0]);
  1577.                 $icopts = json_decode($matches[0]);
  1578.             }
  1579.         }
  1580.  
  1581.         if (!function_exists('shortcodelic_match_quotes_2')) {
  1582.             function shortcodelic_match_quotes_2($matches) {
  1583.                 $icopts = json_decode($matches[1]);
  1584.                 $icoin = '';
  1585.                 $icoout = '';
  1586.                 if ( isset($icopts->style) ) {
  1587.                     $icoout .= 'data-style="'.$icopts->style.'" ';
  1588.                 }
  1589.                 if ( isset($icopts->size) ) {
  1590.                     $icoin .= 'font-size:'.$icopts->size.'px;';
  1591.                 }
  1592.                 if ( isset($icopts->color) ) {
  1593.                     $icoin .= 'color:'.$icopts->color.';';
  1594.                 }
  1595.                 if ( isset($icopts->bg) ) {
  1596.                     if ( isset($icopts->style) && $icopts->style=='disc' ) {
  1597.                         $icoin .= 'background-color:'.$icopts->bg.';';
  1598.                     } elseif ( isset($icopts->style) && $icopts->style=='circle' ) {
  1599.                         $icoin .= 'border-color:'.$icopts->color.';';
  1600.                     }
  1601.                 }
  1602.                 if ( $icoin!='' ) {
  1603.                     $icoout .= 'style="'.$icoin.'"';
  1604.                 }
  1605.                 return $icoout;
  1606.             }
  1607.         }
  1608.  
  1609.         extract(shortcode_atts(array(
  1610.             'postid' => '',
  1611.             'tabs' => ''
  1612.         ), $atts));
  1613.  
  1614.         $postid = $postid == '' ? $post->ID : $postid;
  1615.  
  1616.         global $wp_embed;
  1617.         $out = '';
  1618.  
  1619.         $values = get_post_custom( $postid );
  1620.         $shortcodelic_tabs = isset( $values['shortcodelic_tabs'] ) ? $values['shortcodelic_tabs'][0] : '';
  1621.         $shortcodelic_tabs = maybe_unserialize($shortcodelic_tabs);
  1622.         $tabsSize = $tabs;
  1623.  
  1624.         if (is_array($shortcodelic_tabs)) {
  1625.  
  1626.             $tabsvsacc = esc_attr($shortcodelic_tabs['shortcodelic_tabs_'.$tabsSize]['tabsvsacc']);
  1627.             $active = esc_attr($shortcodelic_tabs['shortcodelic_tabs_'.$tabsSize]['active']);
  1628.             $minwidth = esc_attr($shortcodelic_tabs['shortcodelic_tabs_'.$tabsSize]['minwidth']);
  1629.             $easing = esc_attr($shortcodelic_tabs['shortcodelic_tabs_'.$tabsSize]['easing']);
  1630.             $speed = esc_attr($shortcodelic_tabs['shortcodelic_tabs_'.$tabsSize]['speed']);
  1631.             $fx = implode(",", $shortcodelic_tabs['shortcodelic_tabs_'.$tabsSize]['fx']);
  1632.  
  1633.             $type = 'tabs';
  1634.             $columned = '';
  1635.             if ( $tabsvsacc == 'accordion' ) { $type = $tabsvsacc; } else { $columned = ' simple exsimple'; }
  1636.             if ( $tabsvsacc == 'tabsleft' || $tabsvsacc == 'tabsright' ) $columned = " columned $tabsvsacc";
  1637.  
  1638.             $out .= "<div class='pix_tabs$columned pix_tabs-post-$postid pix_tabs-$tabs' data-opts='{\"active\":".($active-1).",\"type\":\"$type\",\"minwidth\":$minwidth,\"easing\":\"$easing\",\"speed\":\"$speed\",\"fx\":\"$fx\"}'>";
  1639.  
  1640.             if (isset($shortcodelic_tabs['shortcodelic_tabs_'.$tabsSize]['tab']) && is_array($shortcodelic_tabs['shortcodelic_tabs_'.$tabsSize]['tab'])) {
  1641.                 foreach ($shortcodelic_tabs['shortcodelic_tabs_'.$tabsSize]['tab'] as $key => &$slide) {
  1642.  
  1643.                     $title = isset($shortcodelic_tabs['shortcodelic_tabs_'.$tabsSize]['tab'][$key]['title']) ? esc_attr($shortcodelic_tabs['shortcodelic_tabs_'.$tabsSize]['tab'][$key]['title']) : '';
  1644.                     $icon = isset($shortcodelic_tabs['shortcodelic_tabs_'.$tabsSize]['tab'][$key]['icon']) ? $shortcodelic_tabs['shortcodelic_tabs_'.$tabsSize]['tab'][$key]['icon'] : '';
  1645.                     $icon_2 = isset($shortcodelic_tabs['shortcodelic_tabs_'.$tabsSize]['tab'][$key]['icon_2']) ? $shortcodelic_tabs['shortcodelic_tabs_'.$tabsSize]['tab'][$key]['icon_2'] : '';
  1646.                     $content = isset($shortcodelic_tabs['shortcodelic_tabs_'.$tabsSize]['tab'][$key]['caption']) ? esc_attr($shortcodelic_tabs['shortcodelic_tabs_'.$tabsSize]['tab'][$key]['caption']) : '<p>'.__('content', 'shortcodelic').'</p>';
  1647.                     $the_content = wp_specialchars_decode($content, ENT_QUOTES); $the_content = $wp_embed->autoembed(apply_filters('the_content', $the_content));
  1648.                     $out .= "<a href='#tab-$key-$postid-$tabs' class='tab header-$key-$postid-$tabs'><span class='icon-tab-open alignleft'>$icon</span><span class='icon-tab-closed alignleft'>$icon_2</span>$title</a>";
  1649.                     $out .= "<div id='tab-$key-$postid-$tabs'>$the_content</div><!-- #tab-$key-$postid-$tabs -->";
  1650.                    
  1651.                 }
  1652.             }
  1653.  
  1654.             $out .= "</div><!-- .pix_$tabsvsacc -->";
  1655.  
  1656.             $out = preg_replace('/\<(.*?) class=([\'|"])scicon-(.*?)>(.*?)<\/(.*?)>/', '<$1 class=$2scicon-$3></$5>', $out);
  1657.             $out = preg_replace_callback(
  1658.                 '/data-icopts=([\'|"]){(.*?)}([\'|"])/',
  1659.                 'shortcodelic_match_quotes',
  1660.                 $out
  1661.             );
  1662.             $out = preg_replace('/data-icopts=([\'|"]){(.*?)}([\'|"])/', 'data-icopts=\'{$2}\'', $out);
  1663.             $out = preg_replace_callback(
  1664.                 '/data-icopts=\'(.*?)\'/',
  1665.                 'shortcodelic_match_quotes_2',
  1666.                 $out
  1667.             );
  1668.         }
  1669.  
  1670.         return $out;
  1671.  
  1672.     }  
  1673.  
  1674.  
  1675.     /**
  1676.      * Data tables shortcode.
  1677.      *
  1678.      * @since    2.3.3
  1679.      */
  1680.     public function shortcodelicTablesSC($atts) {
  1681.  
  1682.         wp_enqueue_style( $this->plugin_slug . '-tables' );
  1683.         wp_enqueue_script( $this->plugin_slug . '-tables', SHORTCODELIC_URL.'scripts/tables.js', array('pix-modernizr','jquery'));
  1684.  
  1685.         global $post;
  1686.  
  1687.         if (!function_exists('shortcodelic_match_quotes')) {
  1688.             function shortcodelic_match_quotes($matches) {
  1689.                 return preg_replace('/&quot;/','"',$matches[0]);
  1690.                 $icopts = json_decode($matches[0]);
  1691.             }
  1692.         }
  1693.  
  1694.         if (!function_exists('shortcodelic_match_quotes_3')) {
  1695.             function shortcodelic_match_quotes_3($matches) {
  1696.                 return preg_replace('/"/','&quot;',$matches[0]);
  1697.                 $icopts = json_decode($matches[0]);
  1698.             }
  1699.         }
  1700.  
  1701.         extract(shortcode_atts(array(
  1702.             'postid' => '',
  1703.             'table' => ''
  1704.         ), $atts));
  1705.  
  1706.         $postid = $postid == '' ? $post->ID : $postid;
  1707.  
  1708.         $out = '';
  1709.  
  1710.         $values = get_post_custom( $postid );
  1711.         $shortcodelic_tables = isset( $values['shortcodelic_tables'] ) ? $values['shortcodelic_tables'][0] : '';
  1712.         $shortcodelic_tables = maybe_unserialize($shortcodelic_tables);
  1713.         $tablesSize = $table;
  1714.         $rows = count($shortcodelic_tables['shortcodelic_tables_'.$tablesSize]['table']);
  1715.         $rowW = 100/$rows;
  1716.  
  1717.         if (is_array($shortcodelic_tables)) {
  1718.  
  1719.             $style = esc_attr($shortcodelic_tables['shortcodelic_tables_'.$tablesSize]['style']);
  1720.             $minwidth = esc_attr($shortcodelic_tables['shortcodelic_tables_'.$tablesSize]['minwidth']);
  1721.  
  1722.             if (isset($shortcodelic_tables['shortcodelic_tables_'.$tablesSize]['table']) && is_array($shortcodelic_tables['shortcodelic_tables_'.$tablesSize]['table'])) {
  1723.                 $maxrows = 0;
  1724.                 foreach ($shortcodelic_tables['shortcodelic_tables_'.$tablesSize]['table'] as $key => &$column) {
  1725.                     $table_elements = isset($shortcodelic_tables['shortcodelic_tables_'.$tablesSize]['table'][$key]['elements']) ? esc_attr($shortcodelic_tables['shortcodelic_tables_'.$tablesSize]['table'][$key]['elements']): '';
  1726.                     $table_elements = preg_replace('/\"\{\"(.*?)\"\}\"/', '\'{"$1"}\'', $table_elements);
  1727.                     $arr_elements = html_entity_decode($table_elements);
  1728.                     $arr_elements = preg_replace("/\"\{/", "{", $arr_elements);
  1729.                     $arr_elements = preg_replace("/\}\"/", "}", $arr_elements);
  1730.                     $arr_elements = preg_replace("/\;quot\;/", "&quot;", $arr_elements);
  1731.                     $arr_elements = preg_replace_callback(
  1732.                         '/data-(.+?)=&quot;\{(.+?)\}&quot;/',
  1733.                         'shortcodelic_match_quotes_3',
  1734.                         $arr_elements
  1735.                     );
  1736.                     $arr_elements = preg_replace_callback(
  1737.                         '/data-(.+?)=\{(.+?)\}/',
  1738.                         'shortcodelic_match_quotes_3',
  1739.                         $arr_elements
  1740.                     );
  1741.                     $arr_elements = preg_replace_callback(
  1742.                         '/data-(.+?)=[\'"]\{(.+?)\}[\'"]/',
  1743.                         'shortcodelic_match_quotes_3',
  1744.                         $arr_elements
  1745.                     );
  1746.                     $arr_elements = preg_replace("/data-(.+?)=(&quot;)\s?<p>(.*)?<\/p>\s?(&quot;)/", "data-$1=$2$3$4", $arr_elements);
  1747.                     $arr_elements = preg_replace("/data-(.+?)=&quot;\{(.+?)\}&quot;/", "data-$1='$2'", $arr_elements);
  1748.                     $arr_elements = preg_replace("/data-(.+?)=(\'\")\{(.+?)\}(\'\")/", "data-$1='$2'", $arr_elements);
  1749.                     $arr_elements = preg_replace("/data-(.+?)=\{(.+?)\}/", "data-$1='$2'", $arr_elements);
  1750.                     $arr_elements = json_decode($arr_elements);
  1751.                    
  1752.                     if (!empty($arr_elements)) {
  1753.                         foreach ($arr_elements as $k3y => $valu3) {
  1754.                             $i = preg_replace("/slide_elements\[elements\]\[(.*?)\]\[(.*?)\]/", "$1", $arr_elements[$k3y]->name);
  1755.                             $k = preg_replace("/slide_elements\[elements\]\[(.*?)\]\[(.*?)\]/", "$2", $arr_elements[$k3y]->name);
  1756.                             $v = $arr_elements[$k3y]->value;
  1757.                             $element[$key][$i][$k] = $v;
  1758.                         }
  1759.                         $maxrows = count($element[$key]) > $maxrows ? count($element[$key]) : $maxrows ;
  1760.                     }
  1761.                 }
  1762.  
  1763.                 if ( $style == 'pricing' ) {
  1764.                     $out .= "<div class='pix_tables pix_tables-post-$postid pix_tables-table-$table pricing' data-opts='{\"minwidth\":$minwidth}'>";
  1765.                         foreach ($shortcodelic_tables['shortcodelic_tables_'.$tablesSize]['table'] as $key => &$column) {
  1766.                             $cell_active = isset($shortcodelic_tables['shortcodelic_tables_'.$tablesSize]['table'][$key]['active']) ? esc_attr($shortcodelic_tables['shortcodelic_tables_'.$tablesSize]['table'][$key]['active']): '';
  1767.                             $highlighted = $cell_active != '' ? ' col-highlighted' : '';
  1768.                             $highlighted .= $key%2 == 0 ? ' odd' : ' even';
  1769.                             $out .= "<div class='table_column$highlighted' style='width:$rowW%'><div>";
  1770.                             if ( isset($element[$key]) ) {
  1771.                                 foreach ($element[$key] as $el_key => $el_val ) {
  1772.                                     $alttd = $el_key%2 == 0 ? ' odd' : ' even';
  1773.                                     if ( isset($el_key) ) {
  1774.                                         $el = $element[$key][$el_key];
  1775.                                         $the_content = preg_replace("/data-(.+?)=\'\"(.+?)\"\'/", "data-$1='{\"$2\"}'", $el['caption']);
  1776.                                         $the_content = preg_replace("/data-(.+?)=\'&quot;(.+?)&quot;\'/", "data-$1='{\"$2\"}'", $the_content);
  1777.                                         $the_content = preg_replace_callback(
  1778.                                             '/data-(.+?)=\'\{(.+?)\}\'/',
  1779.                                             'shortcodelic_match_quotes',
  1780.                                             $the_content
  1781.                                         );
  1782.                                         $the_content = wp_specialchars_decode($the_content, ENT_QUOTES);
  1783.                                         $out .= "<span class='table-cell ".$el['class']." ".$el['customclass']."$alttd'>".apply_filters('the_content', $the_content)."</span>";
  1784.                                     }
  1785.                                 }
  1786.                             }
  1787.                             $out .= "</div></div>";
  1788.                         }
  1789.                     $out .= "</div><!-- .pix_tables -->";
  1790.                     $out .= "<div class='clear'></div>";
  1791.                 } else {
  1792.                     $out .= "<div class='pix_tables pix_tables-post-$postid pix_tables-table-$table data off' data-opts='{\"minwidth\":$minwidth}'>";
  1793.                         $out .= "<table>";
  1794.                             $out .= "<colgroup>";
  1795.                             foreach ($shortcodelic_tables['shortcodelic_tables_'.$tablesSize]['table'] as $key => &$column) {
  1796.                                 $cell_active = isset($shortcodelic_tables['shortcodelic_tables_'.$tablesSize]['table'][$key]['active']) ? esc_attr($shortcodelic_tables['shortcodelic_tables_'.$tablesSize]['table'][$key]['active']): '';
  1797.                                 $highlighted = $cell_active != '' ? ' col-highlighted' : '';
  1798.                                 $highlighted .= $key%2 == 0 ? ' odd' : ' even';
  1799.                                 $out .= "<col class='table_column$highlighted'>";
  1800.                             }
  1801.                             $out .= "</colgroup>";
  1802.                             for ($irow = 1; $irow <= $maxrows; $irow++) {
  1803.                                 $alttr = $irow%2 == 0 ? ' odd' : ' even';
  1804.                                 $out .= "<tr class='$alttr'>";
  1805.                                 foreach ($shortcodelic_tables['shortcodelic_tables_'.$tablesSize]['table'] as $key => &$column) {
  1806.                                     $td = $irow==1 ? 'th' : 'td';
  1807.                                     $alttd = $key%2 == 0 ? ' odd' : ' even';
  1808.                                     if ( $element[$key][$irow]['caption']=='' ) {
  1809.                                         $out .= "<$td class='empty$alttd' style='width:$rowW%'>&nbsp;</$td>";
  1810.                                     } else {
  1811.                                         $the_content = preg_replace("/data-(.+?)=\'\"(.+?)\"\'/", "data-$1='{\"$2\"}'", $element[$key][$irow]['caption']);
  1812.                                         $the_content = preg_replace("/data-(.+?)=\'&quot;(.+?)&quot;\'/", "data-$1='{\"$2\"}'", $the_content);
  1813.                                         $the_content = preg_replace_callback(
  1814.                                             '/data-(.+?)=\'\{(.+?)\}\'/',
  1815.                                             'shortcodelic_match_quotes',
  1816.                                             $the_content
  1817.                                         );
  1818.                                         $the_content = wp_specialchars_decode($the_content, ENT_QUOTES);
  1819.                                         $out .= "<$td class='".$element[$key][$irow]['class']." ".$element[$key][$irow]['customclass']."$alttd' style='width:$rowW%'>".apply_filters('the_content', $the_content)."</$td>";
  1820.                                     }
  1821.                                 }
  1822.                                 $out .= "</tr>";
  1823.                             }
  1824.                         $out .= "</table>";
  1825.                     $out .= "</div><!-- .pix_tables -->";
  1826.                     $out .= "<div class='pix_tables pix_tables-post-$postid pix_tables-table-$table data alt' data-opts='{\"minwidth\":$minwidth}'>";
  1827.                         $out .= "<table>";
  1828.                             foreach ($shortcodelic_tables['shortcodelic_tables_'.$tablesSize]['table'] as $key => &$column) {
  1829.                                 $cell_active = isset($shortcodelic_tables['shortcodelic_tables_'.$tablesSize]['table'][$key]['active']) ? esc_attr($shortcodelic_tables['shortcodelic_tables_'.$tablesSize]['table'][$key]['active']): '';
  1830.                                 $highlighted = $cell_active != '' ? ' col-highlighted' : '';
  1831.                                 $highlighted .= $key%2 == 0 ? ' odd' : ' even';
  1832.                                 $out .= "<tr>";
  1833.                                 foreach ($element[$key] as $el_key => $el_val ) {
  1834.                                     $alttd = $el_key%2 == 0 ? ' odd' : ' even';
  1835.                                     if ( isset($el_key) ) {
  1836.                                         $el = $element[$key][$el_key];
  1837.                                         if ( $el_key == 1 ) {
  1838.                                             $td = 'th';
  1839.                                         } else {
  1840.                                             $td = 'td';
  1841.                                         }
  1842.                                         $the_content = preg_replace("/data-(.+?)=\'\"(.+?)\"\'/", "data-$1='{\"$2\"}'", $el['caption']);
  1843.                                         $the_content = preg_replace("/data-(.+?)=\'&quot;(.+?)&quot;\'/", "data-$1='{\"$2\"}'", $the_content);
  1844.                                         $the_content = preg_replace_callback(
  1845.                                             '/data-(.+?)=\'\{(.+?)\}\'/',
  1846.                                             'shortcodelic_match_quotes',
  1847.                                             $the_content
  1848.                                         );
  1849.                                         $the_content = wp_specialchars_decode($the_content, ENT_QUOTES);
  1850.                                         $out .= "<$td class='".$el['class']."  ".$el['customclass']."$alttd' style='width:$rowW%'>".apply_filters('the_content', $the_content)."</$td>";
  1851.                                     }
  1852.                                 }
  1853.                                 $out .= "</tr>";
  1854.                             }
  1855.                         $out .= "</table>";
  1856.                     $out .= "</div><!-- .pix_tables -->";
  1857.                     $out .= "<div class='clear'></div>";
  1858.                 }
  1859.  
  1860.             }
  1861.  
  1862.         }
  1863.  
  1864.         return $out;
  1865.  
  1866.     }  
  1867.  
  1868.     /**
  1869.      * Maps shortcode.
  1870.      *
  1871.      * @since    2.0.0
  1872.      */
  1873.     public function shortcodelicMapsSC($atts) {
  1874.  
  1875.         if (!function_exists('shortcodelic_match_apostrophes')) {
  1876.             function shortcodelic_match_apostrophes($matches) {
  1877.                 $match = preg_replace('/\'/','[apostrophe;]',$matches[0]);
  1878.                 $match = preg_replace('/\"/','[quotes;]',$match);
  1879.                 return $match;
  1880.             }
  1881.         }
  1882.  
  1883.         wp_enqueue_style( $this->plugin_slug . '-gmaps' );
  1884.         wp_enqueue_script( $this->plugin_slug . '-maps', SHORTCODELIC_URL.'scripts/maps.js', array('pix-modernizr','jquery',$this->plugin_slug.'-gmaps'));
  1885.  
  1886.         global $post;
  1887.  
  1888.         extract(shortcode_atts(array(
  1889.             'postid' => '',
  1890.             'map' => ''
  1891.         ), $atts));
  1892.  
  1893.         $postid = $postid == '' ? $post->ID : $postid;
  1894.  
  1895.         $out = '';
  1896.  
  1897.         $values = get_post_custom( $postid );
  1898.         $shortcodelic_maps = isset( $values['shortcodelic_maps'] ) ? $values['shortcodelic_maps'][0] : '';
  1899.         $shortcodelic_maps = maybe_unserialize($shortcodelic_maps);
  1900.         $mapsSize = $map;
  1901.  
  1902.         if (is_array($shortcodelic_maps)) {
  1903.  
  1904.             $coords = isset($shortcodelic_maps['shortcodelic_maps_'.$mapsSize]['coords']) ? esc_attr($shortcodelic_maps['shortcodelic_maps_'.$mapsSize]['coords']) : '41.890322,12.492312';
  1905.             $width = isset($shortcodelic_maps['shortcodelic_maps_'.$mapsSize]['width']) ? esc_attr($shortcodelic_maps['shortcodelic_maps_'.$mapsSize]['width']) : '100';
  1906.             $height = isset($shortcodelic_maps['shortcodelic_maps_'.$mapsSize]['height']) ? esc_attr($shortcodelic_maps['shortcodelic_maps_'.$mapsSize]['height']) : '56';
  1907.             $type = isset($shortcodelic_maps['shortcodelic_maps_'.$mapsSize]['type']) ? esc_attr($shortcodelic_maps['shortcodelic_maps_'.$mapsSize]['type']) : 'roadmap';
  1908.             $heading = isset($shortcodelic_maps['shortcodelic_maps_'.$mapsSize]['heading']) ? esc_attr($shortcodelic_maps['shortcodelic_maps_'.$mapsSize]['heading']) : '90';
  1909.             $pitch = isset($shortcodelic_maps['shortcodelic_maps_'.$mapsSize]['pitch']) ? esc_attr($shortcodelic_maps['shortcodelic_maps_'.$mapsSize]['pitch']) : '0';
  1910.             $zoom = isset($shortcodelic_maps['shortcodelic_maps_'.$mapsSize]['zoom']) ? esc_attr($shortcodelic_maps['shortcodelic_maps_'.$mapsSize]['zoom']) : '12';
  1911.             $maptype = isset($shortcodelic_maps['shortcodelic_maps_'.$mapsSize]['maptype']) ? strtoupper(esc_attr($shortcodelic_maps['shortcodelic_maps_'.$mapsSize]['maptype'])) : 'TOP_RIGHT';
  1912.             $pancontrol = isset($shortcodelic_maps['shortcodelic_maps_'.$mapsSize]['pancontrol']) ? strtoupper(esc_attr($shortcodelic_maps['shortcodelic_maps_'.$mapsSize]['pancontrol'])) : 'TOP_LEFT';
  1913.             $zoomcontrol = isset($shortcodelic_maps['shortcodelic_maps_'.$mapsSize]['zoomcontrol']) ? strtoupper(esc_attr($shortcodelic_maps['shortcodelic_maps_'.$mapsSize]['zoomcontrol'])) : 'TOP_LEFT';
  1914.             $zoomcontrolsize = isset($shortcodelic_maps['shortcodelic_maps_'.$mapsSize]['zoomcontrolsize']) ? strtoupper(esc_attr($shortcodelic_maps['shortcodelic_maps_'.$mapsSize]['zoomcontrolsize'])) : 'DEFAULT';
  1915.             $scalecontrol = isset($shortcodelic_maps['shortcodelic_maps_'.$mapsSize]['scalecontrol']) ? esc_attr($shortcodelic_maps['shortcodelic_maps_'.$mapsSize]['scalecontrol']) : '""';
  1916.             $swcontrol = isset($shortcodelic_maps['shortcodelic_maps_'.$mapsSize]['swcontrol']) ? strtoupper(esc_attr($shortcodelic_maps['shortcodelic_maps_'.$mapsSize]['swcontrol'])) : 'TOP_LEFT';
  1917.             $start = isset($shortcodelic_maps['shortcodelic_maps_'.$mapsSize]['start']) ? esc_attr($shortcodelic_maps['shortcodelic_maps_'.$mapsSize]['start']) : '""';
  1918.             $end = isset($shortcodelic_maps['shortcodelic_maps_'.$mapsSize]['end']) ? esc_attr($shortcodelic_maps['shortcodelic_maps_'.$mapsSize]['end']) : '';
  1919.             $travelmode = isset($shortcodelic_maps['shortcodelic_maps_'.$mapsSize]['travelmode']) ? esc_attr($shortcodelic_maps['shortcodelic_maps_'.$mapsSize]['travelmode']) : '""';
  1920.             $color = isset($shortcodelic_maps['shortcodelic_maps_'.$mapsSize]['color']) ? esc_attr($shortcodelic_maps['shortcodelic_maps_'.$mapsSize]['color']) : '#d42027';
  1921.             $opacity = isset($shortcodelic_maps['shortcodelic_maps_'.$mapsSize]['opacity']) ? esc_attr($shortcodelic_maps['shortcodelic_maps_'.$mapsSize]['opacity']) : '0.75';
  1922.             $strokeweight = isset($shortcodelic_maps['shortcodelic_maps_'.$mapsSize]['strokeweight']) ? esc_attr($shortcodelic_maps['shortcodelic_maps_'.$mapsSize]['strokeweight']) : '5';
  1923.             $markers = isset($shortcodelic_maps['shortcodelic_maps_'.$mapsSize]['markers']) && is_array($shortcodelic_maps['shortcodelic_maps_'.$mapsSize]['markers']) ? stripslashes(json_encode($shortcodelic_maps['shortcodelic_maps_'.$mapsSize]['markers'])) : '""';
  1924.             $markers = preg_replace_callback(
  1925.                 '/<p>(.*?)<\/p>/',
  1926.                 'shortcodelic_match_apostrophes',
  1927.                 $markers
  1928.             );
  1929.             $style = isset($shortcodelic_maps['shortcodelic_maps_'.$mapsSize]['style']) ? html_entity_decode($shortcodelic_maps['shortcodelic_maps_'.$mapsSize]['style']) : '';
  1930.  
  1931.             $out .= "<div data-id='pix_maps-$postid-$map' class='pix_maps pix_maps-post-$postid pix_maps-map-$map' data-opts='{\"coords\":\"$coords\",\"width\":\"$width\",\"height\":\"$height\",\"type\":\"$type\",\"heading\":\"$heading\",\"pitch\":\"$pitch\",\"zoom\":\"$zoom\",\"maptype\":\"$maptype\",\"pancontrol\":\"$pancontrol\",\"zoomcontrol\":\"$zoomcontrol\",\"zoomcontrolsize\":\"$zoomcontrolsize\",\"scalecontrol\":\"$scalecontrol\",\"swcontrol\":\"$swcontrol\",\"start\":\"$start\",\"end\":\"$end\",\"travelmode\":\"$travelmode\",\"color\":\"$color\",\"opacity\":\"$opacity\",\"strokeweight\":\"$strokeweight\",\"markers\":$markers,\"id\":\"$postid"."_$map\"}'>";
  1932.  
  1933.             if ( $style!='' ) {
  1934.                 $style = preg_replace("/\s+/", " ", $style);
  1935.                 $style = preg_replace("/var(.+?)\=/", "", $style);
  1936.                 $style = preg_replace("/;/", "", $style);
  1937.                 $out .= "<script type='text/javascript'>
  1938.                     var styles_$postid"."_$map = $style;
  1939.                 </script>";
  1940.             } else {
  1941.                 $out .= "<script type='text/javascript'>
  1942.                     var styles_$postid"."_$map = '';
  1943.                 </script>";
  1944.             }
  1945.  
  1946.             $out .= "</div><!-- .pix_maps -->";
  1947.             $out .= "<div class='clear'></div>";
  1948.  
  1949.         }
  1950.  
  1951.         return $out;
  1952.  
  1953.     }  
  1954.  
  1955.     /**
  1956.      * Carousel shortcode.
  1957.      *
  1958.      * @since    2.1.0
  1959.      */
  1960.     public function shortcodelicCarouselsSC($atts) {
  1961.  
  1962.         global $content_widthm, $post;
  1963.         if ( ! isset( $content_width ) ) $content_width = 1280;
  1964.  
  1965.         wp_enqueue_style( $this->plugin_slug . '-carousel' );
  1966.         wp_enqueue_script( $this->plugin_slug . '-carousel', SHORTCODELIC_URL.'scripts/carousel.js', array('pix-modernizr','jquery',$this->plugin_slug.'-bxslider'));
  1967.  
  1968.         extract(shortcode_atts(array(
  1969.             'postid' => '',
  1970.             'carousel' => ''
  1971.         ), $atts));
  1972.  
  1973.         $postid = $postid == '' ? $post->ID : $postid;
  1974.  
  1975.  
  1976.         $out = '';
  1977.  
  1978.         $values = get_post_custom( $postid );
  1979.         $shortcodelic_carousels = isset( $values['shortcodelic_carousels'] ) ? $values['shortcodelic_carousels'][0] : '';
  1980.         $shortcodelic_carousels = maybe_unserialize($shortcodelic_carousels);
  1981.         $carouselSize = $carousel;
  1982.  
  1983.         if (is_array($shortcodelic_carousels)) {
  1984.  
  1985.             $mode = isset($shortcodelic_carousels['shortcodelic_carousels_'.$carouselSize]['mode']) ? esc_attr($shortcodelic_carousels['shortcodelic_carousels_'.$carouselSize]['mode']) : 'horizontal';
  1986.             $slidewidth = isset($shortcodelic_carousels['shortcodelic_carousels_'.$carouselSize]['slidewidth']) ? esc_attr($shortcodelic_carousels['shortcodelic_carousels_'.$carouselSize]['slidewidth']) : floor(($content_width+(20*3))/4);
  1987.             $timeout = isset($shortcodelic_carousels['shortcodelic_carousels_'.$carouselSize]['timeout']) ? esc_attr($shortcodelic_carousels['shortcodelic_carousels_'.$carouselSize]['timeout']) : '7000';
  1988.             $speed = isset($shortcodelic_carousels['shortcodelic_carousels_'.$carouselSize]['speed']) ? esc_attr($shortcodelic_carousels['shortcodelic_carousels_'.$carouselSize]['speed']) : '750';
  1989.             $autoplay = isset($shortcodelic_carousels['shortcodelic_carousels_'.$carouselSize]['autoplay']) ? esc_attr($shortcodelic_carousels['shortcodelic_carousels_'.$carouselSize]['autoplay']) : 'true';
  1990.             $hover = isset($shortcodelic_carousels['shortcodelic_carousels_'.$carouselSize]['hover']) ? esc_attr($shortcodelic_carousels['shortcodelic_carousels_'.$carouselSize]['hover']) : 'true';
  1991.             $play_pause = isset($shortcodelic_carousels['shortcodelic_carousels_'.$carouselSize]['play_pause']) ? esc_attr($shortcodelic_carousels['shortcodelic_carousels_'.$carouselSize]['play_pause']) : 'true';
  1992.             $prev_next = isset($shortcodelic_carousels['shortcodelic_carousels_'.$carouselSize]['prev_next']) ? esc_attr($shortcodelic_carousels['shortcodelic_carousels_'.$carouselSize]['prev_next']) : 'true';
  1993.             $bullets = isset($shortcodelic_carousels['shortcodelic_carousels_'.$carouselSize]['bullets']) ? esc_attr($shortcodelic_carousels['shortcodelic_carousels_'.$carouselSize]['bullets']) : 'true';
  1994.             $minslides = isset($shortcodelic_carousels['shortcodelic_carousels_'.$carouselSize]['minslides']) ? esc_attr($shortcodelic_carousels['shortcodelic_carousels_'.$carouselSize]['minslides']) : 4;
  1995.             $maxslides = isset($shortcodelic_carousels['shortcodelic_carousels_'.$carouselSize]['maxslides']) ? esc_attr($shortcodelic_carousels['shortcodelic_carousels_'.$carouselSize]['maxslides']) : 4;
  1996.             $slidemargin = isset($shortcodelic_carousels['shortcodelic_carousels_'.$carouselSize]['slidemargin']) ? esc_attr($shortcodelic_carousels['shortcodelic_carousels_'.$carouselSize]['slidemargin']) : 20;
  1997.  
  1998.             $out .= "<div id='pix_carousels-post-$postid-carousel-$carousel' class='pix_carousels pix_carousels-post-$postid pix_carousels-carousel-$carousel lazyme' data-opts='{\"mode\":\"$mode\",\"slidewidth\":\"$slidewidth\",\"timeout\":\"$timeout\",\"speed\":\"$speed\",\"autoplay\":\"$autoplay\",\"hover\":\"$hover\",\"play_pause\":\"$play_pause\",\"prev_next\":\"$prev_next\",\"bullets\":\"$bullets\",\"minslides\":\"$minslides\",\"maxslides\":\"$maxslides\",\"slidemargin\":\"$slidemargin\"}'>";
  1999.  
  2000.                 if (isset($shortcodelic_carousels['shortcodelic_carousels_'.$carouselSize]['slide']) && is_array($shortcodelic_carousels['shortcodelic_carousels_'.$carouselSize]['slide'])) {
  2001.                     $i = 1; foreach ($shortcodelic_carousels['shortcodelic_carousels_'.$carouselSize]['slide'] as $key => &$slide) {
  2002.  
  2003.                         $attachment_bg = isset($shortcodelic_carousels['shortcodelic_carousels_'.$carouselSize]['slide'][$key]['bg']) ? esc_attr($shortcodelic_carousels['shortcodelic_carousels_'.$carouselSize]['slide'][$key]['bg']) : '';
  2004.                         $attachment_id = $this->attachment_meta_by_url($attachment_bg);
  2005.                         $attachment_size = isset($shortcodelic_carousels['shortcodelic_carousels_'.$carouselSize]['slide'][$key]['size']) ? esc_attr($shortcodelic_carousels['shortcodelic_carousels_'.$carouselSize]['slide'][$key]['size']): '';
  2006.                         $attachment_box = isset($shortcodelic_carousels['shortcodelic_carousels_'.$carouselSize]['slide'][$key]['box']) ? esc_attr($shortcodelic_carousels['shortcodelic_carousels_'.$carouselSize]['slide'][$key]['box']): 'true';
  2007.                         $attachment_link = isset($shortcodelic_carousels['shortcodelic_carousels_'.$carouselSize]['slide'][$key]['link']) ? esc_attr($shortcodelic_carousels['shortcodelic_carousels_'.$carouselSize]['slide'][$key]['link']): '';
  2008.                         $attachment_target = isset($shortcodelic_carousels['shortcodelic_carousels_'.$carouselSize]['slide'][$key]['target']) ? esc_attr($shortcodelic_carousels['shortcodelic_carousels_'.$carouselSize]['slide'][$key]['target']): '';
  2009.                         $attachment_caption = isset($shortcodelic_carousels['shortcodelic_carousels_'.$carouselSize]['slide'][$key]['caption']) ? esc_attr($shortcodelic_carousels['shortcodelic_carousels_'.$carouselSize]['slide'][$key]['caption']): '';
  2010.  
  2011.                         $cover = '';
  2012.                         if ( $attachment_id != '' ) {
  2013.                             $attachment_bg = wp_get_attachment_image( $attachment_id, $attachment_size );
  2014.                         } else {
  2015.                             $attachment_bg = "<img src='$attachment_bg'>";
  2016.                         }
  2017.  
  2018.                         if ( $attachment_id != '' ) {
  2019.                             $attachment_bg = wp_get_attachment_url( $attachment_id, $attachment_size );
  2020.                             $th_meta = wp_get_attachment_metadata( $attachment_id );
  2021.                             if ( isset($th_meta['sizes'][$attachment_size]) ) {
  2022.                                 $th_W = $th_meta['sizes'][$attachment_size]['width'];
  2023.                                 $th_H = $th_meta['sizes'][$attachment_size]['height'];
  2024.                             } else {
  2025.                                 $th_W = $th_meta['width'];
  2026.                                 $th_H = $th_meta['height'];
  2027.                             }
  2028.                             $max_H = ($th_H/$th_W)*100 . '%';
  2029.                             $attachment_bg = "<img src='".SHORTCODELIC_URL."images/blank.png' data-src='$attachment_bg' width='$th_W' height='$th_H' data-maxheight='$max_H'>";
  2030.                         } else {
  2031.                              $attachment_bg = "<img src='$attachment_bg'>";
  2032.                         }
  2033.  
  2034.  
  2035.  
  2036.                         $out .= "<div>";
  2037.                         $closelink = false;
  2038.  
  2039.                         if ( $attachment_box == 'true' && $attachment_id != '' ) {
  2040.                             $attachment_full = wp_get_attachment_image_src( $attachment_id, 'full' );
  2041.                             $out .= "<a href='$attachment_full[0]' data-rel='pix_carousels-post-$postid-carousel-$carousel'>";
  2042.                             $closelink = true;
  2043.                         } elseif ( $attachment_link != '' ) {
  2044.                             $out .= "<a href='$attachment_link' target='$attachment_target'>";
  2045.                             $closelink = true;
  2046.                         }
  2047.                         $out .= $attachment_bg;
  2048.                         if ( $closelink == true ) {
  2049.                             $out .= "</a>";
  2050.                         }
  2051.                         $the_content = wp_specialchars_decode($attachment_caption, ENT_QUOTES);
  2052.                         $out .= $the_content;
  2053.                         $out .= "</div>";
  2054.                     }
  2055.                 }
  2056.             $out .= "</div><!-- .pix_carousels -->";
  2057.             $out .= "<div class='clear'></div>";
  2058.  
  2059.         }
  2060.  
  2061.         return $out;
  2062.  
  2063.     }  
  2064.  
  2065.     /**
  2066.      * Post carousel shortcode.
  2067.      *
  2068.      * @since    2.3.0
  2069.      */
  2070.     /**
  2071.      * Post carousel shortcode.
  2072.      *
  2073.      * @since    2.4.3
  2074.      */
  2075.     public function shortcodelicPostCarouselsSC($atts) {
  2076.  
  2077.         global $content_width, $post;
  2078.         if ( ! isset( $content_width ) ) $content_width = 1280;
  2079.  
  2080.         wp_enqueue_style( $this->plugin_slug . '-carousel' );
  2081.         wp_enqueue_script( $this->plugin_slug . '-carousel', SHORTCODELIC_URL.'scripts/carousel.js', array('pix-modernizr','jquery',$this->plugin_slug.'-bxslider'));
  2082.  
  2083.         extract(shortcode_atts(array(
  2084.             'postid' => '',
  2085.             'carousel' => ''
  2086.         ), $atts));
  2087.  
  2088.         $postid = $postid == '' ? $post->ID : $postid;
  2089.  
  2090.         $out = '';
  2091.  
  2092.         $values = get_post_custom( $postid );
  2093.         $shortcodelic_postcarousels = isset( $values['shortcodelic_postcarousels'] ) ? $values['shortcodelic_postcarousels'][0] : '';
  2094.         $shortcodelic_postcarousels = maybe_unserialize($shortcodelic_postcarousels);
  2095.         $postcarouselSize = $carousel;
  2096.  
  2097.         if (is_array($shortcodelic_postcarousels)) {
  2098.  
  2099.             $cats = isset($shortcodelic_postcarousels['shortcodelic_postcarousels_'.$postcarouselSize]['cats']) && is_array($shortcodelic_postcarousels['shortcodelic_postcarousels_'.$postcarouselSize]['cats']) ? $shortcodelic_postcarousels['shortcodelic_postcarousels_'.$postcarouselSize]['cats'] : array();
  2100.  
  2101.             $included = isset($shortcodelic_postcarousels['shortcodelic_postcarousels_'.$postcarouselSize]['included']) ? $shortcodelic_postcarousels['shortcodelic_postcarousels_'.$postcarouselSize]['included'] : '';
  2102.             $included = (!is_array($included) && $included!='') ? explode(',',$included) : $included;
  2103.  
  2104.             $excluded = isset($shortcodelic_postcarousels['shortcodelic_postcarousels_'.$postcarouselSize]['excluded']) ? $shortcodelic_postcarousels['shortcodelic_postcarousels_'.$postcarouselSize]['excluded'] : '';
  2105.             $excluded = (!is_array($excluded) && $excluded!='') ? explode(',',$excluded) : $excluded;
  2106.  
  2107.             $order = isset($shortcodelic_postcarousels['shortcodelic_postcarousels_'.$postcarouselSize]['order']) ? esc_attr($shortcodelic_postcarousels['shortcodelic_postcarousels_'.$postcarouselSize]['order']) : 'DESC';
  2108.             $orderby = isset($shortcodelic_postcarousels['shortcodelic_postcarousels_'.$postcarouselSize]['orderby']) ? esc_attr($shortcodelic_postcarousels['shortcodelic_postcarousels_'.$postcarouselSize]['orderby']) : 'date';
  2109.             $mode = isset($shortcodelic_postcarousels['shortcodelic_postcarousels_'.$postcarouselSize]['mode']) ? esc_attr($shortcodelic_postcarousels['shortcodelic_postcarousels_'.$postcarouselSize]['mode']) : 'horizontal';
  2110.             $slidewidth = isset($shortcodelic_postcarousels['shortcodelic_postcarousels_'.$postcarouselSize]['slidewidth']) ? esc_attr($shortcodelic_postcarousels['shortcodelic_postcarousels_'.$postcarouselSize]['slidewidth']) : floor(($content_width+(20*3))/4);
  2111.             $timeout = isset($shortcodelic_postcarousels['shortcodelic_postcarousels_'.$postcarouselSize]['timeout']) ? esc_attr($shortcodelic_postcarousels['shortcodelic_postcarousels_'.$postcarouselSize]['timeout']) : '7000';
  2112.             $speed = isset($shortcodelic_postcarousels['shortcodelic_postcarousels_'.$postcarouselSize]['speed']) ? esc_attr($shortcodelic_postcarousels['shortcodelic_postcarousels_'.$postcarouselSize]['speed']) : '750';
  2113.             $ppp = isset($shortcodelic_postcarousels['shortcodelic_postcarousels_'.$postcarouselSize]['ppp']) ? esc_attr($shortcodelic_postcarousels['shortcodelic_postcarousels_'.$postcarouselSize]['ppp']) : '10';
  2114.             $post_title = isset($shortcodelic_postcarousels['shortcodelic_postcarousels_'.$postcarouselSize]['post_title']) ? esc_attr($shortcodelic_postcarousels['shortcodelic_postcarousels_'.$postcarouselSize]['post_title']) : 'true';
  2115.             $featured_img = isset($shortcodelic_postcarousels['shortcodelic_postcarousels_'.$postcarouselSize]['featured_img']) ? esc_attr($shortcodelic_postcarousels['shortcodelic_postcarousels_'.$postcarouselSize]['featured_img']) : 'true';
  2116.             $post_excerpt = isset($shortcodelic_postcarousels['shortcodelic_postcarousels_'.$postcarouselSize]['post_excerpt']) ? esc_attr($shortcodelic_postcarousels['shortcodelic_postcarousels_'.$postcarouselSize]['post_excerpt']) : 'true';
  2117.             $link = isset($shortcodelic_postcarousels['shortcodelic_postcarousels_'.$postcarouselSize]['link']) ? esc_attr($shortcodelic_postcarousels['shortcodelic_postcarousels_'.$postcarouselSize]['link']) : 'post';
  2118.             $linktitle = isset($shortcodelic_postcarousels['shortcodelic_postcarousels_'.$postcarouselSize]['linktitle']) ? esc_attr($shortcodelic_postcarousels['shortcodelic_postcarousels_'.$postcarouselSize]['linktitle']) : 'post';
  2119.             $size = isset($shortcodelic_postcarousels['shortcodelic_postcarousels_'.$postcarouselSize]['size']) ? esc_attr($shortcodelic_postcarousels['shortcodelic_postcarousels_'.$postcarouselSize]['size']) : 'full';
  2120.             $autoplay = isset($shortcodelic_postcarousels['shortcodelic_postcarousels_'.$postcarouselSize]['autoplay']) ? esc_attr($shortcodelic_postcarousels['shortcodelic_postcarousels_'.$postcarouselSize]['autoplay']) : 'true';
  2121.             $hover = isset($shortcodelic_postcarousels['shortcodelic_postcarousels_'.$postcarouselSize]['hover']) ? esc_attr($shortcodelic_postcarousels['shortcodelic_postcarousels_'.$postcarouselSize]['hover']) : 'true';
  2122.             $play_pause = isset($shortcodelic_postcarousels['shortcodelic_postcarousels_'.$postcarouselSize]['play_pause']) ? esc_attr($shortcodelic_postcarousels['shortcodelic_postcarousels_'.$postcarouselSize]['play_pause']) : 'true';
  2123.             $prev_next = isset($shortcodelic_postcarousels['shortcodelic_postcarousels_'.$postcarouselSize]['prev_next']) ? esc_attr($shortcodelic_postcarousels['shortcodelic_postcarousels_'.$postcarouselSize]['prev_next']) : 'true';
  2124.             $bullets = isset($shortcodelic_postcarousels['shortcodelic_postcarousels_'.$postcarouselSize]['bullets']) ? esc_attr($shortcodelic_postcarousels['shortcodelic_postcarousels_'.$postcarouselSize]['bullets']) : 'true';
  2125.             $minslides = isset($shortcodelic_postcarousels['shortcodelic_postcarousels_'.$postcarouselSize]['minslides']) ? esc_attr($shortcodelic_postcarousels['shortcodelic_postcarousels_'.$postcarouselSize]['minslides']) : 2;
  2126.             $maxslides = isset($shortcodelic_postcarousels['shortcodelic_postcarousels_'.$postcarouselSize]['maxslides']) ? esc_attr($shortcodelic_postcarousels['shortcodelic_postcarousels_'.$postcarouselSize]['maxslides']) : 4;
  2127.             $slidemargin = isset($shortcodelic_postcarousels['shortcodelic_postcarousels_'.$postcarouselSize]['slidemargin']) ? esc_attr($shortcodelic_postcarousels['shortcodelic_postcarousels_'.$postcarouselSize]['slidemargin']) : 20;
  2128.  
  2129.             $out .= "<div id='pix_postcarousels-$carousel' class='pix_postcarousels pix_postcarousels-post-$postid pix_postcarousels-postcarousel-$carousel' data-opts='{\"mode\":\"$mode\",\"slidewidth\":\"$slidewidth\",\"timeout\":\"$timeout\",\"speed\":\"$speed\",\"autoplay\":\"$autoplay\",\"hover\":\"$hover\",\"play_pause\":\"$play_pause\",\"prev_next\":\"$prev_next\",\"bullets\":\"$bullets\",\"minslides\":\"$minslides\",\"maxslides\":\"$maxslides\",\"slidemargin\":\"$slidemargin\"}'>";
  2130.  
  2131.                 $more_args = array();
  2132.  
  2133.                 $car_args = array(
  2134.                     'post_type' => 'post',
  2135.                     'posts_per_page' => $ppp,
  2136.                     'orderby' => $orderby,
  2137.                     'order' => $order,
  2138.                     'ignore_sticky_posts'   => 1,
  2139.                 );
  2140.  
  2141.                 if ( !empty($cats)) {
  2142.                     $more_args['tax_query'] = array(
  2143.                         array(
  2144.                             'taxonomy' => 'category',
  2145.                             'field' => 'ID',
  2146.                             'terms' => $cats
  2147.                         )
  2148.                     );
  2149.                 }
  2150.  
  2151.                 if ( !empty($included)) {
  2152.                     $more_args['post__in'] = $included;
  2153.                 }
  2154.  
  2155.                 if ( !empty($excluded)) {
  2156.                     $more_args['post__not_in'] = $excluded;
  2157.                 }
  2158.  
  2159.                 $car_args = array_merge( $car_args, $more_args );
  2160.  
  2161.                 $query_car = new wp_query( $car_args );
  2162.                 if( $query_car->have_posts() ) {
  2163.                     while ( $query_car->have_posts() ) { $query_car->the_post();
  2164.                         $out .= '<div>';
  2165.                             $thumb = false;
  2166.                             if ( has_post_thumbnail() ) {
  2167.                                 $thumb_id = get_post_thumbnail_id();
  2168.                                 $thumb_src = wp_get_attachment_url( $thumb_id, $size );
  2169.                                 $th_meta = wp_get_attachment_metadata( $thumb_id );
  2170.                                 if ( isset($th_meta['sizes'][$size]) ) {
  2171.                                     $th_W = $th_meta['sizes'][$size]['width'];
  2172.                                     $th_H = $th_meta['sizes'][$size]['height'];
  2173.                                 } else {
  2174.                                     $th_W = $th_meta['width'];
  2175.                                     $th_H = $th_meta['height'];
  2176.                                 }
  2177.                                 $max_H = ($th_H/$th_W)*100 . '%';
  2178.                                 $postTh = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full' );
  2179.                                
  2180.                                 if ( $link == 'post' ) {
  2181.                                     $out .= '<a href="'. get_permalink(). '" title="'. sprintf( esc_attr__( 'Go to %s', 'shortcodelic' ), the_title_attribute( 'echo=0' ) ) .'">';
  2182.                                 } elseif ( $link == 'image' ) {
  2183.                                     $thumb = true;
  2184.                                     $out .= '<a href="'.$postTh[0].'" data-rel="pix_carousels-post-'.$postid.'-carousel-'.$carousel.'">';
  2185.                                 }
  2186.                                 //$out .= get_the_post_thumbnail(get_the_id(), $size );
  2187.                                 $out .= "<img src='".SHORTCODELIC_URL."images/blank.gif' data-src='$thumb_src' width='$th_W' height='$th_H' data-maxheight='$max_H'>";
  2188.                                 if ( $link != '' ) {
  2189.                                     $out .= '</a>';
  2190.                                 }
  2191.                             }
  2192.                             if ( $post_title == 'true' ) {
  2193.                                 $out .= '<h4>';
  2194.                                 if ( $linktitle == 'post' ) {
  2195.                                     $out .= '<a href="'. get_permalink(). '" title="'. sprintf( esc_attr__( 'Go to %s', 'shortcodelic' ), the_title_attribute( 'echo=0' ) ) .'">';
  2196.                                 } elseif ( $linktitle == 'image' && $thumb == true ) {
  2197.                                     $out .= '<a href="'.$postTh[0].'" data-rel="pix_carousels-post-'.$postid.'-carousel-'.$carousel.'">';
  2198.                                 }
  2199.                                 $out .= get_the_title();
  2200.                                 if ( $linktitle == 'post' || ($linktitle == 'image' && $thumb == true) ) {
  2201.                                     $out .= '</a>';
  2202.                                 }
  2203.                                 $out .= '</h4>';
  2204.                             }
  2205.                             if ( $post_excerpt == 'true' ) {
  2206.                                 $out .= wpautop('<p>'.get_the_excerpt().'</p>');
  2207.                             }
  2208.                         $out .= '</div>';
  2209.                     }
  2210.                 }
  2211.                 wp_reset_postdata();
  2212.  
  2213.  
  2214.                
  2215.             $out .= "</div><!-- .pix_postcarousels -->";
  2216.             $out .= "<div class='clear'></div>";
  2217.  
  2218.         }
  2219.  
  2220.         return $out;
  2221.  
  2222.     }  
  2223.  
  2224.  
  2225.     /**
  2226.      * Check if WooCommerce is active.
  2227.      *
  2228.      * @since    2.0.0
  2229.      */
  2230.     public function sc_is_woocommerce_active(){
  2231.         include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
  2232.         if (is_plugin_active('woocommerce/woocommerce.php')) {
  2233.             return true;
  2234.         } else {
  2235.             return false;
  2236.         }
  2237.     }
  2238.  
  2239.     /**
  2240.      * WooCommerce carousel shortcode.
  2241.      *
  2242.      * @since    2.4.3
  2243.      */
  2244.     public function shortcodelicWooCarouselsSC($atts) {
  2245.  
  2246.         global $post, $woocommerce, $woocommerce_loop, $woocommerce_carousel;
  2247.  
  2248.         if (self::sc_is_woocommerce_active()) {
  2249.  
  2250.             wp_enqueue_style( $this->plugin_slug . '-carousel' );
  2251.             wp_enqueue_script( $this->plugin_slug . '-carousel', SHORTCODELIC_URL.'scripts/carousel.js', array('pix-modernizr','jquery',$this->plugin_slug.'-bxslider'));
  2252.  
  2253.             extract(shortcode_atts(array(
  2254.                 'postid' => '',
  2255.                 'carousel' => ''
  2256.             ), $atts));
  2257.  
  2258.             $postid = $postid == '' ? $post->ID : $postid;
  2259.  
  2260.             $out = '';
  2261.  
  2262.             $values = get_post_custom( $postid );
  2263.             $shortcodelic_woocarousels = isset( $values['shortcodelic_woocarousels'] ) ? $values['shortcodelic_woocarousels'][0] : '';
  2264.             $shortcodelic_woocarousels = maybe_unserialize($shortcodelic_woocarousels);
  2265.             $woocarouselSize = $carousel;
  2266.  
  2267.             if (is_array($shortcodelic_woocarousels)) {
  2268.  
  2269.                 $type = isset($shortcodelic_woocarousels['shortcodelic_woocarousels_'.$woocarouselSize]['type']) ? esc_attr($shortcodelic_woocarousels['shortcodelic_woocarousels_'.$woocarouselSize]['type']) : '';
  2270.                 $category = isset($shortcodelic_woocarousels['shortcodelic_woocarousels_'.$woocarouselSize]['cats']) && is_array($shortcodelic_woocarousels['shortcodelic_woocarousels_'.$woocarouselSize]['cats']) ? $shortcodelic_woocarousels['shortcodelic_woocarousels_'.$woocarouselSize]['cats'] : array();
  2271.  
  2272.                 $included = isset($shortcodelic_woocarousels['shortcodelic_woocarousels_'.$woocarouselSize]['included']) ? $shortcodelic_woocarousels['shortcodelic_woocarousels_'.$woocarouselSize]['included'] : '';
  2273.                 $included = (!is_array($included) && $included!='') ? explode(',',$included) : $included;
  2274.  
  2275.                 $excluded = isset($shortcodelic_woocarousels['shortcodelic_woocarousels_'.$woocarouselSize]['excluded']) ? $shortcodelic_woocarousels['shortcodelic_woocarousels_'.$woocarouselSize]['excluded'] : '';
  2276.                 $excluded = (!is_array($excluded) && $excluded!='') ? explode(',',$excluded) : $excluded;
  2277.  
  2278.                 $order = isset($shortcodelic_woocarousels['shortcodelic_woocarousels_'.$woocarouselSize]['order']) ? esc_attr($shortcodelic_woocarousels['shortcodelic_woocarousels_'.$woocarouselSize]['order']) : 'DESC';
  2279.                 $orderby = isset($shortcodelic_woocarousels['shortcodelic_woocarousels_'.$woocarouselSize]['orderby']) ? esc_attr($shortcodelic_woocarousels['shortcodelic_woocarousels_'.$woocarouselSize]['orderby']) : 'date';
  2280.                 $mode = isset($shortcodelic_woocarousels['shortcodelic_woocarousels_'.$woocarouselSize]['mode']) ? esc_attr($shortcodelic_woocarousels['shortcodelic_woocarousels_'.$woocarouselSize]['mode']) : 'horizontal';
  2281.                 $columns = isset($shortcodelic_woocarousels['shortcodelic_woocarousels_'.$woocarouselSize]['column_n']) ? esc_attr($shortcodelic_woocarousels['shortcodelic_woocarousels_'.$woocarouselSize]['column_n']) : '4';
  2282.                 $timeout = isset($shortcodelic_woocarousels['shortcodelic_woocarousels_'.$woocarouselSize]['timeout']) ? esc_attr($shortcodelic_woocarousels['shortcodelic_woocarousels_'.$woocarouselSize]['timeout']) : '7000';
  2283.                 $speed = isset($shortcodelic_woocarousels['shortcodelic_woocarousels_'.$woocarouselSize]['speed']) ? esc_attr($shortcodelic_woocarousels['shortcodelic_woocarousels_'.$woocarouselSize]['speed']) : '750';
  2284.                 $per_page = isset($shortcodelic_woocarousels['shortcodelic_woocarousels_'.$woocarouselSize]['ppp']) ? esc_attr($shortcodelic_woocarousels['shortcodelic_woocarousels_'.$woocarouselSize]['ppp']) : '10';
  2285.                 $size = isset($shortcodelic_woocarousels['shortcodelic_woocarousels_'.$woocarouselSize]['size']) ? esc_attr($shortcodelic_woocarousels['shortcodelic_woocarousels_'.$woocarouselSize]['size']) : 'large';
  2286.                 $autoplay = isset($shortcodelic_woocarousels['shortcodelic_woocarousels_'.$woocarouselSize]['autoplay']) ? esc_attr($shortcodelic_woocarousels['shortcodelic_woocarousels_'.$woocarouselSize]['autoplay']) : 'true';
  2287.                 $hover = isset($shortcodelic_woocarousels['shortcodelic_woocarousels_'.$woocarouselSize]['hover']) ? esc_attr($shortcodelic_woocarousels['shortcodelic_woocarousels_'.$woocarouselSize]['hover']) : 'true';
  2288.                 $play_pause = isset($shortcodelic_woocarousels['shortcodelic_woocarousels_'.$woocarouselSize]['play_pause']) ? esc_attr($shortcodelic_woocarousels['shortcodelic_woocarousels_'.$woocarouselSize]['play_pause']) : 'true';
  2289.                 $prev_next = isset($shortcodelic_woocarousels['shortcodelic_woocarousels_'.$woocarouselSize]['prev_next']) ? esc_attr($shortcodelic_woocarousels['shortcodelic_woocarousels_'.$woocarouselSize]['prev_next']) : 'true';
  2290.                 $bullets = isset($shortcodelic_woocarousels['shortcodelic_woocarousels_'.$woocarouselSize]['bullets']) ? esc_attr($shortcodelic_woocarousels['shortcodelic_woocarousels_'.$woocarouselSize]['bullets']) : 'true';
  2291.                 $minslides = isset($shortcodelic_woocarousels['shortcodelic_woocarousels_'.$woocarouselSize]['minslides']) ? esc_attr($shortcodelic_woocarousels['shortcodelic_woocarousels_'.$woocarouselSize]['minslides']) : 4;
  2292.                 $maxslides = isset($shortcodelic_woocarousels['shortcodelic_woocarousels_'.$woocarouselSize]['maxslides']) ? esc_attr($shortcodelic_woocarousels['shortcodelic_woocarousels_'.$woocarouselSize]['maxslides']) : 4;
  2293.                 $slidemargin = isset($shortcodelic_woocarousels['shortcodelic_woocarousels_'.$woocarouselSize]['slidemargin']) ? esc_attr($shortcodelic_woocarousels['shortcodelic_woocarousels_'.$woocarouselSize]['slidemargin']) : 20;
  2294.  
  2295.                 $woocommerce_carousel = true;
  2296.                 $out .= "<div id='pix_woocarousels-$carousel' class='pix_woocarousels $woocommerce_carousel pix_woocarousels-post-$postid pix_woocarousels-woocarousel-$carousel pix-letmebe' data-opts='{\"mode\":\"$mode\",\"timeout\":\"$timeout\",\"speed\":\"$speed\",\"autoplay\":\"$autoplay\",\"hover\":\"$hover\",\"play_pause\":\"$play_pause\",\"prev_next\":\"$prev_next\",\"bullets\":\"$bullets\",\"minslides\":\"$minslides\",\"maxslides\":\"$maxslides\",\"slidemargin\":\"$slidemargin\"}'>";
  2297.  
  2298.                     if ( $type!='' &&  $type!='categories' ) {
  2299.                         $out .= do_shortcode("[$type per_page='$per_page' columns='$columns' orderby='$orderby' order='$order']");
  2300.                     } else {
  2301.                         $ordering_args = $woocommerce->query->get_catalog_ordering_args( $orderby, $order );
  2302.  
  2303.  
  2304.                         $args = array(
  2305.                             'post_type'             => 'product',
  2306.                             'post_status'           => 'publish',
  2307.                             'ignore_sticky_posts'   => 1,
  2308.                             'orderby'               => $ordering_args['orderby'],
  2309.                             'order'                 => $ordering_args['order'],
  2310.                             'posts_per_page'        => $per_page,
  2311.                             'meta_query'            => array(
  2312.                                 array(
  2313.                                     'key'           => '_visibility',
  2314.                                     'value'         => array('catalog', 'visible'),
  2315.                                     'compare'       => 'IN'
  2316.                                 )
  2317.                             ),
  2318.                             'tax_query'             => array(
  2319.                                 array(
  2320.                                     'taxonomy'      => 'product_cat',
  2321.                                     'terms'         => $category,
  2322.                                     'field'         => 'slug',
  2323.                                     'operator'      => 'IN'
  2324.                                 )
  2325.                             )
  2326.                         );
  2327.  
  2328.                         if ( !empty($included)) {
  2329.                             $args['post__in'] = $included;
  2330.                         }
  2331.  
  2332.                         if ( !empty($excluded)) {
  2333.                             $args['post__not_in'] = $excluded;
  2334.                         }
  2335.  
  2336.                         if ( isset( $ordering_args['meta_key'] ) ) {
  2337.                             $args['meta_key'] = $ordering_args['meta_key'];
  2338.                         }
  2339.  
  2340.                         ob_start();
  2341.  
  2342.                         $products = new WP_Query( $args );
  2343.  
  2344.                         $woocommerce_loop['columns'] = $columns;
  2345.  
  2346.                         if ( $products->have_posts() ) : ?>
  2347.  
  2348.                             <?php woocommerce_product_loop_start(); ?>
  2349.  
  2350.                                 <?php while ( $products->have_posts() ) : $products->the_post(); ?>
  2351.  
  2352.                                     <?php woocommerce_get_template_part( 'content', 'product' ); ?>
  2353.  
  2354.                                 <?php endwhile; // end of the loop. ?>
  2355.  
  2356.                             <?php woocommerce_product_loop_end(); ?>
  2357.  
  2358.                         <?php endif;
  2359.  
  2360.                         wp_reset_postdata();
  2361.  
  2362.                         $out .= '<div class="woocommerce">' . ob_get_clean() . '</div>';
  2363.  
  2364.                     }
  2365.                    
  2366.                 $out .= "</div><!-- .pix_woocarousels -->";
  2367.                 $out .= "<div class='clear'></div>";
  2368.  
  2369.             }
  2370.  
  2371.             $woocommerce_carousel = false;
  2372.            
  2373.             return $out;
  2374.         }
  2375.  
  2376.     }  
  2377.  
  2378.     /**
  2379.      * Progress indicators.
  2380.      *
  2381.      * @since    1.0.0
  2382.      */
  2383.     public function shortcodelicProgressSC($atts, $content = null) {
  2384.  
  2385.         global $content_width;
  2386.         if ( ! isset( $content_width ) ) $content_width = 1280;
  2387.  
  2388.         wp_enqueue_style( $this->plugin_slug . '-progress' );
  2389.         wp_enqueue_script( $this->plugin_slug . '-progress', SHORTCODELIC_URL.'scripts/progress.js', array($this->plugin_slug.'-chart','pix-modernizr','jquery','jquery-easing',$this->plugin_slug . '-transit',$this->plugin_slug . '-plugins'));
  2390.  
  2391.         extract(shortcode_atts(array(
  2392.             'label2' => '',
  2393.             'unit' => '',
  2394.             'percent' => '',
  2395.             'value' => '',
  2396.             'maximum' => '',
  2397.             'barcolor' => '',
  2398.             'trackcolor' => '',
  2399.             'style' => '',
  2400.             'linecap' => '',
  2401.             'linewidth' => '',
  2402.             'size' => '',
  2403.             'zoom' => '',
  2404.             'animate' => '',
  2405.             'class' => '',
  2406.             'id' => ''
  2407.         ), $atts));
  2408.  
  2409.         if ( $value=='' ) {
  2410.             $value = $percent;
  2411.             $maximum = 100;
  2412.         }
  2413.  
  2414.         $out = '';
  2415.  
  2416.         $id = $id !== '' ? " id='$id'" : '';
  2417.  
  2418.         if ( $style=='counter') {
  2419.             $out .= "<span class='pix_progress_$style $class'$id data-opts='{\"animate\":\"$animate\"}'>
  2420.                <span data-value=\"$value\" data-maximum=\"$value\">";
  2421.         } elseif ( $style=='pie') {
  2422.             $out .= "<span class='pix_progress_$style $class'$id data-opts='{\"barColor\":\"$barcolor\",\"trackColor\":\"$trackcolor\",\"lineCap\":\"$linecap\",\"lineWidth\":\"$linewidth\",\"size\":\"$size\",\"zoom\":\"$zoom\",\"animate\":\"$animate\"}'>
  2423.             <canvas class=\"doughnut\" width=\"$size\" height=\"$size\" data-value=\"$value\" data-maximum=\"$maximum\"></canvas>";
  2424.         } else {
  2425.             $out .= "<span class='pix_progress_$style $class'$id data-opts='{\"barColor\":\"$barcolor\",\"trackColor\":\"$trackcolor\",\"lineCap\":\"$linecap\",\"lineWidth\":\"$linewidth\",\"size\":\"$size\",\"animate\":\"$animate\"}'>
  2426.                 <span data-value=\"$value\" data-maximum=\"$maximum\">";
  2427.         }
  2428.  
  2429.         if ( $label2=='true' ) {
  2430.             $out .= "<span class='chart-amount'>
  2431.                 <span class='percent label'>$content</span>
  2432.             </span>";
  2433.         } else {
  2434.             $out .= "<span class='chart-amount'>
  2435.                 <span class='percent'></span><span class='unit'>$unit</span>
  2436.             </span>
  2437.             <span class='chart-label'>$content</span>";
  2438.         }
  2439.  
  2440.         if ( $style!='pie') {
  2441.             $out .= "</span>";
  2442.         }
  2443.  
  2444.         $out .= "</span>";
  2445.  
  2446.         return $out;
  2447.  
  2448.     }  
  2449.  
  2450.     /**
  2451.      * Text boxes.
  2452.      *
  2453.      * @since    1.0.0
  2454.      */
  2455.     public function shortcodelicBoxSC($atts, $content = null) {
  2456.  
  2457.         global $post;
  2458.  
  2459.         wp_enqueue_style( $this->plugin_slug . '-box' );
  2460.         wp_enqueue_style( $this->plugin_slug . '-fontello' );
  2461.         wp_enqueue_script( $this->plugin_slug . '-box', SHORTCODELIC_URL.'scripts/box.js', array('pix-modernizr','jquery',$this->plugin_slug.'-cookie'));
  2462.  
  2463.         extract(shortcode_atts(array(
  2464.             'position' => '',
  2465.             'custom' => '',
  2466.             'dismiss' => ''
  2467.         ), $atts));
  2468.  
  2469.         preg_match("/\<(.*?) class=[\'|\"]scicon-(.*?)<\/(.*?)>/", $content, $icon);
  2470.         if ( isset($icon[0]) ) {
  2471.             $icon = "<span class='shortcodelic-featured-icon'>$icon[0]</span>";
  2472.             $icon = preg_replace('/\<p\>/', '', $icon);
  2473.             $icon = preg_replace('/\<\/p\>/', '', $icon);
  2474.             $content = preg_replace("/\<(.*?) class=[\'|\"]scicon-(.*?)<\/(.*?)>/", "", $content, 1);
  2475.         } else {
  2476.             $icon = '';
  2477.         }
  2478.  
  2479.         $close = $dismiss != '' ? '<span class="close-box-sc"><i class="scicon-iconic-cancel"></i></span>' : '';
  2480.         $cookie = $dismiss != '' ? "data-cookie='".site_url()."_ID_".$post->ID."_".$dismiss."'" : '';
  2481.  
  2482.         $out = '';
  2483.  
  2484.         if ( $position == 'topicon' || $position == 'lefticon' ) {
  2485.             $out .= "<div class='pix_box $custom $position' $cookie>$close$icon<div class='shortcodelic-content-box'>".('<p>'.$content)."</div></div>";
  2486.         } else {
  2487.             $out .= "<div class='pix_box $custom $position' $cookie>$close<div class='shortcodelic-content-box'>".('<p>'.$content)."</div>$icon</div>";
  2488.         }
  2489.  
  2490.         $out = force_balance_tags($out);
  2491.         $out = preg_replace('/\<p\>\<\/p\>/', '', $out);
  2492.  
  2493.         return $out;
  2494.  
  2495.  
  2496.     }  
  2497.  
  2498.     /**
  2499.      * License checker.
  2500.      *
  2501.      * @since    1.2.0
  2502.      */
  2503.     public function check_license($context) {
  2504.  
  2505.         $request_url = 'http://www.pixedelic.com/api/products/shortcodelic.php';
  2506.  
  2507.         $request_string = array(
  2508.                 'body' => array(
  2509.                     'action' => 'check_shortcodelic_license',
  2510.                     'id' => '6076939',
  2511.                     'username' => $_REQUEST['shortcodelic_user_name'],
  2512.                     'license' => $_REQUEST['shortcodelic_license_key']
  2513.                 )
  2514.             );
  2515.        
  2516.         $raw_response = wp_remote_post($request_url, $request_string);
  2517.  
  2518.         if (!is_wp_error($raw_response) && ($raw_response['response']['code'] == 200)) {
  2519.             $body = addslashes($raw_response['body']);
  2520.             if( stripos($body,'perfect')!=false ) { ?>
  2521. <script type="text/javascript">
  2522. /* <![CDATA[ */
  2523. var shortcodelic_check_license = 'true',
  2524.     shortcodelic_check_message = '<?php echo $body; ?>';
  2525. /* ]]> */
  2526. </script>
  2527.             <?php } else { ?>
  2528. <script type="text/javascript">
  2529. /* <![CDATA[ */
  2530. var shortcodelic_check_license = 'false',
  2531.     shortcodelic_check_message = '<?php echo $body; ?>';
  2532. /* ]]> */
  2533. </script>
  2534.             <?php }
  2535.         }
  2536.        
  2537.     }
  2538.  
  2539.     /**
  2540.      * Check for update.
  2541.      *
  2542.      * @since    1.2.0
  2543.      */
  2544.     public function check_for_plugin_update($checked_data) {
  2545.         global $wp_version;
  2546.  
  2547.         $api_url = 'http://www.pixedelic.com/api/';
  2548.  
  2549.         if (empty($checked_data->checked))
  2550.             return $checked_data;
  2551.        
  2552.         $args = array(
  2553.             'dir' => sanitize_title( $this->plugin_name ),
  2554.             'slug' => $this->plugin_slug,
  2555.             'version' => $checked_data->checked[ SHORTCODELIC_NAME ],
  2556.             'id' => '6076939',
  2557.             'user' => get_option('shortcodelic_user_name'),
  2558.             'license' => get_option('shortcodelic_license_key')
  2559.         );
  2560.  
  2561.         $request_string = array(
  2562.                 'body' => array(
  2563.                     'action' => 'basic_check',
  2564.                     'request' => serialize($args),
  2565.                     'api-key' => md5(get_bloginfo('url'))
  2566.                 ),
  2567.                 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo('url')
  2568.             );
  2569.        
  2570.         $raw_response = wp_remote_post($api_url, $request_string);
  2571.  
  2572.         if (!is_wp_error($raw_response) && ($raw_response['response']['code'] == 200))
  2573.             $response = unserialize($raw_response['body']);
  2574.  
  2575.         if (is_object($response) && !empty($response)) // Feed the update data into WP updater
  2576.             $checked_data->response[ SHORTCODELIC_NAME ] = $response;
  2577.        
  2578.         return $checked_data;
  2579.     }
  2580.  
  2581.     /**
  2582.      * Call for update.
  2583.      *
  2584.      * @since    1.2.0
  2585.      */
  2586.     public function plugin_api_call($def, $action, $args) {
  2587.         global $wp_version;
  2588.        
  2589.         $api_url = 'http://www.pixedelic.com/api/';
  2590.        
  2591.         if (!isset($args->slug) || ($args->slug != $this->plugin_slug))
  2592.             return false;
  2593.        
  2594.         $plugin_info = get_site_transient('update_plugins');
  2595.         $current_version = $plugin_info->checked[ SHORTCODELIC_NAME ];
  2596.         $args->version = $current_version;
  2597.        
  2598.         $request_string = array(
  2599.                 'body' => array(
  2600.                     'action' => $action,
  2601.                     'request' => serialize($args),
  2602.                     'api-key' => md5(get_bloginfo('url'))
  2603.                 ),
  2604.                 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo('url')
  2605.             );
  2606.        
  2607.         $request = wp_remote_post($api_url, $request_string);
  2608.  
  2609.         if (is_wp_error($request)) {
  2610.             $res = new WP_Error('plugins_api_failed', __('An Unexpected HTTP Error occurred during the API request.</p> <p><a href="?" onclick="document.location.reload(); return false;">Try again</a>'), $request->get_error_message());
  2611.         } else {
  2612.             $res = unserialize($request['body']);
  2613.  
  2614.             if ($res === false)
  2615.                 $res = new WP_Error('plugins_api_failed', __('An unknown error occurred'), $request['body']);
  2616.         }
  2617.        
  2618.         return $res;
  2619.     }
  2620.  
  2621.  
  2622.     /**
  2623.      * Workaround for Sharedaddy.
  2624.      *
  2625.      * @since    2.0.0
  2626.      */
  2627.     public function shortcodelic_remove_sharedaddy() {
  2628.         remove_filter( 'the_content', 'sharing_display',19 );
  2629.         if ( class_exists( 'Jetpack_Likes' ) ) {
  2630.             remove_filter( 'the_content', array( Jetpack_Likes::init(), 'post_likes' ), 30, 1 );
  2631.         }
  2632.     }
  2633.  
  2634.  
  2635.     /**
  2636.      * Workaround for Sharedaddy (2).
  2637.      *
  2638.      * @since    2.0.0
  2639.      */
  2640.     public function shortcodelic_append_sharedaddy($content) {
  2641.         if ( function_exists( 'sharing_display' ) ) {
  2642.             $content .= sharing_display( '', false );
  2643.         }
  2644.  
  2645.         if ( class_exists( 'Jetpack_Likes' ) ) {
  2646.             $custom_likes = new Jetpack_Likes;
  2647.             $content .= $custom_likes->post_likes( '' );
  2648.         }
  2649.  
  2650.         return $content;
  2651.     }
  2652.  
  2653.     /**
  2654.     * Get the attachment ID by url
  2655.     *
  2656.      * @since    2.1.0
  2657.     */
  2658.     public function attachment_meta_by_url( $image_src ) {
  2659.  
  2660.         global $wpdb;
  2661.         $query = "SELECT ID FROM {$wpdb->posts} WHERE guid='$image_src'";
  2662.         $id = $wpdb->get_var($query);
  2663.  
  2664.         if($id != null){
  2665.             $array = wp_get_attachment_metadata($id);
  2666.             if (is_array($array)) {
  2667.                 $meta['width'] = $array['width'];
  2668.                 $meta['height'] = $array['height'];
  2669.             } else {
  2670.                 $meta['width'] = '';
  2671.                 $meta['height'] = '';
  2672.             }
  2673.         } else {
  2674.             $image_src = basename ( $image_src );
  2675.             $q2 = "SELECT post_id FROM {$wpdb->postmeta}  WHERE meta_key = '_wp_attachment_metadata' AND meta_value LIKE '%$image_src%'";
  2676.             $id = $wpdb->get_var($q2);
  2677.             $array = wp_get_attachment_metadata($id);
  2678.             if ( isset($array['sizes']) ) {
  2679.                 foreach ($array['sizes'] as $key => $value) {
  2680.                     if ( in_array($image_src, $value) ) {
  2681.                         $meta['width'] = $value['width'];
  2682.                         $meta['height'] = $value['height'];
  2683.                         break;
  2684.                     }
  2685.                 }
  2686.             }
  2687.         }
  2688.  
  2689.         //$meta['id'] = $id;
  2690.  
  2691.         return $id;
  2692.  
  2693.     }
  2694.  
  2695. }
  2696.  
  2697. if ( !function_exists('shortcodelic_preg_callback_meta_value_json_quotes') ) {
  2698.     function shortcodelic_preg_callback_meta_value_json_quotes($matches){
  2699.         $noquotes = preg_replace( '/\"/', '\'', $matches[3] );
  2700.         return "s:$matches[1]:\"$matches[2][$noquotes]";
  2701.     }
  2702. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement