functions.php 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877
  1. <?php
  2. /**
  3. * Taskereasy functions and definitions
  4. *
  5. * Set up the theme and provides some helper functions, which are used in the
  6. * theme as custom template tags. Others are attached to action and filter
  7. * hooks in WordPress to change core functionality.
  8. *
  9. * When using a child theme you can override certain functions (those wrapped
  10. * in a function_exists() call) by defining them first in your child theme's
  11. * functions.php file. The child theme's functions.php file is included before
  12. * the parent theme's file, so the child theme functions would be used.
  13. *
  14. * @link https://codex.wordpress.org/Theme_Development
  15. * @link https://codex.wordpress.org/Child_Themes
  16. *
  17. * Functions that are not pluggable (not wrapped in function_exists()) are
  18. * instead attached to a filter or action hook.
  19. *
  20. *
  21. * @package WordPress
  22. * @subpackage Taskereasy
  23. * @since Taskereasy 1.0.0
  24. */
  25. /**
  26. * Set the content width based on the theme's design and stylesheet.
  27. *
  28. * @since Taskereasy 1.0.0
  29. */
  30. if ( ! isset( $content_width ) ) {
  31. $content_width = 660;
  32. }
  33. /**
  34. * taskereasy only works in WordPress 4.1 or later.
  35. */
  36. if ( version_compare( $GLOBALS['wp_version'], '4.1-alpha', '<' ) ) {
  37. require get_template_directory() . '/inc/back-compat.php';
  38. }
  39. if ( ! function_exists( 'taskereasy_setup' ) ) :
  40. /**
  41. * Sets up theme defaults and registers support for various WordPress features.
  42. *
  43. * Note that this function is hooked into the after_setup_theme hook, which
  44. * runs before the init hook. The init hook is too late for some features, such
  45. * as indicating support for post thumbnails.
  46. *
  47. * @since taskereasy 1.0.0
  48. */
  49. function taskereasy_setup() {
  50. /*
  51. * Make theme available for translation.
  52. * Translations can be filed at WordPress.org. See: https://translate.wordpress.org/projects/wp-themes/taskereasy
  53. * If you're building a theme based on taskereasy, use a find and replace
  54. * to change 'taskereasy' to the name of your theme in all the template files
  55. */
  56. load_theme_textdomain( 'taskereasy' );
  57. // Add default posts and comments RSS feed links to head.
  58. add_theme_support( 'automatic-feed-links' );
  59. /*
  60. * Let WordPress manage the document title.
  61. * By adding theme support, we declare that this theme does not use a
  62. * hard-coded <title> tag in the document head, and expect WordPress to
  63. * provide it for us.
  64. */
  65. add_theme_support( 'title-tag' );
  66. /*
  67. * Enable support for Post Thumbnails on posts and pages.
  68. *
  69. * See: https://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails
  70. */
  71. add_theme_support( 'custom-header' );
  72. add_theme_support( 'post-thumbnails' );
  73. set_post_thumbnail_size( 825, 530, true );
  74. add_image_size('services-detail', 1200, 650, true);
  75. // This theme uses wp_nav_menu() in two locations.
  76. register_nav_menus( array(
  77. 'primary' => esc_html__( 'Primary Menu', 'taskereasy' ),
  78. ) );
  79. /*
  80. * Switch default core markup for search form, comment form, and comments
  81. * to output valid HTML5.
  82. */
  83. add_theme_support( 'html5', array(
  84. 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption'
  85. ) );
  86. /*
  87. * Enable support for Post Formats.
  88. *
  89. * See: https://codex.wordpress.org/Post_Formats
  90. */
  91. add_theme_support( 'post-formats', array(
  92. 'aside', 'image', 'video', 'quote', 'link', 'gallery', 'status', 'audio', 'chat'
  93. ) );
  94. /*
  95. * Enable support for custom logo.
  96. *
  97. * @since taskereasy 1.5
  98. */
  99. add_theme_support( 'custom-logo', array(
  100. 'height' => 50,
  101. 'width' => 200,
  102. 'flex-height' => true,
  103. ) );
  104. }
  105. endif;
  106. add_action( 'after_setup_theme', 'taskereasy_setup' );
  107. /**
  108. * Load Theme Google fonts
  109. */
  110. if( !function_exists('taskereasy_load_google_fonts') ){
  111. function taskereasy_load_google_fonts(){
  112. $fonts_url = '';
  113. /* Translators: If there are characters in your language that are not
  114. * supported by Lora, translate this to 'off'. Do not translate
  115. * into your own language.
  116. */
  117. $montserrat = _x( 'on', 'Montserrat font: on or off', 'taskereasy' );
  118. $open_sans = _x( 'on', 'Open Sans font: on or off', 'taskereasy' );
  119. if ( 'off' !== $montserrat || 'off' !== $open_sans ) {
  120. $font_families = array();
  121. if ( 'off' !== $montserrat ) {
  122. $font_families[] = 'Montserrat:300,400,500,600,700,800';
  123. }
  124. if ( 'off' !== $open_sans ) {
  125. $font_families[] = 'Open+Sans:400,600,700';
  126. }
  127. $query_args =
  128. array(
  129. 'family' => urlencode( implode( '|', $font_families ) ),
  130. 'subset' => urlencode( 'latin,latin-ext' ),
  131. );
  132. $fonts_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' );
  133. }
  134. return $fonts_url;
  135. }
  136. }
  137. /**
  138. * Load front-end styles and scripts
  139. */
  140. if( !function_exists( 'taskereasy_scripts' ) ){
  141. function taskereasy_scripts(){
  142. wp_enqueue_style( 'bootstrap', get_theme_file_uri( '/assets/css/bootstrap.min.css'), array() );
  143. wp_enqueue_style( 'font-awesome', get_theme_file_uri( '/assets/css/font-awesome.min.css'), array() );
  144. wp_enqueue_style( 'taskereasy-custom-stylesheet', get_theme_file_uri( '/assets/css/style.css'), array() );
  145. wp_enqueue_style( 'taskereasy-style', get_theme_file_uri( '/style.css'), array() );
  146. wp_enqueue_style( 'owl-stylesheet', get_theme_file_uri( '/assets/css/owl.carousel.css'), array() );
  147. wp_enqueue_style( 'slick-stylesheet', get_theme_file_uri( '/assets/css/slick.css'), array() );
  148. wp_enqueue_style( 'magnific-popup-stylesheet', get_theme_file_uri( '/assets/css/magnific-popup.css'), array() );
  149. //Load google fonts
  150. wp_enqueue_style( 'google-fonts', taskereasy_load_google_fonts(), array(), null );
  151. /***** Scripts ******/
  152. wp_enqueue_script( 'bootstrap', get_theme_file_uri( '/assets/js/bootstrap.min.js'), array('jquery'), false, true );
  153. wp_enqueue_script( 'jquery-magnific-popup', get_theme_file_uri( '/assets/js/jquery.magnific-popup.min.js'), array('jquery'), false, true );
  154. wp_enqueue_script( 'owl-carousel', get_theme_file_uri( '/assets/js/owl.carousel.min.js'), array('jquery'), false, true );
  155. wp_enqueue_script( 'slick-slider', get_theme_file_uri( '/assets/js/slick.min.js'), array('jquery'), false, true );
  156. wp_enqueue_script( 'taskereasy-javascript', get_theme_file_uri( '/assets/js/interface.js'), array('jquery'), false, true );
  157. wp_enqueue_script( 'isotope', get_theme_file_uri( '/assets/js/isotope.pkgd.min.js'), array('jquery'), false, true );
  158. wp_enqueue_script( 'jquery-instagramFeed', get_theme_file_uri( '/assets/js/jquery.instagramFeed.min.js'), array('jquery'), false, true );
  159. $custom_dynamic_style = taskereasy_custom_dynamic_style();
  160. if( ! empty( $custom_dynamic_style ) ){
  161. wp_add_inline_style( 'taskereasy-style', $custom_dynamic_style );
  162. }
  163. if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
  164. wp_enqueue_script( 'comment-reply' );
  165. }
  166. }
  167. add_action( 'wp_enqueue_scripts', 'taskereasy_scripts' );
  168. }
  169. if( ! function_exists( 'taskereasy_admin_script' ) ){
  170. function taskereasy_admin_script(){
  171. wp_enqueue_style( '', get_theme_file_uri( '/assets/css/admin/style.css' ) );
  172. }
  173. add_action( 'admin_enqueue_scripts', 'taskereasy_admin_script' );
  174. }
  175. // Set the theme's favicon
  176. if( ! function_exists( 'taskereasy_favicon' ) ){
  177. function taskereasy_favicon() {
  178. if ( function_exists( 'has_site_icon' ) && has_site_icon() ) {
  179. if( !empty( get_site_icon_url() ) ){
  180. echo '<link rel="shortcut icon" href="' . get_site_icon_url() . '"/>';
  181. }
  182. }
  183. }
  184. }
  185. // Theme Setup Wizard
  186. require_once get_parent_theme_file_path( '/setup/envato_setup.php' );
  187. function taskereasy_primary_menu(){
  188. $defaults = array(
  189. 'menu_class' => 'nav navbar-nav',
  190. 'menu_id' => '',
  191. 'container' => '',
  192. 'fallback_cb' => '',
  193. 'container_class' => 'collapse navbar-collapse',
  194. );
  195. if( has_nav_menu( 'primary' ) ){
  196. $defaults = array(
  197. 'theme_location'=> 'primary',
  198. 'menu_class' => 'nav navbar-nav',
  199. 'menu_id' => '',
  200. 'container' => '',
  201. 'fallback_cb' => '',
  202. );
  203. }
  204. return wp_nav_menu( $defaults );
  205. }
  206. function taskereasy_widgets_init() {
  207. register_sidebar( array(
  208. 'name' => esc_html__( 'Blog Sidebar', 'taskereasy' ),
  209. 'id' => 'sidebar-7',
  210. 'description' => esc_html__( 'Add widgets here to appear in your blog.', 'taskereasy' ),
  211. 'before_widget' => '<div class="sidebar-widget">',
  212. 'after_widget' => '</div>',
  213. 'before_title' => '<h5 class="widget-title">',
  214. 'after_title' => '</h5>',
  215. ) );
  216. register_sidebar( array(
  217. 'name' => esc_html__( 'Footer 1', 'taskereasy' ),
  218. 'id' => 'sidebar-3',
  219. 'description' => esc_html__( 'Add widgets here to appear in your header.', 'taskereasy' ),
  220. 'before_widget' => '<div class="sidebar-widget">',
  221. 'after_widget' => '</div>',
  222. 'before_title' => '<h5 class="widget-title">',
  223. 'after_title' => '</h5>',
  224. ) );
  225. register_sidebar( array(
  226. 'name' => esc_html__( 'Footer 2', 'taskereasy' ),
  227. 'id' => 'sidebar-4',
  228. 'description' => esc_html__( 'Add widgets here to appear in your header.', 'taskereasy' ),
  229. 'before_widget' => '<div class="sidebar-widget">',
  230. 'after_widget' => '</div>',
  231. 'before_title' => '<h5 class="widget-title">',
  232. 'after_title' => '</h5>',
  233. ) );
  234. register_sidebar( array(
  235. 'name' => esc_html__( 'Footer 3', 'taskereasy' ),
  236. 'id' => 'sidebar-5',
  237. 'description' => esc_html__( 'Add widgets here to appear in your header.', 'taskereasy' ),
  238. 'before_widget' => '<div class="sidebar-widget">',
  239. 'after_widget' => '</div>',
  240. 'before_title' => '<h5 class="widget-title">',
  241. 'after_title' => '</h5>',
  242. ) );
  243. register_sidebar( array(
  244. 'name' => esc_html__( 'Footer 4', 'taskereasy' ),
  245. 'id' => 'sidebar-6',
  246. 'description' => esc_html__( 'Add widgets here to appear in your header.', 'taskereasy' ),
  247. 'before_widget' => '<div class="sidebar-widget">',
  248. 'after_widget' => '</div>',
  249. 'before_title' => '<h5 class="widget-title">',
  250. 'after_title' => '</h5>',
  251. ) );
  252. register_sidebar( array(
  253. 'name' => esc_html__( 'Bottom Footer', 'taskereasy' ),
  254. 'id' => 'sidebar-9',
  255. 'description' => esc_html__( 'Add widgets here to appear in bottom footer.', 'taskereasy' ),
  256. 'before_widget' => '<div class="sidebar-widget">',
  257. 'after_widget' => '</div>',
  258. 'before_title' => '<h5 class="widget-title">',
  259. 'after_title' => '</h5>',
  260. ) );
  261. register_sidebar( array(
  262. 'name' => esc_html__( 'Free Widget Area', 'taskereasy' ),
  263. 'id' => 'free-sidebar',
  264. 'description' => esc_html__( 'Add widgets here to use in WPBakery', 'taskereasy' ),
  265. 'before_widget' => '',
  266. 'after_widget' => '',
  267. 'before_title' => '<h5 class="widget-title">',
  268. 'after_title' => '</h5>',
  269. ) );
  270. }
  271. add_action( 'widgets_init', 'taskereasy_widgets_init' );
  272. /*****************************blog banner******************************/
  273. function taskereasy_blog_banner(){
  274. echo '<section id="inner-intro" class="section-padding dark-overlay">
  275. <div class="container">
  276. <div class="text-center white-text z-index">
  277. <h1>'.wp_title('', false).'</h1>'.taskereasy_breadcrumbs().'
  278. </div>
  279. </div>
  280. </section>';
  281. }
  282. /**
  283. * Register the Welcome page after theme activation.
  284. *
  285. * @since 2.1.1
  286. */
  287. function taskereasy_register_welcome_page(){
  288. add_theme_page( 'Taskereasy', 'Taskereasy', 'edit_theme_options', 'taskereasy', 'taskereasy_welcome_page_content' );
  289. }
  290. add_action( 'admin_menu', 'taskereasy_register_welcome_page' );
  291. /**
  292. * Welcome Page content.
  293. *
  294. * @since 2.1.1
  295. */
  296. function taskereasy_welcome_page_content(){
  297. get_template_part('template-parts/admin/welcome');
  298. }
  299. /* Redirect to wizard on theme activation */
  300. if (is_admin() && isset($_GET['activated']) && $pagenow == "themes.php")
  301. wp_redirect('themes.php?page=taskereasy');
  302. /**
  303. * Add a pingback url auto-discovery header for single posts, pages, or attachments.
  304. */
  305. function taskereasy_pingback_header() {
  306. if ( is_singular() && pings_open() ) {
  307. echo '<link rel="pingback" href="', esc_url( get_bloginfo( 'pingback_url' ) ), '">';
  308. }
  309. }
  310. add_action( 'wp_head', 'taskereasy_pingback_header' );
  311. /***********************end of blog banner******************************/
  312. function taskereasy_breadcrumbs(){
  313. // Set variables for later use
  314. $home_link = esc_url(home_url('/'));
  315. $home_text = esc_html__( 'Home', 'taskereasy' );
  316. $link_before = '<li class="breadcrumb-item">';
  317. $link_after = '</li>';
  318. $link_attr = '';
  319. $link = $link_before . '<a' . $link_attr . ' href="%1$s">%2$s</a>' . $link_after;
  320. $delimiter = ''; // Delimiter between crumbs
  321. $before = '<li class="breadcrumb-item active" aria-current="page">'; // Tag before the current crumb
  322. $after = '</li>'; // Tag after the current crumb
  323. $page_addon = ''; // Adds the page number if the query is paged
  324. $breadcrumb_trail = '';
  325. $category_links = '';
  326. /**
  327. * Set our own $wp_the_query variable. Do not use the global variable version due to
  328. * reliability
  329. */
  330. $wp_the_query = $GLOBALS['wp_the_query'];
  331. $queried_object = $wp_the_query->get_queried_object();
  332. // Handle single post requests which includes single pages, posts and attatchments
  333. if ( is_singular() )
  334. {
  335. /**
  336. * Set our own $post variable. Do not use the global variable version due to
  337. * reliability. We will set $post_object variable to $GLOBALS['wp_the_query']
  338. */
  339. $post_object = sanitize_post( $queried_object );
  340. // Set variables
  341. $title = apply_filters( 'the_title', $post_object->post_title, $post_object->ID );
  342. $parent = $post_object->post_parent;
  343. $post_type = $post_object->post_type;
  344. $post_id = $post_object->ID;
  345. $post_link = $before . $title . $after;
  346. $parent_string = '';
  347. $post_type_link = '';
  348. if ( 'post' === $post_type )
  349. {
  350. // Get the post categories
  351. $categories = get_the_category( $post_id );
  352. if ( $categories ) {
  353. // Lets grab the first category
  354. $category = $categories[0];
  355. $category_links = get_category_parents( $category, true, $delimiter );
  356. $category_links = str_replace( '<a', $link_before . '<a' . $link_attr, $category_links );
  357. $category_links = str_replace( '</a>', '</a>' . $link_after, $category_links );
  358. }
  359. }
  360. if ( !in_array( $post_type, ['post', 'page', 'attachment'] ) )
  361. {
  362. $post_type_object = get_post_type_object( $post_type );
  363. $archive_link = esc_url( get_post_type_archive_link( $post_type ) );
  364. $post_type_link = sprintf( $link, $archive_link, $post_type_object->labels->singular_name );
  365. }
  366. // Get post parents if $parent !== 0
  367. if ( 0 !== $parent )
  368. {
  369. $parent_links = [];
  370. while ( $parent ) {
  371. $post_parent = get_post( $parent );
  372. $parent_links[] = sprintf( $link, esc_url( get_permalink( $post_parent->ID ) ), get_the_title( $post_parent->ID ) );
  373. $parent = $post_parent->post_parent;
  374. }
  375. $parent_links = array_reverse( $parent_links );
  376. $parent_string = implode( $delimiter, $parent_links );
  377. }
  378. // Lets build the breadcrumb trail
  379. if ( $parent_string ) {
  380. $breadcrumb_trail = $parent_string . $delimiter . $post_link;
  381. } else {
  382. $breadcrumb_trail = $post_link;
  383. }
  384. if ( $post_type_link )
  385. $breadcrumb_trail = $post_type_link . $delimiter . $breadcrumb_trail;
  386. if ( $category_links )
  387. $breadcrumb_trail = $category_links . $breadcrumb_trail;
  388. }
  389. // Handle archives which includes category-, tag-, taxonomy-, date-, custom post type archives and author archives
  390. if( is_archive() )
  391. {
  392. if ( is_category()
  393. || is_tag()
  394. || is_tax()
  395. ) {
  396. // Set the variables for this section
  397. $term_object = get_term( $queried_object );
  398. $taxonomy = $term_object->taxonomy;
  399. $term_id = $term_object->term_id;
  400. $term_name = $term_object->name;
  401. $term_parent = $term_object->parent;
  402. $taxonomy_object = get_taxonomy( $taxonomy );
  403. $current_term_link = $before . $taxonomy_object->labels->singular_name . ': ' . $term_name . $after;
  404. $parent_term_string = '';
  405. if ( 0 !== $term_parent )
  406. {
  407. // Get all the current term ancestors
  408. $parent_term_links = [];
  409. while ( $term_parent ) {
  410. $term = get_term( $term_parent, $taxonomy );
  411. $parent_term_links[] = sprintf( $link, esc_url( get_term_link( $term ) ), $term->name );
  412. $term_parent = $term->parent;
  413. }
  414. $parent_term_links = array_reverse( $parent_term_links );
  415. $parent_term_string = implode( $delimiter, $parent_term_links );
  416. }
  417. if ( $parent_term_string ) {
  418. $breadcrumb_trail = $parent_term_string . $delimiter . $current_term_link;
  419. } else {
  420. $breadcrumb_trail = $current_term_link;
  421. }
  422. } elseif ( is_author() ) {
  423. $breadcrumb_trail = $before . esc_html__( 'Author archive for', 'taskereasy') . $before . $queried_object->data->display_name . $after;
  424. } elseif ( is_date() ) {
  425. // Set default variables
  426. $year = $wp_the_query->query_vars['year'];
  427. $monthnum = $wp_the_query->query_vars['monthnum'];
  428. $day = $wp_the_query->query_vars['day'];
  429. // Get the month name if $monthnum has a value
  430. if ( $monthnum ) {
  431. $date_time = DateTime::createFromFormat( '!m', $monthnum );
  432. $month_name = $date_time->format( 'F' );
  433. }
  434. if ( is_year() ) {
  435. $breadcrumb_trail = $before . $year . $after;
  436. } elseif( is_month() ) {
  437. $year_link = sprintf( $link, esc_url( get_year_link( $year ) ), $year );
  438. $breadcrumb_trail = $year_link . $delimiter . $before . $month_name . $after;
  439. } elseif( is_day() ) {
  440. $year_link = sprintf( $link, esc_url( get_year_link( $year ) ), $year );
  441. $month_link = sprintf( $link, esc_url( get_month_link( $year, $monthnum ) ), $month_name );
  442. $breadcrumb_trail = $year_link . $delimiter . $month_link . $delimiter . $before . $day . $after;
  443. }
  444. } elseif ( is_post_type_archive() ) {
  445. $post_type = $wp_the_query->query_vars['post_type'];
  446. $post_type_object = get_post_type_object( $post_type );
  447. $breadcrumb_trail = $before . $post_type_object->labels->singular_name . $after;
  448. }
  449. }
  450. // Handle the search page
  451. if ( is_search() ) {
  452. $breadcrumb_trail = $before . esc_html__( ' Search query for: ', 'taskereasy' ) . get_search_query() . $after;
  453. }
  454. // Handle 404's
  455. if ( is_404() ) {
  456. $breadcrumb_trail = $before . esc_html__( ' Error 404', 'taskereasy' ) . $after;
  457. }
  458. // Handle paged pages
  459. if ( is_paged() ) {
  460. $current_page = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : get_query_var( 'page' );
  461. $page_addon = $before . sprintf( esc_html__( ' ( Page %s )', 'taskereasy' ), number_format_i18n( $current_page ) ) . $after;
  462. }
  463. $breadcrumb_output_link = '';
  464. $breadcrumb_output_link .= '<nav aria-label="breadcrumb"><ol class="breadcrumb">';
  465. if ( is_home() || is_front_page() ) {
  466. $breadcrumb_output_link .= '<li class="breadcrumb-item"><a href="' . esc_url($home_link) . '">' . $home_text . '</a></li>';
  467. // Do not show breadcrumbs on page one of home and frontpage
  468. if ( is_paged() ) {
  469. $breadcrumb_output_link = '';
  470. $breadcrumb_output_link .= '<li class="breadcrumb-item"><a href="' . esc_url($home_link) . '">' . $home_text . '</a></li>';
  471. $breadcrumb_output_link .= $page_addon;
  472. }
  473. } else {
  474. $breadcrumb_output_link .= '<li class="breadcrumb-item"><a href="' . esc_url($home_link) . '">' . $home_text . '</a></li>';
  475. $breadcrumb_output_link .= $delimiter;
  476. $breadcrumb_output_link .= $breadcrumb_trail;
  477. $breadcrumb_output_link .= $page_addon;
  478. }
  479. $breadcrumb_output_link .= '</ol></nav><!-- .breadcrumbs -->';
  480. return $breadcrumb_output_link;
  481. }
  482. /* Comment Form */
  483. if( ! function_exists( 'taskereasy_comment_form' ) ){
  484. function taskereasy_comment_form( $comment, $args, $depth ){
  485. $GLOBALS['comment'] = $comment;
  486. extract($args, EXTR_SKIP);
  487. ?>
  488. <li id="comment-<?php comment_ID(); ?>" class="comment">
  489. <?php
  490. if( get_avatar( $comment ) != '' ){
  491. ?>
  492. <div class="comment-avatar">
  493. <?php
  494. echo get_avatar( $comment, 70 );
  495. ?>
  496. </div>
  497. <?php } ?>
  498. <div class="comment-body">
  499. <h4 class="comment-header">
  500. <span class="author-name"><?php comment_author_link(); ?></span>
  501. <span class="comment-date"><?php the_time(get_option( 'date_format' )); ?></span>
  502. </h4>
  503. <div class="comment-entry">
  504. <?php comment_text(); ?>
  505. </div>
  506. <?php comment_reply_link(
  507. array_merge(
  508. $args,
  509. array(
  510. 'depth' => $depth,
  511. 'max_depth' => $args['max_depth'],
  512. 'reply_text'=>'<i class="fa fa-comment"></i>' . esc_html__( 'Reply', 'taskereasy' )
  513. )
  514. )
  515. ); ?>
  516. </div>
  517. </li>
  518. <?php
  519. }
  520. }
  521. /*************End of category page*****************/
  522. // Additional feature of the template
  523. define('TASKEREASY_CORE_REDUX_FRAMEWORK_ACTIVED', in_array( 'redux-framework/redux-framework.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) )));
  524. if (TASKEREASY_CORE_REDUX_FRAMEWORK_ACTIVED) {
  525. require_once get_template_directory() . '/inc/theme-options.php';
  526. }
  527. /**
  528. * Theme option configaretion
  529. */
  530. function taskereasy_get_config( $name, $default = '' ){
  531. global $taskereasy_options;
  532. if( isset( $taskereasy_options[ $name ] ) ){
  533. return $taskereasy_options[ $name ];
  534. }
  535. return $default;
  536. }
  537. function taskereasy_isset_config(){
  538. global $taskereasy_options;
  539. return !empty($taskereasy_options);
  540. }
  541. //function for convert color code in rgb
  542. function hex2rgb($hex) {
  543. $hex = str_replace("#", "", $hex);
  544. if(strlen($hex) == 3) {
  545. $r = hexdec(substr($hex,0,1).substr($hex,0,1));
  546. $g = hexdec(substr($hex,1,1).substr($hex,1,1));
  547. $b = hexdec(substr($hex,2,1).substr($hex,2,1));
  548. } else {
  549. $r = hexdec(substr($hex,0,2));
  550. $g = hexdec(substr($hex,2,2));
  551. $b = hexdec(substr($hex,4,2));
  552. }
  553. $rgb = array($r, $g, $b);
  554. return $rgb; // returns an array with the rgb values
  555. }
  556. if( ! function_exists( 'taskereasy_post_pagination' ) ) {
  557. function taskereasy_post_pagination(){
  558. the_posts_pagination( array(
  559. 'prev_text' => esc_html__( '&laquo;', 'taskereasy' ),
  560. 'next_text' => esc_html__( '&raquo;', 'taskereasy' ),
  561. 'mid_size' => 2,
  562. 'screen_reader_text' => ' ',
  563. ) );
  564. }
  565. }
  566. //Exclude pages from WordPress Search
  567. if (!is_admin()) {
  568. function taskereasy_search_filter($query) {
  569. if ($query->is_search) {
  570. $query->set('post_type', 'post');
  571. }
  572. return $query;
  573. }
  574. add_filter('pre_get_posts','taskereasy_search_filter');
  575. }
  576. // Define excerpt length
  577. if( ! function_exists( 'taskereasy_custom_excerpt_length' ) ){
  578. function taskereasy_custom_excerpt_length( $limit ){
  579. $excerpt = explode(' ', get_the_excerpt(), $limit);
  580. if (count($excerpt)>=$limit) {
  581. array_pop($excerpt);
  582. $excerpt = implode(" ",$excerpt).'';
  583. } else {
  584. $excerpt = implode(" ",$excerpt);
  585. }
  586. $excerpt = preg_replace('`[[^]]*]`','',$excerpt);
  587. return $excerpt;
  588. }
  589. }
  590. // For recommended plugin
  591. require get_parent_theme_file_path( '/inc/class-tgm-plugin-activation.php');
  592. // Require Custom style
  593. require get_template_directory(). '/inc/dynamic-style.php';
  594. /**
  595. * Require Plugin
  596. */
  597. function taskereasy_register_required_plugins() {
  598. $plugins = array(
  599. array(
  600. 'name' => esc_html__('Redux Framework','taskereasy'),
  601. 'slug' => 'redux-framework',
  602. 'required' => true,
  603. ),
  604. array(
  605. 'name' => esc_html__('Contact Form 7','taskereasy'),
  606. 'slug' => 'contact-form-7',
  607. 'required' => false,
  608. ),
  609. array(
  610. 'name' => esc_html__('Newsletter','taskereasy'),
  611. 'slug' => 'newsletter',
  612. 'required' => false,
  613. ),
  614. array(
  615. 'name' => esc_html__('WPBakery Visual Composer','taskereasy'),
  616. 'slug' => 'js_composer',
  617. 'source' => esc_url('https://slidesigma.com/themes/wp/taskereasy/plugins/js_composer.zip'),
  618. 'required' => true,
  619. 'external_url' => esc_url('https://slidesigma.com/themes/wp/taskereasy/plugins/js_composer.zip'),
  620. ),
  621. array(
  622. 'name' => esc_html__('Slider Revolution','taskereasy'),
  623. 'slug' => 'revslider',
  624. 'source' => esc_url('https://slidesigma.com/themes/wp/taskereasy/plugins/revslider.zip'),
  625. 'required' => true,
  626. 'external_url' => esc_url('https://slidesigma.com/themes/wp/taskereasy/plugins/revslider.zip'),
  627. ),
  628. array(
  629. 'name' => esc_html__('Taskereasy Plugin','taskereasy'),
  630. 'slug' => 'taskereasy-plugin',
  631. 'source' => esc_url('https://slidesigma.com/themes/wp/taskereasy/plugins/taskereasy-plugin.zip'),
  632. 'required' => true,
  633. 'external_url' => esc_url('https://slidesigma.com/themes/wp/taskereasy/plugins/taskereasy-plugin.zip'),
  634. ),
  635. );
  636. /**
  637. * Array of configuration settings. Amend each line as needed.
  638. * If you want the default strings to be available under your own theme domain,
  639. * leave the strings uncommented.
  640. * Some of the strings are added into a sprintf, so see the comments at the
  641. * end of each line for what each argument will be.
  642. */
  643. $config = array(
  644. 'id' => 'taskereasy', // Text domain - likely want to be the same as your theme.
  645. 'menu' => 'tgmpa-install-plugins', // Menu slug
  646. 'has_notices' => true, // Show admin notices or not
  647. 'dismissable' => true, // If false, a user cannot dismiss the nag message.
  648. 'dismiss_msg' => '', // If 'dismissable' is false, this message will be output at top of nag.
  649. 'is_automatic' => false, // Automatically activate plugins after installation or not
  650. 'message' => '', // Message to output right before the plugins table
  651. 'strings' => array(
  652. 'page_title' => esc_html__( 'Install Required Plugins', 'taskereasy' ),
  653. 'menu_title' => esc_html__( 'Install Plugins', 'taskereasy' ),
  654. 'installing' => esc_html__( 'Installing Plugin: %s', 'taskereasy' ), // %1$s = plugin name
  655. 'oops' => esc_html__( 'Something went wrong with the plugin API.', 'taskereasy' ),
  656. 'notice_can_install_required' => _n_noop( 'This theme requires the following plugin: %1$s.', 'This theme requires the following plugins: %1$s.', 'taskereasy' ), // %1$s = plugin name(s)
  657. 'notice_can_install_recommended' => _n_noop( 'This theme recommends the following plugin: %1$s.', 'This theme recommends the following plugins: %1$s.', 'taskereasy' ), // %1$s = plugin name(s)
  658. '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.', 'taskereasy' ), // %1$s = plugin name(s)
  659. 'notice_can_activate_required' => _n_noop( 'The following required plugin is currently inactive: %1$s.', 'The following required plugins are currently inactive: %1$s.' , 'taskereasy'), // %1$s = plugin name(s)
  660. 'notice_can_activate_recommended' => _n_noop( 'The following recommended plugin is currently inactive: %1$s.', 'The following recommended plugins are currently inactive: %1$s.', 'taskereasy' ), // %1$s = plugin name(s)
  661. '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.' , 'taskereasy'), // %1$s = plugin name(s)
  662. '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.', 'taskereasy' ), // %1$s = plugin name(s)
  663. '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.', 'taskereasy' ), // %1$s = plugin name(s)
  664. 'install_link' => _n_noop( 'Begin installing plugin', 'Begin installing plugins', 'taskereasy' ),
  665. 'activate_link' => _n_noop( 'Activate installed plugin', 'Activate installed plugins', 'taskereasy' ),
  666. 'return' => esc_html__( 'Return to Required Plugins Installer', 'taskereasy' ),
  667. 'plugin_activated' => esc_html__( 'Plugin activated successfully.', 'taskereasy' ),
  668. 'complete' => esc_html__( 'All plugins installed and activated successfully. %s', 'taskereasy' ), // %1$s = dashboard link
  669. 'nag_type' => 'updated' // Determines admin notice type - can only be 'updated' or 'error'
  670. )
  671. );
  672. tgmpa( $plugins, $config );
  673. }
  674. add_action( 'tgmpa_register', 'taskereasy_register_required_plugins' );
  675. /**
  676. * Activation Key function.
  677. *
  678. * @since 2.0.0
  679. */
  680. if (!function_exists('taskereasy_activation')) {
  681. function taskereasy_activation() {
  682. $status = get_option( 'theme_activation' );
  683. $user_license = get_option('user_license');
  684. if(empty($status) && $status != 'none'){
  685. update_option( 'theme_activation', 'none' );
  686. }
  687. ?>
  688. <form action="" method="post">
  689. <h2><?php echo esc_html__('Activate Taskereasy', 'taskereasy') ?> <a target="_blank" href="<?php echo esc_url('https://slidesigma.com/themes/wp/taskereasy/docs/') ?>"> <span class="dashicons dashicons-info"></span> </a> </h2>
  690. <p><?php esc_html__('Verify your purchase code to unlock all features', 'taskereasy'); ?></p>
  691. <input id="title" placeholder="<?php echo esc_html__('Place your purchase Key here', 'taskereasy' ) ?>" value="<?php echo esc_attr($user_license); ?>" name="key" autocomplete="off" type="text">
  692. <?php echo wp_nonce_field( 'api_nonce', 'api_nonce_field' ,true, false ); ?>
  693. <?php if(empty($user_license)){ ?>
  694. <input type="submit" name="verify" class="btn" value="<?php echo esc_html__('Activate', 'taskereasy') ?>"/>
  695. <?php }else{ ?>
  696. <input type="submit" class="btn" name="unlink-domain" value="<?php echo esc_html__('Unlink Domain', 'taskereasy') ?>">
  697. <?php } ?>
  698. </form>
  699. <?php
  700. if( isset( $_POST['verify'] ) && wp_verify_nonce( $_POST['api_nonce_field'], 'api_nonce' ) && !empty($_POST['key'])){
  701. $purchase_key = trim($_POST['key']);
  702. $purchase_data = verify_envato_purchase_code( $purchase_key );
  703. if(empty($purchase_data->error)){
  704. if( $purchase_data->item->id != '23832008' ) {
  705. echo '<p class="error-color bold"> '.__( 'Invalid License Key!', 'taskereasy' ).' </p>';
  706. } else{
  707. update_option( 'user_license', $_POST['key'] );
  708. update_option( 'theme_activation', 'activated' );
  709. echo '<p class="success-color bold"> '.__( 'Valid license key, please refresh your page.', 'taskereasy' ).' </p>';
  710. }
  711. }else{
  712. echo '<p class="error-color bold"> '.__( 'Invalid License Key!', 'taskereasy' ).' </p>';
  713. }
  714. }elseif( isset( $_POST['unlink-domain'] ) && wp_verify_nonce( $_POST['api_nonce_field'], 'api_nonce' ) && !empty($user_license) ){
  715. update_option( 'user_license', '' );
  716. update_option( 'theme_activation', 'none' );
  717. echo '<p class="success-color bold"> '.__( 'Domain Unlinked successfully, please refresh your page.', 'taskereasy' ).' </p>';
  718. }
  719. }
  720. }
  721. function verify_envato_purchase_code($code_to_verify) {
  722. $url = "https://api.envato.com/v3/market/author/sale?code=".$code_to_verify;
  723. $personal_token = "0xwVOzxFyTMvX1SIJdErkgUhe6kuv8GY";
  724. $headers = array(
  725. 'Authorization' => 'Bearer ' . $personal_token,
  726. 'Accept' => 'application/json;ver=1.0',
  727. 'Content-Type' => 'application/json; charset=UTF-8',
  728. 'timeout' => 20,
  729. );
  730. $request = array(
  731. 'headers' => $headers,
  732. );
  733. $response = wp_remote_request( $url, $request );
  734. $envatoRes = json_decode($response['body']);
  735. // Return output
  736. return $envatoRes;
  737. }