Advertisement
Guest User

Untitled

a guest
May 27th, 2015
370
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 83.21 KB | None | 0 0
  1. <?php
  2. /**
  3. * @package WordPress
  4. * @subpackage Everything
  5. * @since 1.0
  6. */
  7.  
  8. // -----------------------------------------------------------------------------
  9.  
  10. require_once get_template_directory().'/drone/drone.php'; // 5.3.1.1
  11. require_once get_template_directory().'/inc/class-tgm-plugin-activation.php'; // 2.4.1
  12.  
  13. // -----------------------------------------------------------------------------
  14.  
  15. class Everything extends \Drone\Theme
  16. {
  17.  
  18. // -------------------------------------------------------------------------
  19.  
  20. /**
  21. * Default sidebar width
  22. *
  23. * @since 1.0
  24. * @var int
  25. */
  26. const DEFAULT_SIDEBAR_WIDTH = 308;
  27.  
  28. /**
  29. * Vector icons font path
  30. *
  31. * @since 1.0
  32. * @var string
  33. */
  34. const ICON_FONT_PATH = 'data/img/icons/icons.svg';
  35.  
  36. /**
  37. * LayerSlider WP plugin version
  38. *
  39. * @since 1.0
  40. * @var string
  41. */
  42. const LAYERSLIDER_VERSION = '5.4.0';
  43.  
  44. /**
  45. * Master Slider plugin version
  46. *
  47. * @since 1.0
  48. * @var string
  49. */
  50. const MASTERSLIDER_VERSION = '2.14.2';
  51.  
  52. /**
  53. * Revolution Slider plugin version
  54. *
  55. * @since 1.0
  56. * @var string
  57. */
  58. const REVSLIDER_VERSION = '4.6.93';
  59.  
  60. /**
  61. * Item page URL
  62. *
  63. * @since 1.9.3
  64. * @var string
  65. */
  66. const ITEM_PAGE_URL = 'http://themeforest.net/item/everything-responsive-wordpress-theme/8661152/?ref=kubasto';
  67.  
  68. // -------------------------------------------------------------------------
  69.  
  70. /**
  71. * Headline used status
  72. *
  73. * @since 1.0
  74. * @var bool
  75. */
  76. public static $headline_used = false;
  77.  
  78. /**
  79. * Previous posts stack
  80. *
  81. * @since 1.5
  82. * @var array
  83. */
  84. public static $posts_stack = array();
  85.  
  86. /**
  87. * Max width
  88. *
  89. * @since 1.7
  90. * @var int
  91. */
  92. protected static $max_width = 1140;
  93.  
  94. // -------------------------------------------------------------------------
  95.  
  96. /**
  97. * Add meta options
  98. *
  99. * @since 1.0
  100. *
  101. * @param object $group
  102. * @param bool $default_visible
  103. * @param array $default_items
  104. * @return object
  105. */
  106. protected function addMetaOptions($group, $default_visible, $default_items)
  107. {
  108. $visible = $group->addOption('boolean', 'visible', $default_visible, '', '', array('caption' => __('Visible', 'everything')));
  109. return $group->addOption('group', 'items', $default_items, '', '', array('options' => array(
  110. 'date_time' => __('Date &amp time', 'everything'),
  111. 'date' => __('Date', 'everything'),
  112. 'mod_date' => __('Modification date', 'everything'),
  113. 'time_diff' => __('Relative time', 'everything'),
  114. 'comments' => __('Comments number', 'everything'),
  115. 'author' => __('Author', 'everything'),
  116. 'permalink' => __('Permalink', 'everything')
  117. ), 'indent' => true, 'multiple' => true, 'sortable' => true, 'owner' => $visible));
  118. }
  119.  
  120. // -------------------------------------------------------------------------
  121.  
  122. /**
  123. * Add post meta options
  124. *
  125. * @since 1.0
  126. *
  127. * @param object $group
  128. * @param bool $default_visible
  129. * @param array $default_items
  130. * @return object
  131. */
  132. protected function addPostMetaOptions($group, $default_visible, $default_items)
  133. {
  134. $visible = $group->addOption('boolean', 'visible', $default_visible, '', '', array('caption' => __('Visible', 'everything')));
  135. return $group->addOption('group', 'items', $default_items, '', '', array('options' => array(
  136. 'date_time' => __('Date &amp time', 'everything'),
  137. 'date' => __('Date', 'everything'),
  138. 'mod_date' => __('Modification date', 'everything'),
  139. 'time_diff' => __('Relative time', 'everything'),
  140. 'comments' => __('Comments number', 'everything'),
  141. 'categories' => __('Categories', 'everything'),
  142. 'tags' => __('Tags', 'everything'),
  143. 'author' => __('Author', 'everything'),
  144. 'permalink' => __('Permalink', 'everything')
  145. ), 'indent' => true, 'multiple' => true, 'sortable' => true, 'owner' => $visible));
  146. }
  147.  
  148. // -------------------------------------------------------------------------
  149.  
  150. /**
  151. * Add social buttons options
  152. *
  153. * @since 1.0
  154. *
  155. * @param object $group
  156. * @param bool $default_visible
  157. * @param array $default_items
  158. * @return object
  159. */
  160. protected function addSocialButtonsOptions($group, $default_visible, $default_items)
  161. {
  162. $visible = $group->addOption('boolean', 'visible', $default_visible, '', '', array('caption' => __('Visible', 'everything')));
  163. return $group->addOption('group', 'items', $default_items, '', '', array('options' => array(
  164. 'facebook' => __('Facebook', 'everything'),
  165. 'twitter' => __('Twitter', 'everything'),
  166. 'googleplus' => __('Google+', 'everything'),
  167. 'linkedin' => __('LinkedIn', 'everything'),
  168. 'pinterest' => __('Pinterest', 'everything')
  169. ), 'indent' => true, 'multiple' => true, 'sortable' => true, 'owner' => $visible));
  170. }
  171.  
  172. // -------------------------------------------------------------------------
  173.  
  174. /**
  175. * Options setup
  176. *
  177. * @since 1.0
  178. *
  179. * @param $theme_options
  180. */
  181. protected function onSetupOptions(\Drone\Options\Group\Theme $theme_options)
  182. {
  183. require $this->template_dir.'/inc/options-setup.php';
  184. }
  185.  
  186. // -------------------------------------------------------------------------
  187.  
  188. /**
  189. * Theme options compatybility
  190. *
  191. * @since 1.7
  192. *
  193. * @param array $data
  194. * @param string $version
  195. */
  196. public function onThemeOptionsCompatybility(array &$data, $version)
  197. {
  198.  
  199. // 1.7
  200. if (version_compare($version, '1.7-alpha-3') < 0) {
  201.  
  202. $conditional_tags_migrate = function($data, $sidebars_widgets = false) {
  203. foreach ($_ = $data as $tag => $value) {
  204. if ($sidebars_widgets) {
  205. if (!preg_match('/^footer-(?P<tag>.+)-(?P<i>[0-5])$/', $tag, $footer_sidebar)) {
  206. continue;
  207. }
  208. $tag = $footer_sidebar['tag'];
  209. }
  210. $new_tag = false;
  211. if (preg_match('/^(post_type_|term_|bbpress|woocommerce)/', $tag)) { // new format
  212. continue;
  213. }
  214. else if (in_array($tag, array('default', 'front_page', 'blog', 'search', '404'))) { // general
  215. continue;
  216. }
  217. else if (in_array($tag, array('forum', 'topic'))) { // bbpress
  218. $new_tag = 'bbpress_'.$tag;
  219. }
  220. else if (in_array($tag, array('shop', 'cart', 'checkout', 'order_received_page', 'account_page'))) { // woocommerce
  221. $new_tag = 'woocommerce_'.$tag;
  222. }
  223. else if (strpos($tag, 'template_') === 0) { // template
  224. if (!preg_match('/.\.php$/', $tag)) {
  225. foreach (array_keys(Everything::getInstance()->theme->get_page_templates()) as $template) {
  226. if ($tag == \Drone\Func::stringID('template_'.preg_replace('/\.php$/i', '', $template), '_')) {
  227. $new_tag = 'template_'.preg_replace('/\.(php)$/i', '_\1', $template);
  228. break;
  229. }
  230. }
  231. }
  232. }
  233. else if (preg_match('/^[_a-z]+_[0-9]+$/', $tag)) { // taxonomy
  234. if (preg_match('/^(portfolio_(category|tag)|topic_tag)_/', $tag)) {
  235. $new_tag = 'term_'.preg_replace('/_/', '-', $tag, 1);
  236. } else {
  237. $new_tag = 'term_'.$tag;
  238. }
  239. }
  240. else if (preg_match('/^[_a-z]+$/', $tag)) { // post type
  241. $new_tag = 'post_type_'.$tag;
  242. }
  243. if ($new_tag !== false) {
  244. if ($sidebars_widgets) {
  245. $tag = $footer_sidebar[0];
  246. $new_tag = "footer-{$new_tag}-{$footer_sidebar['i']}";
  247. }
  248. unset($data[$tag]);
  249. $data[$new_tag] = $value;
  250. }
  251. }
  252. return $data;
  253. };
  254.  
  255. if (isset($data['general']['layout']) && is_array($data['general']['layout'])) {
  256. $data['general']['layout'] = $conditional_tags_migrate($data['general']['layout']);
  257. }
  258. if (isset($data['general']['max_width']) && is_array($data['general']['max_width'])) {
  259. $data['general']['max_width'] = $conditional_tags_migrate($data['general']['max_width']);
  260. }
  261. if (isset($data['general']['background']['background']) && is_array($data['general']['background']['background'])) {
  262. $data['general']['background']['background'] = $conditional_tags_migrate($data['general']['background']['background']);
  263. }
  264. if (isset($data['banner']['content']) && is_array($data['banner']['content'])) {
  265. $data['banner']['content'] = $conditional_tags_migrate($data['banner']['content']);
  266. }
  267. if (isset($data['nav']['secondary']['upper']) && is_array($data['nav']['secondary']['upper'])) {
  268. $data['nav']['secondary']['upper'] = $conditional_tags_migrate($data['nav']['secondary']['upper']);
  269. }
  270. if (isset($data['nav']['secondary']['lower']) && is_array($data['nav']['secondary']['lower'])) {
  271. $data['nav']['secondary']['lower'] = $conditional_tags_migrate($data['nav']['secondary']['lower']);
  272. }
  273. if (isset($data['nav']['headline']) && is_array($data['nav']['headline'])) {
  274. $data['nav']['headline'] = $conditional_tags_migrate($data['nav']['headline']);
  275. }
  276. if (isset($data['sidebar']['layout']) && is_array($data['sidebar']['layout'])) {
  277. $data['sidebar']['layout'] = $conditional_tags_migrate($data['sidebar']['layout']);
  278. }
  279. if (isset($data['footer']['layout']) && is_array($data['footer']['layout'])) {
  280. $data['footer']['layout'] = $conditional_tags_migrate($data['footer']['layout']);
  281. }
  282.  
  283. if (($sidebars_widgets = get_option('sidebars_widgets')) !== false && is_array($sidebars_widgets)) {
  284. $new_sidebars_widgets = $conditional_tags_migrate($sidebars_widgets, true);
  285. if ($sidebars_widgets !== $new_sidebars_widgets) {
  286. update_option('sidebars_widgets', $new_sidebars_widgets);
  287. }
  288. }
  289.  
  290. }
  291.  
  292. }
  293.  
  294. // -------------------------------------------------------------------------
  295.  
  296. /**
  297. * Theme setup
  298. *
  299. * @since 1.0
  300. * @see \Drone\Theme::onSetupTheme()
  301. */
  302. protected function onSetupTheme()
  303. {
  304.  
  305. // Theme features
  306. $this->addThemeFeature('x-ua-compatible');
  307. $this->addThemeFeature('nav-menu-current-item');
  308. $this->addThemeFeature('force-img-caption-shortcode-filter');
  309.  
  310. // Editor style
  311. add_editor_style('data/css/wp/editor.css');
  312.  
  313. // Menus
  314. register_nav_menus(array(
  315. 'main-desktop' => __('Main menu (desktop)', 'everything'),
  316. 'main-mobile' => __('Main menu (mobile)', 'everything'),
  317. 'additional-mobile' => __('Additional menu (mobile)', 'everything'),
  318. 'top-bar-desktop' => __('Top bar menu (desktop)', 'everything'),
  319. 'top-bar-mobile' => __('Top bar menu (mobile)', 'everything'),
  320. 'secondary-upper' => __('Upper secondary menu', 'everything'),
  321. 'secondary-lower' => __('Lower secondary menu', 'everything')
  322. ));
  323.  
  324. // Title
  325. if (version_compare($this->wp_version, '4.1') < 0) { // @deprecated WordPress 4.1
  326.  
  327. add_action('wp_head', function() {
  328. echo '<title>'.wp_title('-', false, 'right').'</title>';
  329. });
  330.  
  331. add_filter('wp_title', function($title, $sep) {
  332. if (is_feed()) {
  333. return $title;
  334. }
  335. if ((is_home() || is_front_page()) && ($description = get_bloginfo('description', 'display'))) {
  336. return $sep ? get_bloginfo('name')." {$sep} {$description}" : get_bloginfo('name');
  337. } else {
  338. return $sep ? $title.get_bloginfo('name') : $title;
  339. }
  340. }, 10, 2);
  341.  
  342. }
  343.  
  344. // Images
  345. add_theme_support('post-thumbnails');
  346. if (Everything::to('general/retina')) {
  347. $this->addThemeFeature('retina-image-size');
  348. }
  349.  
  350. $thumbnail_size = Everything::to('post/thumbnail/size');
  351. $max_width = Everything::to_('general/max_width')->value('default');
  352.  
  353. add_image_size('post-thumbnail', $thumbnail_size['width'], $thumbnail_size['height'], true);
  354. add_image_size('post-thumbnail-mini', 56, 84, false);
  355. add_image_size('post-thumbnail-mini-crop', 56, 56, true);
  356. add_image_size('logo', 999, 60, false);
  357. add_image_size('full-hd', 1920, 2880, false);
  358.  
  359. add_image_size('auto', 236, 354, false); // mobile 3 columns
  360. add_image_size('auto-1', 364, 546, false); // mobile 2 columns
  361. add_image_size('auto-2', 748, 1122, false); // mobile 1 column
  362. add_image_size('auto-3', 960, 1140, false);
  363. add_image_size('max-width', $max_width['default'], round($max_width['default']*1.5), false);
  364.  
  365. // Post formats
  366. add_theme_support('post-formats', array(
  367. 'aside', 'audio', 'chat', 'gallery', 'image', 'link', 'quote', 'status', 'video'
  368. ));
  369.  
  370. // Shortcodes
  371. $this->addThemeFeature('shortcode-page');
  372. $this->addThemeFeature('shortcode-no-format');
  373.  
  374. // Classes
  375. \Drone\Options\Option\Font::$always_used = array('Open Sans', 'Montserrat');
  376.  
  377. // bbPress
  378. if (Everything::isPluginActive('bbpress')) {
  379. $func = function($show) { return is_bbpress() ? false : $show; };
  380. add_filter('everything_meta_display', $func, 20);
  381. add_filter('everything_social_buttons_display', $func, 20);
  382. }
  383.  
  384. // Captcha
  385. if (Everything::isPluginActive('captcha')) {
  386. if (has_action('comment_form_after_fields', 'cptch_comment_form_wp3')) {
  387. remove_action('comment_form_after_fields', 'cptch_comment_form_wp3', 1);
  388. remove_action('comment_form_logged_in_after', 'cptch_comment_form_wp3', 1);
  389. add_filter('comment_form_field_comment', function($comment_field) {
  390. $captcha = \Drone\Func::functionGetOutputBuffer('cptch_comment_form_wp3');
  391. $captcha = preg_replace('#<br( /)?>#', '', $captcha);
  392. return $comment_field.$captcha;
  393. });
  394. }
  395. }
  396.  
  397. // WooCommerce
  398. if (Everything::isPluginActive('woocommerce')) {
  399. require $this->template_dir.'/inc/woocommerce.php';
  400. add_theme_support('woocommerce');
  401. }
  402.  
  403. // WooCommerce Brands
  404. if (Everything::isPluginActive('woocommerce-brands')) {
  405. remove_action('woocommerce_product_meta_end', array($GLOBALS['WC_Brands'], 'show_brand'));
  406. }
  407.  
  408. // WPML
  409. if (Everything::isPluginActive('wpml')) {
  410. define('ICL_DONT_LOAD_LANGUAGE_SELECTOR_CSS', true);
  411. }
  412.  
  413. // Illegal
  414. if (!is_admin() && Everything::isIllegal()) {
  415. Everything::to_('footer/end_note/right')->value = Everything::to_('footer/end_note/right')->default;
  416. }
  417.  
  418. }
  419.  
  420. // -------------------------------------------------------------------------
  421.  
  422. /**
  423. * Initialization
  424. *
  425. * @since 1.0
  426. * @see \Drone\Theme::onInit()
  427. */
  428. public function onInit()
  429. {
  430.  
  431. // Gallery
  432. register_post_type('gallery', apply_filters('everything_register_post_type_gallery_args', array(
  433. 'label' => __('Galleries', 'everything'),
  434. 'description' => __('Galleries', 'everything'),
  435. 'public' => true,
  436. 'menu_icon' => 'dashicons-images-alt2',
  437. 'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions'),
  438. 'rewrite' => array('slug' => Everything::to('gallery/slug')),
  439. 'labels' => array(
  440. 'name' => __('Galleries', 'everything'),
  441. 'singular_name' => __('Gallery', 'everything'),
  442. 'add_new' => _x('Add New', 'gallery', 'everything'),
  443. 'all_items' => __('All Galleries', 'everything'),
  444. 'add_new_item' => __('Add New Gallery', 'everything'),
  445. 'edit_item' => __('Edit Gallery', 'everything'),
  446. 'new_item' => __('New Gallery', 'everything'),
  447. 'view_item' => __('View Gallery', 'everything'),
  448. 'search_items' => __('Search Galleries', 'everything'),
  449. 'not_found' => __('No Galleries found', 'everything'),
  450. 'not_found_in_trash' => __('No Galleries found in Trash', 'everything'),
  451. 'menu_name' => __('Galleries', 'everything')
  452. )
  453. )));
  454.  
  455. // Portfolio
  456. register_post_type('portfolio', apply_filters('everything_register_post_type_portfolio_args', array(
  457. 'label' => __('Portfolios', 'everything'),
  458. 'description' => __('Portfolios', 'everything'),
  459. 'public' => true,
  460. 'menu_icon' => 'dashicons-exerpt-view',
  461. 'hierarchical' => true,
  462. 'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'page-attributes'),
  463. //'taxonomies' => array('portfolio-category', 'portfolio-tag'),
  464. 'has_archive' => true,
  465. 'rewrite' => array('slug' => Everything::to('portfolio/slug')),
  466. 'labels' => array(
  467. 'name' => __('Portfolios', 'everything'),
  468. 'singular_name' => __('Portfolio', 'everything'),
  469. 'add_new' => _x('Add New', 'portfolio', 'everything'),
  470. 'all_items' => __('All Portfolios', 'everything'),
  471. 'add_new_item' => __('Add New Portfolio', 'everything'),
  472. 'edit_item' => __('Edit Portfolio', 'everything'),
  473. 'new_item' => __('New Portfolio', 'everything'),
  474. 'view_item' => __('View Portfolio', 'everything'),
  475. 'search_items' => __('Search Portfolios', 'everything'),
  476. 'not_found' => __('No Portfolios found', 'everything'),
  477. 'not_found_in_trash' => __('No Portfolios found in Trash', 'everything'),
  478. 'menu_name' => __('Portfolios', 'everything')
  479. )
  480. )));
  481. register_taxonomy('portfolio-category', array('portfolio'), apply_filters('everything_register_taxonomy_portfolio_category_args', array(
  482. 'label' => __('Categories', 'everything'),
  483. 'hierarchical' => true,
  484. 'rewrite' => array('slug' => Everything::to('portfolio/slug').'-category')
  485. )));
  486. register_taxonomy('portfolio-tag', array('portfolio'), apply_filters('everything_register_taxonomy_portfolio_tag_args', array(
  487. 'label' => __('Tags', 'everything'),
  488. 'hierarchical' => false,
  489. 'rewrite' => array('slug' => Everything::to('portfolio/slug').'-tag')
  490. )));
  491.  
  492. }
  493.  
  494. // -------------------------------------------------------------------------
  495.  
  496. /**
  497. * Widgets initialization
  498. *
  499. * @since 1.0
  500. * @see \Drone\Theme::onWidgetsInit()
  501. */
  502. public function onWidgetsInit()
  503. {
  504.  
  505. // Built-in sidebars
  506. foreach (Everything::to_('sidebar/list/builtin')->childs() as $id => $sidebar) {
  507. register_sidebar(array(
  508. 'id' => $id,
  509. 'name' => $sidebar->label,
  510. 'before_widget' => '<section id="%1$s" class="section widget %2$s">',
  511. 'after_widget' => '</section>',
  512. 'before_title' => '<h2 class="title">',
  513. 'after_title' => '</h2>'
  514. ));
  515. }
  516.  
  517. // Additional sidebars
  518. foreach (Everything::to('sidebar/list/additional') as $id => $sidebar) {
  519. register_sidebar(array(
  520. 'id' => $id,
  521. 'name' => $sidebar['id'],
  522. 'before_widget' => '<section id="%1$s" class="section widget %2$s">',
  523. 'after_widget' => '</section>',
  524. 'before_title' => '<h2 class="title">',
  525. 'after_title' => '</h2>'
  526. ));
  527. }
  528.  
  529. // Footer sidebars
  530. if (is_admin()) {
  531. $tags = \Drone\Options\Option\ConditionalTags::getTagsList();
  532. }
  533. foreach (Everything::to('footer/layout') as $tag => $layout) {
  534.  
  535. for ($i = 0; $i < count(Everything::stringToColumns($layout)); $i++) {
  536.  
  537. if ($tag == 'default') {
  538. $name = sprintf(__('Footer column %d', 'everything'), $i+1);
  539. } else {
  540. $name = sprintf(__('(%1$s) Footer column %2$d', 'everything'), isset($tags[$tag]) ? $tags[$tag]['caption'] : '~'.$tag, $i+1);
  541. }
  542.  
  543. register_sidebar(array(
  544. 'name' => $name,
  545. 'id' => "footer-{$tag}-{$i}",
  546. 'before_widget' => '<div id="%1$s" class="widget %2$s">',
  547. 'after_widget' => '</div>',
  548. 'before_title' => '<h2 class="title">',
  549. 'after_title' => '</h2>'
  550. ));
  551.  
  552. }
  553.  
  554. }
  555.  
  556. // Widgets
  557. $this->addThemeFeature('widget-unwrapped-text');
  558. $this->addThemeFeature('widget-page');
  559. $this->addThemeFeature('widget-posts-list');
  560. $this->addThemeFeature('widget-twitter');
  561. $this->addThemeFeature('widget-flickr');
  562. $this->addThemeFeature('widget-facebook-like-box');
  563.  
  564. // WooCommerce
  565. if (Everything::isPluginActive('woocommerce')) {
  566.  
  567. require $this->template_dir.'/inc/woocommerce-widgets.php';
  568.  
  569. foreach (array(
  570. 'WC_Widget_Best_Sellers',
  571. 'WC_Widget_Cart',
  572. 'WC_Widget_Featured_Products',
  573. 'WC_Widget_Layered_Nav_Filters',
  574. 'WC_Widget_Layered_Nav',
  575. 'WC_Widget_Onsale',
  576. 'WC_Widget_Price_Filter',
  577. 'WC_Widget_Product_Categories',
  578. 'WC_Widget_Product_Search',
  579. 'WC_Widget_Product_Tag_Cloud',
  580. 'WC_Widget_Products',
  581. 'WC_Widget_Random_Products',
  582. 'WC_Widget_Recent_Products',
  583. 'WC_Widget_Recent_Reviews',
  584. 'WC_Widget_Recently_Viewed',
  585. 'WC_Widget_Top_Rated_Products'
  586. ) as $class) {
  587. if (class_exists($class)) {
  588. unregister_widget($class);
  589. register_widget('Everything_'.$class);
  590. }
  591. }
  592.  
  593. }
  594.  
  595. // WooCommerce Brands
  596. if (Everything::isPluginActive('woocommerce-brands')) {
  597.  
  598. require $this->template_dir.'/inc/woocommerce-brands-widgets.php';
  599.  
  600. foreach (array(
  601. 'WC_Widget_Brand_Nav'
  602. ) as $class) {
  603. if (class_exists($class)) {
  604. unregister_widget($class);
  605. register_widget('Everything_'.$class);
  606. }
  607. }
  608.  
  609. }
  610.  
  611. }
  612.  
  613. // -------------------------------------------------------------------------
  614.  
  615. /**
  616. * tgmpa_register action
  617. *
  618. * @internal action: tgmpa_register
  619. * @since 1.0
  620. */
  621. public function actionTGMPARegister()
  622. {
  623. $plugins = array(
  624. array(
  625. 'name' => 'LayerSlider',
  626. 'slug' => 'LayerSlider',
  627. 'source' => $this->template_dir.'/plugins/layerslider.zip',
  628. 'required' => false,
  629. 'version' => Everything::LAYERSLIDER_VERSION,
  630. 'force_activation' => false,
  631. 'force_deactivation' => true
  632. ),
  633. array(
  634. 'name' => 'Master Slider',
  635. 'slug' => 'masterslider',
  636. 'source' => $this->template_dir.'/plugins/masterslider.zip',
  637. 'required' => false,
  638. 'version' => Everything::MASTERSLIDER_VERSION,
  639. 'force_activation' => false,
  640. 'force_deactivation' => true
  641. ),
  642. array(
  643. 'name' => 'Revolution Slider',
  644. 'slug' => 'revslider',
  645. 'source' => $this->template_dir.'/plugins/revslider.zip',
  646. 'required' => false,
  647. 'version' => Everything::REVSLIDER_VERSION,
  648. 'force_activation' => false,
  649. 'force_deactivation' => true
  650. )
  651. );
  652. tgmpa($plugins);
  653. }
  654.  
  655. // -------------------------------------------------------------------------
  656.  
  657. /**
  658. * wp_enqueue_scripts action
  659. *
  660. * @internal action: wp_enqueue_scripts
  661. * @since 1.0
  662. */
  663. public function actionWPEnqueueScripts()
  664. {
  665.  
  666. // Debug
  667. $this->beginMarker(__METHOD__);
  668.  
  669. $min_sufix = !$this->debug_mode ? '.min' : '';
  670. $ver = $this->base_theme->version;
  671.  
  672. // 3rd party styles
  673. wp_enqueue_style('everything-3rd-party', $this->template_uri.'/data/css/3rd-party.min.css', array(), $ver);
  674.  
  675. // Main style
  676. wp_enqueue_style('everything-style', $this->template_uri."/data/css/style{$min_sufix}.css", array(), $ver);
  677.  
  678. // Color scheme
  679. wp_enqueue_style('everything-scheme', $this->template_uri.'/data/css/'.Everything::to('general/scheme').$min_sufix.'.css', array(), $ver);
  680.  
  681. // Responsive design
  682. if (Everything::to('general/responsive')) {
  683. wp_enqueue_style('everything-mobile', $this->template_uri."/data/css/mobile{$min_sufix}.css", array(), $ver, 'only screen and (max-width: 767px)');
  684. }
  685.  
  686. // Stylesheet
  687. wp_enqueue_style('everything-stylesheet', get_stylesheet_uri());
  688.  
  689. // Leading color
  690. $this->addDocumentStyle(sprintf(
  691. <<<'EOS'
  692. a,
  693. a.alt:hover,
  694. .alt a:hover,
  695. h1 a:hover, h2 a:hover, h3 a:hover, h4 a:hover, h5 a:hover, h6 a:hover,
  696. .color,
  697. .toggles > div > h3:hover > i,
  698. .nav-menu a:hover,
  699. .nav-menu .current > a, .nav-menu .current > a:hover,
  700. .mobile-nav-menu a:hover,
  701. .mobile-nav-menu .current > a, .mobile-nav-menu .current > a:hover,
  702. .aside-nav-menu a:hover,
  703. .aside-nav-menu .current:not(.current-menu-parent):not(.current-menu-ancestor) > a, .aside-nav-menu .current:not(.current-menu-parent):not(.current-menu-ancestor) > a:hover {
  704. color: %1$s;
  705. }
  706.  
  707. mark,
  708. .background-color,
  709. .sy-pager li.sy-active a {
  710. background-color: %1$s;
  711. }
  712.  
  713. .zoom-hover > .zoom-hover-overlay {
  714. background-color: rgba(%2$s, 0.75);
  715. }
  716.  
  717. blockquote.bar,
  718. .sticky:before {
  719. border-color: %1$s;
  720. }
  721. EOS
  722. ,
  723. Everything::to('general/color'),
  724. implode(', ', array_map('hexdec', str_split(substr(Everything::to('general/color'), 1), 2)))
  725. ));
  726.  
  727. // Comment reply
  728. if (is_singular() && comments_open() && get_option('thread_comments')) {
  729. wp_enqueue_script('comment-reply');
  730. }
  731.  
  732. // 3rd party scripts
  733. wp_enqueue_script('everything-3rd-party', $this->template_uri.'/data/js/3rd-party.min.js', array('jquery'), $ver, true);
  734.  
  735. // Main script
  736. wp_enqueue_script('everything-script', $this->template_uri."/data/js/everything{$min_sufix}.js", array('jquery'), $ver, true);
  737.  
  738. // WooCommerce
  739. if (Everything::isPluginActive('woocommerce')) {
  740. wp_deregister_script('wc-single-product');
  741. wp_register_script('wc-single-product', $this->template_uri."/data/js/woocommerce/single-product{$min_sufix}.js", array('jquery'), $ver, true);
  742. }
  743.  
  744. // Configuration
  745. $this->addDocumentScript(sprintf('everythingConfig = %s;', json_encode(array(
  746. 'retinaSupport' => Everything::to('general/retina'),
  747. 'fancyboxOptions' => Everything::to('site/image/fancybox_horizontal_fit_only') ? array('maxWidth' => '100%', 'fitToView' => false) : array(),
  748. 'zoomHoverIcons' => array_map(function($s) { return 'icon-'.$s; }, Everything::to_('site/hover_icons')->toArray()),
  749. 'captions' => array('bricksAllButton' => __('all', 'everything'))
  750. ))));
  751.  
  752. // Max. width style
  753. if (!Everything::to_('general/max_width')->isDefault()) {
  754. Everything::$max_width = Everything::to_('general/max_width')->value();
  755. $this->addDocumentStyle(sprintf(
  756. <<<'EOS'
  757. .layout-boxed .outer-container, .container {
  758. max-width: %dpx;
  759. }
  760. EOS
  761. , Everything::$max_width));
  762. }
  763.  
  764. // Colors styles
  765. foreach (Everything::to_('color')->childs() as $name => $group) {
  766. if ($group->child('enabled')->value) {
  767. $color = $group->child($name);
  768. $css = str_replace('%color', $color->value, $color->tag);
  769. if (strpos($css, '%rgba') !== false) {
  770. $css = preg_replace_callback('/%rgba0([0-9]{2})/', function($m) use ($color) {
  771. return \Drone\Func::cssHexToRGBA($color->value, $m[1]/100);
  772. }, $css);
  773. }
  774. if (strpos($css, '%darken') !== false) {
  775. $hsl = \Drone\Func::colorRGBToHSL(\Drone\Func::cssColorToDec($color->value));
  776. $hsl[2] = max($hsl[2]-0.12, 0);
  777. $css = str_replace('%darken', \Drone\Func::cssDecToColor(\Drone\Func::colorHSLToRGB($hsl)), $css);
  778. }
  779. $this->addDocumentStyle($css);
  780. }
  781. }
  782.  
  783. // Header style
  784. if (Everything::to_('header/style/settings')->value('floated')) {
  785. $this->addDocumentStyle(sprintf('#header:before { opacity: %.2f; }', Everything::to('header/style/opacity')/100));
  786. }
  787.  
  788. // Content
  789. if (!is_null($background = Everything::io_('layout/background/background', 'general/background/background', '__hidden_ns', '__hidden'))) {
  790. if ($background instanceof \Drone\Options\Option\ConditionalTags) {
  791. $background = $background->option();
  792. }
  793. if (!$background->option('opacity')->isDefault()) {
  794. $this->addDocumentStyle(sprintf(
  795. <<<'EOS'
  796. .layout-boxed #content aside.aside .aside-nav-menu .current:not(.current-menu-parent):not(.current-menu-ancestor) > a:before {
  797. display: none;
  798. }
  799. #content:before {
  800. opacity: %.2f;
  801. }
  802. EOS
  803. , $background->property('opacity')/100));
  804. }
  805. }
  806.  
  807. // Fonts styles
  808. foreach (\Drone\Options\Option\Font::getInstances() as $font) {
  809. if ($font->isVisible() && !is_null($font->tag)) {
  810. foreach ((array)$font->tag as $selector) {
  811. $this->addDocumentStyle($font->css($selector));
  812. }
  813. }
  814. }
  815.  
  816. // MediaElement.js progress bar color
  817. if (version_compare($this->wp_version, '4.0') >= 0) {
  818. $this->addDocumentStyle(sprintf(
  819. <<<'EOS'
  820. .mejs-container .mejs-controls .mejs-time-rail .mejs-time-current {
  821. background-color: %s;
  822. }
  823. EOS
  824. , Everything::to('general/color')));
  825. }
  826.  
  827. // Google Chrome fonts fix
  828. if (Everything::to('advanced/chrome_fonts_fix')) {
  829. $this->addDocumentStyle(
  830. <<<'EOS'
  831. @media screen and (-webkit-min-device-pixel-ratio: 0) {
  832. * {
  833. -webkit-font-smoothing: antialiased;
  834. -webkit-text-stroke: 0.1pt;
  835. }
  836. h1, h2, h3, .button.big *, .button.huge *, #header * {
  837. -webkit-text-stroke: 0.2pt;
  838. }
  839. }
  840. EOS
  841. );
  842. }
  843.  
  844. // List widgets script
  845. if (is_active_widget(false, false, 'pages') ||
  846. is_active_widget(false, false, 'archives') ||
  847. is_active_widget(false, false, 'categories') ||
  848. is_active_widget(false, false, 'recent-posts') ||
  849. is_active_widget(false, false, 'recent-comments') ||
  850. is_active_widget(false, false, 'bbp_forums_widget') ||
  851. is_active_widget(false, false, 'bbp_replies_widget') ||
  852. is_active_widget(false, false, 'bbp_topics_widget') ||
  853. is_active_widget(false, false, 'bbp_views_widget')) {
  854. $this->addDocumentJQueryScript(
  855. <<<'EOS'
  856. $('.widget_pages, .widget_archive, .widget_categories, .widget_recent_entries, .widget_recent_comments, .widget_display_forums, .widget_display_replies, .widget_display_topics, .widget_display_views').each(function() {
  857. $('ul', this).addClass('fancy alt');
  858. $('li', this).prepend($('<i />', {'class': 'icon-right-open'}));
  859. if ($(this).closest('#content').length > 0) {
  860. $('li > .icon-right-open', this).addClass('color');
  861. }
  862. });
  863. EOS
  864. );
  865. }
  866.  
  867. // Menu widgets script
  868. if (is_active_widget(false, false, 'meta') ||
  869. is_active_widget(false, false, 'nav_menu')) {
  870. $this->addDocumentJQueryScript(
  871. <<<'EOS'
  872. $('.widget_meta, .widget_nav_menu').each(function() {
  873. if ($(this).is('#content .widget')) {
  874. $('> div:has(> ul)', this).replaceWith(function() { return $(this).contents(); });
  875. $('ul:first', this).wrap('<nav class="aside-nav-menu"></nav>');
  876. } else {
  877. $('ul', this).addClass('fancy alt');
  878. $('li', this).prepend($('<i />', {'class': 'icon-right-open'}));
  879. }
  880. });
  881. EOS
  882. );
  883. }
  884.  
  885. // Calendar widget
  886. if (is_active_widget(false, false, 'calendar')) {
  887. $this->addDocumentJQueryScript(
  888. <<<'EOS'
  889. $('.widget_calendar #calendar_wrap > table').unwrap();
  890. EOS
  891. );
  892. }
  893.  
  894. // Tag cloud widget
  895. if (is_active_widget(false, false, 'tag_cloud')) {
  896. $this->addDocumentJQueryScript(
  897. <<<'EOS'
  898. $('.widget_tag_cloud .tagcloud').wrapInner('<div />').find('a').addClass('button small').css('font-size', '');
  899. EOS
  900. );
  901. }
  902.  
  903. // bbPress
  904. if (Everything::isPluginActive('bbpress') && is_active_widget(false, false, 'bbp_replies_widget')) {
  905. $this->addDocumentJQueryScript(
  906. <<<'EOS'
  907. $('.widget_display_replies li > div').addClass('small');
  908. EOS
  909. );
  910. }
  911.  
  912. // Disqus Comment System
  913. if (Everything::isPluginActive('disqus')) {
  914. $this->addDocumentJQueryScript(
  915. <<<'EOS'
  916. $('#disqus_thread').addClass('section');
  917. EOS
  918. );
  919. }
  920.  
  921. // WooCommerce
  922. if (Everything::isPluginActive('woocommerce')) {
  923. if (!is_null($color = Everything::to('woocommerce/cart/color', '__default'))) {
  924. $this->addDocumentStyle(sprintf(
  925. <<<'EOS'
  926. i.icon-woocommerce-cart {
  927. color: %s;
  928. }
  929. EOS
  930. ,
  931. $color
  932. ));
  933. }
  934. $this->addDocumentStyle(sprintf(
  935. <<<'EOS'
  936. .widget_price_filter .ui-slider .ui-slider-range,
  937. .widget_price_filter .ui-slider .ui-slider-handle {
  938. background-color: %s;
  939. }
  940. EOS
  941. ,
  942. Everything::to('general/color')
  943. ));
  944. if (Everything::to('woocommerce/onsale/custom')) {
  945. $this->addDocumentStyle(sprintf(
  946. <<<'EOS'
  947. .woocommerce .onsale,
  948. .woocommerce-page .onsale {
  949. background: %s;
  950. color: %s;
  951. }
  952. EOS
  953. ,
  954. Everything::to('woocommerce/onsale/background'),
  955. Everything::to('woocommerce/onsale/color')
  956. ));
  957. }
  958. if (Everything::to('woocommerce/rating/custom')) {
  959. $this->addDocumentStyle(sprintf(
  960. <<<'EOS'
  961. .woocommerce .rating i:not(.pad),
  962. .woocommerce-page .rating i:not(.pad) {
  963. color: %s;
  964. }
  965. EOS
  966. ,
  967. Everything::to('woocommerce/rating/color')
  968. ));
  969. }
  970. if (\Drone\Options\Option\ConditionalTags::is('account_page')) {
  971. $this->addDocumentJQueryScript(
  972. <<<'EOS'
  973. $('.woocommerce .my_account_orders .order-actions .button').addClass('small');
  974. EOS
  975. );
  976. }
  977. }
  978.  
  979. // WooCommerce Brands
  980. if (Everything::isPluginActive('woocommerce-brands')) {
  981. wp_dequeue_style('brands-styles');
  982. }
  983.  
  984. // WPML
  985. if (Everything::isPluginActive('wpml')) {
  986. if (is_active_widget(false, false, 'icl_lang_sel_widget')) {
  987. $this->addDocumentJQueryScript(
  988. <<<'EOS'
  989. $('.widget_icl_lang_sel_widget').each(function() {
  990. $('ul', this).unwrap().addClass('simple alt');
  991. $('img', this).addClass('icon');
  992. });
  993. EOS
  994. );
  995. }
  996. }
  997.  
  998. // Debug
  999. $this->endMarker(__METHOD__);
  1000.  
  1001. }
  1002.  
  1003. // -------------------------------------------------------------------------
  1004.  
  1005. /**
  1006. * pre_get_posts action
  1007. *
  1008. * @internal action: pre_get_posts
  1009. * @since 1.0
  1010. *
  1011. * @param object $query
  1012. */
  1013. public function actionPreGetPosts($query)
  1014. {
  1015. if ($query->is_tax('portfolio-category') || $query->is_tax('portfolio-tag')) {
  1016. $query->query_vars['posts_per_page'] = Everything::to('portfolio/archive/count');
  1017. }
  1018. }
  1019.  
  1020. // -------------------------------------------------------------------------
  1021.  
  1022. /**
  1023. * the_post action
  1024. *
  1025. * @internal action: the_post
  1026. * @since 1.5
  1027. *
  1028. * @param \WP_Query $query
  1029. */
  1030. public function actionThePost(&$post)
  1031. {
  1032. Everything::$posts_stack[] = $post->ID;
  1033. }
  1034.  
  1035. // -------------------------------------------------------------------------
  1036.  
  1037. /**
  1038. * comment_form_before_fields action
  1039. *
  1040. * @internal action: comment_form_before_fields
  1041. * @since 1.0
  1042. */
  1043. public function actionCommentFormBeforeFields()
  1044. {
  1045. echo '<div class="columns alt-mobile"><ul>';
  1046. }
  1047.  
  1048. // -------------------------------------------------------------------------
  1049.  
  1050. /**
  1051. * comment_form_after_fields action
  1052. *
  1053. * @internal action: comment_form_after_fields
  1054. * @since 1.0
  1055. */
  1056. public function actionCommentFormAfterFields()
  1057. {
  1058. echo '</ul></div>';
  1059. }
  1060.  
  1061. // -------------------------------------------------------------------------
  1062.  
  1063. /**
  1064. * layerslider_ready action
  1065. *
  1066. * @internal action: layerslider_ready
  1067. * @since 1.0
  1068. */
  1069. public function actionLayersliderReady()
  1070. {
  1071. $GLOBALS['lsAutoUpdateBox'] = false;
  1072. }
  1073.  
  1074. // -------------------------------------------------------------------------
  1075.  
  1076. /**
  1077. * woocommerce_single_product_summary action
  1078. *
  1079. * @internal action: woocommerce_single_product_summary, 35
  1080. * @since 1.0
  1081. */
  1082. public function actionWoocommerceSingleProductSummary()
  1083. {
  1084.  
  1085. if (!Everything::isPluginActive('woocommerce-brands') || !Everything::to('woocommerce/product/brands')) {
  1086. return;
  1087. }
  1088.  
  1089. // Brand
  1090. $brands = wp_get_post_terms(get_the_ID(), 'product_brand', array('fields' => 'ids'));
  1091.  
  1092. if (count($brands) == 0) {
  1093. return;
  1094. }
  1095. $brand = get_term($brands[0], 'product_brand');
  1096.  
  1097. // Validation
  1098. if (!$brand->description) {
  1099. return;
  1100. }
  1101.  
  1102. // HTML
  1103. $html = \Drone\HTML::make();
  1104. $html->addNew('hr');
  1105.  
  1106. // Thumbnail
  1107. if ($thumbnail_id = get_woocommerce_term_meta($brand->term_id, 'thumbnail_id', true)) {
  1108. $html->addNew('figure')
  1109. ->class('alignleft')
  1110. ->addNew('a')
  1111. ->attr(Everything::getImageAttrs('a', array('border' => false, 'hover' => '')))
  1112. ->href(get_term_link($brand, 'product_brand'))
  1113. ->title($brand->name)
  1114. ->add(wp_get_attachment_image($thumbnail_id, 'logo'));
  1115. }
  1116.  
  1117. // Description
  1118. $html->add(wpautop(wptexturize($brand->description)));
  1119.  
  1120. echo $html->html();
  1121.  
  1122. }
  1123.  
  1124. // -------------------------------------------------------------------------
  1125.  
  1126. /**
  1127. * image_size_names_choose filter
  1128. *
  1129. * @internal filter: image_size_names_choose, 100
  1130. * @since 1.0
  1131. *
  1132. * @param array $sizes
  1133. * @return array
  1134. */
  1135. public function filterImageSizeNamesChoose($sizes)
  1136. {
  1137. $sizes = \Drone\Func::arrayInsert($sizes, array('logo' => __('Logo', 'everything')), 'thumbnail');
  1138. $sizes = \Drone\Func::arrayInsert($sizes, array('max-width' => __('Site width', 'everything')), 'full');
  1139. return $sizes;
  1140. }
  1141.  
  1142. // -------------------------------------------------------------------------
  1143.  
  1144. /**
  1145. * body_class filter
  1146. *
  1147. * @internal filter: body_class
  1148. * @since 1.0
  1149. *
  1150. * @param array $classes
  1151. * @return array
  1152. */
  1153. public function filterBodyClass($classes)
  1154. {
  1155. if (Everything::isPluginActive('wpml')) {
  1156. $classes[] = 'lang-'.ICL_LANGUAGE_CODE;
  1157. }
  1158. $classes[] = 'layout-'.Everything::to_('general/layout')->value();
  1159. $classes[] = 'scheme-'.Everything::to('general/scheme');
  1160. return $classes;
  1161. }
  1162.  
  1163. // -------------------------------------------------------------------------
  1164.  
  1165. /**
  1166. * wp_nav_menu_items and wp_list_pages filter
  1167. *
  1168. * @internal filter: wp_nav_menu_items
  1169. * @internal filter: wp_list_pages
  1170. * @since 1.0
  1171. *
  1172. * @param string $items
  1173. * @param array $args
  1174. * @return string
  1175. */
  1176. public function filterWPNavMenuItems($items, $args)
  1177. {
  1178.  
  1179. // Theme location
  1180. if (isset($args->theme_location)) {
  1181. $theme_location = $args->theme_location;
  1182. } else if (isset($args['theme_location'])) {
  1183. $theme_location = $args['theme_location'];
  1184. } else {
  1185. return $items;
  1186. }
  1187.  
  1188. // Icons
  1189. $items = preg_replace_callback('#<li(?P<li_attrs>[^>]*)>\s*<a(?P<a_attrs>[^>]*)>(?P<label>[^<>]*?)</a>#i', function($matches) {
  1190. if (!preg_match('/[ "](?P<class>icon-(?P<icon>[-_a-z0-9]+))[ "]/', $matches['li_attrs'], $class_matches)) {
  1191. return $matches[0];
  1192. }
  1193. return sprintf(
  1194. '<li%s><a%s>%s%s</a>',
  1195. str_replace($class_matches['class'], '', $matches['li_attrs']),
  1196. $matches['a_attrs'],
  1197. Everything::getShortcodeOutput(
  1198. strpos($class_matches['icon'], '_') === false ? 'vector_icon' : 'image_icon',
  1199. array('name' => str_replace('_', '/', $class_matches['icon']))
  1200. ),
  1201. $matches['label']
  1202. );
  1203. }, $items);
  1204.  
  1205. // Result
  1206. return $items;
  1207.  
  1208. }
  1209.  
  1210. // -------------------------------------------------------------------------
  1211.  
  1212. /**
  1213. * get_search_form filter
  1214. *
  1215. * @internal filter: get_search_form
  1216. * @since 1.0
  1217. *
  1218. * @return string
  1219. */
  1220. public function filterGetSearchForm()
  1221. {
  1222. $search_form = \Drone\HTML::form()
  1223. ->method('get')
  1224. ->action(home_url('/'))
  1225. ->class('search')
  1226. ->role('search');
  1227. $search_form->addNew('input')
  1228. ->type('text')
  1229. ->name('s')
  1230. ->value(get_search_query())
  1231. ->placeholder(__('Search site', 'everything'));
  1232. $search_form->addNew('button')
  1233. ->type('submit')
  1234. ->addNew('i')
  1235. ->class('icon-search');
  1236. return $search_form->html();
  1237. }
  1238.  
  1239. // -------------------------------------------------------------------------
  1240.  
  1241. /**
  1242. * wp_get_attachment_image_attributes filter
  1243. *
  1244. * @internal filter: wp_get_attachment_image_attributes
  1245. * @since 1.0
  1246. *
  1247. * @param array $attr
  1248. * @param object $attachment
  1249. * @return string
  1250. */
  1251. public function filterWPGetAttachmentImageAttributes($attr, $attachment)
  1252. {
  1253.  
  1254. // Admin
  1255. if (is_admin()) {
  1256. return $attr;
  1257. }
  1258.  
  1259. // Size name
  1260. if (!preg_match('/attachment-(?P<size>[-_a-z0-9]+)/i', $attr['class'], $matches)) {
  1261. return $attr;
  1262. }
  1263.  
  1264. // Images
  1265. if (count($images = Everything::getAttachmentImages($attachment->ID, $matches['size'])) == 0) {
  1266. return $attr;
  1267. }
  1268.  
  1269. return $attr+$images;
  1270.  
  1271. }
  1272.  
  1273. // -------------------------------------------------------------------------
  1274.  
  1275. /**
  1276. * get_calendar filter
  1277. *
  1278. * @internal filter: get_calendar
  1279. * @since 1.0
  1280. *
  1281. * @param string $calendar_output
  1282. * @return string
  1283. */
  1284. public function filterGetCalendar($calendar_output)
  1285. {
  1286. return str_replace('<table ', '<table class="fixed" ', $calendar_output);
  1287. }
  1288.  
  1289. // -------------------------------------------------------------------------
  1290.  
  1291. /**
  1292. * the_content filter
  1293. *
  1294. * @internal filter: the_content, 1
  1295. * @since 1.0
  1296. *
  1297. * @param string $content
  1298. * @return string
  1299. */
  1300. public function filterTheContent1($content)
  1301. {
  1302.  
  1303. // More anchor
  1304. if (stripos($content, 'id="more-') !== false) {
  1305. $content = preg_replace('#^\s*<span id="more-[0-9]+"></span>\s*#i', '', $content);
  1306. }
  1307.  
  1308. // Align-none
  1309. if (stripos($content, 'alignnone') !== false) {
  1310. $content = preg_replace(
  1311. '#(<p([^>]*)>)?(( *(<a[^>]*>)?<img[^>]*class="[^"]*alignnone[^"]*"[^>]*>(</a>)? *){2,})(</p>)?#i',
  1312. '<div class="figuregroup"\2>\3</div>',
  1313. $content
  1314. );
  1315. }
  1316.  
  1317. return $content;
  1318.  
  1319. }
  1320.  
  1321. // -------------------------------------------------------------------------
  1322.  
  1323. /**
  1324. * the_content filter
  1325. *
  1326. * @internal filter: the_content, 15
  1327. *
  1328. * @param string $content
  1329. * @return string
  1330. */
  1331. public function filterTheContent($content)
  1332. {
  1333. if (stripos($content, 'iframe') !== false || stripos($content, 'embed') !== false) {
  1334. $content = preg_replace('#(<p>)?(<(iframe|embed).*?></\3>)(</p>)?#i', '<div class="embed">\2</div>', $content);
  1335. }
  1336. return $content;
  1337. }
  1338.  
  1339. // -------------------------------------------------------------------------
  1340.  
  1341. /**
  1342. * wp_trim_excerpt filter
  1343. *
  1344. * @internal filter: wp_trim_excerpt
  1345. * @since 1.0
  1346. *
  1347. * @param string $text
  1348. * @return string
  1349. */
  1350. public function filterWPTrimExcerpt($text)
  1351. {
  1352. if (is_feed() || is_attachment() || trim($text) == '') {
  1353. return $text;
  1354. }
  1355. return sprintf('%s <a href="%s" class="more-link">%s</a>', $text, get_permalink(), Everything::getReadMore());
  1356. }
  1357.  
  1358. // -------------------------------------------------------------------------
  1359.  
  1360. /**
  1361. * the_password_form filter
  1362. *
  1363. * @internal filter: the_password_form
  1364. * @since 1.0
  1365. *
  1366. * @param string $html
  1367. * @return string
  1368. */
  1369. public function filterThePasswordForm($html)
  1370. {
  1371. return str_replace('</label> <input ', '</label><input ', $html);
  1372. }
  1373.  
  1374. // -------------------------------------------------------------------------
  1375.  
  1376. /**
  1377. * comment_form_defaults filter
  1378. *
  1379. * @internal filter: comment_form_defaults
  1380. * @since 1.0
  1381. *
  1382. * @param array $defaults
  1383. * @return array
  1384. */
  1385. public function filterCommentFormDefaults($defaults)
  1386. {
  1387. $commenter = wp_get_current_commenter();
  1388. return array_merge($defaults, array(
  1389. 'fields' => array(
  1390. 'author' => '<li class="col-1-3"><input class="full-width" type="text" name="author" placeholder="'.__('Name', 'everything').'*" value="'.esc_attr($commenter['comment_author']).'" required /></li>',
  1391. 'email' => '<li class="col-1-3"><input class="full-width" type="email" name="email" placeholder="'.__('E-mail', 'everything').' ('.__('not published', 'everything').')*" value="'.esc_attr($commenter['comment_author_email']).'" required /></li>',
  1392. 'url' => '<li class="col-1-3"><input class="full-width" type="text" name="url" placeholder="'.__('Website', 'everything').'" value="'.esc_attr($commenter['comment_author_url']).'" /></li>'
  1393. ),
  1394. 'comment_field' => '<p><textarea class="full-width" name="comment" placeholder="'.__('Message', 'everything').'" required></textarea></p>',
  1395. 'must_log_in' => str_replace('<p class="must-log-in">', '<p class="must-log-in small">', $defaults['must_log_in']),
  1396. 'logged_in_as' => str_replace('<p class="logged-in-as">', '<p class="logged-in-as small">', $defaults['logged_in_as']),
  1397. 'comment_notes_before' => '',
  1398. 'comment_notes_after' => '',
  1399. 'title_reply' => __('Leave a comment', 'everything'),
  1400. 'title_reply_to' => __('Leave a reply to %s', 'everything'),
  1401. 'cancel_reply_link' => __('Cancel reply', 'everything'),
  1402. 'label_submit' => __('Send &rsaquo;', 'everything'),
  1403. 'format' => 'html5'
  1404. ));
  1405. }
  1406.  
  1407. // -------------------------------------------------------------------------
  1408.  
  1409. /**
  1410. * wp_video_extensions filter
  1411. *
  1412. * @internal filter: wp_video_extensions
  1413. * @since 1.0
  1414. *
  1415. * @param array $exts
  1416. * @return array
  1417. */
  1418. public function filterWPVideoExtensions($exts)
  1419. {
  1420. $exts[] = 'ogg';
  1421. return $exts;
  1422. }
  1423.  
  1424. // -------------------------------------------------------------------------
  1425.  
  1426. /**
  1427. * wp_audio_shortcode and wp_video_shortcode filter
  1428. *
  1429. * @internal filter: wp_audio_shortcode
  1430. * @internal filter: wp_video_shortcode
  1431. * @since 1.0
  1432. *
  1433. * @param string $html
  1434. * @return string
  1435. */
  1436. public function filterWPAudioVideoShortcode($html)
  1437. {
  1438. $class = preg_match('/<(audio|video) /i', $html, $m) ? strtolower($m[1]) : '';
  1439. return "<div class=\"embed {$class}\">".preg_replace('#^<div.*?>(.+?)</div>$#i', '\1', $html).'</div>';
  1440. }
  1441.  
  1442. // -------------------------------------------------------------------------
  1443.  
  1444. /**
  1445. * get_previous_post_where and get_next_post_where filter
  1446. *
  1447. * @internal filter: get_previous_post_where
  1448. * @internal filter: get_next_post_where
  1449. * @since 1.0
  1450. *
  1451. * @param string $query
  1452. * @return string
  1453. */
  1454. public function filterGetAdjacentPostWhere($query)
  1455. {
  1456. if (is_singular('portfolio')) {
  1457. $query .= $GLOBALS['wpdb']->prepare(' AND p.post_parent = %d', $GLOBALS['post']->post_parent);
  1458. }
  1459. return $query;
  1460. }
  1461.  
  1462. // -------------------------------------------------------------------------
  1463.  
  1464. /**
  1465. * everything_headline filter
  1466. *
  1467. * @internal filter: everything_headline
  1468. * @since 1.0
  1469. *
  1470. * @param string $headline
  1471. * @return string
  1472. */
  1473. public function filterBBPEverythingHeadline($headline)
  1474. {
  1475. if (Everything::isPluginActive('bbpress') && is_bbpress()) {
  1476. switch ($headline) {
  1477. case 'mixed': return Everything::isPluginActive('breadcrumb-navxt', 'breadcrumb-trail', 'wordpress-seo') ? 'breadcrumbs' : 'none';
  1478. case 'navigation': return 'none';
  1479. }
  1480. }
  1481. return $headline;
  1482. }
  1483.  
  1484. // -------------------------------------------------------------------------
  1485.  
  1486. /**
  1487. * bbp_get_breadcrumb filter
  1488. *
  1489. * @internal filter: bbp_get_breadcrumb
  1490. * @since 1.0
  1491. *
  1492. * @param string $trail
  1493. * @param array $crumbs
  1494. * @param array $r
  1495. * @return bool
  1496. */
  1497. public function filterBBPGetBreadcrumb($trail, $crumbs, $r)
  1498. {
  1499. return !$r['before'] || !$r['after'] ? $trail : '';
  1500. }
  1501.  
  1502. // -------------------------------------------------------------------------
  1503.  
  1504. /**
  1505. * breadcrumb_trail filter
  1506. *
  1507. * @internal filter: breadcrumb_trail
  1508. * @since 1.0
  1509. *
  1510. * @param string $breadcrumb
  1511. * @param array $args
  1512. * @return string
  1513. */
  1514. public function filterBreadcrumbTrail($breadcrumb, $args)
  1515. {
  1516. return preg_replace('#</?(div|span).*?>#i', '', $breadcrumb);
  1517. }
  1518.  
  1519. // -------------------------------------------------------------------------
  1520.  
  1521. /**
  1522. * masterslider_disable_auto_update filter
  1523. *
  1524. * @internal filter: masterslider_disable_auto_update
  1525. * @since 1.0
  1526. *
  1527. * @return bool
  1528. */
  1529. public function filterMastersliderDisableAutoUpdate()
  1530. {
  1531. return true;
  1532. }
  1533.  
  1534. // -------------------------------------------------------------------------
  1535.  
  1536. /**
  1537. * masterslider_panel_default_setting filter
  1538. *
  1539. * @internal filter: masterslider_panel_default_setting
  1540. * @since 1.0
  1541. *
  1542. * @param array $options
  1543. * @return array
  1544. */
  1545. public function filterMastersliderPanelDefaultSetting($options)
  1546. {
  1547. $options['width'] = Everything::to_('general/max_width')->value('default');
  1548. $options['height'] = round($options['width'] / 1.7778);
  1549. $options['layout'] = Everything::to_('general/layout')->value('default') == 'open' ? 'fullwidth' : 'boxed';
  1550. $options['autoHeight'] = Everything::to_('general/layout')->value('default') == 'boxed';
  1551. return $options;
  1552. }
  1553.  
  1554. // -------------------------------------------------------------------------
  1555.  
  1556. /**
  1557. * everything_headline filter
  1558. *
  1559. * @internal filter: everything_headline
  1560. * @since 1.0
  1561. *
  1562. * @param string $headline
  1563. * @return string
  1564. */
  1565. public function filterWoocommerceEverythingHeadline($headline)
  1566. {
  1567. if (Everything::isPluginActive('woocommerce') && is_product()) {
  1568. switch ($headline) {
  1569. case 'mixed': return Everything::isPluginActive('breadcrumb-navxt', 'breadcrumb-trail', 'wordpress-seo') ? 'breadcrumbs' : 'none';
  1570. case 'navigation': return 'none';
  1571. }
  1572. }
  1573. return $headline;
  1574. }
  1575.  
  1576. // -------------------------------------------------------------------------
  1577.  
  1578. /**
  1579. * everything_author_bio_display, everything_social_buttons_display, everything_meta_display filter
  1580. *
  1581. * @internal filter: everything_author_bio_display
  1582. * @internal filter: everything_social_buttons_display
  1583. * @internal filter: everything_meta_display
  1584. * @since 1.0
  1585. *
  1586. * @param bool $show
  1587. * @return bool
  1588. */
  1589. public function filterWoocommerceEverythingDisplay($show)
  1590. {
  1591. if (Everything::isPluginActive('woocommerce') && (is_cart() || is_checkout() || is_account_page() || is_order_received_page())) {
  1592. return false;
  1593. }
  1594. return $show;
  1595. }
  1596.  
  1597. // -------------------------------------------------------------------------
  1598.  
  1599. /**
  1600. * woocommerce_enqueue_styles filter
  1601. *
  1602. * @internal filter: woocommerce_enqueue_styles
  1603. * @since 1.0
  1604. *
  1605. * @return boolean
  1606. */
  1607. public function filterWoocommerceEnqueueStyles()
  1608. {
  1609. return false;
  1610. }
  1611.  
  1612. // -------------------------------------------------------------------------
  1613.  
  1614. /**
  1615. * loop_shop_per_page filter
  1616. *
  1617. * @internal filter: loop_shop_per_page
  1618. * @since 1.0
  1619. *
  1620. * @return int
  1621. */
  1622. public function filterWoocommerceLoopShopPerPage()
  1623. {
  1624. return Everything::to('woocommerce/shop/per_page');
  1625. }
  1626.  
  1627. // -------------------------------------------------------------------------
  1628.  
  1629. /**
  1630. * woocommerce_output_related_products_args filter
  1631. *
  1632. * @internal filter: woocommerce_output_related_products_args
  1633. * @since 1.0
  1634. *
  1635. * @param array $args
  1636. * @return array
  1637. */
  1638. public function filterWoocommerceOutputRelatedProductsArgs($args)
  1639. {
  1640. $args['posts_per_page'] = Everything::to('woocommerce/related_products/total');
  1641. $args['columns'] = Everything::to('woocommerce/related_products/columns');
  1642. return $args;
  1643. }
  1644.  
  1645. // -------------------------------------------------------------------------
  1646.  
  1647. /**
  1648. * woocommerce_cross_sells_total filter
  1649. *
  1650. * @internal filter: woocommerce_cross_sells_total
  1651. * @since 1.0
  1652. *
  1653. * @param int $posts_per_page
  1654. * @return int
  1655. */
  1656. public function filterWoocommercCrossSellsTotal($posts_per_page)
  1657. {
  1658. return Everything::to('woocommerce/cross_sells/total');
  1659. }
  1660.  
  1661. // -------------------------------------------------------------------------
  1662.  
  1663. /**
  1664. * woocommerce_cross_sells_columns filter
  1665. *
  1666. * @internal filter: woocommerce_cross_sells_columns
  1667. * @since 1.0
  1668. *
  1669. * @param int $columns
  1670. * @return int
  1671. */
  1672. public function filterWoocommercCrossSellsColumns($columns)
  1673. {
  1674. return Everything::to('woocommerce/cross_sells/columns');
  1675. }
  1676.  
  1677. // -------------------------------------------------------------------------
  1678.  
  1679. /**
  1680. * woocommerce_show_page_title filter
  1681. *
  1682. * @internal filter: woocommerce_show_page_title
  1683. * @since 1.0
  1684. *
  1685. * @return bool
  1686. */
  1687. public function filterWoocommerceShowPageTitle()
  1688. {
  1689. return !Everything::$headline_used;
  1690. }
  1691.  
  1692. // -------------------------------------------------------------------------
  1693.  
  1694. /**
  1695. * woocommerce_placeholder_img_src filter
  1696. *
  1697. * @internal filter: woocommerce_placeholder_img_src
  1698. * @since 1.0
  1699. *
  1700. * @return string
  1701. */
  1702. public function filterWoocommercePlaceholderImgSrc()
  1703. {
  1704. return $this->template_uri.'/data/img/woocommerce/placeholder.jpg';
  1705. }
  1706.  
  1707. // -------------------------------------------------------------------------
  1708.  
  1709. /**
  1710. * woocommerce_placeholder_img filter
  1711. *
  1712. * @internal filter: woocommerce_placeholder_img
  1713. * @since 1.0
  1714. *
  1715. * @param string $html
  1716. * @return string
  1717. */
  1718. public function filterWoocommercePlaceholderImg($html)
  1719. {
  1720. return str_replace('<img ', '<img data-image1496="'.$this->template_uri.'/data/img/woocommerce/placeholder@2x.jpg" ', $html);
  1721. }
  1722.  
  1723. // -------------------------------------------------------------------------
  1724.  
  1725. /**
  1726. * wc_add_to_cart_message filter
  1727. *
  1728. * @internal filter: wc_add_to_cart_message
  1729. * @since 1.0
  1730. *
  1731. * @param string $html
  1732. * @return string
  1733. */
  1734. public function filterWoocommerceAddToCartMessage($html)
  1735. {
  1736. return str_replace('class="button ', 'class="button small ', $html);
  1737. }
  1738.  
  1739. // -------------------------------------------------------------------------
  1740.  
  1741. /**
  1742. * woocommerce_loop_add_to_cart_link filter
  1743. *
  1744. * @internal filter: woocommerce_loop_add_to_cart_link
  1745. * @since 1.0
  1746. *
  1747. * @param string $html
  1748. * @return string
  1749. */
  1750. public function filterWoocommerceLoopAddToCartLink($html)
  1751. {
  1752. return str_replace('class="button ', 'class="button small ', $html);
  1753. }
  1754.  
  1755. // -------------------------------------------------------------------------
  1756.  
  1757. /**
  1758. * woocommerce_order_button_html filter
  1759. *
  1760. * @internal filter: woocommerce_order_button_html
  1761. * @since 1.0
  1762. *
  1763. * @param string $html
  1764. * @return string
  1765. */
  1766. public function filterWoocommerceOrderButtonHTML($html)
  1767. {
  1768. if (preg_match('/value="(.*?)"/', $html, $matches)) {
  1769. return '<button type="submit" class="big" name="woocommerce_checkout_place_order" id="place_order" style="border-color: #129a00; color: #129a00;"><span>'.$matches[1].'</span><i class="icon-right-bold"></i></button>';
  1770. } else {
  1771. return $html;
  1772. }
  1773. }
  1774.  
  1775. // -------------------------------------------------------------------------
  1776.  
  1777. /**
  1778. * get_product_search_form filter
  1779. *
  1780. * @internal filter: get_product_search_form
  1781. * @since 1.0
  1782. *
  1783. * @param string $html
  1784. * @return string
  1785. */
  1786. public function filterWoocommerceGetProductSearchForm($html)
  1787. {
  1788. return preg_replace('/\s*\n\s*/', '', $html);
  1789. }
  1790.  
  1791. // -------------------------------------------------------------------------
  1792.  
  1793. /**
  1794. * woocommerce_add_to_cart_fragments filter
  1795. *
  1796. * @internal filter: woocommerce_add_to_cart_fragments
  1797. * @since 1.2
  1798. *
  1799. * @param array $fragments
  1800. * @return array
  1801. */
  1802. public function filterWoocommerceAddToCartFragments($fragments)
  1803. {
  1804. $fragments['.cart-info.small'] = Everything::woocommerceGetCartInfo('small');
  1805. $fragments['.cart-info.big'] = Everything::woocommerceGetCartInfo('big', Everything::to('header/cart/visible', '__hidden', array()));
  1806. return $fragments;
  1807. }
  1808.  
  1809. // -------------------------------------------------------------------------
  1810.  
  1811. /**
  1812. * products_shortcode_tag filter
  1813. *
  1814. * @internal filter: products_shortcode_tag
  1815. * @since 1.0
  1816. *
  1817. * @param string $tag
  1818. * @return string
  1819. */
  1820. public function filterWoocommerceProductsShortcodeTag($tag)
  1821. {
  1822.  
  1823. add_shortcode($tag, function($atts) {
  1824.  
  1825. // class-wc-shortcodes.php snippet
  1826. extract( shortcode_atts( array(
  1827. 'columns' => '1',
  1828. 'orderby' => 'title',
  1829. 'order' => 'asc'
  1830. ), $atts ) );
  1831.  
  1832. $args = array(
  1833. 'post_type' => 'product',
  1834. 'post_status' => 'publish',
  1835. 'ignore_sticky_posts' => 1,
  1836. 'orderby' => $orderby,
  1837. 'order' => $order,
  1838. 'posts_per_page' => -1,
  1839. 'meta_query' => array(
  1840. array(
  1841. 'key' => '_visibility',
  1842. 'value' => array('catalog', 'visible'),
  1843. 'compare' => 'IN'
  1844. )
  1845. )
  1846. );
  1847.  
  1848. if ( isset( $atts['skus'] ) ) {
  1849. $skus = explode( ',', $atts['skus'] );
  1850. $skus = array_map( 'trim', $skus );
  1851. $args['meta_query'][] = array(
  1852. 'key' => '_sku',
  1853. 'value' => $skus,
  1854. 'compare' => 'IN'
  1855. );
  1856. }
  1857.  
  1858. if ( isset( $atts['ids'] ) ) {
  1859. $ids = explode( ',', $atts['ids'] );
  1860. $ids = array_map( 'trim', $ids );
  1861. $args['post__in'] = $ids;
  1862. }
  1863. // class-wc-shortcodes.php
  1864.  
  1865. $products = new WP_Query(apply_filters('woocommerce_shortcode_products_query', $args, $atts));
  1866.  
  1867. if (!$products->have_posts()) {
  1868. return;
  1869. }
  1870.  
  1871. $html = \Drone\HTML::div()
  1872. ->class('woocommerce columns')
  1873. ->add(
  1874. $ul = \Drone\HTML::ul()
  1875. );
  1876.  
  1877. $posts_list = array();
  1878. for ($i = 0; $i < $columns; $i++) {
  1879. $posts_list[$i] = $ul->addNew('li')
  1880. ->class('col-1-'.$columns)
  1881. ->addNew('ul')
  1882. ->class('posts-list');
  1883. }
  1884.  
  1885. $i = 0;
  1886. while ($products->have_posts()) {
  1887. $products->the_post();
  1888. $posts_list[$i % $columns]->add(str_replace('<figure class="alignright fixed">', '<figure class="alignleft fixed">',
  1889. \Drone\Func::functionGetOutputBuffer('wc_get_template', 'content-widget-product.php', array('show_rating' => true))
  1890. ));
  1891. $i++;
  1892. }
  1893.  
  1894. wp_reset_postdata();
  1895.  
  1896. return $html->html();
  1897.  
  1898. });
  1899.  
  1900. return '__'.$tag;
  1901.  
  1902. }
  1903.  
  1904. // -------------------------------------------------------------------------
  1905.  
  1906. /**
  1907. * drone_widget_posts_list_on_setup_options action
  1908. *
  1909. * @internal action: drone_widget_posts_list_on_setup_options
  1910. * @since 1.0
  1911. *
  1912. * @param object $options
  1913. * @param object $widget
  1914. */
  1915. public function actionWidgetPostsListOnSetupOptions($options, $widget)
  1916. {
  1917. $options->addOption('select', 'orientation', 'scrollable', __('Orientation', 'everything'), '', array('options' => array(
  1918. 'vertical' => __('Vertical', 'everything'),
  1919. 'scrollable' => __('Scrollable', 'everything')
  1920. )), 'count');
  1921. $options->addOption('boolean', 'thumbnail', true, '', '', array('caption' => __('Show thumbnail', 'everything')), 'author');
  1922. $options->addOption('boolean', 'date', true, '', '', array('caption' => __('Show date', 'everything')), 'author');
  1923. $options->deleteChild('author');
  1924. }
  1925.  
  1926. // -------------------------------------------------------------------------
  1927.  
  1928. /**
  1929. * drone_widget_posts_list_widget filter
  1930. *
  1931. * @internal filter: drone_widget_posts_list_widget
  1932. * @since 1.0
  1933. *
  1934. * @param object $html
  1935. * @param object $widget
  1936. */
  1937. public function filterWidgetPostsListWidget($html, $widget)
  1938. {
  1939. $html->addClass('posts-list');
  1940. if ($widget->wo('orientation') == 'scrollable') {
  1941. $html->addClass('scroller');
  1942. }
  1943. return $html;
  1944. }
  1945.  
  1946. // -------------------------------------------------------------------------
  1947.  
  1948. /**
  1949. * drone_widget_posts_list_post filter
  1950. *
  1951. * @internal filter: drone_widget_posts_list_post
  1952. * @since 1.0
  1953. *
  1954. * @param object $li
  1955. * @param object $widget
  1956. * @param object $post
  1957. */
  1958. public function filterWidgetPostsListPost($li, $widget, $post)
  1959. {
  1960. $li = \Drone\HTML::li();
  1961. if ($widget->wo('thumbnail') && has_post_thumbnail($post->ID)) {
  1962. $li->addNew('figure')
  1963. ->class('alignleft fixed')
  1964. ->addNew('a')
  1965. ->attr(Everything::getImageAttrs('a', array('border' => true, 'hover' => '', 'fanbcybox' => false)))
  1966. ->href(get_permalink($post->ID))
  1967. ->add(get_the_post_thumbnail($post->ID, apply_filters('everything_image_size', 'post-thumbnail-mini-crop', 'widget_posts_list')));
  1968. }
  1969. if ($widget->wo('date')) {
  1970. $GLOBALS['post'] = $post;
  1971. $li->addNew('p')->class('small')->add(Everything::getPostMeta('date'));
  1972. wp_reset_postdata();
  1973. }
  1974. $li->addNew('h3')->addNew('a')
  1975. ->href(get_permalink($post->ID))
  1976. ->title($post->post_title)
  1977. ->add(wp_trim_words($post->post_title, $widget->wo('limit')));
  1978. if ($widget->wo('comments')) {
  1979. $GLOBALS['post'] = $post;
  1980. $li->addNew('p')->class('small')->add(Everything::getPostMeta('comments_number'));
  1981. wp_reset_postdata();
  1982. }
  1983. return $li;
  1984. }
  1985.  
  1986. // -------------------------------------------------------------------------
  1987.  
  1988. /**
  1989. * drone_widget_twitter_on_setup_options action
  1990. *
  1991. * @internal action: drone_widget_twitter_on_setup_options
  1992. * @since 1.0
  1993. *
  1994. * @param object $options
  1995. * @param object $widget
  1996. */
  1997. public function actionWidgetTwitterOnSetupOptions($options, $widget)
  1998. {
  1999. $options->addOption('select', 'orientation', 'vertical', __('Orientation', 'everything'), '', array('options' => array(
  2000. 'vertical' => __('Vertical', 'everything'),
  2001. 'horizontal' => __('Horizontal', 'everything'),
  2002. 'scrollable' => __('Scrollable', 'everything')
  2003. )), 'count');
  2004. $options->addOption('boolean', 'follow_me_button', true, '', '', array('caption' => __('Add "follow me" button', 'everything')), 'oauth');
  2005. }
  2006.  
  2007. // -------------------------------------------------------------------------
  2008.  
  2009. /**
  2010. * drone_widget_twitter_widget filter
  2011. *
  2012. * @internal filter: drone_widget_twitter_widget
  2013. * @since 1.0
  2014. *
  2015. * @param object $html
  2016. * @param object $widget
  2017. */
  2018. public function filterWidgetTwitterWidget($html, $widget)
  2019. {
  2020. $html = \Drone\HTML::div()->class('twitter')->add($html);
  2021. if ($widget->wo('orientation') == 'horizontal') {
  2022. $ul = $html->child(0);
  2023. $class = 'col-1-'.$ul->count();
  2024. foreach ($ul->childs() as $li) {
  2025. $li->addClass($class);
  2026. }
  2027. $ul->wrap('div');
  2028. $html->child(0)->class = 'columns';
  2029. } else if ($widget->wo('orientation') == 'scrollable') {
  2030. $html->child(0)->addClass('scroller');
  2031. }
  2032. if ($widget->wo('follow_me_button')) {
  2033. $html->addNew('p')->addNew('a')
  2034. ->class('button small')
  2035. ->href('https://twitter.com/'.$widget->wo('username'))
  2036. ->add(__('follow me', 'everything').' &rsaquo;');
  2037. }
  2038. return $html;
  2039. }
  2040.  
  2041. // -------------------------------------------------------------------------
  2042.  
  2043. /**
  2044. * drone_widget_twitter_tweet filter
  2045. *
  2046. * @internal filter: drone_widget_twitter_tweet
  2047. * @since 1.0
  2048. *
  2049. * @param object $li
  2050. * @param object $widget
  2051. * @param object $tweet
  2052. */
  2053. public function filterWidgetTwitterTweet($li, $widget, $tweet)
  2054. {
  2055. $li->insert('<i class="icon-twitter"></i>')->child(3)->addClass('alt');
  2056. return $li;
  2057. }
  2058.  
  2059. // -------------------------------------------------------------------------
  2060.  
  2061. /**
  2062. * drone_widget_flickr_widget filter
  2063. *
  2064. * @internal filter: drone_widget_flickr_widget
  2065. * @since 1.0
  2066. *
  2067. * @param object $html
  2068. * @param object $widget
  2069. */
  2070. public function filterWidgetFlickrWidget($html, $widget)
  2071. {
  2072. return \Drone\HTML::div()->class('flickr')->add($html);
  2073. }
  2074.  
  2075. // -------------------------------------------------------------------------
  2076.  
  2077. /**
  2078. * drone_widget_flickr_photo filter
  2079. *
  2080. * @internal filter: drone_widget_flickr_photo
  2081. * @since 1.0
  2082. *
  2083. * @param object $li
  2084. * @param object $widget
  2085. * @param object $photo
  2086. */
  2087. public function filterWidgetFlickrPhoto($li, $widget, $photo)
  2088. {
  2089. $li->child(0)->attr(Everything::getImageAttrs('a', array('border' => false)))->title(null);
  2090. return $li;
  2091. }
  2092.  
  2093. // -------------------------------------------------------------------------
  2094.  
  2095. /**
  2096. * drone_widget_facebook_like_box_widget filter
  2097. *
  2098. * @internal filter: drone_widget_facebook_like_box_widget
  2099. * @since 1.0
  2100. *
  2101. * @param object $html
  2102. * @param object $widget
  2103. * @param array $args
  2104. */
  2105. public function filterWidgetFacebookLikeBoxWidget($html, $widget, $args)
  2106. {
  2107. $html->child(0)
  2108. ->data('width', strpos($args['id'], 'footer-') !== 0 ? $GLOBALS['content_width'] : 258)
  2109. ->data('colorscheme', Everything::to('general/scheme') == 'bright' ? 'light' : 'dark');
  2110. return $html;
  2111. }
  2112.  
  2113. // -------------------------------------------------------------------------
  2114.  
  2115. /**
  2116. * Begin content layer
  2117. *
  2118. * @since 1.0
  2119. *
  2120. * @param string $content
  2121. * @return string
  2122. */
  2123. public static function beginContent()
  2124. {
  2125.  
  2126. if (is_page_template('tpl-hidden-content.php')) {
  2127. return '';
  2128. }
  2129.  
  2130. // Content
  2131. $content = \Drone\HTML::make();
  2132. $main = $content->addNew('div')->class('main');
  2133.  
  2134. // Layout
  2135. $layout = Everything::io('layout/layout/layout', 'sidebar/layout', '__hidden_ns');
  2136. $layout = apply_filters('everything_layout', $layout);
  2137.  
  2138. // Sidebars
  2139. $pad = array('left' => 0, 'right' => 0);
  2140. $side = 'left';
  2141.  
  2142. foreach ($layout as $sidebar) {
  2143.  
  2144. if ($sidebar == '#') {
  2145.  
  2146. $side = 'right';
  2147.  
  2148. } else if ($sidebar) {
  2149.  
  2150. $sidebar = apply_filters('everything_sidebar', $sidebar, 'aside');
  2151.  
  2152. $width = Everything::to(array('sidebar/list/builtin/'.$sidebar), null, Everything::to_('sidebar/list/additional')->value($sidebar));
  2153. if (is_array($width)) {
  2154. $width = $width['width'];
  2155. }
  2156.  
  2157. $pad[$side] += $side == 'right' ? $width : Everything::DEFAULT_SIDEBAR_WIDTH;
  2158. $GLOBALS['content_width'] = $width - 50;
  2159.  
  2160. $aside = \Drone\HTML::aside()
  2161. ->addClass('aside', $side == 'left' ? 'alpha' : 'beta')
  2162. ->add(\Drone\Func::functionGetOutputBuffer('dynamic_sidebar', $sidebar));
  2163. if ($side == 'right') {
  2164. $aside->style = "width: {$width}px;";
  2165. }
  2166.  
  2167. if ($side == 'left' && $layout[0] && $layout[1] == '#' && $layout[2]) { // left-content-right
  2168. $content->insert($aside);
  2169. } else if ($side == 'right' && $layout[0] == '#') { // content-right-right
  2170. $content->insert($aside, 1);
  2171. } else {
  2172. $content->add($aside);
  2173. }
  2174.  
  2175. }
  2176.  
  2177. }
  2178.  
  2179. $main->addClass($pad['right'] ? 'alpha' : ($pad['left'] ? 'beta' : ''));
  2180. $main->style = sprintf('padding: 0 %2$dpx 0 %1$dpx; margin: 0 -%2$dpx 0 -%1$dpx;', $pad['left'], $pad['right']);
  2181.  
  2182. // Content width
  2183. $GLOBALS['content_width'] = apply_filters('everything_content_width', Everything::$max_width - array_sum($pad) - 50);
  2184. if (false) {
  2185. global $content_width; // Theme-Check
  2186. }
  2187.  
  2188. // Content
  2189. ob_start(function($buffer) use ($content, $main) {
  2190. $main->add($buffer);
  2191. return $content->html();
  2192. });
  2193.  
  2194. }
  2195.  
  2196. // -------------------------------------------------------------------------
  2197.  
  2198. /**
  2199. * End content layer
  2200. *
  2201. * @since 1.0
  2202. */
  2203. public static function endContent()
  2204. {
  2205. if (!is_page_template('tpl-hidden-content.php')) {
  2206. ob_end_flush();
  2207. }
  2208. }
  2209.  
  2210. // -------------------------------------------------------------------------
  2211.  
  2212. /**
  2213. * Columns from string definition
  2214. *
  2215. * @since 1.0
  2216. *
  2217. * @param string $s
  2218. * @return array
  2219. */
  2220. public static function stringToColumns($s)
  2221. {
  2222. $s = str_replace(' ', '', $s);
  2223. if (!$s) {
  2224. return array();
  2225. }
  2226. return array_map(function($s) {
  2227. list($span, $total) = strpos($s, '/') === false ? str_split($s) : explode('/', $s);
  2228. return array(
  2229. 'span' => $span,
  2230. 'total' => $total,
  2231. 'width' => $span/$total,
  2232. 'class' => sprintf('col-%d-%d', $span, $total)
  2233. );
  2234. }, preg_split('/[_\+]/', $s));
  2235. }
  2236.  
  2237. // -------------------------------------------------------------------------
  2238.  
  2239. /**
  2240. * Get attachment images
  2241. *
  2242. * @since 1.0
  2243. *
  2244. * @param int $id
  2245. * @param string $size
  2246. * @param string $format
  2247. * @return array
  2248. */
  2249. public static function getAttachmentImages($id, $size, $format = 'array')
  2250. {
  2251.  
  2252. // Meta data
  2253. if (($metadata = wp_get_attachment_metadata($id)) === false || !isset($metadata['sizes'][$size])) {
  2254. return $format == 'html' ? '' : array();
  2255. }
  2256.  
  2257. $file = explode('/', $metadata['file']);
  2258. $metadata['sizes']['full'] = array(
  2259. 'file' => array_pop($file),
  2260. 'width' => $metadata['width'],
  2261. 'height' => $metadata['height']
  2262. );
  2263.  
  2264. // Current
  2265. $current = $metadata['sizes'][$size];
  2266. $current['ratio'] = $current['width'] / $current['height'];
  2267. $current['crop'] = isset($GLOBALS['_wp_additional_image_sizes'][$size]) ? $GLOBALS['_wp_additional_image_sizes'][$size]['crop'] : null;
  2268.  
  2269. // Images
  2270. $images = array();
  2271. foreach ($metadata['sizes'] as $_size => $size) {
  2272. if (
  2273. $size['width'] > $current['width'] &&
  2274. (
  2275. ($current['crop'] === false && isset($GLOBALS['_wp_additional_image_sizes'][$_size]) && !$GLOBALS['_wp_additional_image_sizes'][$_size]['crop']) ||
  2276. abs(($size['width'] / $size['height']) - $current['ratio']) <= 0.015
  2277. )
  2278. ) {
  2279. $src = wp_get_attachment_image_src($id, $_size);
  2280. $images[$size['width']] = esc_url($src[0]);
  2281. }
  2282. }
  2283.  
  2284. // Sort
  2285. ksort($images);
  2286.  
  2287. // Keys prefix
  2288. $images = \Drone\Func::arrayKeysMap(function($s) { return 'data-image'.$s; }, $images);
  2289.  
  2290. // Output
  2291. switch ($format) {
  2292. case 'html': return \Drone\Func::arraySerialize($images, 'html');
  2293. default: return $images;
  2294. }
  2295.  
  2296. }
  2297.  
  2298. // -------------------------------------------------------------------------
  2299.  
  2300. /**
  2301. * Get image attributes
  2302. *
  2303. * @since 1.0
  2304. *
  2305. * @param string $tag
  2306. * @param array $atts
  2307. * @param string $format
  2308. * @return array
  2309. */
  2310. public static function getImageAttrs($tag, $atts = array(), $format = 'array')
  2311. {
  2312.  
  2313. // Image settings
  2314. $settings = Everything::to_('site/image/settings');
  2315.  
  2316. // Attributes
  2317. extract(array_merge($defaults = array(
  2318. 'border' => $settings->value('border'),
  2319. 'hover' => $settings->value('hover') ? 'zoom' : '',
  2320. 'fancybox' => $settings->value('fancybox')
  2321. ), $atts));
  2322.  
  2323. // Border
  2324. $border = $border === 'inherit' ? $defaults['border'] : \Drone\Func::stringToBool($border);
  2325.  
  2326. // Hover
  2327. if ($hover === 'inherit' || !in_array($hover, array('', 'zoom', 'image', 'grayscale'), true)) {
  2328. $hover = $defaults['hover'];
  2329. }
  2330.  
  2331. // Fancybox
  2332. $fancybox = $fancybox === 'inherit' ? $defaults['fancybox'] : \Drone\Func::stringToBool($fancybox);
  2333.  
  2334. // Properties
  2335. $attrs = array('class' => array());
  2336.  
  2337. if ($border) {
  2338. $attrs['class'][] = 'inset-border';
  2339. }
  2340. if ($tag == 'a') {
  2341. if ($hover) {
  2342. $attrs['class'][] = $hover.'-hover';
  2343. }
  2344. if ($fancybox) {
  2345. $attrs['class'][] = 'fb';
  2346. }
  2347. }
  2348.  
  2349. $attrs['class'] = implode(' ', $attrs['class']);
  2350.  
  2351. // Output
  2352. switch ($format) {
  2353. case 'html': return \Drone\Func::arraySerialize($attrs, 'html');
  2354. default: return $attrs;
  2355. }
  2356.  
  2357. }
  2358.  
  2359. // -------------------------------------------------------------------------
  2360.  
  2361. /**
  2362. * Image attributes
  2363. *
  2364. * @since 1.0
  2365. *
  2366. * @param string $tag
  2367. * @param array $atts
  2368. */
  2369. public static function imageAttrs($tag, $atts = array())
  2370. {
  2371. echo Everything::getImageAttrs($tag, $atts, 'html');
  2372. }
  2373.  
  2374. // -------------------------------------------------------------------------
  2375.  
  2376. /**
  2377. * Current blog style
  2378. *
  2379. * @since 1.0
  2380. *
  2381. * @return string
  2382. */
  2383. public static function getBlogStyle()
  2384. {
  2385. return \Drone\Shortcodes\Shortcode::inShortcode('blog') ? \Drone\Shortcodes\Shortcode::getInstance('blog')->so('style') : Everything::to('site/blog/style');
  2386. }
  2387.  
  2388. // -------------------------------------------------------------------------
  2389.  
  2390. /**
  2391. * Post format icon
  2392. *
  2393. * @since 1.0
  2394. *
  2395. * @return string
  2396. */
  2397. public static function getPostIcon()
  2398. {
  2399. if (Everything::to('post/hide_icons')) {
  2400. return;
  2401. }
  2402. if (($post_format = get_post_format()) === false) {
  2403. return;
  2404. }
  2405. $icons = apply_filters('everything_post_formats_icons', array(
  2406. 'aside' => 'doc-text',
  2407. 'audio' => 'mic',
  2408. 'chat' => 'chat',
  2409. 'gallery' => 'picture',
  2410. 'image' => 'camera',
  2411. 'link' => 'link',
  2412. 'quote' => 'quote',
  2413. 'status' => 'comment',
  2414. 'video' => 'youtube-alt'
  2415. ));
  2416. if (!isset($icons[$post_format])) {
  2417. return;
  2418. }
  2419. return \Drone\HTML::i()->class('icon-'.$icons[$post_format])->html();
  2420. }
  2421.  
  2422. // -------------------------------------------------------------------------
  2423.  
  2424. /**
  2425. * Read more phrase and icon
  2426. *
  2427. * @since 1.0
  2428. *
  2429. * @return string
  2430. */
  2431. public static function getReadMore()
  2432. {
  2433. $readmore = Everything::to_(array(get_post_type().'/readmore', 'post/readmore'));
  2434. $html = \Drone\HTML::make()->add($readmore->value('phrase'));
  2435. if ($readmore->value('icon')) {
  2436. $html->addNew('i')->class('icon-'.$readmore->value('icon'));
  2437. }
  2438. return $html->html();
  2439. }
  2440.  
  2441. // -------------------------------------------------------------------------
  2442.  
  2443. /**
  2444. * Paginate links
  2445. *
  2446. * @since 1.0
  2447. *
  2448. * @param string $name
  2449. * @param WP_Query $query
  2450. * @return string
  2451. */
  2452. public static function getPaginateLinks($name, $query = null)
  2453. {
  2454.  
  2455. if (!apply_filters('everything_pagination_display', true, $name)) {
  2456. return '';
  2457. }
  2458.  
  2459. // Paginate links
  2460. switch ($name) {
  2461.  
  2462. // Page
  2463. case 'page':
  2464. if (!is_singular()) {
  2465. return '';
  2466. }
  2467. $pagination = wp_link_pages(array(
  2468. 'before' => ' ',
  2469. 'after' => ' ',
  2470. 'next_or_number' => rtrim(Everything::to('site/page_pagination'), 's'),
  2471. 'previouspagelink' => '<i class="icon-left-open"></i><span>'.__('Previous page', 'everything').'</span>',
  2472. 'nextpagelink' => '<span>'.__('Next page', 'everything').'</span><i class="icon-right-open"></i>',
  2473. 'echo' => false
  2474. ));
  2475. $pagination = str_replace('<a ', '<a class="button small" ', $pagination);
  2476. $pagination = preg_replace('/ ([0-9]+) /',' <span class="button small active">\1</span> ', $pagination);
  2477. break;
  2478.  
  2479. // Comment
  2480. case 'comments':
  2481. if (!is_singular()) {
  2482. return '';
  2483. }
  2484. $pagination = paginate_comments_links(array(
  2485. 'prev_next' => Everything::to('site/comments/pagination') == 'numbers_navigation',
  2486. 'prev_text' => '<i class="icon-left-open"></i>',
  2487. 'next_text' => '<i class="icon-right-open"></i>',
  2488. 'echo' => false
  2489. ));
  2490. $pagination = str_replace(array('page-numbers', 'current'), array('button small', 'active'), $pagination);
  2491. break;
  2492.  
  2493. // Default
  2494. default:
  2495. $args = array(
  2496. 'prev_next' => Everything::to('site/pagination') == 'numbers_navigation',
  2497. 'prev_text' => '<i class="icon-left-open"></i>',
  2498. 'next_text' => '<i class="icon-right-open"></i>',
  2499. 'end_size' => 1,
  2500. 'mid_size' => 2
  2501. );
  2502. if ($name == 'woocommerce') {
  2503. $args['base'] = esc_url_raw(str_replace('99999999', '%#%', remove_query_arg('add-to-cart', htmlspecialchars_decode(get_pagenum_link(99999999)))));
  2504. }
  2505. $pagination = \Drone\Func::wpPaginateLinks($args, $query);
  2506. $pagination = preg_replace_callback(
  2507. '/class=[\'"](?P<dir>prev |next )?page-numbers(?P<current> current)?[\'"]()/i',
  2508. function($m) { return "class=\"{$m['dir']}button small".str_replace('current', 'active', $m['current']).'"'; },
  2509. $pagination
  2510. );
  2511.  
  2512. }
  2513.  
  2514. if (!$pagination) {
  2515. return '';
  2516. }
  2517.  
  2518. return \Drone\HTML::div()->class('pagination')->add($pagination)->html();
  2519.  
  2520. }
  2521.  
  2522. // -------------------------------------------------------------------------
  2523.  
  2524. /**
  2525. * Navigation menu
  2526. *
  2527. * @since 1.0
  2528. *
  2529. * @param string $theme_location
  2530. * @param int $menu
  2531. * @param int $depth
  2532. */
  2533. public static function navMenu($theme_location, $menu = null, $depth = 0)
  2534. {
  2535. echo wp_nav_menu(array(
  2536. 'theme_location' => $theme_location,
  2537. 'menu' => apply_filters('everything_menu', $menu, $theme_location),
  2538. 'depth' => $depth,
  2539. 'container' => '',
  2540. 'menu_id' => '',
  2541. 'menu_class' => '',
  2542. 'echo' => false,
  2543. 'fallback_cb' => function() use ($theme_location, $depth) {
  2544. return '<ul>'.wp_list_pages(array(
  2545. 'theme_location' => $theme_location,
  2546. 'title_li' => '',
  2547. 'depth' => $depth,
  2548. 'echo' => false
  2549. )).'</ul>';
  2550. }
  2551. ));
  2552. }
  2553.  
  2554.  
  2555. // -------------------------------------------------------------------------
  2556.  
  2557. /**
  2558. * Languages menus
  2559. *
  2560. * @since 1.0
  2561. */
  2562. public static function langMenu()
  2563. {
  2564.  
  2565. if (count($langs = icl_get_languages('skip_missing=0&orderby=code')) == 0) {
  2566. return;
  2567. }
  2568.  
  2569. $html = \Drone\HTML::ul();
  2570. $main = $html->addNew('li');
  2571. $sub = $main->addNew('ul');
  2572.  
  2573. foreach ($langs as $lang) {
  2574.  
  2575. $li = $sub->addNew('li');
  2576.  
  2577. $a = $li->addNew('a')
  2578. ->href($lang['url'])
  2579. ->title($lang['native_name'])
  2580. ->add(
  2581. $lang['native_name'],
  2582. \Drone\HTML::span()->class('flag-'.$lang['language_code'])
  2583. );
  2584.  
  2585. if ($lang['active']) {
  2586. $li->class = 'current';
  2587. $main->insertNew('a')
  2588. ->href('#')
  2589. ->title($lang['native_name'])
  2590. ->add(
  2591. \Drone\HTML::span()->class('flag-'.$lang['language_code']),
  2592. \Drone\HTML::i()->class('icon-down-open')
  2593. );
  2594. }
  2595.  
  2596. }
  2597.  
  2598. echo $html->html();
  2599.  
  2600. }
  2601.  
  2602. // -------------------------------------------------------------------------
  2603.  
  2604. /**
  2605. * Title
  2606. *
  2607. * @since 1.6
  2608. */
  2609. public static function title()
  2610. {
  2611.  
  2612. if (Everything::isPluginActive('bbpress') && is_bbpress()) {
  2613. if (!Everything::$headline_used) {
  2614. echo '<h1 class="title">'.get_the_title().'</h1>';
  2615. }
  2616. }
  2617.  
  2618. else if (!is_singular()) {
  2619. echo '<h1 class="title"><a href="'.esc_url(apply_filters('the_permalink', get_permalink())).'" rel="bookmark">'.Everything::getPostIcon().get_the_title().'</a></h1>';
  2620. }
  2621.  
  2622. else if (!Everything::$headline_used && !Everything::io('layout/page/hide_title/hide_title', array(get_post_type().'/hide_title', 'page/hide_title'), '__hidden')) {
  2623. echo '<h1 class="title">'.Everything::getPostIcon().get_the_title().'</h1>';
  2624. }
  2625.  
  2626. }
  2627.  
  2628. // -------------------------------------------------------------------------
  2629.  
  2630. /**
  2631. * Social buttons
  2632. *
  2633. * @since 1.6
  2634. */
  2635. public static function socialButtons()
  2636. {
  2637.  
  2638. if (is_search()) {
  2639. return;
  2640. }
  2641.  
  2642. $items = Everything::to_(array(
  2643. sprintf('%s/social_buttons/%s/items', get_post_type(), is_singular() ? 'single' : 'list'),
  2644. sprintf('%s/social_buttons/items', get_post_type()),
  2645. 'page/social_buttons/items'
  2646. ));
  2647.  
  2648. if (!$items->value || !apply_filters('everything_social_buttons_display', (bool)Everything::po('layout/page/social_buttons/social_buttons', '__hidden', $items->isVisible()))) {
  2649. return;
  2650. }
  2651.  
  2652. $html = is_singular() ? \Drone\HTML::section()->class('section') : \Drone\HTML::make();
  2653.  
  2654. foreach (array_keys($items->options) as $item) {
  2655. $media['media_'.$item] = in_array($item, $items->value);
  2656. }
  2657. $html->add(Everything::getShortcodeOutput('social_buttons', array('size' => 'small')+$media));
  2658.  
  2659. echo $html->html();
  2660.  
  2661. }
  2662.  
  2663. // -------------------------------------------------------------------------
  2664.  
  2665. /**
  2666. * Meta
  2667. *
  2668. * @since 1.6
  2669. *
  2670. * @param string $position
  2671. */
  2672. public static function meta($position = 'after')
  2673. {
  2674.  
  2675. if (is_search()) {
  2676. return;
  2677. }
  2678. if ($position == 'before' && (is_single() || get_post_type() != 'post')) {
  2679. return;
  2680. }
  2681.  
  2682. if ($position == 'before') {
  2683. $items = Everything::to_('post/meta/before/items');
  2684. } else {
  2685. $items = Everything::to_(array(
  2686. sprintf('%s/meta/%s/items', get_post_type(), is_singular() ? 'single' : 'list'),
  2687. sprintf('%s/meta/items', get_post_type()),
  2688. 'page/meta/items'
  2689. ));
  2690. }
  2691.  
  2692. if (!$items->value || !apply_filters('everything_meta_display', (bool)Everything::po('layout/page/meta/meta', '__hidden', $items->isVisible()), $position)) {
  2693. return;
  2694. }
  2695.  
  2696. $html = is_singular() ? \Drone\HTML::section()->class('section') : \Drone\HTML::make();
  2697.  
  2698. $ul = $html->addNew('ul')->class('meta alt');
  2699. foreach ((array)$items->value as $item) {
  2700. switch ($item) {
  2701. case 'date_time':
  2702. $ul->add(Everything::getPostMetaFormat(
  2703. '<li><a href="%date_month_link%" title="%s"><i class="icon-clock"></i>%s</a></li>',
  2704. sprintf(__('View all posts from %s', 'everything'), get_the_date('F')),
  2705. sprintf(__('%1$s at %2$s', 'everything'), Everything::getPostMeta('date'), Everything::getPostMeta('time'))
  2706. ));
  2707. break;
  2708. case 'date':
  2709. $ul->add(Everything::getPostMetaFormat('<li><a href="%date_month_link%" title="%s"><i class="icon-clock"></i>%date%</a></li>', sprintf(__('View all posts from %s', 'everything'), get_the_date('F'))));
  2710. break;
  2711. case 'mod_date':
  2712. $ul->add(Everything::getPostMetaFormat('<li><a href="%link%" title="%title_esc%"><i class="icon-clock"></i>%date_modified%</a></li>'));
  2713. break;
  2714. case 'time_diff':
  2715. $ul->add(Everything::getPostMetaFormat('<li><a href="%link%" title="%title_esc%"><i class="icon-clock"></i>%time_diff%</a></li>'));
  2716. break;
  2717. case 'comments':
  2718. if (Everything::isPluginActive('disqus')) {
  2719. $ul->add(Everything::getPostMetaFormat('<li><i class="icon-comment"></i><a href="%comments_link%">%comments_number%</a></li>'));
  2720. } else {
  2721. $ul->add(Everything::getPostMetaFormat('<li><a href="%comments_link%" title="%comments_number_esc%"><i class="icon-comment"></i>%comments_number%</a></li>'));
  2722. }
  2723. break;
  2724. case 'author':
  2725. $ul->add(Everything::getPostMetaFormat('<li><a href="%author_link%" title="%author_name_esc%"><i class="icon-user"></i>%author_name%</a></li>'));
  2726. break;
  2727. case 'categories':
  2728. if (get_post_type() == 'portfolio') {
  2729. $ul->add(get_the_term_list(get_the_ID(), 'portfolio-category', '<li><i class="icon-list"></i>', ', ', '</li>'));
  2730. } else {
  2731. $ul->add(Everything::getPostMetaFormat('[%category_list%]<li><i class="icon-list"></i>%category_list%</li>[/%category_list%]'));
  2732. }
  2733. break;
  2734. case 'tags':
  2735. if (get_post_type() == 'portfolio') {
  2736. $ul->add(get_the_term_list(get_the_ID(), 'portfolio-tag', '<li><i class="icon-tag"></i>', ', ', '</li>'));
  2737. } else {
  2738. $ul->add(Everything::getPostMetaFormat('[%tags_list%]<li><i class="icon-tag"></i>%tags_list%</li>[/%tags_list%]'));
  2739. }
  2740. break;
  2741. case 'permalink':
  2742. $ul->add(Everything::getPostMetaFormat('<li><a href="%link%" title="%title_esc%"><i class="icon-link"></i>%s</a></li>', __('Permalink', 'everything')));
  2743. break;
  2744. }
  2745. }
  2746.  
  2747. if ($position == 'after' || $ul->count() > 0) {
  2748. echo $html->html();
  2749. }
  2750.  
  2751. }
  2752.  
  2753. // -------------------------------------------------------------------------
  2754.  
  2755. /**
  2756. * Cart info
  2757. *
  2758. * @since 1.0
  2759. *
  2760. * @param string $type
  2761. * @param array $visible
  2762. * @return string
  2763. */
  2764. public static function woocommerceGetCartInfo($type, $visible = array('desktop', 'mobile'))
  2765. {
  2766.  
  2767. if (count($visible) == 0) {
  2768. return '';
  2769. }
  2770.  
  2771. // HTML
  2772. $a = \Drone\HTML::a()
  2773. ->href($GLOBALS['woocommerce']->cart->get_cart_url())
  2774. ->title(__('Cart', 'everything'))
  2775. ->addClass('cart-info', $type);
  2776.  
  2777. // Visibility
  2778. if (count($visible) == 1) {
  2779. $a->addClass($visible[0].'-only');
  2780. }
  2781.  
  2782. // Icon
  2783. $a->addNew('i')
  2784. ->addClass('icon-woocommerce-cart', 'icon-'.Everything::to('woocommerce/cart/icon'));
  2785.  
  2786. // Content
  2787. if (Everything::to_('header/cart/content')->value('count')) {
  2788. $a->addNew('span')
  2789. ->class('count')
  2790. ->add($GLOBALS['woocommerce']->cart->get_cart_contents_count());
  2791. }
  2792. if (Everything::to_('header/cart/content')->value('total') && $GLOBALS['woocommerce']->cart->get_cart_contents_count()) {
  2793. $cart_total = strip_tags($GLOBALS['woocommerce']->cart->get_cart_total());
  2794. $cart_total = preg_replace('/('.preg_quote(get_option('woocommerce_price_decimal_sep'), '/').')([0-9]+)/', '\1<small>\2</small>', $cart_total);
  2795. $a->addNew('span')
  2796. ->class('total')
  2797. ->add($cart_total);
  2798. }
  2799.  
  2800. return $a->html();
  2801.  
  2802. }
  2803.  
  2804. // -------------------------------------------------------------------------
  2805.  
  2806. /**
  2807. * Get thumbnail caption for WooCommerce product image
  2808. *
  2809. * @since 1.0
  2810. *
  2811. * @param int|object $thumbnail
  2812. * @return string
  2813. */
  2814. public static function woocommerceGetThumbnailCaption($thumbnail)
  2815. {
  2816. if (!Everything::to('woocommerce/product/captions')) {
  2817. return '';
  2818. }
  2819. if (!is_object($thumbnail)) {
  2820. $thumbnail = get_post($thumbnail);
  2821. }
  2822. switch (Everything::to('woocommerce/product/captions')) {
  2823. case 'title':
  2824. return trim($thumbnail->post_title);
  2825. case 'caption':
  2826. return trim($thumbnail->post_excerpt);
  2827. case 'caption_title':
  2828. $caption = trim($thumbnail->post_excerpt) or $caption = trim($thumbnail->post_title);
  2829. return $caption;
  2830. }
  2831. }
  2832.  
  2833. // -------------------------------------------------------------------------
  2834.  
  2835. /**
  2836. * Parse/fix WooCommerce widget list
  2837. *
  2838. * @since 1.0
  2839. *
  2840. * @param string $s
  2841. * @return string
  2842. */
  2843. public static function woocommerceWidgetParseList($s)
  2844. {
  2845. return preg_replace('#<ul class="([^"]*product_list_widget[^"]*)">#i', '<ul class="\1 posts-list">', $s);
  2846. }
  2847.  
  2848. // -------------------------------------------------------------------------
  2849.  
  2850. /**
  2851. * Parse/fix WooCommerce widget navigation
  2852. *
  2853. * @since 1.0
  2854. *
  2855. * @param string $s
  2856. * @return string
  2857. */
  2858. public static function woocommerceWidgetparseNav($s)
  2859. {
  2860. $s = preg_replace('#<ul[^<>]*>.*</ul>#is', '<nav class="aside-nav-menu">\0</nav>', $s);
  2861. $s = preg_replace('#(<a href="[^"]*">)([^<>]*)(</a>)\s*<(span|small) class="count">\(?([0-9]+)\)?</\4>#i', '\1\2 <small>(\5)</small>\3', $s);
  2862. return $s;
  2863. }
  2864.  
  2865. }
  2866.  
  2867. // -----------------------------------------------------------------------------
  2868.  
  2869. Everything::getInstance();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement