Guest User

Untitled

a guest
Jan 15th, 2018
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.18 KB | None | 0 0
  1. <?php
  2. // Translation
  3. load_theme_textdomain('Creativo', get_template_directory() . '/languages');
  4.  
  5. // Add default posts and comments RSS feed links to head.
  6. add_theme_support( 'automatic-feed-links' );
  7.  
  8. /*
  9. * Let WordPress manage the document title.
  10. * By adding theme support, we declare that this theme does not use a
  11. * hard-coded <title> tag in the document head, and expect WordPress to
  12. * provide it for us.
  13. */
  14. add_theme_support( 'title-tag' );
  15.  
  16. require_once (get_template_directory().'/admin/index.php');
  17. /*
  18. if ($_GET['activated']){
  19. wp_redirect(admin_url("themes.php?page=optionsframework"));
  20. }
  21. */
  22. require_once(get_template_directory() . "/functions/megamenu/wp-nav-custom-walker.php");
  23.  
  24. if (is_admin()) {
  25. include_once (get_template_directory().'/functions/megamenu/mega-menu.php');
  26. include_once (get_template_directory().'/radium-demo-install/init.php');
  27. }
  28.  
  29. function cr_theme_is_menus()
  30. {
  31. if ('nav-menus.php' == basename($_SERVER['PHP_SELF'])) {
  32. return true;
  33. }
  34. // to be add some check code for validate only in theme options pages
  35. return false;
  36. }
  37.  
  38. /* Load here the required actions */
  39. require_once locate_template('functions/actions/header.php');
  40.  
  41. /*-----------------------------------------------------------------------------------*/
  42. /* Register WP3.0+ Menus
  43. /*-----------------------------------------------------------------------------------*/
  44.  
  45. if( !function_exists( 'cr_register_menu' ) ) {
  46. function cr_register_menu() {
  47. register_nav_menu('primary-menu', __('Primary Menu'));
  48. register_nav_menu('side-menu', __('Side Navigation Menu'));
  49. register_nav_menu('top-menu', __('Top Menu'));
  50. register_nav_menu('one-page-menu', __('One Page Menu'));
  51. register_nav_menu('footer-menu', __('Footer Menu'));
  52. }
  53.  
  54. add_action('init', 'cr_register_menu');
  55. }
  56.  
  57. /**
  58. * Register our sidebars and widgetized areas.
  59. *
  60. * @since Twenty Eleven 1.0
  61. */
  62. function creativo_widgets_init() {
  63. register_sidebar( array(
  64. 'name' => __( 'Blog Sidebar', 'Creativo' ),
  65. 'id' => 'sidebar-1',
  66. 'before_widget' => '<div class="sidebar-widget">',
  67. 'after_widget' => '</div>',
  68. 'before_title' => '<div class="title-holder"><h3 class="sidebar-title">',
  69. 'after_title' => '</h3></div>',
  70. ) );
  71.  
  72. register_sidebar( array(
  73. 'name' => __( 'Off-Canvas Sidebar', 'Creativo' ),
  74. 'id' => 'sidebar-3',
  75. 'before_widget' => '<div class="sidebar-widget">',
  76. 'after_widget' => '</div>',
  77. 'before_title' => '<h3 class="sidebar-title">',
  78. 'after_title' => '</h3>',
  79. ) );
  80.  
  81. register_sidebar( array(
  82. 'name' => __( 'WooCommerce Sidebar', 'Creativo' ),
  83. 'id' => 'woocommerce-sidebar',
  84. 'before_widget' => '<div class="sidebar-widget %2$s">',
  85. 'after_widget' => '</div>',
  86. 'before_title' => '<h3 class="sidebar-title">',
  87. 'after_title' => '</h3>',
  88. ) );
  89.  
  90. register_sidebar( array(
  91. 'name' => __( 'Footer Sidebar', 'Creativo' ),
  92. 'id' => 'sidebar-2',
  93. 'before_widget' => '<div class="footer_widget_content">',
  94. 'after_widget' => '</div>',
  95. 'before_title' => '<h3 class="footer-widget-title">',
  96. 'after_title' => '</h3>',
  97. ) );
  98.  
  99. register_sidebar( array(
  100. 'name' => __( 'bbPress Sidebar', 'Creativo' ),
  101. 'id' => 'sidebar-5',
  102. 'before_widget' => '<div class="sidebar-widget %2$s">',
  103. 'after_widget' => '</div>',
  104. 'before_title' => '<h3 class="sidebar-title">',
  105. 'after_title' => '</h3>',
  106. ) );
  107.  
  108. }
  109. add_action( 'widgets_init', 'creativo_widgets_init' );
  110.  
  111. //fixing filtering for shortcodes
  112. function shortcode_empty_paragraph_fix($content){
  113. $array = array (
  114. '<p>[' => '[',
  115. ']</p>' => ']',
  116. ']<br />' => ']'
  117. );
  118.  
  119. $content = strtr($content, $array);
  120. return $content;
  121. }
  122.  
  123. //allow custom font upload
  124. add_filter('the_content', 'shortcode_empty_paragraph_fix');
  125.  
  126. add_filter('upload_mimes', 'cr_filter_mime_types');
  127. function cr_filter_mime_types($mimes)
  128. {
  129. $mimes['ttf'] = 'font/ttf';
  130. $mimes['woff'] = 'font/woff';
  131. $mimes['svg'] = 'font/svg';
  132. $mimes['eot'] = 'font/eot';
  133.  
  134. return $mimes;
  135. }
  136.  
  137. //dropdown arrows
  138. class Arrow_Walker_Nav_Menu extends Walker_Nav_Menu {
  139. function display_element($element, &$children_elements, $max_depth, $depth=0, $args, &$output) {
  140. $id_field = $this->db_fields['id'];
  141. if (!empty($children_elements[$element->$id_field]) && $element->menu_item_parent == 0) {
  142. $element->title = $element->title . '<span class="sf-sub-indicator"><i class="fa fa-angle-down"></i></span>';
  143. $element->classes[] = 'sf-with-ul';
  144. }
  145.  
  146. if (!empty($children_elements[$element->$id_field]) && $element->menu_item_parent != 0) {
  147. $element->title = $element->title . '<span class="sf-sub-indicator"><i class="fa fa-angle-right"></i></span>';
  148. }
  149.  
  150. Walker_Nav_Menu::display_element($element, $children_elements, $max_depth, $depth, $args, $output);
  151. }
  152. }
  153.  
  154. /*-----------------------------------------------------------------------------------*/
  155. /* Configure WP2.9+ Thumbnails
  156. /*-----------------------------------------------------------------------------------*/
  157.  
  158. if( function_exists( 'add_theme_support' ) ) {
  159. add_theme_support( 'post-thumbnails' );
  160. add_theme_support( 'woocommerce' );
  161. // Add post thumbnail functionality
  162. add_image_size('blog-xxl', 800, 533, true);
  163. add_image_size('blog-large', 600, 400, true);
  164. add_image_size('blog-small', 345, 230, true);
  165. add_image_size('related-img', 180, 138, true);
  166. add_image_size('portfolio-one', 540, 272, true);
  167. add_image_size('portfolio-two', 550, 353, true);
  168. add_image_size('portfolio-three', 381, 285, true);
  169. add_image_size('portfolio-four', 271, 198, true);
  170. add_image_size('testimonial', 90, 90, true);
  171. add_image_size('recent-posts', 220, 135, true);
  172. add_image_size('recent-posts-col-2', 600, 370, true);
  173. add_image_size('recent-posts-col-3', 400, 245, true);
  174. }
  175.  
  176.  
  177. /*-----------------------------------------------------------------------------------*/
  178. /* Configure Excerpt String
  179. /*-----------------------------------------------------------------------------------*/
  180. function new_excerpt_more( $more ) {
  181. return '...';
  182. }
  183. add_filter('excerpt_more', 'new_excerpt_more');
  184.  
  185.  
  186.  
  187. if ( is_admin() ) {
  188. $of_page= 'appearance_page_options-framework';
  189. add_action( "admin_print_scripts-$of_page", 'optionsframework_custom_js', 0 );
  190. }
  191.  
  192. function creativo_js_scripts() {
  193.  
  194. global $data;
  195.  
  196. wp_enqueue_script( 'jquery', false, array(), '5.5.8', true );
  197.  
  198. if($data['load_minified_css']) {
  199. wp_enqueue_style( 'creativo-style-min' , get_template_directory_uri() . '/style.min.css' );
  200. }
  201. else {
  202. wp_enqueue_style( 'creativo-style', get_stylesheet_uri() );
  203. wp_enqueue_style( 'fontawesome' , get_template_directory_uri() . '/css/fontawesome/css/font-awesome.css' );
  204. wp_enqueue_style( 'icomoon' , get_template_directory_uri() . '/css/customfonts/css/style.css' );
  205. if ($data['responsiveness']) {
  206. wp_enqueue_style( 'responsive' , get_template_directory_uri() . '/css/responsive.css' );
  207. }
  208. else {
  209. wp_enqueue_style( 'fixed' , get_template_directory_uri() . '/css/fixed.css' );
  210. }
  211. }
  212. if ($data['page_load_effect']) {
  213. wp_enqueue_style( 'animsition' , get_template_directory_uri() . '/css/animsition.min.css' );
  214. }
  215.  
  216. if($data['load_minified']) {
  217. wp_enqueue_script( 'creativo.minified' , get_template_directory_uri() . '/js/main.min.js', array(), '6', TRUE );
  218. }
  219. else {
  220. wp_enqueue_script( 'plugins' , get_template_directory_uri() . '/js/plugins.js', array(), '6', TRUE );
  221. wp_enqueue_script( 'creativo.main', get_template_directory_uri().'/js/main.js', array(), '6', TRUE );
  222. }
  223.  
  224. $gmap_key = !empty( $data['gmap_api'] ) ? '?key='.$data['gmap_api'] : '';
  225.  
  226. wp_register_script( 'google-maps', '//maps.google.com/maps/api/js'.$gmap_key, array(), '6', TRUE );
  227. wp_register_script( 'youtube-api', get_template_directory_uri() . '/js/youtube-api.js', array(), '6', TRUE );
  228.  
  229. if( $data['google_maps_add'] == 0 ) {
  230. wp_deregister_script( 'google-maps');
  231. }
  232.  
  233. if ( function_exists( 'is_woocommerce' ) ) {
  234. //dequeue scripts and styles
  235. if ( is_woocommerce() || is_cart() || is_checkout() ) {
  236. wp_enqueue_script( 'woo', get_template_directory_uri().'/js/woo.js', array(), '6', TRUE );
  237. }
  238. }
  239.  
  240. if($data['page_smooth_scroll']) {
  241. wp_enqueue_script( 'smoothscroll', get_template_directory_uri().'/js/smoothscroll.js', array(), '6', TRUE );
  242. }
  243.  
  244. if($data['body_font'] && $data['body_font'] != 'Select Font') {
  245. $ggl_font[ urlencode( $data['body_font'] ) ] = '' . urlencode( $data['body_font'] );
  246. }
  247. if($data['heading_font'] && $data['heading_font'] != 'Select Font') {
  248. $ggl_font[ urlencode( $data['heading_font'] ) ] = '' . urlencode( $data['heading_font'] );
  249. }
  250. if($data['side_heading_font'] && $data['side_heading_font'] != 'Select Font') {
  251. $ggl_font[ urlencode( $data['side_heading_font'] ) ] = '' . urlencode( $data['side_heading_font'] );
  252. }
  253. if($data['menu_font_family'] && $data['menu_font_family'] != 'Select Font') {
  254. $ggl_font[ urlencode( $data['menu_font_family'] ) ] = '' . urlencode( $data['menu_font_family'] );
  255. }
  256.  
  257. if($data['tm_font_family'] && $data['tm_font_family'] != 'Select Font') {
  258. $ggl_font[ urlencode( $data['tm_font_family'] ) ] = '' . urlencode( $data['tm_font_family'] );
  259. }
  260.  
  261. if($data['btn_font_family'] && $data['btn_font_family'] != 'Select Font') {
  262. $ggl_font[ urlencode( $data['btn_font_family'] ) ] = '' . urlencode( $data['btn_font_family'] );
  263. }
  264.  
  265. if($data['logo_tagline_font'] && $data['logo_tagline_font'] != 'Select Font') {
  266. $ggl_font[ urlencode( $data['logo_tagline_font'] ) ] = '' . urlencode( $data['logo_tagline_font'] );
  267. }
  268.  
  269. if($data['hlr_font_family'] && $data['hlr_font_family'] != 'Select Font') {
  270. $ggl_font[ urlencode( $data['hlr_font_family'] ) ] = '' . urlencode( $data['hlr_font_family'] );
  271. }
  272.  
  273. if ( isset( $ggl_font ) && $ggl_font ) {
  274. $font_families = '';
  275.  
  276. $font_styles = $font_subsets = '';
  277.  
  278. $font_subsets = $data['ggl_character_sets'];
  279. $font_styles = $data['ggl_font_weight'];
  280.  
  281. foreach ( $ggl_font as $g_font ) {
  282. $font_families .= sprintf( '%s:%s|', $g_font, urlencode( $font_styles ) );
  283. }
  284.  
  285. if ( $font_subsets ) {
  286. $font_families = sprintf( '%s&%s', rtrim( $font_families, '|' ), $font_subsets );
  287. } else {
  288. $font_families = rtrim( $font_families, '|' );
  289. }
  290.  
  291. wp_enqueue_style( 'google-fonts', 'http' . ( ( is_ssl() ) ? 's' : '' ) . '://fonts.googleapis.com/css?family=' . $font_families, array(), '6' );
  292. }
  293.  
  294. }
  295. add_action('wp_enqueue_scripts', 'creativo_js_scripts');
  296.  
  297. function extra_vc_style() {
  298. wp_enqueue_style( 'vc_style' , get_template_directory_uri() . '/css/vc_style.min.css' );
  299. }
  300.  
  301. add_action( 'wp_enqueue_scripts', 'extra_vc_style', 15 );
  302.  
  303. function creativo_admin_script(){
  304. wp_enqueue_script('chosen', get_template_directory_uri() . '/js/chosen.jquery.min.js', array('jquery'), '6', true);
  305. wp_enqueue_style('chosen_style', get_template_directory_uri() . '/css/chosen-select.css');
  306. wp_enqueue_style('creativo_vc', get_template_directory_uri() . '/css/creativo_vc.css');
  307. }
  308.  
  309. add_action('admin_enqueue_scripts', 'creativo_admin_script');
  310.  
  311. function cr_searchform() {
  312. echo '<form method="get" id="searchform" action="'. get_home_url().'"><fieldset style="border:none;"><input type="text" name="s" id="s" value="'. __('Search keywords here', 'Creativo') .'" onfocus="if(this.value==\''. __('Search keywords here', 'Creativo'). '\') this.value=\'\';" onblur="if(this.value==\'\')this.value=\''. __('Search keywords here', 'Creativo').'\';" /></fieldset><!--END #searchform--></form>';
  313. }
  314.  
  315.  
  316.  
  317. // Auto plugin activation
  318. require_once('functions/plugin/class-tgm-plugin-activation.php');
  319. add_action('tgmpa_register', 'cr_register_required_plugins');
  320. function cr_register_required_plugins() {
  321. global $data;
  322. $plugins = array(
  323. array(
  324. 'name' => '1. WPBakery Visual Composer', // The plugin name
  325. 'slug' => 'js_composer', // The plugin slug (typically the folder name)
  326. 'source' => 'https://rockythemes.com/dev/plugs/js_composer.zip', // The plugin source
  327. 'required' => true, // If false, the plugin is only 'recommended' instead of required
  328. 'version' => '5.4.5', // E.g. 1.0.0. If set, the active plugin must be this version or higher, otherwise a notice is presented
  329. 'force_activation' => false, // If true, plugin is activated upon theme activation and cannot be deactivated until theme switch
  330. 'force_deactivation' => true, // If true, plugin is deactivated upon theme switch, useful for theme-specific plugins
  331. 'external_url' => '', // If set, overrides default API URL and points to an external URL
  332. ),
  333. array(
  334. 'name' => '2. Layer Slider', // The plugin name
  335. 'slug' => 'LayerSlider', // The plugin slug (typically the folder name)
  336. 'source' => 'https://rockythemes.com/dev/plugs/layerslider.zip', // The plugin source
  337. 'required' => true, // If false, the plugin is only 'recommended' instead of required
  338. 'version' => '6.6.7', // E.g. 1.0.0. If set, the active plugin must be this version or higher, otherwise a notice is presented
  339. 'force_activation' => false, // If true, plugin is activated upon theme activation and cannot be deactivated until theme switch
  340. 'force_deactivation' => true, // If true, plugin is deactivated upon theme switch, useful for theme-specific plugins
  341. 'external_url' => '', // If set, overrides default API URL and points to an external URL
  342. ),
  343. array(
  344. 'name' => '3. Revolution Slider ', // The plugin name
  345. 'slug' => 'revslider', // Theplugin slug (typically the folder name)
  346. 'source' => 'https://rockythemes.com/dev/plugs/revslider.zip', // The plugin source
  347. 'required' => true, // If false, the plugin is only 'recommended' instead of required
  348. 'version' => '5.4.6.4', // E.g. 1.0.0. If set, the active plugin must be this version or higher, otherwise a notice is presented
  349. 'force_activation' => false, // If true, plugin is activated upon theme activation and cannot be deactivated until theme switch
  350. 'force_deactivation' => true, // If true, plugin is deactivated upon theme switch, useful for theme-specific plugins
  351. 'external_url' => '', // If set, overrides default API URL and points to an external URL
  352. ),
  353. array(
  354. 'name' => 'WooCommerce',
  355. 'slug' => 'woocommerce',
  356. 'required' => false,
  357. ),
  358. array(
  359. 'name' => 'The Events Calendar',
  360. 'slug' => 'the-events-calendar',
  361. 'required' => false,
  362. ),
  363. array(
  364. 'name' => 'Contact Form 7',
  365. 'slug' => 'contact-form-7',
  366. 'required' => false,
  367. ),
  368. array(
  369. 'name' => 'MailChimp for WordPress',
  370. 'slug' => 'mailchimp-for-wp',
  371. 'required' => false,
  372. ),
  373. );
  374.  
  375. // Change this to your theme text domain, used for internationalising strings
  376. $theme_text_domain = 'Creativo';
  377.  
  378. /**
  379. * Array of configuration settings. Amend each line as needed.
  380. * If you want the default strings to be available under your own theme domain,
  381. * leave the strings uncommented.
  382. * Some of the strings are added into a sprintf, so see the comments at the
  383. * end of each line for what each argument will be.
  384. */
  385. $config = array(
  386. 'domain' => 'Creativo', // Text domain - likely want to be the same as your theme.
  387. 'default_path' => '', // Default absolute path to pre-packaged plugins
  388. 'parent_slug' => 'themes.php', // Default parent menu slug
  389. 'menu' => 'install-required-plugins', // Menu slug
  390. 'has_notices' => true, // Show admin notices or not
  391. 'is_automatic' => true, // Automatically activate plugins after installation or not
  392. 'message' => '', // Message to output right before the plugins table
  393. 'strings' => array(
  394. 'page_title' => __( 'Install Required Plugins', 'Creativo' ),
  395. 'menu_title' => __( 'Install Plugins', 'Creativo' ),
  396. 'installing' => __( 'Installing Plugin: %s', 'Creativo' ), // %1$s = plugin name
  397. 'oops' => __( 'Something went wrong with the plugin API.', 'Creativo' ),
  398. 'notice_can_install_required' => _n_noop( 'This theme requires the following plugin installed or update: %1$s.', 'This theme requires the following plugins installed or updated: %1$s.' ), // %1$s = plugin name(s)
  399. 'notice_can_install_recommended' => _n_noop( 'This theme recommends the following plugin installed or updated: %1$s.', 'This theme recommends the following plugins installed or updated: %1$s.' ), // %1$s = plugin name(s)
  400. 'notice_cannot_install' => _n_noop( 'Sorry, but you do not have the correct permissions to install the %s plugin. Contact the administrator of this site for help on getting the plugin installed.', 'Sorry, but you do not have the correct permissions to install the %s plugins. Contact the administrator of this site for help on getting the plugins installed.' ), // %1$s = plugin name(s)
  401. 'notice_can_activate_required' => _n_noop( 'The following required plugin is currently inactive: %1$s.', 'The following required plugins are currently inactive: %1$s.' ), // %1$s = plugin name(s)
  402. 'notice_can_activate_recommended' => _n_noop( 'The following recommended plugin is currently inactive: %1$s.', 'The following recommended plugins are currently inactive: %1$s.' ), // %1$s = plugin name(s)
  403. 'notice_cannot_activate' => _n_noop( 'Sorry, but you do not have the correct permissions to activate the %s plugin. Contact the administrator of this site for help on getting the plugin activated.', 'Sorry, but you do not have the correct permissions to activate the %s plugins. Contact the administrator of this site for help on getting the plugins activated.' ), // %1$s = plugin name(s)
  404. 'notice_ask_to_update' => _n_noop( 'The following plugin needs to be updated to its latest version to ensure maximum compatibility with this theme: %1$s.', 'The following plugins need to be updated to their latest version to ensure maximum compatibility with this theme: %1$s.' ), // %1$s = plugin name(s)
  405. 'notice_cannot_update' => _n_noop( 'Sorry, but you do not have the correct permissions to update the %s plugin. Contact the administrator of this site for help on getting the plugin updated.', 'Sorry, but you do not have the correct permissions to update the %s plugins. Contact the administrator of this site for help on getting the plugins updated.' ), // %1$s = plugin name(s)
  406. 'install_link' => _n_noop( 'Begin installing plugin', 'Begin installing plugins' ),
  407. 'activate_link' => _n_noop( 'Activate installed plugin', 'Activate installed plugins' ),
  408. 'return' => __( 'Return to Required Plugins Installer', 'Creativo' ),
  409. 'plugin_activated' => __( 'Plugin activated successfully.', 'Creativo' ),
  410. 'complete' => __( 'All plugins installed and activated successfully. %s', 'Creativo' ), // %1$s = dashboard link
  411. 'nag_type' => 'updated' // Determines admin notice type - can only be 'updated' or 'error'
  412. )
  413. );
  414.  
  415. tgmpa($plugins, $config);
  416. }
  417.  
  418.  
  419.  
  420. /* Force Visual Composer to initialize as "built into the theme". This will hide certain tabs under the Settings->Visual Composer page */
  421. add_action( 'vc_before_init', 'cr_vcSetAsTheme' );
  422. function cr_vcSetAsTheme() {
  423. vc_set_as_theme($disable_updater = true);
  424. }
  425.  
  426.  
  427. require_once('functions/plugin/multiple-featured-images/multiple-featured-images.php');
  428.  
  429. if( class_exists( 'kdMultipleFeaturedImages' )) {
  430. $i = 2;
  431.  
  432. while($i <= $data['featured_images_count']) {
  433. $args = array(
  434. 'id' => 'featured-image-'.$i,
  435. 'post_type' => 'post', // Set this to post or page
  436. 'labels' => array(
  437. 'name' => __( 'Featured image ', 'Creativo' ).$i,
  438. 'set' => __( 'Set featured image ', 'Creativo' ).$i,
  439. 'remove' => __( 'Remove featured image ', 'Creativo' ).$i,
  440. 'use' => __( 'Use as featured image ', 'Creativo' ).$i,
  441. )
  442. );
  443.  
  444. new kdMultipleFeaturedImages( $args );
  445.  
  446. $args = array(
  447. 'id' => 'featured-image-'.$i,
  448. 'post_type' => 'page', // Set this to post or page
  449. 'labels' => array(
  450. 'name' => __( 'Featured image ', 'Creativo' ).$i,
  451. 'set' => __( 'Set featured image ', 'Creativo' ).$i,
  452. 'remove' => __( 'Remove featured image ', 'Creativo' ).$i,
  453. 'use' => __( 'Use as featured image ', 'Creativo' ).$i,
  454. )
  455. );
  456.  
  457. new kdMultipleFeaturedImages( $args );
  458.  
  459. $args = array(
  460. 'id' => 'featured-image-'.$i,
  461. 'post_type' => 'creativo_portfolio', // Set this to post or page
  462. 'labels' => array(
  463. 'name' => __( 'Featured image ', 'Creativo' ).$i,
  464. 'set' => __( 'Set featured image ', 'Creativo' ).$i,
  465. 'remove' => __( 'Remove featured image ', 'Creativo' ).$i,
  466. 'use' => __( 'Use as featured image ', 'Creativo' ).$i,
  467. )
  468. );
  469.  
  470. new kdMultipleFeaturedImages( $args );
  471.  
  472. $i++;
  473. }
  474.  
  475. }
  476.  
  477. include_once('functions/plugin/cr-mfi.php');
  478.  
  479. new CR_Multiple_Featured_Images();
  480.  
  481.  
  482. /* Load Widgets & Shortcodes */
  483.  
  484. // More custom functions
  485. include_once('functions/custom_functions.php');
  486.  
  487. // VC custom classes
  488. include_once('functions/vc_class.php');
  489.  
  490. // Add the Theme Shortcodes
  491. include("functions/shortcodes.php");
  492.  
  493. // Add meta boxes
  494. include('functions/metaboxes.php');
  495.  
  496. // Add the post types
  497. include("functions/theme-posttypes.php");
  498.  
  499. // Add about me widget
  500. include("functions/widget-about.php");
  501.  
  502. // Add about business widget
  503. include("functions/widget-business.php");
  504.  
  505. // Add flickr widget
  506. include("functions/widget-flickr.php");
  507.  
  508. // Add Instagram widget
  509. include("functions/widget-instagram.php");
  510.  
  511. // Add contact info widget
  512. include("functions/widget-contact.php");
  513.  
  514. // Add latest tweets widget
  515. include("functions/widget-tweets.php");
  516.  
  517. // Add the Custom Youtube Widget
  518. include("functions/widget-youtube.php");
  519.  
  520. // Add the Custom Vimeo Widget
  521. include("functions/widget-vimeo.php");
  522.  
  523. // Add the Popular/Recent Tabs Widget
  524. include("functions/widget-tabs.php");
  525.  
  526. // Add Custom Blog Posts Widget
  527. include('functions/widget-blogposts.php');
  528.  
  529. // Add socila links widget
  530. include("functions/widget-social.php");
  531.  
  532. // Add Custom Recent Portfolios Widget
  533. include('functions/widget-recentportfolios.php');
  534.  
  535. // Add the post types
  536. include_once('functions/plugin/multiple_sidebars.php');
  537.  
  538. /*-----------------------------------------------------------------------------------*/
  539. /* Filters that allow shortcodes in Text Widgets
  540. /*-----------------------------------------------------------------------------------*/
  541.  
  542. add_filter('widget_text', 'shortcode_unautop');
  543. add_filter('widget_text', 'do_shortcode');
  544.  
  545.  
  546. function SearchFilter($query) {
  547. global $data;
  548. $search_array = array();
  549. $search_array[] = 'nav_menu_item';
  550.  
  551. if($data['en_search_post']) $search_array[] = 'post';
  552. if($data['en_search_page']) $search_array[] = 'page';
  553. if($data['en_search_portfolio']) $search_array[] = 'creativo_portfolio';
  554. if($data['en_search_product']) $search_array[] = 'product';
  555. if( empty( $search_array ) ) $search_array[] = ' ';
  556.  
  557. $spb = false;
  558. if(class_exists('Woocommerce') && ( is_product() || is_woocommerce() ) ) $spb = true;
  559.  
  560. if (is_search() && !$spb && !is_admin()) {
  561. $query->set( 'post_type', array( 'page' ) );
  562. }
  563. return $query;
  564. wp_reset_query();
  565. }
  566.  
  567. add_filter('pre_get_posts','SearchFilter');
  568.  
  569. function custom_sanitize_textarea($input) {
  570. global $allowedposttags;
  571. $custom_allowedtags["embed"] = array(
  572. "src" => array(),
  573. "type" => array(),
  574. "allowfullscreen" => array(),
  575. "allowscriptaccess" => array(),
  576. "height" => array(),
  577. "width" => array()
  578. );
  579. $custom_allowedtags["script"] = array();
  580. $custom_allowedtags = array_merge($custom_allowedtags, $allowedposttags);
  581. $output = wp_kses( $input, $custom_allowedtags);
  582. return $output;
  583. }
  584.  
  585. /* Include Admin scripts only on Admin area */
  586.  
  587. if ( is_admin() ) {
  588.  
  589. /* Add MultiSelect Option to Visual Composer Params */
  590.  
  591. if (function_exists('vc_add_shortcode_param')) {
  592. vc_add_shortcode_param('multiselect', 'multiselect_param_field');
  593. }
  594.  
  595. function multiselect_param_field($settings, $value) {
  596.  
  597. //$dependency = vc_generate_dependencies_attributes($settings);
  598. $param_name = isset($settings['param_name']) ? $settings['param_name'] : '';
  599. $type = isset($settings['type']) ? $settings['type'] : '';
  600. $output = '';
  601.  
  602. $output .= '<select multiple="multiple" name="' . $param_name . '" id="multiselect-' . $param_name . '" style="width:100%" ' . $dependency . ' class="wpb-multiselect ' . $dependency . ' wpb_vc_param_value ' . $param_name . ' ' . $type . '">';
  603. if ($settings['value'] != null && !empty($settings['value'])) {
  604. foreach ($settings['value'] as $key => $option) {
  605. $selected = '';
  606. if(is_array($value) ) {
  607. if (in_array($key, $value)) {
  608. $selected = ' selected="selected"';
  609. }
  610. }
  611. else{
  612. if (in_array($key, explode(',', $value))) {
  613. $selected = ' selected="selected"';
  614. }
  615. }
  616. $output .= '<option value="' . $key . '"' . $selected . '>' . $option . '</option>';
  617. }
  618. }
  619. $output .= '</select>';
  620.  
  621. $output .= '<script type="text/javascript">
  622.  
  623. jQuery("#multiselect-' . $param_name . '").chosen();
  624.  
  625. </script>';
  626.  
  627. return $output;
  628. }
  629.  
  630. }
  631.  
  632. /* Remove ?ver from static scripts and css files - useful for page speed optimization */
  633. function cr_remove_script_version( $src ){
  634. $parts = explode( '?ver', $src );
  635. return $parts[0];
  636. }
  637.  
  638. add_filter( 'script_loader_src', 'cr_remove_script_version' );
  639. add_filter( 'style_loader_src', 'cr_remove_script_version' );
Advertisement
Add Comment
Please, Sign In to add comment