dariotoby

functions.php

Aug 20th, 2022
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 101.43 KB | None | 0 0
  1. <?php
  2. /**
  3. * Zerif Lite functions and definitions
  4. *
  5. * @package zerif-lite
  6. */
  7.  
  8.  
  9.  
  10. $vendor_file = trailingslashit( get_template_directory() ) . 'vendor/autoload.php';
  11. if ( is_readable( $vendor_file ) ) {
  12. require_once $vendor_file;
  13. }
  14.  
  15. if ( ! defined( 'WPFORMS_SHAREASALE_ID' ) ) {
  16. define( 'WPFORMS_SHAREASALE_ID', '848264' );
  17. }
  18.  
  19. add_filter( 'themeisle_sdk_products', 'zerif_load_sdk' );
  20. /**
  21. * Loads products array.
  22. *
  23. * @param array $products All products.
  24. *
  25. * @return array Products array.
  26. */
  27. function zerif_load_sdk( $products ) {
  28. $products[] = get_template_directory() . '/style.css';
  29.  
  30. return $products;
  31. }
  32.  
  33. if ( ! defined( 'ELEMENTOR_PARTNER_ID' ) ) {
  34. define( 'ELEMENTOR_PARTNER_ID', 2112 );
  35. }
  36.  
  37.  
  38. define( 'ZERIF_LITE_VERSION', '1.8.5.47' );
  39.  
  40.  
  41.  
  42. /**
  43. * Main setup function
  44. */
  45. function zerif_setup() {
  46.  
  47. global $content_width;
  48.  
  49. if ( ! isset( $content_width ) ) {
  50. $content_width = 640;
  51. }
  52.  
  53. /*
  54. * Make theme available for translation.
  55. * Translations can be filed in the /languages/ directory.
  56. * If you're building a theme based on zerif, use a find and replace
  57. * to change 'zerif-lite' to the name of your theme in all the template files
  58. */
  59. load_theme_textdomain( 'zerif-lite', get_template_directory() . '/languages' );
  60.  
  61. add_theme_support( 'automatic-feed-links' );
  62.  
  63. /*
  64. * Enable support for Post Thumbnails on posts and pages.
  65. */
  66. add_theme_support( 'post-thumbnails' );
  67.  
  68. /* Set the image size by cropping the image */
  69. add_image_size( 'zerif-post-thumbnail', 250, 250, true );
  70. add_image_size( 'zerif-post-thumbnail-large', 750, 500, true ); /* blog thumbnail */
  71. add_image_size( 'zerif-post-thumbnail-large-table', 600, 300, true ); /* blog thumbnail for table */
  72. add_image_size( 'zerif-post-thumbnail-large-mobile', 400, 200, true ); /* blog thumbnail for mobile */
  73. add_image_size( 'zerif_project_photo', 285, 214, true );
  74. add_image_size( 'zerif_our_team_photo', 174, 174, true );
  75.  
  76. /* Register primary menu */
  77. register_nav_menus(
  78. array(
  79. 'primary' => __( 'Primary Menu', 'zerif-lite' ),
  80. )
  81. );
  82.  
  83. /* Enable support for Post Formats. */
  84. add_theme_support( 'post-formats', array( 'aside', 'image', 'video', 'quote', 'link' ) );
  85.  
  86. /* Setup the WordPress core custom background feature. */
  87.  
  88. if ( file_exists( get_stylesheet_directory() . '/images/bg.jpg' ) ) {
  89. $zerif_default_image = get_stylesheet_directory_uri() . '/images/bg.jpg';
  90. } else {
  91. $zerif_default_image = get_template_directory_uri() . '/images/bg.jpg';
  92. }
  93. add_theme_support(
  94. 'custom-background',
  95. apply_filters(
  96. 'zerif_custom_background_args',
  97. array(
  98. 'default-color' => 'ffffff',
  99. 'default-image' => $zerif_default_image,
  100. )
  101. )
  102. );
  103.  
  104. /* Enable support for HTML5 markup. */
  105. add_theme_support(
  106. 'html5',
  107. array(
  108. 'comment-list',
  109. 'search-form',
  110. 'comment-form',
  111. 'gallery',
  112. )
  113. );
  114.  
  115. /* Enable support for title-tag */
  116. add_theme_support( 'title-tag' );
  117.  
  118. /* Enable support for custom logo */
  119. add_theme_support(
  120. 'custom-logo',
  121. array(
  122. 'flex-width' => true,
  123. )
  124. );
  125.  
  126. /* Custom template tags for this theme. */
  127. require get_template_directory() . '/inc/template-tags.php';
  128.  
  129. /* Custom functions that act independently of the theme templates. */
  130. require get_template_directory() . '/inc/extras.php';
  131.  
  132. /* Customizer additions. */
  133. require get_template_directory() . '/inc/customizer.php';
  134.  
  135. /* tgm-plugin-activation */
  136. require_once get_template_directory() . '/class-tgm-plugin-activation.php';
  137.  
  138. /* preview demo */
  139. require_once get_template_directory() . '/ti-prevdem/init-prevdem.php';
  140.  
  141.  
  142.  
  143.  
  144. /* woocommerce support */
  145. add_theme_support( 'woocommerce' );
  146. add_theme_support( 'wc-product-gallery-zoom' );
  147. add_theme_support( 'wc-product-gallery-lightbox' );
  148. add_theme_support( 'wc-product-gallery-slider' );
  149.  
  150. /* selective widget refresh */
  151. add_theme_support( 'customize-selective-refresh-widgets' );
  152.  
  153.  
  154.  
  155. function mytheme_add_woocommerce_support() {
  156. add_theme_support( 'woocommerce' );
  157. }
  158. add_action( 'after_setup_theme', 'mytheme_add_woocommerce_support' );
  159.  
  160.  
  161.  
  162. /**
  163. * HOOKS
  164. */
  165.  
  166. /* Enables user customization via WordPress plugin API. */
  167. require get_template_directory() . '/inc/hooks.php';
  168.  
  169. add_action( 'zerif_404_title', 'zerif_404_title_function' ); // Outputs the title on 404 pages
  170. add_action( 'zerif_404_content', 'zerif_404_content_function' ); // Outputs a helpful message on 404 pages
  171.  
  172. add_action( 'zerif_page_header', 'zerif_page_header_function' ); // Outputs the title on pages
  173.  
  174. add_action( 'zerif_page_header_title_archive', 'zerif_page_header_title_archive_function' ); // Outputs the title on archive pages
  175. add_action( 'zerif_page_term_description_archive', 'zerif_page_term_description_archive_function' ); // Outputs the term description
  176.  
  177. add_action( 'zerif_footer_widgets', 'zerif_footer_widgets_function' ); // Outputs the 3 sidebars in footer
  178.  
  179. add_action( 'zerif_our_focus_header_title', 'zerif_our_focus_header_title_function' ); // Outputs the title in Our focus section
  180. add_action( 'zerif_our_focus_header_subtitle', 'zerif_our_focus_header_subtitle_function' ); // Outputs the subtitle in Our focus section
  181.  
  182. add_action( 'zerif_our_team_header_title', 'zerif_our_team_header_title_function' ); // Outputs the title in Our team section
  183. add_action( 'zerif_our_team_header_subtitle', 'zerif_our_team_header_subtitle_function' ); // Outputs the subtitle in Our team section
  184.  
  185. add_action( 'zerif_testimonials_header_title', 'zerif_testimonials_header_title_function' ); // Outputs the title in Testimonials section
  186. add_action( 'zerif_testimonials_header_subtitle', 'zerif_testimonials_header_subtitle_function' ); // Outputs the subtitle in Testimonials section
  187.  
  188. add_action( 'zerif_latest_news_header_title', 'zerif_latest_news_header_title_function' ); // Outputs the title in Latest news section
  189. add_action( 'zerif_latest_news_header_subtitle', 'zerif_latest_news_header_subtitle_function' ); // Outputs the subtitle in Latest news section
  190.  
  191. add_action( 'zerif_big_title_text', 'zerif_big_title_text_function' ); // Outputs the text in Big title section
  192.  
  193. add_action( 'zerif_about_us_header_title', 'zerif_about_us_header_title_function' ); // Outputs the title in About us section
  194. add_action( 'zerif_about_us_header_subtitle', 'zerif_about_us_header_subtitle_function' ); // Outputs the subtitle in About us section
  195.  
  196. add_action( 'zerif_sidebar', 'zerif_sidebar_function' ); // Outputs the sidebar
  197.  
  198. add_action( 'zerif_primary_navigation', 'zerif_primary_navigation_function' ); // Outputs the navigation menu
  199.  
  200. add_filter( 'excerpt_more', 'zerif_excerpt_more' );
  201.  
  202. require_once( trailingslashit( get_template_directory() ) . 'inc/class/class-customizer-theme-info-control/class-customizer-theme-info-root.php' );
  203.  
  204. /**
  205. * About page class
  206. */
  207. require_once get_template_directory() . '/ti-about-page/class-ti-about-page.php';
  208.  
  209. /*
  210. * About page instance
  211. */
  212. $config = array(
  213. // Menu name under Appearance.
  214. 'menu_name' => __( 'About Zerif Lite', 'zerif-lite' ),
  215. // Page title.
  216. 'page_name' => __( 'About Zerif Lite', 'zerif-lite' ),
  217. // Main welcome title
  218. /* translators: Theme Name */
  219. 'welcome_title' => sprintf( __( 'Welcome to %s! - Version ', 'zerif-lite' ), 'Zerif Lite' ),
  220. // Main welcome content
  221. 'welcome_content' => esc_html__( 'Zerif LITE is a free one page WordPress theme. It\'s perfect for web agency business,corporate business,personal and parallax business portfolio, photography sites and freelancer.Is built on BootStrap with parallax support, is responsive, clean, modern, flat and minimal. Zerif Lite is ecommerce (WooCommerce) Compatible, WPML, RTL, Retina-Ready, SEO Friendly and with parallax, full screen image is one of the best business themes.', 'zerif-lite' ),
  222. /**
  223. * Tabs array.
  224. *
  225. * The key needs to be ONLY consisted from letters and underscores. If we want to define outside the class a function to render the tab,
  226. * the will be the name of the function which will be used to render the tab content.
  227. */
  228. 'tabs' => array(
  229. 'getting_started' => __( 'Getting Started', 'zerif-lite' ),
  230. 'recommended_actions' => __( 'Recommended Actions', 'zerif-lite' ),
  231. 'recommended_plugins' => __( 'Useful Plugins', 'zerif-lite' ),
  232. 'support' => __( 'Support', 'zerif-lite' ),
  233. 'changelog' => __( 'Changelog', 'zerif-lite' ),
  234. 'free_pro' => __( 'Free VS PRO', 'zerif-lite' ),
  235. ),
  236. // Support content tab.
  237. 'support_content' => array(
  238. 'first' => array(
  239. 'title' => esc_html__( 'Contact Support', 'zerif-lite' ),
  240. 'icon' => 'dashicons dashicons-sos',
  241. 'text' => esc_html__( 'We want to make sure you have the best experience using Zerif Lite and that is why we gathered here all the necessary informations for you. We hope you will enjoy using Zerif Lite, as much as we enjoy creating great products.', 'zerif-lite' ),
  242. 'button_label' => esc_html__( 'Contact Support', 'zerif-lite' ),
  243. 'button_link' => esc_url( 'https://themeisle.com/contact/' ),
  244. 'is_button' => true,
  245. 'is_new_tab' => true,
  246. ),
  247. 'second' => array(
  248. 'title' => esc_html__( 'Documentation', 'zerif-lite' ),
  249. 'icon' => 'dashicons dashicons-book-alt',
  250. 'text' => esc_html__( 'Need more details? Please check our full documentation for detailed information on how to use Zerif Lite.', 'zerif-lite' ),
  251. 'button_label' => esc_html__( 'Read full documentation', 'zerif-lite' ),
  252. 'button_link' => 'https://docs.themeisle.com/article/5-zerif-lite-documentation',
  253. 'is_button' => false,
  254. 'is_new_tab' => true,
  255. ),
  256. 'third' => array(
  257. 'title' => esc_html__( 'Changelog', 'zerif-lite' ),
  258. 'icon' => 'dashicons dashicons-portfolio',
  259. 'text' => esc_html__( 'Want to get the gist on the latest theme changes? Just consult our changelog below to get a taste of the recent fixes and features implemented.', 'zerif-lite' ),
  260. 'button_label' => esc_html__( 'Changelog', 'zerif-lite' ),
  261. 'button_link' => esc_url( admin_url( 'themes.php?page=zerif-lite-welcome&tab=changelog&show=yes' ) ),
  262. 'is_button' => false,
  263. 'is_new_tab' => false,
  264. ),
  265. 'fourth' => array(
  266. 'title' => esc_html__( 'Create a child theme', 'zerif-lite' ),
  267. 'icon' => 'dashicons dashicons-admin-customizer',
  268. 'text' => esc_html__( "If you want to make changes to the theme's files, those changes are likely to be overwritten when you next update the theme. In order to prevent that from happening, you need to create a child theme. For this, please follow the documentation below.", 'zerif-lite' ),
  269. 'button_label' => esc_html__( 'View how to do this', 'zerif-lite' ),
  270. 'button_link' => 'https://docs.themeisle.com/article/14-how-to-create-a-child-theme',
  271. 'is_button' => false,
  272. 'is_new_tab' => true,
  273. ),
  274. 'fifth' => array(
  275. 'title' => esc_html__( 'Speed up your site', 'zerif-lite' ),
  276. 'icon' => 'dashicons dashicons-controls-skipforward',
  277. 'text' => esc_html__( 'If you find yourself in the situation where everything on your site is running very slow, you might consider having a look at the below documentation where you will find the most common issues causing this and possible solutions for each of the issues.', 'zerif-lite' ),
  278. 'button_label' => esc_html__( 'View how to do this', 'zerif-lite' ),
  279. 'button_link' => 'https://docs.themeisle.com/article/63-speed-up-your-wordpress-site',
  280. 'is_button' => false,
  281. 'is_new_tab' => true,
  282. ),
  283. 'sixth' => array(
  284. 'title' => esc_html__( 'Build a landing page with a drag-and-drop content builder', 'zerif-lite' ),
  285. 'icon' => 'dashicons dashicons-images-alt2',
  286. 'text' => esc_html__( 'In the below documentation you will find an easy way to build a great looking landing page using a drag-and-drop content builder plugin.', 'zerif-lite' ),
  287. 'button_label' => esc_html__( 'View how to do this', 'zerif-lite' ),
  288. 'button_link' => 'https://docs.themeisle.com/article/219-how-to-build-a-landing-page-with-a-drag-and-drop-content-builder',
  289. 'is_button' => false,
  290. 'is_new_tab' => true,
  291. ),
  292. ),
  293. // Getting started tab
  294. 'getting_started' => array(
  295. 'first' => array(
  296. 'title' => esc_html__( 'Recommended actions', 'zerif-lite' ),
  297. 'text' => esc_html__( 'We have compiled a list of steps for you, to take make sure the experience you will have using one of our products is very easy to follow.', 'zerif-lite' ),
  298. 'button_label' => esc_html__( 'Recommended actions', 'zerif-lite' ),
  299. 'button_link' => esc_url( admin_url( 'themes.php?page=zerif-lite-welcome&tab=recommended_actions' ) ),
  300. 'is_button' => false,
  301. 'recommended_actions' => true,
  302. 'is_new_tab' => false,
  303. ),
  304. 'second' => array(
  305. 'title' => esc_html__( 'Read full documentation', 'zerif-lite' ),
  306. 'text' => esc_html__( 'Need more details? Please check our full documentation for detailed information on how to use Zerif Lite.', 'zerif-lite' ),
  307. 'button_label' => esc_html__( 'Documentation', 'zerif-lite' ),
  308. 'button_link' => 'https://docs.themeisle.com/article/5-zerif-lite-documentation',
  309. 'is_button' => false,
  310. 'recommended_actions' => false,
  311. 'is_new_tab' => true,
  312. ),
  313. 'third' => array(
  314. 'title' => esc_html__( 'Go to Customizer', 'zerif-lite' ),
  315. 'text' => esc_html__( 'Using the WordPress Customizer you can easily customize every aspect of the theme.', 'zerif-lite' ),
  316. 'button_label' => esc_html__( 'Go to Customizer', 'zerif-lite' ),
  317. 'button_link' => esc_url( admin_url( 'customize.php' ) ),
  318. 'is_button' => true,
  319. 'recommended_actions' => false,
  320. 'is_new_tab' => true,
  321. ),
  322. ),
  323. // Free vs pro array.
  324. 'free_pro' => array(
  325. 'free_theme_name' => 'Zerif Lite',
  326. 'pro_theme_name' => 'Zerif PRO',
  327. 'pro_theme_link' => 'https://themeisle.com/themes/zerif-pro-one-page-wordpress-theme/upgrade/',
  328. /* translators: Zerif Pro name */
  329. 'get_pro_theme_label' => sprintf( __( 'Get %s now!', 'zerif-lite' ), 'Zerif Pro' ),
  330. 'features' => array(
  331. array(
  332. 'title' => __( 'Parallax effect', 'zerif-lite' ),
  333. 'description' => __( 'Smooth, catchy and easy scrolling experience.', 'zerif-lite' ),
  334. 'is_in_lite' => 'true',
  335. 'is_in_pro' => 'true',
  336. ),
  337. array(
  338. 'title' => __( 'Mobile friendly', 'zerif-lite' ),
  339. 'description' => __( 'Responsive layout. Works on every device.', 'zerif-lite' ),
  340. 'is_in_lite' => 'true',
  341. 'is_in_pro' => 'true',
  342. ),
  343. array(
  344. 'title' => __( 'WooCommerce Compatible', 'zerif-lite' ),
  345. 'description' => __( 'Ready for e-commerce. You can build an online store here.', 'zerif-lite' ),
  346. 'is_in_lite' => 'true',
  347. 'is_in_pro' => 'true',
  348. ),
  349. array(
  350. 'title' => __( 'Frontpage sections', 'zerif-lite' ),
  351. 'description' => __( 'Big title, Our focus, About us, Our team, Testimonials, Ribbons, Latest news, Contat us', 'zerif-lite' ),
  352. 'is_in_lite' => 'true',
  353. 'is_in_pro' => 'true',
  354. ),
  355. array(
  356. 'title' => __( 'Background image', 'zerif-lite' ),
  357. 'description' => __( 'You can use any background image you want.', 'zerif-lite' ),
  358. 'is_in_lite' => 'true',
  359. 'is_in_pro' => 'true',
  360. ),
  361. array(
  362. 'title' => __( 'Unlimited color option', 'zerif-lite' ),
  363. 'description' => __( 'You can change the colors of each section. You have unlimited options.', 'zerif-lite' ),
  364. 'is_in_lite' => 'false',
  365. 'is_in_pro' => 'true',
  366. ),
  367. array(
  368. 'title' => __( 'Google map section', 'zerif-lite' ),
  369. 'description' => __( 'Embed your current location to your website by using a Google map.', 'zerif-lite' ),
  370. 'is_in_lite' => 'false',
  371. 'is_in_pro' => 'true',
  372. ),
  373. array(
  374. 'title' => __( 'Portfolio', 'zerif-lite' ),
  375. 'description' => __( 'Showcase your best projects in the portfolio section.', 'zerif-lite' ),
  376. 'is_in_lite' => 'false',
  377. 'is_in_pro' => 'true',
  378. ),
  379. array(
  380. 'title' => __( 'Sections order', 'zerif-lite' ),
  381. 'description' => __( 'Arrange the sections by your priorities.', 'zerif-lite' ),
  382. 'is_in_lite' => 'false',
  383. 'is_in_pro' => 'true',
  384. ),
  385. array(
  386. 'title' => __( 'Background slider/video', 'zerif-lite' ),
  387. 'description' => __( 'Apart from static images, you can use videos or sliders on the background.', 'zerif-lite' ),
  388. 'is_in_lite' => 'false',
  389. 'is_in_pro' => 'true',
  390. ),
  391. array(
  392. 'title' => __( 'Support', 'zerif-lite' ),
  393. 'description' => __( 'You will benefit of our full support for any issues you have with the theme.', 'zerif-lite' ),
  394. 'is_in_lite' => 'false',
  395. 'is_in_pro' => 'true',
  396. ),
  397. array(
  398. 'title' => __( 'Packages/Subscribe sections', 'zerif-lite' ),
  399. 'description' => __( 'Add pricing tables for your products and use newsletter forms to attract the clients.', 'zerif-lite' ),
  400. 'is_in_lite' => 'false',
  401. 'is_in_pro' => 'true',
  402. ),
  403. array(
  404. 'title' => __( 'Change labels for the Contact Us section', 'zerif-lite' ),
  405. 'description' => __( 'Write an original text in each Contact us section field.', 'zerif-lite' ),
  406. 'is_in_lite' => 'false',
  407. 'is_in_pro' => 'true',
  408. ),
  409. array(
  410. 'title' => __( 'No credit footer link', 'zerif-lite' ),
  411. 'description' => __( 'Remove "Zerif Lite developed by ThemeIsle" copyright from the footer.', 'zerif-lite' ),
  412. 'is_in_lite' => 'false',
  413. 'is_in_pro' => 'true',
  414. ),
  415. ),
  416. ),
  417. // Plugins array.
  418. 'recommended_plugins' => array(
  419. 'already_activated_message' => esc_html__( 'Already activated', 'zerif-lite' ),
  420. 'version_label' => esc_html__( 'Version: ', 'zerif-lite' ),
  421. 'install_label' => esc_html__( 'Install and Activate', 'zerif-lite' ),
  422. 'activate_label' => esc_html__( 'Activate', 'zerif-lite' ),
  423. 'deactivate_label' => esc_html__( 'Deactivate', 'zerif-lite' ),
  424. 'content' => array(
  425. array(
  426. 'slug' => 'wpforms-lite',
  427. ),
  428. array(
  429. 'slug' => 'translatepress-multilingual',
  430. ),
  431. array(
  432. 'slug' => 'siteorigin-panels',
  433. ),
  434. array(
  435. 'slug' => 'wp-product-review',
  436. ),
  437. array(
  438. 'slug' => 'intergeo-maps',
  439. ),
  440. array(
  441. 'slug' => 'visualizer',
  442. ),
  443. array(
  444. 'slug' => 'adblock-notify-by-bweb',
  445. ),
  446. array(
  447. 'slug' => 'nivo-slider-lite',
  448. ),
  449. ),
  450. ),
  451. // Required actions array.
  452. 'recommended_actions' => array(
  453. 'install_label' => esc_html__( 'Install and Activate', 'zerif-lite' ),
  454. 'activate_label' => esc_html__( 'Activate', 'zerif-lite' ),
  455. 'deactivate_label' => esc_html__( 'Deactivate', 'zerif-lite' ),
  456. 'content' => array(
  457. 'themeisle-companion' => array(
  458. 'title' => 'Orbit Fox',
  459. 'description' => __( 'It is highly recommended that you install the companion plugin to have access to the frontpage sections widgets.', 'zerif-lite' ),
  460. 'check' => defined( 'THEMEISLE_COMPANION_VERSION' ),
  461. 'plugin_slug' => 'themeisle-companion',
  462. 'id' => 'themeisle-companion',
  463. ),
  464. 'wpforms-lite' => array(
  465. 'title' => 'WPForms',
  466. 'description' => __( 'Makes your contact page more engaging by creating a good-looking contact form on your website. The interaction with your visitors was never easier.', 'zerif-lite' ),
  467. 'check' => defined( 'PIRATE_FORMS_VERSION' ),
  468. 'plugin_slug' => 'wpforms-lite',
  469. 'id' => 'wpforms-lite',
  470. ),
  471.  
  472. ),
  473. ),
  474. );
  475.  
  476. /*
  477. * Add recommendation for Beaver Builder plugin, after 5 days of installing the theme
  478. **/
  479. if ( ! defined( 'FL_BUILDER_VERSION' ) && zerif_check_passed_time( '259200' ) ) {
  480. $elementor_array = array(
  481. 'slug' => 'beaver-builder-lite-version',
  482. );
  483. if ( ! empty( $config['recommended_plugins']['content'] ) ) {
  484. array_push( $config['recommended_plugins']['content'], $elementor_array );
  485. }
  486. }
  487.  
  488. TI_About_Page::init( $config );
  489.  
  490. /*
  491. * Notifications in customize
  492. */
  493. require get_template_directory() . '/ti-customizer-notify/class-ti-customizer-notify.php';
  494.  
  495. $config_customizer = array(
  496. 'recommended_plugins' => array(
  497. 'themeisle-companion' => array(
  498. 'recommended' => true,
  499. /* translators: ThemeIsle Companion install link */
  500. 'description' => sprintf( esc_html__( 'If you want to take full advantage of the options this theme has to offer, please install and activate %s', 'zerif-lite' ), sprintf( '<strong>%s</strong>', 'ThemeIsle Companion' ) ),
  501. ),
  502. ),
  503. 'recommended_actions' => array(),
  504. 'recommended_actions_title' => esc_html__( 'Recommended Actions', 'zerif-lite' ),
  505. 'recommended_plugins_title' => esc_html__( 'Recommended Plugins', 'zerif-lite' ),
  506. 'install_button_label' => esc_html__( 'Install and Activate', 'zerif-lite' ),
  507. 'activate_button_label' => esc_html__( 'Activate', 'zerif-lite' ),
  508. 'deactivate_button_label' => esc_html__( 'Deactivate', 'zerif-lite' ),
  509. );
  510. Ti_Customizer_Notify::init( apply_filters( 'zerif_customizer_notify_array', $config_customizer ) );
  511.  
  512. }
  513.  
  514. add_action( 'after_setup_theme', 'zerif_setup' );
  515.  
  516. /**
  517. * Add compatibility with WooCommerce Product Images customizer controls.
  518. */
  519. function zerif_set_woo_image_sizes() {
  520.  
  521. $execute = get_option( 'zerif_update_woocommerce_customizer_controls', false );
  522. if ( $execute !== false ) {
  523. return;
  524. }
  525.  
  526. update_option( 'woocommerce_thumbnail_cropping', 'custom' );
  527. update_option( 'woocommerce_thumbnail_cropping_custom_width', '3' );
  528. update_option( 'woocommerce_thumbnail_cropping_custom_height', '2' );
  529.  
  530. if ( class_exists( 'WC_Regenerate_Images' ) ) {
  531. $regenerate_obj = new WC_Regenerate_Images();
  532. $regenerate_obj::init();
  533. if ( method_exists( $regenerate_obj, 'maybe_regenerate_images' ) ) {
  534. $regenerate_obj::maybe_regenerate_images();
  535. } elseif ( method_exists( $regenerate_obj, 'maybe_regenerate_images_option_update' ) ) {
  536. // Force woocommerce 3.3.1 to regenerate images
  537. $regenerate_obj::maybe_regenerate_images_option_update( 1, 2, '' );
  538. }
  539. }
  540.  
  541. update_option( 'zerif_update_woocommerce_customizer_controls', true );
  542. }
  543.  
  544.  
  545. /**
  546. * Migrate logo from theme to core
  547. */
  548. function zerif_migrate_logo() {
  549.  
  550. $zerif_old_logo = get_theme_mod( 'zerif_logo' );
  551.  
  552. if ( ! empty( $zerif_old_logo ) ) {
  553.  
  554. $zerif_old_logo_id = attachment_url_to_postid( $zerif_old_logo );
  555. if ( is_int( $zerif_old_logo_id ) ) {
  556. set_theme_mod( 'custom_logo', $zerif_old_logo_id );
  557. }
  558. remove_theme_mod( 'zerif_logo' );
  559. }
  560. }
  561.  
  562. add_action( 'after_setup_theme', 'zerif_migrate_logo' );
  563.  
  564. /**
  565. * Custom excerpt more link
  566. */
  567. function zerif_excerpt_more( $more ) {
  568. return ' <a href="' . esc_url( get_the_permalink() ) . '" rel="nofollow"><span class="sr-only">' . esc_html__( 'Read more about ', 'zerif-lite' ) . esc_attr( get_the_title() ) . '</span>[&hellip;]</a>';
  569. }
  570.  
  571. /**
  572. * Check if latest posts
  573. */
  574. function zerif_lite_is_not_latest_posts() {
  575. return ( 'posts' == get_option( 'show_on_front' ) ? true : false );
  576. }
  577.  
  578. /**
  579. * Check if frontpage
  580. */
  581. function zerif_lite_is_static_frontpage() {
  582. if ( 'posts' == get_option( 'show_on_front' ) ) {
  583. return false;
  584. } else {
  585. $frontpage_id = get_option( 'page_on_front' );
  586. if ( 'template-frontpage.php' == get_post_meta( $frontpage_id, '_wp_page_template', true ) ) {
  587. return true;
  588. } else {
  589. return false;
  590. }
  591. }
  592. }
  593.  
  594. /**
  595. * Register widgetized area and update sidebar with default widgets.
  596. */
  597. function zerif_widgets_init() {
  598.  
  599. register_sidebar(
  600. array(
  601. 'name' => __( 'Sidebar', 'zerif-lite' ),
  602. 'id' => 'sidebar-1',
  603. 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  604. 'after_widget' => '</aside>',
  605. 'before_title' => '<h2 class="widget-title">',
  606. 'after_title' => '</h2>',
  607. )
  608. );
  609.  
  610. register_sidebar(
  611. array(
  612. 'name' => __( 'About us section', 'zerif-lite' ),
  613. 'id' => 'sidebar-aboutus',
  614. 'before_widget' => '<span id="%1$s">',
  615. 'after_widget' => '</span>',
  616. 'before_title' => '<h1 class="widget-title">',
  617. 'after_title' => '</h1>',
  618. )
  619. );
  620.  
  621. register_sidebars(
  622. 3,
  623. array(
  624. /* translators: Footer area number */
  625. 'name' => __( 'Footer area %d', 'zerif-lite' ),
  626. 'id' => 'zerif-sidebar-footer',
  627. 'before_widget' => '<aside id="%1$s" class="widget footer-widget-footer %2$s">',
  628. 'after_widget' => '</aside>',
  629. 'before_title' => '<h1 class="widget-title">',
  630. 'after_title' => '</h1>',
  631. )
  632. );
  633.  
  634. }
  635.  
  636. add_action( 'widgets_init', 'zerif_widgets_init' );
  637.  
  638. /**
  639. * Enqueue fonts
  640. */
  641. function zerif_slug_fonts_url() {
  642. $fonts_url = '';
  643.  
  644. /**
  645. * Translators: If there are characters in your language that are not
  646. * supported by Lora, translate this to 'off'. Do not translate
  647. * into your own language.
  648. */
  649. $lato = _x( 'on', 'Lato font: on or off', 'zerif-lite' );
  650. $homemade = _x( 'on', 'Homemade font: on or off', 'zerif-lite' );
  651.  
  652. /**
  653. * Translators: If there are characters in your language that are not
  654. * supported by Open Sans, translate this to 'off'. Do not translate
  655. * into your own language.
  656. */
  657. $monserrat = _x( 'on', 'Monserrat font: on or off', 'zerif-lite' );
  658.  
  659. $zerif_use_safe_font = get_theme_mod( 'zerif_use_safe_font' );
  660.  
  661. if ( ( 'off' !== $lato || 'off' !== $monserrat || 'off' !== $homemade ) && isset( $zerif_use_safe_font ) && ( $zerif_use_safe_font != 1 ) ) {
  662. $font_families = array();
  663.  
  664. if ( 'off' !== $lato ) {
  665. $font_families[] = 'Lato:300,400,700,400italic';
  666. }
  667. if ( 'off' !== $monserrat ) {
  668. $font_families[] = 'Montserrat:400,700';
  669. }
  670.  
  671. if ( 'off' !== $homemade ) {
  672. $font_families[] = 'Homemade Apple';
  673. }
  674. $query_args = array(
  675. 'family' => urlencode( implode( '|', $font_families ) ),
  676. 'subset' => urlencode( 'latin,latin-ext' ),
  677. );
  678. $fonts_url = add_query_arg( $query_args, '//fonts.googleapis.com/css' );
  679. }
  680. return $fonts_url;
  681. }
  682.  
  683. /**
  684. * Enqueue scripts and styles.
  685. */
  686. function zerif_scripts() {
  687.  
  688. wp_enqueue_style( 'zerif_font', zerif_slug_fonts_url(), array(), null );
  689.  
  690. wp_enqueue_style(
  691. 'zerif_font_all',
  692. add_query_arg(
  693. array(
  694. 'family' => urlencode( 'Open Sans:300,300italic,400,400italic,600,600italic,700,700italic,800,800italic' ),
  695. 'subset' => urlencode( 'latin' ),
  696. ),
  697. '//fonts.googleapis.com/css'
  698. )
  699. );
  700.  
  701. wp_enqueue_style( 'zerif_bootstrap_style', get_template_directory_uri() . '/css/bootstrap.css' );
  702.  
  703. wp_style_add_data( 'zerif_bootstrap_style', 'rtl', 'replace' );
  704.  
  705. wp_enqueue_style( 'zerif_fontawesome', get_template_directory_uri() . '/css/font-awesome.min.css', array(), 'v1' );
  706.  
  707. wp_enqueue_style( 'zerif_style', get_stylesheet_uri(), array( 'zerif_fontawesome' ), ZERIF_LITE_VERSION );
  708.  
  709. /* Add this style only for the other cases than New users that have a static page */
  710. $zerif_keep_old_fp_template = get_theme_mod( 'zerif_keep_old_fp_template' );
  711.  
  712. if ( ! ( ! zerif_check_if_old_version_of_theme() && ( get_option( 'show_on_front' ) == 'page' ) && ! $zerif_keep_old_fp_template ) ) {
  713. $custom_css = 'body.home.page:not(.page-template-template-frontpage) {
  714. background-image: none !important;
  715. }';
  716. wp_add_inline_style( 'zerif_style', $custom_css );
  717. }
  718.  
  719. wp_enqueue_style( 'zerif_responsive_style', get_template_directory_uri() . '/css/responsive.css', array( 'zerif_style' ), ZERIF_LITE_VERSION );
  720.  
  721. wp_enqueue_style( 'zerif_ie_style', get_template_directory_uri() . '/css/ie.css', array( 'zerif_style' ), ZERIF_LITE_VERSION );
  722. wp_style_add_data( 'zerif_ie_style', 'conditional', 'lt IE 9' );
  723.  
  724. if ( wp_is_mobile() ) {
  725. wp_enqueue_style( 'zerif_style_mobile', get_template_directory_uri() . '/css/style-mobile.css', array( 'zerif_bootstrap_style', 'zerif_style' ), 'v1' );
  726. }
  727.  
  728. /* Bootstrap script */
  729. wp_enqueue_script( 'zerif_bootstrap_script', get_template_directory_uri() . '/js/bootstrap.min.js', array( 'jquery' ), ZERIF_LITE_VERSION, true );
  730.  
  731. /* Knob script */
  732. wp_enqueue_script( 'zerif_knob_nav', get_template_directory_uri() . '/js/jquery.knob.js', array( 'jquery' ), ZERIF_LITE_VERSION, true );
  733.  
  734. /* Smootscroll script */
  735. $zerif_disable_smooth_scroll = get_theme_mod( 'zerif_disable_smooth_scroll' );
  736. if ( isset( $zerif_disable_smooth_scroll ) && ( $zerif_disable_smooth_scroll != 1 ) ) {
  737. wp_enqueue_script( 'zerif_smoothscroll', get_template_directory_uri() . '/js/smoothscroll.js', array( 'jquery' ), ZERIF_LITE_VERSION, true );
  738. }
  739.  
  740. /* scrollReveal script */
  741. if ( ! wp_is_mobile() ) {
  742. wp_enqueue_script( 'zerif_scrollReveal_script', get_template_directory_uri() . '/js/scrollReveal.js', array( 'jquery' ), ZERIF_LITE_VERSION, true );
  743. }
  744.  
  745. /* zerif script */
  746. wp_enqueue_script( 'zerif_script', get_template_directory_uri() . '/js/zerif.js', array( 'jquery', 'zerif_knob_nav' ), ZERIF_LITE_VERSION, true );
  747.  
  748. if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
  749.  
  750. wp_enqueue_script( 'comment-reply' );
  751.  
  752. }
  753.  
  754. /* HTML5Shiv*/
  755. wp_enqueue_script( 'zerif_html5', get_template_directory_uri() . '/js/html5.js' );
  756. wp_script_add_data( 'zerif_html5', 'conditional', 'lt IE 9' );
  757.  
  758. /* parallax effect */
  759. if ( ! wp_is_mobile() ) {
  760.  
  761. /* include parallax only if on frontpage and the parallax effect is activated */
  762. $zerif_parallax_use = get_theme_mod( 'zerif_parallax_show' );
  763.  
  764. if ( ! empty( $zerif_parallax_use ) && ( $zerif_parallax_use == 1 ) && is_front_page() ) :
  765.  
  766. wp_enqueue_script( 'zerif_parallax', get_template_directory_uri() . '/js/parallax.js', array( 'jquery' ), 'v1', true );
  767.  
  768. endif;
  769. }
  770.  
  771. add_editor_style( '/css/custom-editor-style.css' );
  772.  
  773. }
  774. add_action( 'wp_enqueue_scripts', 'zerif_scripts' );
  775.  
  776. /**
  777. * Adjust content width based on template.
  778. */
  779. function zerif_adjust_content_width() {
  780. global $content_width;
  781.  
  782. $zerif_change_to_full_width = get_theme_mod( 'zerif_change_to_full_width' );
  783. if ( is_page_template( 'template-fullwidth.php' ) || is_page_template( 'template-fullwidth-no-title.php' ) || is_page_template( 'woocommerce.php' ) || is_page_template( 'single-download.php' ) || ( is_page_template( 'page.php' ) && ! empty( $zerif_change_to_full_width ) ) ) {
  784. $content_width = 1110;
  785. }
  786.  
  787. }
  788. add_action( 'template_redirect', 'zerif_adjust_content_width' );
  789.  
  790. /**
  791. * Remove Yoast rel="prev/next" link from header
  792. */
  793. function zerif_remove_yoast_rel_link() {
  794. return false;
  795. }
  796. add_filter( 'wpseo_prev_rel_link', 'zerif_remove_yoast_rel_link' );
  797. add_filter( 'wpseo_next_rel_link', 'zerif_remove_yoast_rel_link' );
  798.  
  799. add_action( 'tgmpa_register', 'zerif_register_required_plugins' );
  800.  
  801. /**
  802. * Recommend plugins with TGMPA
  803. */
  804. function zerif_register_required_plugins() {
  805.  
  806. $wp_version_nr = get_bloginfo( 'version' );
  807.  
  808. if ( $wp_version_nr < 3.9 ) :
  809. $plugins = array(
  810. array(
  811. 'name' => 'Widget customizer',
  812. 'slug' => 'widget-customizer',
  813. 'required' => false,
  814. ),
  815. array(
  816. 'name' => 'WPForms',
  817. 'slug' => 'wpforms-lite',
  818. 'required' => false,
  819. ),
  820. array(
  821. 'name' => 'Orbit Fox',
  822. 'slug' => 'themeisle-companion',
  823. 'required' => false,
  824. ),
  825. );
  826.  
  827. else :
  828.  
  829. $plugins = array(
  830. array(
  831. 'name' => 'WPForms',
  832. 'slug' => 'wpforms-lite',
  833. 'required' => false,
  834. ),
  835. array(
  836. 'name' => 'Orbit Fox',
  837. 'slug' => 'themeisle-companion',
  838. 'required' => false,
  839. ),
  840. );
  841.  
  842. endif;
  843. $config = array(
  844. 'default_path' => '',
  845. 'menu' => 'tgmpa-install-plugins',
  846. 'has_notices' => true,
  847. 'dismissable' => true,
  848. 'dismiss_msg' => '',
  849. 'is_automatic' => false,
  850. 'message' => '',
  851. 'strings' => array(
  852. 'page_title' => __( 'Install Required Plugins', 'zerif-lite' ),
  853. 'menu_title' => __( 'Install Plugins', 'zerif-lite' ),
  854. /* translators: name of installing plugin */
  855. 'installing' => __( 'Installing Plugin: %s', 'zerif-lite' ),
  856. 'oops' => __( 'Something went wrong with the plugin API.', 'zerif-lite' ),
  857. /* translators: Name of required plugin */
  858. 'notice_can_install_required' => _n_noop( 'This theme requires the following plugin: %1$s.', 'This theme requires the following plugins: %1$s.', 'zerif-lite' ),
  859. /* translators: Name of recommended plugin */
  860. 'notice_can_install_recommended' => _n_noop( 'This theme recommends the following plugin: %1$s.', 'This theme recommends the following plugins: %1$s.', 'zerif-lite' ),
  861. /* translators: Name of required plugin */
  862. 'notice_cannot_install' => _n_noop( 'Sorry, but you do not have the correct permissions to install the %s plugin. Contact the administrator of this site for help on getting the plugin installed.', 'Sorry, but you do not have the correct permissions to install the %s plugins. Contact the administrator of this site for help on getting the plugins installed.', 'zerif-lite' ),
  863. /* translators: Name of required plugin that is not active */
  864. 'notice_can_activate_required' => _n_noop( 'The following required plugin is currently inactive: %1$s.', 'The following required plugins are currently inactive: %1$s.', 'zerif-lite' ),
  865. /* translators: Name of recommended plugin that is not active */
  866. 'notice_can_activate_recommended' => _n_noop( 'The following recommended plugin is currently inactive: %1$s.', 'The following recommended plugins are currently inactive: %1$s.', 'zerif-lite' ),
  867. /* translators: Name of plguin that can't be activated */
  868. 'notice_cannot_activate' => _n_noop( 'Sorry, but you do not have the correct permissions to activate the %s plugin. Contact the administrator of this site for help on getting the plugin activated.', 'Sorry, but you do not have the correct permissions to activate the %s plugins. Contact the administrator of this site for help on getting the plugins activated.', 'zerif-lite' ),
  869. /* translators: Name of plugin that needs to be updated */
  870. 'notice_ask_to_update' => _n_noop( 'The following plugin needs to be updated to its latest version to ensure maximum compatibility with this theme: %1$s.', 'The following plugins need to be updated to their latest version to ensure maximum compatibility with this theme: %1$s.', 'zerif-lite' ),
  871. /* translators: Nme of plugin that can't be updated */
  872. 'notice_cannot_update' => _n_noop( 'Sorry, but you do not have the correct permissions to update the %s plugin. Contact the administrator of this site for help on getting the plugin updated.', 'Sorry, but you do not have the correct permissions to update the %s plugins. Contact the administrator of this site for help on getting the plugins updated.', 'zerif-lite' ),
  873. 'install_link' => _n_noop( 'Begin installing plugin', 'Begin installing plugins', 'zerif-lite' ),
  874. 'activate_link' => _n_noop( 'Begin activating plugin', 'Begin activating plugins', 'zerif-lite' ),
  875. 'return' => __( 'Return to Required Plugins Installer', 'zerif-lite' ),
  876. 'plugin_activated' => __( 'Plugin activated successfully.', 'zerif-lite' ),
  877. /* translators: Name of plugins installed and activated successfully */
  878. 'complete' => __( 'All plugins installed and activated successfully. %s', 'zerif-lite' ),
  879. 'nag_type' => 'updated',
  880. ),
  881. );
  882. tgmpa( $plugins, $config );
  883. }
  884.  
  885. /* Load Jetpack compatibility file. */
  886.  
  887. require get_template_directory() . '/inc/jetpack.php';
  888.  
  889. /**
  890. * Menu layout
  891. */
  892. function zerif_wp_page_menu() {
  893.  
  894. echo '<ul class="nav navbar-nav navbar-right responsive-nav main-nav-list">';
  895.  
  896. wp_list_pages(
  897. array(
  898. 'title_li' => '',
  899. 'depth' => 1,
  900. )
  901. );
  902.  
  903. echo '</ul>';
  904.  
  905. }
  906.  
  907. add_filter( 'the_title', 'zerif_default_title' );
  908.  
  909. /**
  910. * Add a default title for posts without one
  911. */
  912. function zerif_default_title( $title ) {
  913.  
  914. if ( $title == '' ) {
  915.  
  916. $title = __( 'Default title', 'zerif-lite' );
  917. }
  918.  
  919. return $title;
  920.  
  921. }
  922.  
  923. add_action( 'widgets_init', 'zerif_register_widgets' );
  924.  
  925. /**
  926. * Register custom widgets
  927. */
  928. function zerif_register_widgets() {
  929.  
  930. if ( ! defined( 'THEMEISLE_COMPANION_VERSION' ) ) {
  931.  
  932. if ( zerif_check_if_old_version_of_theme() ) {
  933. register_widget( 'zerif_ourfocus' );
  934. register_widget( 'zerif_testimonial_widget' );
  935. register_widget( 'zerif_clients_widget' );
  936. register_widget( 'zerif_team_widget' );
  937. }
  938. }
  939.  
  940. $zerif_lite_sidebars = array(
  941. 'sidebar-ourfocus' => 'sidebar-ourfocus',
  942. 'sidebar-testimonials' => 'sidebar-testimonials',
  943. 'sidebar-ourteam' => 'sidebar-ourteam',
  944. );
  945.  
  946. /* Register sidebars */
  947. foreach ( $zerif_lite_sidebars as $zerif_lite_sidebar ) :
  948. $extra_class = '';
  949. if ( $zerif_lite_sidebar == 'sidebar-ourfocus' ) :
  950.  
  951. $zerif_lite_name = __( 'Our focus section widgets', 'zerif-lite' );
  952.  
  953. elseif ( $zerif_lite_sidebar == 'sidebar-testimonials' ) :
  954. $extra_class = 'feedback-box';
  955. $zerif_lite_name = __( 'Testimonials section widgets', 'zerif-lite' );
  956.  
  957. elseif ( $zerif_lite_sidebar == 'sidebar-ourteam' ) :
  958.  
  959. $zerif_lite_name = __( 'Our team section widgets', 'zerif-lite' );
  960.  
  961. else :
  962.  
  963. $zerif_lite_name = $zerif_lite_sidebar;
  964.  
  965. endif;
  966.  
  967. register_sidebar(
  968. array(
  969. 'name' => $zerif_lite_name,
  970. 'id' => $zerif_lite_sidebar,
  971. 'before_widget' => '<span id="%1$s" class="' . $extra_class . '">',
  972. 'after_widget' => '</span>',
  973. )
  974. );
  975.  
  976. endforeach;
  977.  
  978. }
  979.  
  980. if ( ! class_exists( 'zerif_ourfocus' ) && zerif_check_if_old_version_of_theme() ) {
  981.  
  982. /**
  983. * Our focus widget
  984. */
  985. class zerif_ourfocus extends WP_Widget {
  986.  
  987. /**
  988. * Constructor.
  989. */
  990. public function __construct() {
  991.  
  992. parent::__construct(
  993. 'ctUp-ads-widget',
  994. __( 'Zerif - Our focus widget', 'zerif-lite' ),
  995. array(
  996. 'customize_selective_refresh' => true,
  997. )
  998. );
  999. add_action( 'admin_enqueue_scripts', array( $this, 'widget_scripts' ) );
  1000. }
  1001.  
  1002. /**
  1003. * Enqueue scripts
  1004. */
  1005. function widget_scripts( $hook ) {
  1006. if ( $hook != 'widgets.php' ) {
  1007. return;
  1008. }
  1009. wp_enqueue_media();
  1010. wp_enqueue_script( 'zerif_widget_media_script', get_template_directory_uri() . '/js/widget-media.js', false, '1.1', true );
  1011. }
  1012.  
  1013. /**
  1014. * Create the widget
  1015. */
  1016. function widget( $args, $instance ) {
  1017.  
  1018. echo $args['before_widget'];
  1019.  
  1020. echo '<div class="col-lg-3 col-sm-3 focus-box" data-scrollreveal="enter left after 0.15s over 1s">';
  1021.  
  1022. if ( ! empty( $instance['image_uri'] ) && ( preg_match( '/(\.jpg|\.png|\.jpeg|\.gif|\.bmp)$/', $instance['image_uri'] ) ) ) {
  1023. if ( ! empty( $instance['link'] ) ) {
  1024.  
  1025. echo '<a href="' . esc_url( $instance['link'] ) . '" class="service-icon">';
  1026.  
  1027. if ( ! empty( $instance['title'] ) ) {
  1028.  
  1029. echo '<span class="sr-only">';
  1030. printf(
  1031. /* Translators: %s: widget title */
  1032. __( 'Go to %s', 'zerif-lite' ),
  1033. apply_filters( 'widget_title', $instance['title'] )
  1034. );
  1035. echo '</span>';
  1036.  
  1037. }
  1038. echo '<i class="pixeden" style="background:url(' . esc_url( $instance['image_uri'] ) . ') no-repeat center;width:100%; height:100%;"></i>';
  1039. echo '</a>';
  1040.  
  1041. } else {
  1042.  
  1043. echo '<div class="service-icon" tabindex="0">';
  1044. echo '<i class="pixeden" style="background:url(' . esc_url( $instance['image_uri'] ) . ') no-repeat center;width:100%; height:100%;"></i>';
  1045. echo '</div>';
  1046. }
  1047. } elseif ( ! empty( $instance['custom_media_id'] ) ) {
  1048.  
  1049. $zerif_ourfocus_custom_media_id = wp_get_attachment_image_url( $instance['custom_media_id'] );
  1050. if ( ! empty( $zerif_ourfocus_custom_media_id ) ) {
  1051.  
  1052. if ( ! empty( $instance['link'] ) ) {
  1053.  
  1054. echo '<a href="' . esc_url( $instance['link'] ) . '" class="service-icon">';
  1055.  
  1056. if ( ! empty( $instance['title'] ) ) {
  1057.  
  1058. echo '<span class="sr-only">';
  1059. _e( 'Go to', 'zerif-lite' );
  1060. echo apply_filters( 'widget_title', $instance['title'] );
  1061. echo '</span>';
  1062.  
  1063. }
  1064. echo '<i class="pixeden" style="background:url(' . esc_url( $zerif_ourfocus_custom_media_id ) . ') no-repeat center;width:100%; height:100%;"></i>';
  1065. echo '</a>';
  1066.  
  1067. } else {
  1068.  
  1069. echo '<div class="service-icon" tabindex="0">';
  1070. echo '<i class="pixeden" style="background:url(' . esc_url( $zerif_ourfocus_custom_media_id ) . ') no-repeat center;width:100%; height:100%;"></i>';
  1071. echo '</div>';
  1072. }
  1073. }
  1074. }
  1075.  
  1076. echo '<h3 class="red-border-bottom">';
  1077.  
  1078. if ( ! empty( $instance['title'] ) ) {
  1079. echo apply_filters( 'widget_title', $instance['title'] );
  1080. }
  1081. echo '</h3>';
  1082.  
  1083. if ( ! empty( $instance['text'] ) ) {
  1084. echo '<p>' . htmlspecialchars_decode( apply_filters( 'widget_title', $instance['text'] ) ) . '</p>';
  1085. }
  1086.  
  1087. echo '</div>';
  1088.  
  1089. echo $args['after_widget'];
  1090.  
  1091. }
  1092.  
  1093. /**
  1094. * Update widgets instance
  1095. */
  1096. function update( $new_instance, $old_instance ) {
  1097.  
  1098. $instance = $old_instance;
  1099. $instance['text'] = stripslashes( wp_filter_post_kses( $new_instance['text'] ) );
  1100. $instance['title'] = sanitize_text_field( $new_instance['title'] );
  1101. $instance['link'] = esc_url( $new_instance['link'] );
  1102. $instance['image_uri'] = esc_url( $new_instance['image_uri'] );
  1103. $instance['custom_media_id'] = sanitize_text_field( $new_instance['custom_media_id'] );
  1104. $instance['image_in_customizer'] = esc_url( $new_instance['image_in_customizer'] );
  1105.  
  1106. return $instance;
  1107.  
  1108. }
  1109.  
  1110. /**
  1111. * Widget controls
  1112. */
  1113. function form( $instance ) {
  1114.  
  1115. echo '<p>';
  1116. echo '<label for="' . $this->get_field_id( 'title' ) . '">' . __( 'Title', 'zerif-lite' ) . '</label><br/>';
  1117. echo '<input type="text" name="' . $this->get_field_name( 'title' ) . '" id="' . $this->get_field_id( 'title' ) . '" value="';
  1118. if ( ! empty( $instance['title'] ) ) {
  1119. echo $instance['title'];
  1120. }
  1121. echo '" class="widefat">';
  1122. echo '</p>';
  1123. echo '<p>';
  1124. echo '<label for="' . $this->get_field_id( 'text' ) . '">' . __( 'Text', 'zerif-lite' ) . '</label><br/>';
  1125. echo '<textarea class="widefat" rows="8" cols="20" name="' . $this->get_field_name( 'text' ) . '" id="' . $this->get_field_id( 'text' ) . '">';
  1126. if ( ! empty( $instance['text'] ) ) {
  1127. echo htmlspecialchars_decode( $instance['text'] );
  1128. }
  1129. echo '</textarea>';
  1130. echo '</p>';
  1131. echo '<p>';
  1132. echo '<label for="' . $this->get_field_id( 'link' ) . '">' . __( 'Link', 'zerif-lite' ) . '</label><br/>';
  1133. echo '<input type="text" name="' . $this->get_field_name( 'link' ) . '" id="' . $this->get_field_id( 'link' ) . '" value="';
  1134. if ( ! empty( $instance['link'] ) ) {
  1135. echo esc_url( $instance['link'] );
  1136. }
  1137. echo '" class="widefat">';
  1138. echo '</p>';
  1139. echo '<p>';
  1140. echo '<label for="' . $this->get_field_id( 'image_uri' ) . '">' . __( 'Image', 'zerif-lite' ) . '</label><br/>';
  1141.  
  1142. $image_in_customizer = '';
  1143. $display = 'none';
  1144. if ( ! empty( $instance['image_in_customizer'] ) && ! empty( $instance['image_uri'] ) ) {
  1145. $image_in_customizer = esc_url( $instance['image_in_customizer'] );
  1146. $display = 'inline-block';
  1147. } else {
  1148. if ( ! empty( $instance['image_uri'] ) ) {
  1149. $image_in_customizer = esc_url( $instance['image_uri'] );
  1150. $display = 'inline-block';
  1151. }
  1152. }
  1153. $zerif_image_in_customizer = $this->get_field_name( 'image_in_customizer' );
  1154.  
  1155. echo '<input type="hidden" class="custom_media_display_in_customizer" name="';
  1156. if ( ! empty( $zerif_image_in_customizer ) ) {
  1157. echo $zerif_image_in_customizer;
  1158. }
  1159. echo '" value="';
  1160. if ( ! empty( $instance['image_in_customizer'] ) ) {
  1161. echo $instance['image_in_customizer'];
  1162. }
  1163. echo '">';
  1164. echo '<img class="custom_media_image" src="' . $image_in_customizer . '" style="margin:0;padding:0;max-width:100px;float:left;display:' . $display . '" alt="' . __( 'Uploaded image', 'zerif-lite' ) . '"/><br/>';
  1165.  
  1166. echo '<input type="text" class="widefat custom_media_url" name="' . $this->get_field_name( 'image_uri' ) . '" id="' . $this->get_field_id( 'image_uri' ) . '" value="';
  1167. if ( ! empty( $instance['image_uri'] ) ) {
  1168. echo $instance['image_uri'];
  1169. }
  1170. echo '" style="margin-top:5px;">';
  1171.  
  1172. echo '<input type="button" class="button button-primary custom_media_button" id="custom_media_button" name="' . $this->get_field_name( 'image_uri' ) . '" value="' . __( 'Upload Image', 'zerif-lite' ) . '" style="margin-top:5px;">';
  1173. echo '</p>';
  1174.  
  1175. echo '<input class="custom_media_id" id="' . $this->get_field_id( 'custom_media_id' ) . '" name="' . $this->get_field_name( 'custom_media_id' ) . '" type="hidden" value="';
  1176. if ( ! empty( $instance['custom_media_id'] ) ) {
  1177. echo $instance['custom_media_id'];
  1178. }
  1179. echo '"/>';
  1180. }
  1181.  
  1182. }
  1183. }
  1184.  
  1185. if ( ! class_exists( 'zerif_testimonial_widget' ) && zerif_check_if_old_version_of_theme() ) {
  1186.  
  1187. /**
  1188. * Testimonial widget
  1189. */
  1190. class zerif_testimonial_widget extends WP_Widget {
  1191.  
  1192. /**
  1193. * Constructor.
  1194. */
  1195. public function __construct() {
  1196. parent::__construct(
  1197. 'zerif_testim-widget',
  1198. __( 'Zerif - Testimonial widget', 'zerif-lite' ),
  1199. array(
  1200. 'customize_selective_refresh' => true,
  1201. )
  1202. );
  1203. add_action( 'admin_enqueue_scripts', array( $this, 'widget_scripts' ) );
  1204. }
  1205.  
  1206. /**
  1207. * Enqueue scripts
  1208. */
  1209. function widget_scripts( $hook ) {
  1210. if ( $hook != 'widgets.php' ) {
  1211. return;
  1212. }
  1213. wp_enqueue_media();
  1214. wp_enqueue_script( 'zerif_widget_media_script', get_template_directory_uri() . '/js/widget-media.js', false, '1.1', true );
  1215. }
  1216.  
  1217. /**
  1218. * Create the widget
  1219. */
  1220. function widget( $args, $instance ) {
  1221.  
  1222. $zerif_accessibility = get_theme_mod( 'zerif_accessibility' );
  1223. // open link in a new tab when checkbox "accessibility" is not ticked
  1224. $attribut_new_tab = ( isset( $zerif_accessibility ) && ( $zerif_accessibility != 1 ) ? ' target="_blank"' : '' );
  1225.  
  1226. echo $args['before_widget'];
  1227.  
  1228. if ( ! empty( $instance['text'] ) ) {
  1229. echo '<div class="message">' . htmlspecialchars_decode( apply_filters( 'widget_title', $instance['text'] ) ) . '</div>';
  1230. }
  1231.  
  1232. echo '<div class="client">';
  1233.  
  1234. echo '<div class="quote red-text">';
  1235.  
  1236. echo '<i class="fa fa-quote-left"></i>';
  1237.  
  1238. echo '</div>';
  1239.  
  1240. echo '<div class="client-info">';
  1241.  
  1242. echo '<a ' . $attribut_new_tab . ' class="client-name"';
  1243. if ( ! empty( $instance['link'] ) ) {
  1244. echo 'href="' . esc_url( $instance['link'] ) . '"';
  1245. }
  1246. echo '>';
  1247.  
  1248. if ( ! empty( $instance['title'] ) ) {
  1249. echo apply_filters( 'widget_title', $instance['title'] );
  1250. }
  1251. echo '</a>';
  1252.  
  1253. if ( ! empty( $instance['details'] ) ) {
  1254. echo '<div class="client-company">' . apply_filters( 'widget_title', $instance['details'] ) . '</div>';
  1255. }
  1256.  
  1257. echo '</div>';
  1258.  
  1259. if ( ! empty( $instance['image_uri'] ) && ( preg_match( '/(\.jpg|\.png|\.jpeg|\.gif|\.bmp)$/', $instance['image_uri'] ) ) ) {
  1260.  
  1261. echo '<div class="client-image hidden-xs">';
  1262.  
  1263. echo '<img src="' . esc_url( $instance['image_uri'] ) . '" alt="" />';
  1264.  
  1265. echo '</div>';
  1266.  
  1267. } elseif ( ! empty( $instance['custom_media_id'] ) ) {
  1268.  
  1269. $zerif_testimonials_custom_media_id = wp_get_attachment_image_url( $instance['custom_media_id'] );
  1270. $alt = get_post_meta( $instance['custom_media_id'], '_wp_attachment_image_alt', true );
  1271.  
  1272. if ( ! empty( $zerif_testimonials_custom_media_id ) ) {
  1273.  
  1274. echo '<div class="client-image hidden-xs">';
  1275.  
  1276. echo '<img src="' . esc_url( $zerif_testimonials_custom_media_id ) . '" alt="' . esc_attr( $alt ) . '" />';
  1277.  
  1278. echo '</div>';
  1279.  
  1280. }
  1281. }
  1282.  
  1283. echo '</div>';
  1284.  
  1285. echo $args['after_widget'];
  1286.  
  1287. }
  1288.  
  1289. /**
  1290. * Update widget's values
  1291. */
  1292. function update( $new_instance, $old_instance ) {
  1293.  
  1294. $instance = $old_instance;
  1295. $instance['text'] = stripslashes( wp_filter_post_kses( $new_instance['text'] ) );
  1296. $instance['title'] = sanitize_text_field( $new_instance['title'] );
  1297. $instance['details'] = sanitize_text_field( $new_instance['details'] );
  1298. $instance['image_uri'] = esc_url( $new_instance['image_uri'] );
  1299. $instance['link'] = esc_url( $new_instance['link'] );
  1300. $instance['custom_media_id'] = sanitize_text_field( $new_instance['custom_media_id'] );
  1301. $instance['image_in_customizer'] = esc_url( $new_instance['image_in_customizer'] );
  1302.  
  1303. return $instance;
  1304.  
  1305. }
  1306.  
  1307. /**
  1308. * Form the widget
  1309. */
  1310. function form( $instance ) {
  1311.  
  1312. echo '<p>';
  1313. echo '<label for="' . $this->get_field_id( 'title' ) . '">' . __( 'Author', 'zerif-lite' ) . '</label><br/>';
  1314. echo '<input type="text" name="' . $this->get_field_name( 'title' ) . '" id="' . $this->get_field_id( 'title' ) . '" value="';
  1315. if ( ! empty( $instance['title'] ) ) {
  1316. echo $instance['title'];
  1317. }
  1318. echo '" class="widefat">';
  1319. echo '</p>';
  1320. echo '<p>';
  1321. echo '<label for="' . $this->get_field_id( 'link' ) . '">' . __( 'Author link', 'zerif-lite' ) . '</label><br/>';
  1322. echo '<input type="text" name="' . $this->get_field_name( 'link' ) . '" id="' . $this->get_field_id( 'link' ) . '" value="';
  1323. if ( ! empty( $instance['link'] ) ) {
  1324. echo esc_url( $instance['link'] );
  1325. }
  1326. echo '" class="widefat">';
  1327. echo '</p>';
  1328. echo '<p>';
  1329. echo '<label for="' . $this->get_field_id( 'details' ) . '">' . __( 'Author details', 'zerif-lite' ) . '</label><br/>';
  1330. echo '<input type="text" name="' . $this->get_field_name( 'details' ) . '" id="' . $this->get_field_id( 'details' ) . '" value="';
  1331. if ( ! empty( $instance['details'] ) ) {
  1332. echo $instance['details'];
  1333. }
  1334. echo '" class="widefat">';
  1335. echo '</p>';
  1336. echo '<p>';
  1337. echo '<label for="' . $this->get_field_id( 'text' ) . '">' . __( 'Text', 'zerif-lite' ) . '</label><br/>';
  1338. echo '<textarea class="widefat" rows="8" cols="20" name="' . $this->get_field_name( 'text' ) . '" id="' . $this->get_field_id( 'text' ) . '">';
  1339. if ( ! empty( $instance['text'] ) ) {
  1340. echo htmlspecialchars_decode( $instance['text'] );
  1341. }
  1342. echo '</textarea>';
  1343. echo '</p>';
  1344. echo '<p>';
  1345. echo '<label for="' . $this->get_field_id( 'image_uri' ) . '">' . __( 'Image', 'zerif-lite' ) . '</label><br/>';
  1346.  
  1347. $image_in_customizer = '';
  1348. $display = 'none';
  1349. if ( ! empty( $instance['image_in_customizer'] ) && ! empty( $instance['image_uri'] ) ) {
  1350. $image_in_customizer = esc_url( $instance['image_in_customizer'] );
  1351. $display = 'inline-block';
  1352. } else {
  1353. if ( ! empty( $instance['image_uri'] ) ) {
  1354. $image_in_customizer = esc_url( $instance['image_uri'] );
  1355. $display = 'inline-block';
  1356. }
  1357. }
  1358. $zerif_image_in_customizer = $this->get_field_name( 'image_in_customizer' );
  1359.  
  1360. echo '<input type="hidden" class="custom_media_display_in_customizer" name="';
  1361. if ( ! empty( $zerif_image_in_customizer ) ) {
  1362. echo $zerif_image_in_customizer;
  1363. }
  1364. echo '" value="';
  1365. if ( ! empty( $instance['image_in_customizer'] ) ) {
  1366. echo $instance['image_in_customizer'];
  1367. }
  1368. echo '">';
  1369. echo '<img class="custom_media_image" src="' . $image_in_customizer . '" style="margin:0;padding:0;max-width:100px;float:left;display:' . $display . '" alt="' . __( 'Uploaded image', 'zerif-lite' ) . '"/><br/>';
  1370.  
  1371. echo '<input type="text" class="widefat custom_media_url" name="' . $this->get_field_name( 'image_uri' ) . '" id="' . $this->get_field_id( 'image_uri' ) . '" value="';
  1372. if ( ! empty( $instance['image_uri'] ) ) {
  1373. echo $instance['image_uri'];
  1374. }
  1375. echo '" style="margin-top:5px;">';
  1376.  
  1377. echo '<input type="button" class="button button-primary custom_media_button" id="custom_media_button" name="' . $this->get_field_name( 'image_uri' ) . '" value="' . __( 'Upload Image', 'zerif-lite' ) . '" style="margin-top:5px;">';
  1378. echo '</p>';
  1379.  
  1380. echo '<input class="custom_media_id" id="' . $this->get_field_id( 'custom_media_id' ) . '" name="' . $this->get_field_name( 'custom_media_id' ) . '" type="hidden" value="';
  1381. if ( ! empty( $instance['custom_media_id'] ) ) {
  1382. echo $instance['custom_media_id'];
  1383. }
  1384. echo '"/>';
  1385.  
  1386. }
  1387.  
  1388. }
  1389. }
  1390.  
  1391. if ( ! class_exists( 'zerif_clients_widget' ) && zerif_check_if_old_version_of_theme() ) {
  1392.  
  1393. /**
  1394. * Clients widget
  1395. */
  1396. class zerif_clients_widget extends WP_Widget {
  1397.  
  1398. /**
  1399. * Constructor
  1400. */
  1401. public function __construct() {
  1402. parent::__construct(
  1403. 'zerif_clients-widget',
  1404. __( 'Zerif - Clients widget', 'zerif-lite' ),
  1405. array(
  1406. 'customize_selective_refresh' => true,
  1407. )
  1408. );
  1409. add_action( 'admin_enqueue_scripts', array( $this, 'widget_scripts' ) );
  1410. }
  1411.  
  1412. /**
  1413. * Enqueue widgets scripts
  1414. */
  1415. function widget_scripts( $hook ) {
  1416. if ( $hook != 'widgets.php' ) {
  1417. return;
  1418. }
  1419. wp_enqueue_media();
  1420. wp_enqueue_script( 'zerif_widget_media_script', get_template_directory_uri() . '/js/widget-media.js', false, '1.1', true );
  1421. }
  1422.  
  1423. /**
  1424. * Widget instance
  1425. */
  1426. function widget( $args, $instance ) {
  1427.  
  1428. echo $args['before_widget'];
  1429.  
  1430. echo '<a href="';
  1431.  
  1432. if ( ! empty( $instance['link'] ) ) {
  1433. echo apply_filters( 'widget_title', $instance['link'] );
  1434. }
  1435. echo '">';
  1436.  
  1437. if ( ! empty( $instance['image_uri'] ) && ( preg_match( '/(\.jpg|\.png|\.jpeg|\.gif|\.bmp)$/', $instance['image_uri'] ) ) ) {
  1438. echo '<img src="' . esc_url( $instance['image_uri'] ) . '" alt="' . __( 'Client', 'zerif-lite' ) . '">';
  1439.  
  1440. } elseif ( ! empty( $instance['custom_media_id'] ) ) {
  1441.  
  1442. $zerif_clients_custom_media_id = wp_get_attachment_image_url( $instance['custom_media_id'] );
  1443. if ( ! empty( $zerif_clients_custom_media_id ) ) {
  1444.  
  1445. echo '<img src="' . esc_url( $zerif_clients_custom_media_id ) . '" alt="' . __( 'Client', 'zerif-lite' ) . '">';
  1446.  
  1447. }
  1448. }
  1449.  
  1450. echo '</a>';
  1451.  
  1452. echo $args['after_widget'];
  1453.  
  1454. }
  1455.  
  1456. /**
  1457. * Update the widget
  1458. */
  1459. function update( $new_instance, $old_instance ) {
  1460.  
  1461. $instance = $old_instance;
  1462.  
  1463. $instance['link'] = esc_url( $new_instance['link'] );
  1464.  
  1465. $instance['image_uri'] = esc_url( $new_instance['image_uri'] );
  1466.  
  1467. $instance['image_in_customizer'] = esc_url( $new_instance['image_in_customizer'] );
  1468.  
  1469. $instance['custom_media_id'] = sanitize_text_field( $new_instance['custom_media_id'] );
  1470.  
  1471. return $instance;
  1472.  
  1473. }
  1474.  
  1475. /**
  1476. * Form the widget
  1477. */
  1478. function form( $instance ) {
  1479.  
  1480. echo '<p>';
  1481. echo '<label for="' . $this->get_field_id( 'link' ) . '">' . __( 'Link', 'zerif-lite' ) . '</label><br/>';
  1482. echo '<input type="text" name="' . $this->get_field_name( 'link' ) . '" id="' . $this->get_field_id( 'link' ) . '" value="';
  1483. if ( ! empty( $instance['link'] ) ) {
  1484. echo $instance['link'];
  1485. }
  1486. echo '" class="widefat">';
  1487. echo '</p>';
  1488. echo '<p>';
  1489. echo '<label for="' . $this->get_field_id( 'image_uri' ) . '">' . __( 'Image', 'zerif-lite' ) . '</label><br/>';
  1490.  
  1491. $image_in_customizer = '';
  1492. $display = 'none';
  1493. if ( ! empty( $instance['image_in_customizer'] ) && ! empty( $instance['image_uri'] ) ) {
  1494. $image_in_customizer = esc_url( $instance['image_in_customizer'] );
  1495. $display = 'inline-block';
  1496. } else {
  1497. if ( ! empty( $instance['image_uri'] ) ) {
  1498. $image_in_customizer = esc_url( $instance['image_uri'] );
  1499. $display = 'inline-block';
  1500. }
  1501. }
  1502. $zerif_image_in_customizer = $this->get_field_name( 'image_in_customizer' );
  1503.  
  1504. echo '<input type="hidden" class="custom_media_display_in_customizer" name="';
  1505. if ( ! empty( $zerif_image_in_customizer ) ) {
  1506. echo $zerif_image_in_customizer;
  1507. }
  1508. echo '" value="';
  1509.  
  1510. if ( ! empty( $instance['image_in_customizer'] ) ) {
  1511. echo $instance['image_in_customizer'];
  1512. }
  1513. echo '">';
  1514.  
  1515. echo '<img class="custom_media_image" src="' . $image_in_customizer . '" style="margin:0;padding:0;max-width:100px;float:left;display:' . $display . '" alt="' . __( 'Uploaded image', 'zerif-lite' ) . '"/><br/>';
  1516.  
  1517. echo '<input type="text" class="widefat custom_media_url" name="' . $this->get_field_name( 'image_uri' ) . '" id="' . $this->get_field_id( 'image_uri' ) . '" value="';
  1518. if ( ! empty( $instance['image_uri'] ) ) {
  1519. echo $instance['image_uri'];
  1520. }
  1521. echo '" style="margin-top:5px;">';
  1522.  
  1523. echo '<input type="button" class="button button-primary custom_media_button" id="custom_media_button" name="' . $this->get_field_name( 'image_uri' ) . '" value="' . __( 'Upload Image', 'zerif-lite' ) . '" style="margin-top:5px;">';
  1524. echo '</p>';
  1525.  
  1526. echo '<input class="custom_media_id" id="' . $this->get_field_id( 'custom_media_id' ) . '" name="' . $this->get_field_name( 'custom_media_id' ) . '" type="hidden" value="';
  1527. if ( ! empty( $instance['custom_media_id'] ) ) {
  1528. echo $instance['custom_media_id'];
  1529. }
  1530. echo '"/>';
  1531. }
  1532.  
  1533. }
  1534. }
  1535.  
  1536. if ( ! class_exists( 'zerif_team_widget' ) && zerif_check_if_old_version_of_theme() ) {
  1537.  
  1538. /**
  1539. * Team member widget
  1540. */
  1541. class zerif_team_widget extends WP_Widget {
  1542.  
  1543. /**
  1544. * Constructor.
  1545. */
  1546. public function __construct() {
  1547. parent::__construct(
  1548. 'zerif_team-widget',
  1549. __( 'Zerif - Team member widget', 'zerif-lite' ),
  1550. array(
  1551. 'customize_selective_refresh' => true,
  1552. )
  1553. );
  1554. add_action( 'admin_enqueue_scripts', array( $this, 'widget_scripts' ) );
  1555. }
  1556.  
  1557. /**
  1558. * Enqueue widget scripts
  1559. */
  1560. function widget_scripts( $hook ) {
  1561. if ( $hook != 'widgets.php' ) {
  1562. return;
  1563. }
  1564. wp_enqueue_media();
  1565. wp_enqueue_script( 'zerif_widget_media_script', get_template_directory_uri() . '/js/widget-media.js', false, '1.1', true );
  1566. }
  1567.  
  1568. /**
  1569. * Instance widget
  1570. */
  1571. function widget( $args, $instance ) {
  1572.  
  1573. echo $args['before_widget'];
  1574.  
  1575. echo '<div class="col-lg-3 col-sm-3 team-box">';
  1576.  
  1577. echo '<div class="team-member" tabindex="0">';
  1578.  
  1579. if ( ! empty( $instance['image_uri'] ) && ( preg_match( '/(\.jpg|\.png|\.jpeg|\.gif|\.bmp)$/', $instance['image_uri'] ) ) ) {
  1580.  
  1581. echo '<figure class="profile-pic">';
  1582.  
  1583. echo '<img src="' . esc_url( $instance['image_uri'] ) . '" alt=""/>';
  1584.  
  1585. echo '</figure>';
  1586.  
  1587. } elseif ( ! empty( $instance['custom_media_id'] ) ) {
  1588.  
  1589. $zerif_team_custom_media_id = wp_get_attachment_image_url( $instance['custom_media_id'] );
  1590. $alt = get_post_meta( $instance['custom_media_id'], '_wp_attachment_image_alt', true );
  1591.  
  1592. if ( ! empty( $zerif_team_custom_media_id ) ) {
  1593.  
  1594. echo '<figure class="profile-pic">';
  1595.  
  1596. echo '<img src="' . esc_url( $zerif_team_custom_media_id ) . '" alt="' . esc_attr( $alt ) . '"/>';
  1597.  
  1598. echo '</figure>';
  1599. }
  1600. }
  1601.  
  1602. echo '<div class="member-details">';
  1603.  
  1604. if ( ! empty( $instance['name'] ) ) {
  1605.  
  1606. echo '<h3 class="dark-text red-border-bottom">' . apply_filters( 'widget_title', $instance['name'] ) . '</h3>';
  1607.  
  1608. }
  1609.  
  1610. if ( ! empty( $instance['position'] ) ) {
  1611.  
  1612. echo '<div class="position">' . htmlspecialchars_decode( apply_filters( 'widget_title', $instance['position'] ) ) . '</div>';
  1613.  
  1614. }
  1615.  
  1616. echo '</div>';
  1617.  
  1618. echo '<div class="social-icons">';
  1619.  
  1620. echo '<ul>';
  1621.  
  1622. $zerif_team_target = '_self';
  1623. if ( ! empty( $instance['open_new_window'] ) ) {
  1624. $zerif_team_target = '_blank';
  1625. }
  1626.  
  1627. if ( ! empty( $instance['fb_link'] ) ) {
  1628. echo '<li>';
  1629. echo '<a href="' . apply_filters( 'widget_title', $instance['fb_link'] ) . '" target="' . $zerif_team_target . '">';
  1630. if ( ! empty( $instance['name'] ) ) {
  1631.  
  1632. echo '<span class="sr-only">' . __( 'Facebook link', 'zerif-lite' ) . '</span>';
  1633.  
  1634. }
  1635. echo '<i class="fa fa-facebook"></i>';
  1636. echo '</a>';
  1637. echo '</li>';
  1638. }
  1639.  
  1640. if ( ! empty( $instance['tw_link'] ) ) {
  1641. echo '<li>';
  1642. echo '<a href="' . apply_filters( 'widget_title', $instance['tw_link'] ) . '" target="' . $zerif_team_target . '">';
  1643.  
  1644. if ( ! empty( $instance['name'] ) ) {
  1645. echo '<span class="sr-only">' . __( 'Twitter link', 'zerif-lite' ) . '</span>';
  1646. }
  1647. echo '<i class="fa fa-twitter"></i>';
  1648. echo '</a>';
  1649. echo '</li>';
  1650. }
  1651.  
  1652. if ( ! empty( $instance['bh_link'] ) ) {
  1653. echo '<li>';
  1654. echo '<a href="' . apply_filters( 'widget_title', $instance['bh_link'] ) . '" target="' . $zerif_team_target . '">';
  1655. if ( ! empty( $instance['name'] ) ) {
  1656. echo '<span class="sr-only">' . __( 'Behance link', 'zerif-lite' ) . '</span>';
  1657. }
  1658. echo '<i class="fa fa-behance"></i>';
  1659. echo '</a>';
  1660. echo '</li>';
  1661. }
  1662.  
  1663. if ( ! empty( $instance['db_link'] ) ) {
  1664. echo '<li>';
  1665. echo '<a href="' . apply_filters( 'widget_title', $instance['db_link'] ) . '" target="' . $zerif_team_target . '">';
  1666. if ( ! empty( $instance['name'] ) ) {
  1667. echo '<span class="sr-only">' . __( 'Dribble link', 'zerif-lite' ) . '</span>';
  1668. }
  1669. echo '<i class="fa fa-dribbble"></i>';
  1670. echo '</a>';
  1671. echo '</li>';
  1672. }
  1673.  
  1674. if ( ! empty( $instance['ln_link'] ) ) {
  1675. echo '<li>';
  1676. echo '<a href="' . apply_filters( 'widget_title', $instance['ln_link'] ) . '" target="' . $zerif_team_target . '">';
  1677. if ( ! empty( $instance['name'] ) ) {
  1678. echo '<span class="sr-only">' . __( 'Linkedin link', 'zerif-lite' ) . '</span>';
  1679. }
  1680. echo '<i class="fa fa-linkedin"></i>';
  1681. echo '</a>';
  1682. echo '</li>';
  1683. }
  1684.  
  1685. echo '</ul>';
  1686.  
  1687. echo '</div>';
  1688.  
  1689. if ( ! empty( $instance['description'] ) ) {
  1690. echo '<div class="details">' . htmlspecialchars_decode( apply_filters( 'widget_title', $instance['description'] ) ) . '</div>';
  1691. }
  1692.  
  1693. echo '</div>';
  1694.  
  1695. echo '</div>';
  1696.  
  1697. echo $args['after_widget'];
  1698.  
  1699. }
  1700.  
  1701. /**
  1702. * Update the widget
  1703. */
  1704. function update( $new_instance, $old_instance ) {
  1705.  
  1706. $instance = $old_instance;
  1707.  
  1708. $instance['name'] = sanitize_text_field( $new_instance['name'] );
  1709. $instance['position'] = stripslashes( wp_filter_post_kses( $new_instance['position'] ) );
  1710. $instance['description'] = stripslashes( wp_filter_post_kses( $new_instance['description'] ) );
  1711. $instance['fb_link'] = esc_url( $new_instance['fb_link'] );
  1712. $instance['tw_link'] = esc_url( $new_instance['tw_link'] );
  1713. $instance['bh_link'] = esc_url( $new_instance['bh_link'] );
  1714. $instance['db_link'] = esc_url( $new_instance['db_link'] );
  1715. $instance['ln_link'] = esc_url( $new_instance['ln_link'] );
  1716. $instance['image_uri'] = esc_url( $new_instance['image_uri'] );
  1717. $instance['open_new_window'] = strip_tags( $new_instance['open_new_window'] );
  1718. $instance['custom_media_id'] = sanitize_text_field( $new_instance['custom_media_id'] );
  1719. $instance['image_in_customizer'] = esc_url( $new_instance['image_in_customizer'] );
  1720.  
  1721. return $instance;
  1722.  
  1723. }
  1724.  
  1725. /**
  1726. * Form the widget
  1727. */
  1728. function form( $instance ) {
  1729.  
  1730. echo '<p>';
  1731. echo '<label for="' . $this->get_field_id( 'name' ) . '">' . __( 'Name', 'zerif-lite' ) . '</label><br/>';
  1732. echo '<input type="text" name="' . $this->get_field_name( 'name' ) . '" id="' . $this->get_field_id( 'name' ) . '" value="';
  1733. if ( ! empty( $instance['name'] ) ) {
  1734. echo $instance['name'];
  1735. }
  1736. echo '" class="widefat"/>';
  1737. echo '</p>';
  1738. echo '<p>';
  1739. echo '<label for="' . $this->get_field_id( 'position' ) . '">' . __( 'Position', 'zerif-lite' ) . '</label><br/>';
  1740. echo '<textarea class="widefat" rows="8" cols="20" name="' . $this->get_field_name( 'position' ) . '" id="' . $this->get_field_id( 'position' ) . '">';
  1741. if ( ! empty( $instance['position'] ) ) {
  1742. echo htmlspecialchars_decode( $instance['position'] );
  1743. }
  1744. echo '</textarea>';
  1745. echo '</p>';
  1746. echo '<p>';
  1747. echo '<label for="' . $this->get_field_id( 'description' ) . '">' . __( 'Description', 'zerif-lite' ) . '</label><br/>';
  1748. echo '<textarea class="widefat" rows="8" cols="20" name="' . $this->get_field_name( 'description' ) . '" id="' . $this->get_field_id( 'description' ) . '">';
  1749. if ( ! empty( $instance['description'] ) ) {
  1750. echo htmlspecialchars_decode( $instance['description'] );
  1751. }
  1752. echo '</textarea>';
  1753. echo '</p>';
  1754. echo '<p>';
  1755. echo '<label for="' . $this->get_field_id( 'fb_link' ) . '">' . __( 'Facebook link', 'zerif-lite' ) . '</label><br/>';
  1756. echo '<input type="text" name="' . $this->get_field_name( 'fb_link' ) . '" id="' . $this->get_field_id( 'fb_link' ) . '" value="';
  1757. if ( ! empty( $instance['fb_link'] ) ) {
  1758. echo $instance['fb_link'];
  1759. }
  1760. echo '" class="widefat">';
  1761. echo '</p>';
  1762. echo '<p>';
  1763. echo '<label for="' . $this->get_field_id( 'tw_link' ) . '">' . __( 'Twitter link', 'zerif-lite' ) . '</label><br/>';
  1764. echo '<input type="text" name="' . $this->get_field_name( 'tw_link' ) . '" id="' . $this->get_field_id( 'tw_link' ) . '" value="';
  1765. if ( ! empty( $instance['tw_link'] ) ) {
  1766. echo $instance['tw_link'];
  1767. }
  1768. echo '" class="widefat">';
  1769. echo '</p>';
  1770. echo '<p>';
  1771. echo '<label for="' . $this->get_field_id( 'bh_link' ) . '">' . __( 'Behance link', 'zerif-lite' ) . '</label><br/>';
  1772. echo '<input type="text" name="' . $this->get_field_name( 'bh_link' ) . '" id="' . $this->get_field_id( 'bh_link' ) . '" value="';
  1773. if ( ! empty( $instance['bh_link'] ) ) {
  1774. echo $instance['bh_link'];
  1775. }
  1776. echo '" class="widefat">';
  1777. echo '</p>';
  1778. echo '<p>';
  1779. echo '<label for="' . $this->get_field_id( 'db_link' ) . '">' . __( 'Dribble link', 'zerif-lite' ) . '</label><br/>';
  1780. echo '<input type="text" name="' . $this->get_field_name( 'db_link' ) . '" id="' . $this->get_field_id( 'db_link' ) . '" value="';
  1781. if ( ! empty( $instance['db_link'] ) ) {
  1782. echo $instance['db_link'];
  1783. }
  1784. echo '" class="widefat">';
  1785. echo '</p>';
  1786. echo '<p>';
  1787. echo '<label for="' . $this->get_field_id( 'ln_link' ) . '">' . __( 'Linkedin link', 'zerif-lite' ) . '</label><br/>';
  1788. echo '<input type="text" name="' . $this->get_field_name( 'ln_link' ) . '" id="' . $this->get_field_id( 'ln_link' ) . '" value="';
  1789. if ( ! empty( $instance['ln_link'] ) ) {
  1790. echo $instance['ln_link'];
  1791. }
  1792. echo '" class="widefat">';
  1793. echo '</p>';
  1794. echo '<p>';
  1795. echo '<input type="checkbox" name="' . $this->get_field_name( 'open_new_window' ) . '" id="' . $this->get_field_id( 'open_new_window' ) . '"';
  1796. if ( ! empty( $instance['open_new_window'] ) ) {
  1797. checked( (bool) $instance['open_new_window'], true );
  1798. }
  1799. echo '>' . __( 'Open links in new window?', 'zerif-lite' ) . '<br>';
  1800. echo '</p>';
  1801.  
  1802. echo '<p>';
  1803. echo '<label for="' . $this->get_field_id( 'image_uri' ) . '">' . __( 'Image', 'zerif-lite' ) . '</label><br/>';
  1804.  
  1805. $image_in_customizer = '';
  1806. $display = 'none';
  1807. if ( ! empty( $instance['image_in_customizer'] ) && ! empty( $instance['image_uri'] ) ) {
  1808. $image_in_customizer = esc_url( $instance['image_in_customizer'] );
  1809. $display = 'inline-block';
  1810. } else {
  1811. if ( ! empty( $instance['image_uri'] ) ) {
  1812. $image_in_customizer = esc_url( $instance['image_uri'] );
  1813. $display = 'inline-block';
  1814. }
  1815. }
  1816. $zerif_image_in_customizer = $this->get_field_name( 'image_in_customizer' );
  1817.  
  1818. echo '<input type="hidden" class="custom_media_display_in_customizer" name="';
  1819. if ( ! empty( $zerif_image_in_customizer ) ) {
  1820. echo $zerif_image_in_customizer;
  1821. }
  1822. echo '" value="';
  1823. if ( ! empty( $instance['image_in_customizer'] ) ) {
  1824. echo $instance['image_in_customizer'];
  1825. }
  1826. echo '">';
  1827. echo '<img class="custom_media_image" src="' . $image_in_customizer . '" style="margin:0;padding:0;max-width:100px;float:left;display:' . $display . '" alt="' . __( 'Uploaded image', 'zerif-lite' ) . '"/><br/>';
  1828.  
  1829. echo '<input type="text" class="widefat custom_media_url" name="' . $this->get_field_name( 'image_uri' ) . '" id="' . $this->get_field_id( 'image_uri' ) . '" value="';
  1830. if ( ! empty( $instance['image_uri'] ) ) {
  1831. echo $instance['image_uri'];
  1832. }
  1833. echo '" style="margin-top:5px;">';
  1834.  
  1835. echo '<input type="button" class="button button-primary custom_media_button" id="custom_media_button" name="' . $this->get_field_name( 'image_uri' ) . '" value="' . __( 'Upload Image', 'zerif-lite' ) . '" style="margin-top:5px;">';
  1836. echo '</p>';
  1837.  
  1838. echo '<input class="custom_media_id" id="' . $this->get_field_id( 'custom_media_id' ) . '" name="' . $this->get_field_name( 'custom_media_id' ) . '" type="hidden" value="';
  1839. if ( ! empty( $instance['custom_media_id'] ) ) {
  1840. echo $instance['custom_media_id'];
  1841. }
  1842. echo '"/>';
  1843.  
  1844. }
  1845.  
  1846. }
  1847. }
  1848.  
  1849. /**
  1850. * Register CSS needed in customizer
  1851. */
  1852. function zerif_customizer_custom_css() {
  1853.  
  1854. wp_enqueue_style( 'zerif_customizer_custom_css', get_template_directory_uri() . '/css/zerif_customizer_custom_css.css' );
  1855.  
  1856. }
  1857. add_action( 'customize_controls_print_styles', 'zerif_customizer_custom_css' );
  1858.  
  1859. add_filter( 'body_class', 'remove_class_function' );
  1860.  
  1861. /**
  1862. * Remove custom-background from body_class()
  1863. */
  1864. function remove_class_function( $classes ) {
  1865.  
  1866. $zerif_keep_old_fp_template = get_theme_mod( 'zerif_keep_old_fp_template' );
  1867. /* For new users with static page */
  1868. if ( ! zerif_check_if_old_version_of_theme() && ( get_option( 'show_on_front' ) == 'page' ) && ! $zerif_keep_old_fp_template ) {
  1869. if ( ! is_front_page() && ! is_home() ) {
  1870. // index of custom-background
  1871. $key = array_search( 'custom-background', $classes );
  1872. // remove class
  1873. unset( $classes[ $key ] );
  1874. }
  1875. } else {
  1876. if ( ! is_home() && ! is_page_template( 'template-frontpage.php' ) ) {
  1877. // index of custom-background
  1878. $key = array_search( 'custom-background', $classes );
  1879. // remove class
  1880. unset( $classes[ $key ] );
  1881. }
  1882. }
  1883. return $classes;
  1884.  
  1885. }
  1886.  
  1887. add_action( 'customize_save_after', 'zerif_lite_update_options_in_pirate_forms', 99 );
  1888.  
  1889. /**
  1890. * Update Pirate Forms plugin when there is a change in Customizer Contact us section
  1891. */
  1892. function zerif_lite_update_options_in_pirate_forms() {
  1893.  
  1894. /* if Pirate Forms is installed */
  1895. if ( defined( 'PIRATE_FORMS_VERSION' ) ) :
  1896.  
  1897. $zerif_lite_current_mods = get_theme_mods(); /* all theme modification values in Customize for Zerif Lite */
  1898.  
  1899. $pirate_forms_settings_array = get_option( 'pirate_forms_settings_array' ); /* Pirate Forms's options's array */
  1900.  
  1901. if ( ! empty( $zerif_lite_current_mods ) ) :
  1902.  
  1903. if ( isset( $zerif_lite_current_mods['zerif_contactus_button_label'] ) ) :
  1904. $pirate_forms_settings_array['pirateformsopt_label_submit_btn'] = $zerif_lite_current_mods['zerif_contactus_button_label'];
  1905. endif;
  1906.  
  1907. if ( isset( $zerif_lite_current_mods['zerif_contactus_email'] ) ) :
  1908.  
  1909. $pirate_forms_settings_array['pirateformsopt_email'] = $zerif_lite_current_mods['zerif_contactus_email'];
  1910. $pirate_forms_settings_array['pirateformsopt_email_recipients'] = $zerif_lite_current_mods['zerif_contactus_email'];
  1911.  
  1912. endif;
  1913.  
  1914. if ( isset( $zerif_lite_current_mods['zerif_contactus_recaptcha_show'] ) && ( $zerif_lite_current_mods['zerif_contactus_recaptcha_show'] == 1 ) ) :
  1915. if ( isset( $pirate_forms_settings_array['pirateformsopt_recaptcha_field'] ) ) :
  1916. unset( $pirate_forms_settings_array['pirateformsopt_recaptcha_field'] );
  1917. endif;
  1918. else :
  1919. $pirate_forms_settings_array['pirateformsopt_recaptcha_field'] = 'yes';
  1920. endif;
  1921.  
  1922. if ( isset( $zerif_lite_current_mods['zerif_contactus_sitekey'] ) ) :
  1923. $pirate_forms_settings_array['pirateformsopt_recaptcha_sitekey'] = $zerif_lite_current_mods['zerif_contactus_sitekey'];
  1924. endif;
  1925.  
  1926. if ( isset( $zerif_lite_current_mods['zerif_contactus_secretkey'] ) ) :
  1927. $pirate_forms_settings_array['pirateformsopt_recaptcha_secretkey'] = $zerif_lite_current_mods['zerif_contactus_secretkey'];
  1928. endif;
  1929.  
  1930. endif;
  1931.  
  1932. if ( ! empty( $pirate_forms_settings_array ) ) :
  1933. update_option( 'pirate_forms_settings_array', $pirate_forms_settings_array ); /* Update the options */
  1934. endif;
  1935.  
  1936. endif;
  1937. }
  1938.  
  1939. /**
  1940. * Function to check if version 1.8.5 or less has been previously installed.
  1941. */
  1942. function zerif_check_if_old_version_of_theme() {
  1943.  
  1944. $old_zerif_option = get_theme_mod( 'zerif_bigtitle_title' );
  1945. $old_zerif_option_2 = get_theme_mod( 'zerif_bigtitle_redbutton_label' );
  1946. $old_zerif_option_3 = get_theme_mod( 'zerif_ourfocus_title' );
  1947.  
  1948. if ( ! empty( $old_zerif_option ) || ! empty( $old_zerif_option_2 ) || ! empty( $old_zerif_option_3 ) ) {
  1949. return true;
  1950. }
  1951. return false;
  1952. }
  1953.  
  1954. /**
  1955. * Add starter content for fresh sites
  1956. *
  1957. * @since 1.8.5.12
  1958. */
  1959. function zerif_starter_content() {
  1960. /*
  1961. * Starter Content Support
  1962. */
  1963. add_theme_support(
  1964. 'starter-content',
  1965. array(
  1966. // Twenty Seventeen
  1967. 'posts' => array(
  1968. 'home',
  1969. 'blog',
  1970. ),
  1971.  
  1972. 'nav_menus' => array(
  1973. 'primary' => array(
  1974. 'name' => __( 'Primary Menu', 'zerif-lite' ),
  1975. 'items' => array(
  1976. 'page_home',
  1977. 'page_blog',
  1978. ),
  1979. ),
  1980. ),
  1981.  
  1982. 'options' => array(
  1983. 'show_on_front' => 'page',
  1984. 'page_on_front' => '{{home}}',
  1985. 'page_for_posts' => '{{blog}}',
  1986. ),
  1987. )
  1988. );
  1989.  
  1990. }
  1991. add_action( 'after_setup_theme', 'zerif_starter_content' );
  1992.  
  1993. /**
  1994. * Save activation time.
  1995. */
  1996. function zerif_time_activated() {
  1997. update_option( 'zerif_time_activated', time() );
  1998. }
  1999. add_action( 'after_switch_theme', 'zerif_time_activated' );
  2000.  
  2001. /**
  2002. * BeaverBuilder Upgrade
  2003. */
  2004. function zerif_bb_upgrade_link() {
  2005. return 'https://www.wpbeaverbuilder.com/?fla=101&campaign=zf';
  2006. }
  2007.  
  2008. add_filter( 'fl_builder_upgrade_url', 'zerif_bb_upgrade_link' );
  2009.  
  2010.  
  2011. /**
  2012. * Check if $no_seconds have passed since theme was activated.
  2013. * Used to perform certain actions, like adding a new recommended action in About Zerif page.
  2014. *
  2015. * @since 1.8.5.31
  2016. * @access public
  2017. * @return bool
  2018. */
  2019. function zerif_check_passed_time( $no_seconds ) {
  2020. $activation_time = get_option( 'zerif_time_activated' );
  2021. if ( ! empty( $activation_time ) ) {
  2022. $current_time = time();
  2023. $time_difference = (int) $no_seconds;
  2024. if ( $current_time >= $activation_time + $time_difference ) {
  2025. return true;
  2026. } else {
  2027. return false;
  2028. }
  2029. }
  2030. return true;
  2031. }
  2032.  
  2033. add_action( 'woocommerce_before_checkout_form', 'zerif_coupon_after_order_table_js' );
  2034.  
  2035. /**
  2036. * Checkout page
  2037. * Move the coupon fild and message info after the order table
  2038. **/
  2039. function zerif_coupon_after_order_table_js() {
  2040. wc_enqueue_js(
  2041. '
  2042. $( $( "div.woocommerce-info, .checkout_coupon" ).detach() ).appendTo( "#zerif-checkout-coupon" );
  2043. '
  2044. );
  2045. }
  2046.  
  2047. add_action( 'woocommerce_checkout_order_review', 'zerif_coupon_after_order_table' );
  2048.  
  2049. /**
  2050. * Checkout page
  2051. * Add the id zerif-checkout-coupon to be able to Move the coupon fild and message info after the order table
  2052. **/
  2053. function zerif_coupon_after_order_table() {
  2054. echo '<div id="zerif-checkout-coupon"></div><div style="clear:both"></div>';
  2055. }
  2056.  
  2057. /**
  2058. * Max Mega Menu Zerif Theme
  2059. **/
  2060. function megamenu_add_theme_zerif_lite_max_menu( $themes ) {
  2061. $themes['zerif_lite_max_menu'] = array(
  2062. 'title' => 'Zerif Lite',
  2063. 'menu_item_align' => 'right',
  2064. 'menu_item_link_height' => '70px',
  2065. 'container_background_from' => 'rgb(255, 255, 255)',
  2066. 'container_background_to' => 'rgb(255, 255, 255)',
  2067. 'menu_item_background_hover_from' => 'rgb(255, 255, 255)',
  2068. 'menu_item_background_hover_to' => 'rgb(255, 255, 255)',
  2069. 'menu_item_link_font_size' => '15px',
  2070. 'menu_item_link_color' => 'rgb(49, 49, 49)',
  2071. 'menu_item_link_color_hover' => 'rgb(233, 102, 86)',
  2072. 'menu_item_highlight_current' => 'off',
  2073. 'panel_background_from' => 'rgb(255, 255, 255)',
  2074. 'panel_background_to' => 'rgb(255, 255, 255)',
  2075. 'panel_header_font_size' => '15px',
  2076. 'panel_header_font_weight' => 'normal',
  2077. 'panel_header_border_color' => '#555',
  2078. 'panel_font_size' => '15px',
  2079. 'panel_font_color' => 'rgb(49, 49, 49)',
  2080. 'panel_font_color_hover' => 'rgb(233, 102, 86)',
  2081. 'panel_font_family' => 'inherit',
  2082. 'panel_second_level_font_color' => 'rgb(49, 49, 49)',
  2083. 'panel_second_level_font_color_hover' => 'rgb(233, 102, 86)',
  2084. 'panel_second_level_text_transform' => 'none',
  2085. 'panel_second_level_font' => 'inherit',
  2086. 'panel_second_level_font_size' => '15px',
  2087. 'panel_second_level_font_weight' => 'normal',
  2088. 'panel_second_level_font_weight_hover' => 'normal',
  2089. 'panel_second_level_text_decoration' => 'none',
  2090. 'panel_second_level_text_decoration_hover' => 'none',
  2091. 'panel_second_level_padding_left' => '20px',
  2092. 'panel_second_level_border_color' => '#555',
  2093. 'panel_third_level_font_color' => 'rgb(49, 49, 49)',
  2094. 'panel_third_level_font_color_hover' => 'rgb(233, 102, 86)',
  2095. 'panel_third_level_font' => 'inherit',
  2096. 'panel_third_level_font_size' => '15px',
  2097. 'panel_third_level_padding_left' => '20px',
  2098. 'flyout_background_from' => 'rgb(255, 255, 255)',
  2099. 'flyout_background_to' => 'rgb(255, 255, 255)',
  2100. 'flyout_background_hover_from' => 'rgb(255, 255, 255)',
  2101. 'flyout_background_hover_to' => 'rgb(255, 255, 255)',
  2102. 'flyout_link_size' => '15px',
  2103. 'flyout_link_color' => 'rgb(49, 49, 49)',
  2104. 'flyout_link_color_hover' => 'rgb(233, 102, 86)',
  2105. 'flyout_link_family' => 'inherit',
  2106. 'responsive_breakpoint' => '768px',
  2107. 'resets' => 'on',
  2108. 'toggle_background_from' => '#222',
  2109. 'toggle_background_to' => '#222',
  2110. 'toggle_font_color' => 'rgb(102, 102, 102)',
  2111. 'mobile_background_from' => 'rgb(255, 255, 255)',
  2112. 'mobile_background_to' => 'rgb(255, 255, 255)',
  2113. 'mobile_menu_item_link_font_size' => '15px',
  2114. 'mobile_menu_item_link_color' => 'rgb(102, 102, 102)',
  2115. 'mobile_menu_item_link_text_align' => 'left',
  2116. );
  2117. return $themes;
  2118. }
  2119. add_filter( 'megamenu_themes', 'megamenu_add_theme_zerif_lite_max_menu' );
  2120.  
  2121.  
  2122. /**
  2123. * Function that decide if current date is before a certain date.
  2124. *
  2125. * @param string $date Date to compare.
  2126. * @return bool
  2127. */
  2128. function zerif_is_before_date( $date ) {
  2129. $countdown_time = strtotime( $date );
  2130. $current_time = time();
  2131. return $current_time <= $countdown_time;
  2132. }
  2133.  
  2134. /**
  2135. * Add a dismissible notice in the dashboard to let users know they can migrate to Hestia
  2136. */
  2137. function zerif_hestia_notice() {
  2138. global $current_user;
  2139. $user_id = $current_user->ID;
  2140.  
  2141. $ignored_notice = get_user_meta( $user_id, 'zerif_ignore_hestia_notice' );
  2142. if ( ! empty( $ignored_notice ) ) {
  2143. return;
  2144. }
  2145.  
  2146. $should_display_notice = zerif_is_before_date( '2018-11-01' );
  2147. if ( ! $should_display_notice ) {
  2148. return;
  2149. }
  2150.  
  2151. $message =
  2152. sprintf(
  2153. /* translators: Install Hestia link */
  2154. esc_html__( 'Check out our %s, fully compatible with your current Zerif Lite theme. You will love it!', 'zerif-lite' ),
  2155. sprintf(
  2156. '<a href="%1$s"><strong>%2$s</strong></a>',
  2157. admin_url( 'theme-install.php?theme=hestia' ),
  2158. esc_html__( 'best 2018 free theme', 'zerif-lite' )
  2159. )
  2160. );
  2161.  
  2162. $dismiss_button = sprintf(
  2163. '<a href="%s" class="notice-dismiss" style="text-decoration:none;"></a>',
  2164. '?zerif_nag_ignore_hestia=0'
  2165. );
  2166.  
  2167. printf( '<div class="notice updated" style="position:relative;">%1$s<p>%2$s</p></div>', $dismiss_button, $message );
  2168. }
  2169. add_action( 'admin_notices', 'zerif_hestia_notice' );
  2170.  
  2171.  
  2172. /**
  2173. * Update the zerif_ignore_hestia_notice option to true, to dismiss the notice from the dashboard
  2174. */
  2175. function zerif_nag_ignore_hestia() {
  2176. global $current_user;
  2177. $user_id = $current_user->ID;
  2178. /* If user clicks to ignore the notice, add that to their user meta */
  2179. if ( isset( $_GET['zerif_nag_ignore_hestia'] ) && '0' == $_GET['zerif_nag_ignore_hestia'] ) {
  2180. add_user_meta( $user_id, 'zerif_ignore_hestia_notice', 'true', true );
  2181. }
  2182. }
  2183. add_action( 'admin_init', 'zerif_nag_ignore_hestia' );
  2184.  
  2185. /**
  2186. * Add a dismissible notice in the dashboard to let users know they can migrate to Zelle and read about Zerif renaming
  2187. */
  2188. function zerif_neve_notice() {
  2189. global $current_user;
  2190. $user_id = $current_user->ID;
  2191.  
  2192. $ignored_notice = get_user_meta( $user_id, 'zerif_ignore_neve_notice' );
  2193. if ( ! empty( $ignored_notice ) ) {
  2194. return;
  2195. }
  2196.  
  2197. $should_display_notice = ! zerif_is_before_date( '2018-11-01' );
  2198. if ( ! $should_display_notice ) {
  2199. return;
  2200. }
  2201.  
  2202. $dismiss_button =
  2203. sprintf(
  2204. '<a href="%s" class="notice-dismiss" style="text-decoration:none;"></a>',
  2205. '?zerif_nag_ignore_neve=0'
  2206. );
  2207.  
  2208. $message =
  2209. sprintf(
  2210. /* translators: Install Neve link and Zerif renaming article link */
  2211. esc_html__( 'Zerif changes its name and will no longer be maintained. But don\'t worry about that. Check out %1$s, fully compatible with Zerif Lite. It\'s free and it\'s superb. You will love it! %2$s about the Zerif renaming and our next plans.', 'zerif-lite' ),
  2212. sprintf(
  2213. /* translators: Install Neve link */
  2214. '<a target="_blank" href="%1$s"><strong>%2$s</strong></a>',
  2215. esc_url( 'https://themeisle.com/themes/neve/?notice=1' ),
  2216. esc_html__( 'our newest theme', 'zerif-lite' )
  2217. ),
  2218. /* translators: Zerif renaming article link */
  2219. sprintf(
  2220. '<br><a target="_blank" href="%1$s"><strong>%2$s</strong></a>',
  2221. esc_url( 'https://themeisle.com/blog/zerif-changes-its-name-to-zelle/' ),
  2222. esc_html__( 'Read more', 'zerif-lite' )
  2223. )
  2224. );
  2225.  
  2226. printf(
  2227. '<div class="notice updated" style="position:relative;">%1$s<p>%2$s</p></div>',
  2228. $dismiss_button,
  2229. $message
  2230. );
  2231. }
  2232. add_action( 'admin_notices', 'zerif_neve_notice' );
  2233.  
  2234. /**
  2235. * Update the zerif_ignore_hestia_notice option to true, to dismiss the notice from the dashboard
  2236. */
  2237. function zerif_nag_ignore_neve() {
  2238. global $current_user;
  2239. $user_id = $current_user->ID;
  2240. /* If user clicks to ignore the notice, add that to their user meta */
  2241. if ( isset( $_GET['zerif_nag_ignore_neve'] ) && '0' == $_GET['zerif_nag_ignore_neve'] ) {
  2242. add_user_meta( $user_id, 'zerif_ignore_neve_notice', 'true', true );
  2243. }
  2244. }
  2245. add_action( 'admin_init', 'zerif_nag_ignore_neve' );
  2246.  
  2247.  
  2248.  
  2249.  
  2250.  
  2251. // FUNZIONI CUSTOM - Danilo Drago
  2252.  
  2253.  
  2254. // Personalizzazione messaggio richiesta ricevuta
  2255. add_filter( 'woocommerce_endpoint_order-received_title', 'misha_thank_you_title' );
  2256. function misha_thank_you_title( $old_title ){
  2257. return 'Richiesta ricevuta. Grazie.';
  2258. }
  2259.  
  2260.  
  2261.  
  2262. // Personalizzazione limita i prodotti correlati a 6
  2263. function woo_related_products_limit() {
  2264. global $product;
  2265. $args['posts_per_page'] = 6;
  2266. return $args;
  2267. }
  2268. add_filter( 'woocommerce_output_related_products_args', 'jk_related_products_args', 20 );
  2269. function jk_related_products_args( $args ) {
  2270. $args['posts_per_page'] = 6; // 6 related products
  2271. $args['columns'] = 6; // arranged in 6 columns
  2272. return $args;
  2273. }
  2274.  
  2275.  
  2276. // Personalizzazione caselle prodotto virtuale scaricabile flaggate di default
  2277. add_filter( 'product_type_options', 'autocheck_vd');
  2278. function autocheck_vd( $arr ){
  2279. $arr['virtual'] ['default'] = "yes";
  2280. $arr['downloadable']['default'] = "yes";
  2281. return $arr;
  2282. }
  2283.  
  2284.  
  2285.  
  2286. // Personalizzazione messaggio di benvenuto al login sotto testata
  2287. function my_render_wc_login_form( $atts ) {
  2288. if ( ! is_user_logged_in() ) {
  2289. if ( function_exists( 'woocommerce_login_form' ) &&
  2290. function_exists( 'woocommerce_output_all_notices' ) ) {
  2291. //render the WooCommerce login form
  2292. ob_start();
  2293. woocommerce_output_all_notices();
  2294. woocommerce_login_form();
  2295. return ob_get_clean();
  2296. } else {
  2297. //render the WordPress login form
  2298. return wp_login_form( array( 'echo' => false ));
  2299. }
  2300. } else {
  2301. return "Salve. Bentornato/a";
  2302. }
  2303. }
  2304. add_shortcode( 'my_wc_login_form', 'my_render_wc_login_form' );
  2305.  
  2306.  
  2307.  
  2308. // Personalizzazione eliminazione campi del checkout
  2309. add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
  2310. function custom_override_checkout_fields( $fields ) {
  2311. unset($fields['billing']['billing_first_name']);
  2312. unset($fields['billing']['billing_last_name']);
  2313. unset($fields['billing']['billing_company']);
  2314. unset($fields['billing']['billing_address_1']);
  2315. unset($fields['billing']['billing_address_2']);
  2316. unset($fields['billing']['billing_city']);
  2317. unset($fields['billing']['billing_postcode']);
  2318. unset($fields['billing']['billing_country']);
  2319. unset($fields['billing']['billing_state']);
  2320. unset($fields['billing']['billing_phone']);
  2321. unset($fields['order']['order_comments']);
  2322. unset($fields['billing']['billing_address_2']);
  2323. unset($fields['billing']['billing_postcode']);
  2324. unset($fields['billing']['billing_company']);
  2325. unset($fields['billing']['billing_last_name']);
  2326. unset($fields['billing']['billing_email']);
  2327. unset($fields['billing']['billing_city']);
  2328. return $fields;
  2329. }
  2330.  
  2331.  
  2332.  
  2333.  
  2334. // Personalizzazione se utente non loggato redirect al login form
  2335. function woo_login_redirect() {
  2336. if (
  2337. ! is_user_logged_in() && (is_woocommerce() || is_cart() || is_checkout())
  2338. ) {
  2339. wp_redirect( '/accedi-registrati/' );
  2340. exit;
  2341. }
  2342. }
  2343. add_action('template_redirect', 'woo_login_redirect');
  2344.  
  2345.  
  2346.  
  2347.  
  2348. // Personalizzazione cambia il nome di download di default SCARICA
  2349. function change_woocommerce_file_download_filename( $filename, $product_id ) {
  2350. // Get the file extension from the processed file name.
  2351. $filetype = wp_check_filetype( $filename );
  2352. // You can generate a new file using Product ID if you need to.
  2353. $new_file_name = 'Scarica';
  2354. // Join the new file name with file extension with (.).
  2355. return join( '.', array( $new_file_name, $filetype['ext'] ) );
  2356. }
  2357. add_filter( 'woocommerce_file_download_filename', 'change_woocommerce_file_download_filename', 10, 2 );
  2358. function cs_wc_product_type_options( $product_type_options ) {
  2359. $product_type_options['virtual']['default'] = 'yes';
  2360. $product_type_options['downloadable']['default'] = 'yes';
  2361. return $product_type_options;
  2362. }
  2363.  
  2364.  
  2365.  
  2366.  
  2367. // Personalizzazione rimuovi metabox per galleria immagini su singolo prodotto
  2368. add_action( 'add_meta_boxes' , 'remove_my_meta_boxes', 40 );
  2369. function remove_my_meta_boxes()
  2370. {
  2371. remove_meta_box( 'woocommerce-product-images', 'product', 'side');
  2372. }
  2373.  
  2374.  
  2375.  
  2376.  
  2377.  
  2378.  
  2379.  
  2380.  
  2381. // Personalizzazione rimuovi zoom su immagine singolo prodotto
  2382. add_action( 'wp', 'njengah_remove_zoom_effect_theme_support', 99 );
  2383. function njengah_remove_zoom_effect_theme_support() {
  2384. remove_theme_support( 'wc-product-gallery-zoom' );
  2385. remove_theme_support( 'wc-product-gallery-lightbox' );
  2386. remove_theme_support( 'wc-product-gallery-slider' );
  2387. }
  2388.  
  2389. // Personalizzazione rimuovi link su immagine singolo prodotto
  2390. function e12_remove_product_image_link( $html, $post_id ) {
  2391. return preg_replace( "!<(a|/a).*?>!", '', $html );
  2392. }
  2393. add_filter( 'woocommerce_single_product_image_thumbnail_html', 'e12_remove_product_image_link', 10, 2 );
  2394.  
  2395.  
  2396.  
  2397.  
  2398. // Personalizzazione short description singolo prodotto
  2399. add_action( 'woocommerce_after_shop_loop_item_title', 'custom_short_description', 45 );
  2400. function custom_short_description() {
  2401. global $product;
  2402. echo '<div class="custom-short-description">' . $product->get_short_description() . '</div>';
  2403. }
  2404.  
  2405.  
  2406.  
  2407. // Personalizzazione mostra le sottocategorie su singolo prodotto
  2408. add_action( 'woocommerce_after_shop_loop_item_title', 'bbloomer_show_all_subcats', 4 );
  2409. function bbloomer_show_all_subcats() {
  2410. global $product;
  2411. $cats = get_the_terms( $product->get_id(), 'product_cat' );
  2412. if ( empty( $cats ) ) return;
  2413. foreach ( $cats as $term ) {
  2414. // If parent cat ID = 783 echo subcat name...
  2415. if ( $term->parent == 783 ) {
  2416. echo $term->name . ' ';
  2417. }
  2418. }
  2419. }
  2420.  
  2421.  
  2422.  
  2423.  
  2424.  
  2425. // Personalizzazione tag su loop prodotti
  2426. add_action( 'woocommerce_after_shop_loop_item', 'woocommerce_product_loop_tags', 5 );
  2427. function woocommerce_product_loop_tags() {
  2428. global $post, $product;
  2429. $tag_count = sizeof( get_the_terms( $post->ID, 'product_tag' ) );
  2430. echo $product->get_tags( ', ', '<span class="tagged_as tag_in_loop">' . _n( ' ', ' ', $tag_count, 'woocommerce' ) . ' ', '.</span><br>' );
  2431. }
  2432.  
  2433. // Personalizzazione messaggio view cart = vai alla richiesta
  2434. add_filter( 'gettext', function( $translated_text ) {
  2435. if ( 'View cart' === $translated_text ) {
  2436. $translated_text = 'Vai alla richiesta';
  2437. }
  2438. return $translated_text;
  2439. } );
  2440.  
  2441.  
  2442.  
  2443.  
  2444. // Personalizzazione menu su pagina il mio account
  2445. add_filter ( 'woocommerce_account_menu_items', 'misha_remove_my_account_links' );
  2446. function misha_remove_my_account_links( $menu_links ){
  2447. unset( $menu_links['dashboard'] ); // Remove Dashboard
  2448. unset( $menu_links['payment-methods'] ); // Remove Payment Methods
  2449. unset( $menu_links['orders'] ); // Remove Orders
  2450. unset( $menu_links['edit-address'] ); // Addresses
  2451. //unset( $menu_links['downloads'] ); // Disable Downloads
  2452. //unset( $menu_links['edit-account'] ); // Remove Account details tab
  2453. //unset( $menu_links['customer-logout'] ); // Remove Logout link
  2454. return $menu_links;
  2455. }
  2456.  
  2457.  
  2458.  
  2459.  
  2460. // Personalizzazione messaggio added to cart=base aggiunta...
  2461. add_filter( 'wc_add_to_cart_message_html', 'njengah_custom_added_to_cart_message' );
  2462. function njengah_custom_added_to_cart_message() {
  2463. $message = 'Base aggiunta, vai alla richiesta!' ;
  2464. return $message;
  2465. }
  2466.  
  2467.  
  2468.  
  2469.  
  2470. // Personalizzazione aggiunta campo privacy al form commenti
  2471. add_action( 'comment_form_logged_in_after', 'comment_form_additional_fields' );
  2472. add_action( 'comment_form_after_fields', 'comment_form_additional_fields' );
  2473. function comment_form_additional_fields() {
  2474. $commenter = wp_get_current_commenter();
  2475. $req = get_option( 'require_name_email' );
  2476. $aria_req = ( $req ? " aria-required='true'" : '' );
  2477. echo '<p class="privacy-container"><input id="privacy" name="privacy" type="checkbox"' . $aria_req . ' value="si"><small> <a href="' . get_theme_mod('cabi_privacy') . '">' . __('Ho letto la privacy policy</a> ed accetto il trattamento dei dati personali in accordo con il DL 196/2003.') . '</small></p>';
  2478. }
  2479. //salva il valore del campo privacy come meta del commento
  2480. add_action( 'comment_post', 'save_comment_form_additional_fields' );
  2481. function save_comment_form_additional_fields($comment_id) {
  2482. if (isset($_POST['privacy']) && $_POST['privacy'] == 'si') {
  2483. $privacy = wp_filter_nohtml_kses($_POST['privacy']);
  2484. add_comment_meta($comment_id, 'privacy', $privacy);
  2485. }
  2486. }
  2487. //impedisce il salvataggio del commento se non è stato flaggato il checkbox privacy
  2488. //questa funzione è un fallback se non è attivo javascript
  2489. add_filter( 'preprocess_comment', 'verify_comment_form_data' );
  2490. function verify_comment_form_data($commentdata) {
  2491. if (!isset($_POST['privacy']) || $_POST['privacy'] != 'si')
  2492. wp_die( __( '<strong>Errore</strong>: Devi accettare la privacy policy per procedere. Ritenta.' ) );
  2493. return $commentdata;
  2494. }
  2495. //impedisce l'invio del form dei commenti se non si flagga la checkbox privacy
  2496. add_action('wp_footer','validate_privacy_comment_form_javascript');
  2497. function validate_privacy_comment_form_javascript(){
  2498. if (is_single() && comments_open()){
  2499. ?>
  2500. <script type="text/javascript">
  2501. jQuery(document).ready(function($){
  2502. $(".comment-form #submit").on('click', function(e){
  2503. if (!$('#privacy').is(':checked')){
  2504. e.preventDefault();
  2505. return false;
  2506. }
  2507. });
  2508. });
  2509. </script>
  2510. <?php
  2511. }
  2512. }
  2513. //aggiunge un metabox al template dei commenti nel backend
  2514. add_action( 'add_meta_boxes_comment', 'extend_comment_add_meta_box' );
  2515. function extend_comment_add_meta_box() {
  2516. add_meta_box( 'comment_meta_box', __( 'Additional fields' ), 'extend_comment_meta_box', 'comment', 'normal', 'high' );
  2517. }
  2518. //recupera i dati e li mostro nel metabox
  2519. function extend_comment_meta_box($comment) {
  2520. $privacy = get_comment_meta( $comment->comment_ID, 'privacy', true );
  2521. //aggiungo al metabox un campo nascosto con valore random
  2522. wp_nonce_field( 'extend_comment_update', 'extend_comment_update', false );
  2523. ?>
  2524. <p>
  2525. <?php _e('Privacy policy') ?>
  2526. <input type="checkbox" id="privacy" name="privacy" <?php if ($privacy && $privacy == 'si') echo "checked=\"checked\" value=\"{$privacy}\"" ?>>
  2527. </p>
  2528. <?php
  2529. }
  2530. //salva i dati aggiuntivi del metabox
  2531. add_action( 'edit_comment', 'save_extended_comment_data' );
  2532. function save_extended_comment_data($comment_id) {
  2533. //se non ricevo il campo nascosto di sicurezza non eseguo l'aggiornamento
  2534. if(!isset($_POST['extend_comment_update']) || !wp_verify_nonce($_POST['extend_comment_update'], 'extend_comment_update')) return;
  2535. if (isset($_POST['privacy']) && $_POST['privacy'] == 'on') {
  2536. //$privacy = wp_filter_nohtml_kses($_POST['privacy']);
  2537. update_comment_meta( $comment_id, 'privacy', 'si');
  2538. } else {
  2539. update_comment_meta( $comment_id, 'privacy', 'no');
  2540. }
  2541. }
  2542. function mytheme_comment($comment, $args, $depth) {
  2543. if ( 'div' === $args['style'] ) {
  2544. $tag = 'div';
  2545. $add_below = 'comment';
  2546. } else {
  2547. $tag = 'li';
  2548. $add_below = 'div-comment';
  2549. }?>
  2550. <<?php echo $tag; ?> <?php comment_class( empty( $args['has_children'] ) ? '' : 'parent' ); ?> id="comment-<?php comment_ID() ?>"><?php
  2551. if ( 'div' != $args['style'] ) { ?>
  2552. <div id="div-comment-<?php comment_ID() ?>" class="comment-body newcomment1"><?php
  2553. } ?>
  2554. <div class="comment-meta commentmetadata newcomment3">
  2555. <a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ); ?>">
  2556. <?php
  2557. /* translators: 1: date, 2: time */
  2558. printf(
  2559. __('Il %1$s alle %2$s'),
  2560. get_comment_date(),
  2561. get_comment_time()
  2562. ); ?>
  2563. </a>
  2564. <div class="comment-author vcard newcomment2"><?php
  2565. if ( $args['avatar_size'] != 0 ) {
  2566. echo get_avatar( $comment, $args['avatar_size'] );
  2567. }
  2568. printf( __( '<cite class="fn">%s</cite> <span class="says">ha detto:</span>' ), get_comment_author_link() ); ?>
  2569. </div>
  2570. <div class="testocommento"><p>"<?php echo get_comment_text(); ?>"</p></div>
  2571. <?php
  2572. if ( $comment->comment_approved == '0' ) { ?>
  2573. <em class="comment-awaiting-moderation"><?php _e( 'Il tuo commento è in attesa di approvazione.' ); ?></em><br/><?php
  2574. } ?>
  2575. <div class="comment-meta commentmetadata newcomment3">
  2576. <?php
  2577. edit_comment_link( __( '(Modifica questo commento)' ), ' ', '' ); ?>
  2578. </div>
  2579. <div class="reply newcomment4" style="display:block !important;">
  2580. <?php
  2581. comment_reply_link(
  2582. array_merge(
  2583. $args,
  2584. array(
  2585. 'add_below' => $add_below,
  2586. 'depth' => $depth,
  2587. 'max_depth' => $args['max_depth']
  2588. )
  2589. )
  2590. ); ?>
  2591. </div>
  2592. <?php
  2593. if ( 'div' != $args['style'] ) : ?>
  2594. </div><?php
  2595. endif;
  2596. }
  2597. function custom_comment_reply_link($content) {
  2598. $extra_classes = 'button button--small button--white';
  2599. return preg_replace( '/comment-reply-link/', 'comment-reply-link ' . $extra_classes, $content);
  2600. }
  2601. add_filter('comment_reply_link', 'custom_comment_reply_link', 99);
  2602.  
  2603.  
  2604.  
  2605.  
  2606.  
  2607. // Personalizzazione cambia intestazione tab description=elenco brani nei file zippati
  2608. add_filter( 'woocommerce_product_description_heading', 'isa_product_description_heading' );
  2609.  
  2610. function isa_product_description_heading() {
  2611. return 'Info aggiuntive';
  2612. }
  2613.  
  2614.  
  2615.  
  2616.  
  2617. // Personalizzazione prodotti correlati in base ai tag
  2618. add_filter( 'woocommerce_get_related_product_cat_terms', 'remove_related_product_categories', 10, 2 );
  2619. function remove_related_product_categories( $terms_ids, $product_id ){
  2620. return array();
  2621. }
  2622.  
  2623.  
  2624.  
  2625.  
  2626. // Personalizzazione cambia immagine placeholder in base alle categorie
  2627. // Pagina singolo prodotto
  2628. function filter_woocommerce_placeholder_img_src( $src ) {
  2629. // Load the WC logger
  2630. $logger = wc_get_logger();
  2631. // Get the global product object
  2632. global $product;
  2633. // Is a WC product
  2634. if ( is_a( $product, 'WC_Product' ) ) {
  2635. // Has term (product category)
  2636. if ( has_term( 'archivi', 'product_cat', $product->get_id() ) ) {
  2637. $src = 'https://www.love4music.it/wp-content/uploads/2021/08/music1.png';
  2638. } elseif ( has_term( array('zecchino-doro', 'cartoni-animati', 'canzoni-per-bambini'), 'product_cat', $product->get_id() ) ) {
  2639. $src = 'https://www.love4music.it/wp-content/uploads/2021/08/music3bambini.png';
  2640. }
  2641. elseif ( has_term( 'canti-religiosi', 'product_cat', $product->get_id() ) ) {
  2642. $src = 'https://www.love4music.it/wp-content/uploads/2021/08/music4religiosi.png';
  2643. }
  2644. }
  2645. return $src;
  2646. }
  2647. add_filter( 'woocommerce_placeholder_img_src', 'filter_woocommerce_placeholder_img_src', 10, 1 );
  2648. // Pagine archivio
  2649. function filter_woocommerce_placeholder_img ( $image_html, $size, $dimensions ) {
  2650. $dimensions = wc_get_image_size( $size );
  2651. $default_attr = array(
  2652. 'class' => 'woocommerce-placeholder wp-post-image',
  2653. 'alt' => __( 'Placeholder', 'woocommerce' ),
  2654. );
  2655. $attr = wp_parse_args( '', $default_attr );
  2656. $image = wc_placeholder_img_src( $size );
  2657. $hwstring = image_hwstring( $dimensions['width'], $dimensions['height'] );
  2658. $attributes = array();
  2659. foreach ( $attr as $name => $value ) {
  2660. $attribute[] = esc_attr( $name ) . '="' . esc_attr( $value ) . '"';
  2661. }
  2662. $image_html = '<img src="' . esc_url( $image ) . '" ' . $hwstring . implode( ' ', $attribute ) . '/>';
  2663. return $image_html;
  2664. }
  2665. add_filter( 'woocommerce_placeholder_img', 'filter_woocommerce_placeholder_img', 10, 3 );
  2666.  
  2667.  
  2668. // Personalizzazione cambia testo al pulsante se la base è già in richiesta
  2669. add_action( 'wp_footer', 'ajax_button_text_js_script' );
  2670. function ajax_button_text_js_script() {
  2671. $text = __('Base inserita', 'woocommerce');
  2672. ?>
  2673. <script>
  2674. jQuery(function($) {
  2675. var text = '<?php echo $text; ?>', $this;
  2676. $(document.body).on('click', '.ajax_add_to_cart', function(event){
  2677. $this = $(this); // Get button jQuery Object and set it in a variable
  2678. });
  2679. $(document.body).on('added_to_cart', function(event,b,data){
  2680. var buttonText = '<span class="add_to_cart_text product-is-added">'+text+'</span><i class="cart-icon pe-7s-cart"></i>';
  2681. // Change inner button html (with text) and Change "data-tip" attribute value
  2682. $this.html(buttonText).attr('data-tip',text);
  2683. });
  2684. });
  2685. </script>
  2686. <?php
  2687. }
  2688.  
  2689.  
  2690.  
  2691. remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 );
  2692.  
  2693.  
  2694.  
  2695. add_action( 'woocommerce_after_shop_loop_item_title', 'bbloomer_woocommerce_product_excerpt', 35 );
  2696. function bbloomer_woocommerce_product_excerpt() {
  2697. global $post;
  2698. if ( is_home() || is_shop() || is_product_category() || is_product_tag() ) {
  2699. echo '<span class="synchroby_" style="color: #fff; font-size: 14px; text-transform: capitalize;">';
  2700. echo get_post_meta( $post->ID, 'synchro', true );
  2701. echo '</span>';
  2702. }
  2703. }
  2704.  
  2705.  
  2706.  
  2707.  
  2708.  
  2709.  
  2710.  
  2711.  
  2712.  
  2713. /**
  2714. * Both funtions below work the same, they just apply to categories and tags respectively.
  2715. * They exclude the defined IDs from being included in related products in WooCommerce.
  2716. *
  2717. * Note: The results are initially cached, so add this and then clear transients before saying it doesn't work.
  2718. *
  2719. * @param [array] $categories/$tags The array of categories or tags that are being used for related products.
  2720. * @return [array] The filtered array of results.
  2721. */
  2722. function jp_exclude_categories_from_related( $categories ) {
  2723.  
  2724. // Define your category IDs you'd like to have excluded.
  2725. $exclude_cats = array( 2464 );
  2726. foreach( $categories as $index => $cat ){
  2727. if( in_array( $cat, $exclude_cats ) ){
  2728. unset( $categories[ $index ] );
  2729. }
  2730. }
  2731. return $categories;
  2732. }
  2733. add_filter( 'woocommerce_get_related_product_cat_terms', 'jp_exclude_categories_from_related' );
  2734. function jp_exclude_tags_from_related( $tags ) {
  2735.  
  2736. // Define your tag IDs you'd like to have excluded.
  2737. $exclude_tags = array( 1028, 1952, 799, 1624, 1448, 1447 );
  2738. foreach( $tags as $index => $tag ){
  2739. if( in_array( $tag, $exclude_tags ) ){
  2740. unset( $tags[ $index ] );
  2741. }
  2742. }
  2743. return $tags;
  2744. }
  2745. add_filter( 'woocommerce_get_related_product_tag_terms', 'jp_exclude_tags_from_related' );
  2746.  
  2747.  
  2748.  
  2749.  
  2750. //change text to leave a reply on comment form
  2751. function isa_comment_reform ($arg) {
  2752. $arg['title_reply'] = __('Lascia il tuo commento');
  2753. return $arg;
  2754. }
  2755. add_filter('comment_form_defaults','isa_comment_reform');
  2756.  
  2757.  
  2758.  
  2759. function wpsites_change_comment_form_submit_label($arg) {
  2760. $arg['label_submit'] = 'Invia';
  2761. return $arg;
  2762. }
  2763. add_filter('comment_form_defaults', 'wpsites_change_comment_form_submit_label');
  2764.  
  2765.  
  2766. // Personalizzazione rimuovi tutti i campi quantità
  2767. function custom_remove_all_quantity_fields( $return, $product ) {return true;}
  2768. add_filter( 'woocommerce_is_sold_individually','custom_remove_all_quantity_fields', 10, 2 );
  2769.  
  2770.  
Advertisement
Add Comment
Please, Sign In to add comment