| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877 |
- <?php
- /**
- * Taskereasy functions and definitions
- *
- * Set up the theme and provides some helper functions, which are used in the
- * theme as custom template tags. Others are attached to action and filter
- * hooks in WordPress to change core functionality.
- *
- * When using a child theme you can override certain functions (those wrapped
- * in a function_exists() call) by defining them first in your child theme's
- * functions.php file. The child theme's functions.php file is included before
- * the parent theme's file, so the child theme functions would be used.
- *
- * @link https://codex.wordpress.org/Theme_Development
- * @link https://codex.wordpress.org/Child_Themes
- *
- * Functions that are not pluggable (not wrapped in function_exists()) are
- * instead attached to a filter or action hook.
- *
- *
- * @package WordPress
- * @subpackage Taskereasy
- * @since Taskereasy 1.0.0
- */
- /**
- * Set the content width based on the theme's design and stylesheet.
- *
- * @since Taskereasy 1.0.0
- */
- if ( ! isset( $content_width ) ) {
- $content_width = 660;
- }
- /**
- * taskereasy only works in WordPress 4.1 or later.
- */
- if ( version_compare( $GLOBALS['wp_version'], '4.1-alpha', '<' ) ) {
- require get_template_directory() . '/inc/back-compat.php';
- }
- if ( ! function_exists( 'taskereasy_setup' ) ) :
- /**
- * Sets up theme defaults and registers support for various WordPress features.
- *
- * Note that this function is hooked into the after_setup_theme hook, which
- * runs before the init hook. The init hook is too late for some features, such
- * as indicating support for post thumbnails.
- *
- * @since taskereasy 1.0.0
- */
- function taskereasy_setup() {
- /*
- * Make theme available for translation.
- * Translations can be filed at WordPress.org. See: https://translate.wordpress.org/projects/wp-themes/taskereasy
- * If you're building a theme based on taskereasy, use a find and replace
- * to change 'taskereasy' to the name of your theme in all the template files
- */
- load_theme_textdomain( 'taskereasy' );
- // Add default posts and comments RSS feed links to head.
- add_theme_support( 'automatic-feed-links' );
- /*
- * Let WordPress manage the document title.
- * By adding theme support, we declare that this theme does not use a
- * hard-coded <title> tag in the document head, and expect WordPress to
- * provide it for us.
- */
- add_theme_support( 'title-tag' );
- /*
- * Enable support for Post Thumbnails on posts and pages.
- *
- * See: https://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails
- */
- add_theme_support( 'custom-header' );
- add_theme_support( 'post-thumbnails' );
- set_post_thumbnail_size( 825, 530, true );
- add_image_size('services-detail', 1200, 650, true);
- // This theme uses wp_nav_menu() in two locations.
- register_nav_menus( array(
- 'primary' => esc_html__( 'Primary Menu', 'taskereasy' ),
- ) );
- /*
- * Switch default core markup for search form, comment form, and comments
- * to output valid HTML5.
- */
- add_theme_support( 'html5', array(
- 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption'
- ) );
- /*
- * Enable support for Post Formats.
- *
- * See: https://codex.wordpress.org/Post_Formats
- */
- add_theme_support( 'post-formats', array(
- 'aside', 'image', 'video', 'quote', 'link', 'gallery', 'status', 'audio', 'chat'
- ) );
- /*
- * Enable support for custom logo.
- *
- * @since taskereasy 1.5
- */
- add_theme_support( 'custom-logo', array(
- 'height' => 50,
- 'width' => 200,
- 'flex-height' => true,
- ) );
- }
- endif;
- add_action( 'after_setup_theme', 'taskereasy_setup' );
- /**
- * Load Theme Google fonts
- */
- if( !function_exists('taskereasy_load_google_fonts') ){
- function taskereasy_load_google_fonts(){
- $fonts_url = '';
- /* Translators: If there are characters in your language that are not
- * supported by Lora, translate this to 'off'. Do not translate
- * into your own language.
- */
- $montserrat = _x( 'on', 'Montserrat font: on or off', 'taskereasy' );
- $open_sans = _x( 'on', 'Open Sans font: on or off', 'taskereasy' );
- if ( 'off' !== $montserrat || 'off' !== $open_sans ) {
- $font_families = array();
- if ( 'off' !== $montserrat ) {
- $font_families[] = 'Montserrat:300,400,500,600,700,800';
- }
- if ( 'off' !== $open_sans ) {
- $font_families[] = 'Open+Sans:400,600,700';
- }
- $query_args =
- array(
- 'family' => urlencode( implode( '|', $font_families ) ),
- 'subset' => urlencode( 'latin,latin-ext' ),
- );
- $fonts_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' );
- }
- return $fonts_url;
- }
- }
- /**
- * Load front-end styles and scripts
- */
- if( !function_exists( 'taskereasy_scripts' ) ){
- function taskereasy_scripts(){
- wp_enqueue_style( 'bootstrap', get_theme_file_uri( '/assets/css/bootstrap.min.css'), array() );
- wp_enqueue_style( 'font-awesome', get_theme_file_uri( '/assets/css/font-awesome.min.css'), array() );
- wp_enqueue_style( 'taskereasy-custom-stylesheet', get_theme_file_uri( '/assets/css/style.css'), array() );
- wp_enqueue_style( 'taskereasy-style', get_theme_file_uri( '/style.css'), array() );
- wp_enqueue_style( 'owl-stylesheet', get_theme_file_uri( '/assets/css/owl.carousel.css'), array() );
- wp_enqueue_style( 'slick-stylesheet', get_theme_file_uri( '/assets/css/slick.css'), array() );
- wp_enqueue_style( 'magnific-popup-stylesheet', get_theme_file_uri( '/assets/css/magnific-popup.css'), array() );
- //Load google fonts
- wp_enqueue_style( 'google-fonts', taskereasy_load_google_fonts(), array(), null );
- /***** Scripts ******/
- wp_enqueue_script( 'bootstrap', get_theme_file_uri( '/assets/js/bootstrap.min.js'), array('jquery'), false, true );
- wp_enqueue_script( 'jquery-magnific-popup', get_theme_file_uri( '/assets/js/jquery.magnific-popup.min.js'), array('jquery'), false, true );
- wp_enqueue_script( 'owl-carousel', get_theme_file_uri( '/assets/js/owl.carousel.min.js'), array('jquery'), false, true );
- wp_enqueue_script( 'slick-slider', get_theme_file_uri( '/assets/js/slick.min.js'), array('jquery'), false, true );
- wp_enqueue_script( 'taskereasy-javascript', get_theme_file_uri( '/assets/js/interface.js'), array('jquery'), false, true );
- wp_enqueue_script( 'isotope', get_theme_file_uri( '/assets/js/isotope.pkgd.min.js'), array('jquery'), false, true );
- wp_enqueue_script( 'jquery-instagramFeed', get_theme_file_uri( '/assets/js/jquery.instagramFeed.min.js'), array('jquery'), false, true );
- $custom_dynamic_style = taskereasy_custom_dynamic_style();
- if( ! empty( $custom_dynamic_style ) ){
- wp_add_inline_style( 'taskereasy-style', $custom_dynamic_style );
- }
- if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
- wp_enqueue_script( 'comment-reply' );
- }
- }
- add_action( 'wp_enqueue_scripts', 'taskereasy_scripts' );
- }
- if( ! function_exists( 'taskereasy_admin_script' ) ){
- function taskereasy_admin_script(){
- wp_enqueue_style( '', get_theme_file_uri( '/assets/css/admin/style.css' ) );
- }
- add_action( 'admin_enqueue_scripts', 'taskereasy_admin_script' );
- }
- // Set the theme's favicon
- if( ! function_exists( 'taskereasy_favicon' ) ){
- function taskereasy_favicon() {
- if ( function_exists( 'has_site_icon' ) && has_site_icon() ) {
- if( !empty( get_site_icon_url() ) ){
- echo '<link rel="shortcut icon" href="' . get_site_icon_url() . '"/>';
- }
- }
- }
- }
- // Theme Setup Wizard
- require_once get_parent_theme_file_path( '/setup/envato_setup.php' );
- function taskereasy_primary_menu(){
- $defaults = array(
- 'menu_class' => 'nav navbar-nav',
- 'menu_id' => '',
- 'container' => '',
- 'fallback_cb' => '',
- 'container_class' => 'collapse navbar-collapse',
- );
- if( has_nav_menu( 'primary' ) ){
- $defaults = array(
- 'theme_location'=> 'primary',
- 'menu_class' => 'nav navbar-nav',
- 'menu_id' => '',
- 'container' => '',
- 'fallback_cb' => '',
- );
- }
- return wp_nav_menu( $defaults );
- }
- function taskereasy_widgets_init() {
- register_sidebar( array(
- 'name' => esc_html__( 'Blog Sidebar', 'taskereasy' ),
- 'id' => 'sidebar-7',
- 'description' => esc_html__( 'Add widgets here to appear in your blog.', 'taskereasy' ),
- 'before_widget' => '<div class="sidebar-widget">',
- 'after_widget' => '</div>',
- 'before_title' => '<h5 class="widget-title">',
- 'after_title' => '</h5>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'Footer 1', 'taskereasy' ),
- 'id' => 'sidebar-3',
- 'description' => esc_html__( 'Add widgets here to appear in your header.', 'taskereasy' ),
- 'before_widget' => '<div class="sidebar-widget">',
- 'after_widget' => '</div>',
- 'before_title' => '<h5 class="widget-title">',
- 'after_title' => '</h5>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'Footer 2', 'taskereasy' ),
- 'id' => 'sidebar-4',
- 'description' => esc_html__( 'Add widgets here to appear in your header.', 'taskereasy' ),
- 'before_widget' => '<div class="sidebar-widget">',
- 'after_widget' => '</div>',
- 'before_title' => '<h5 class="widget-title">',
- 'after_title' => '</h5>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'Footer 3', 'taskereasy' ),
- 'id' => 'sidebar-5',
- 'description' => esc_html__( 'Add widgets here to appear in your header.', 'taskereasy' ),
- 'before_widget' => '<div class="sidebar-widget">',
- 'after_widget' => '</div>',
- 'before_title' => '<h5 class="widget-title">',
- 'after_title' => '</h5>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'Footer 4', 'taskereasy' ),
- 'id' => 'sidebar-6',
- 'description' => esc_html__( 'Add widgets here to appear in your header.', 'taskereasy' ),
- 'before_widget' => '<div class="sidebar-widget">',
- 'after_widget' => '</div>',
- 'before_title' => '<h5 class="widget-title">',
- 'after_title' => '</h5>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'Bottom Footer', 'taskereasy' ),
- 'id' => 'sidebar-9',
- 'description' => esc_html__( 'Add widgets here to appear in bottom footer.', 'taskereasy' ),
- 'before_widget' => '<div class="sidebar-widget">',
- 'after_widget' => '</div>',
- 'before_title' => '<h5 class="widget-title">',
- 'after_title' => '</h5>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'Free Widget Area', 'taskereasy' ),
- 'id' => 'free-sidebar',
- 'description' => esc_html__( 'Add widgets here to use in WPBakery', 'taskereasy' ),
- 'before_widget' => '',
- 'after_widget' => '',
- 'before_title' => '<h5 class="widget-title">',
- 'after_title' => '</h5>',
- ) );
- }
- add_action( 'widgets_init', 'taskereasy_widgets_init' );
- /*****************************blog banner******************************/
- function taskereasy_blog_banner(){
- echo '<section id="inner-intro" class="section-padding dark-overlay">
- <div class="container">
- <div class="text-center white-text z-index">
- <h1>'.wp_title('', false).'</h1>'.taskereasy_breadcrumbs().'
- </div>
- </div>
- </section>';
- }
- /**
- * Register the Welcome page after theme activation.
- *
- * @since 2.1.1
- */
- function taskereasy_register_welcome_page(){
- add_theme_page( 'Taskereasy', 'Taskereasy', 'edit_theme_options', 'taskereasy', 'taskereasy_welcome_page_content' );
- }
- add_action( 'admin_menu', 'taskereasy_register_welcome_page' );
- /**
- * Welcome Page content.
- *
- * @since 2.1.1
- */
- function taskereasy_welcome_page_content(){
- get_template_part('template-parts/admin/welcome');
- }
- /* Redirect to wizard on theme activation */
- if (is_admin() && isset($_GET['activated']) && $pagenow == "themes.php")
- wp_redirect('themes.php?page=taskereasy');
- /**
- * Add a pingback url auto-discovery header for single posts, pages, or attachments.
- */
- function taskereasy_pingback_header() {
- if ( is_singular() && pings_open() ) {
- echo '<link rel="pingback" href="', esc_url( get_bloginfo( 'pingback_url' ) ), '">';
- }
- }
- add_action( 'wp_head', 'taskereasy_pingback_header' );
- /***********************end of blog banner******************************/
- function taskereasy_breadcrumbs(){
- // Set variables for later use
- $home_link = esc_url(home_url('/'));
- $home_text = esc_html__( 'Home', 'taskereasy' );
- $link_before = '<li class="breadcrumb-item">';
- $link_after = '</li>';
- $link_attr = '';
- $link = $link_before . '<a' . $link_attr . ' href="%1$s">%2$s</a>' . $link_after;
- $delimiter = ''; // Delimiter between crumbs
- $before = '<li class="breadcrumb-item active" aria-current="page">'; // Tag before the current crumb
- $after = '</li>'; // Tag after the current crumb
- $page_addon = ''; // Adds the page number if the query is paged
- $breadcrumb_trail = '';
- $category_links = '';
- /**
- * Set our own $wp_the_query variable. Do not use the global variable version due to
- * reliability
- */
- $wp_the_query = $GLOBALS['wp_the_query'];
- $queried_object = $wp_the_query->get_queried_object();
- // Handle single post requests which includes single pages, posts and attatchments
- if ( is_singular() )
- {
- /**
- * Set our own $post variable. Do not use the global variable version due to
- * reliability. We will set $post_object variable to $GLOBALS['wp_the_query']
- */
- $post_object = sanitize_post( $queried_object );
- // Set variables
- $title = apply_filters( 'the_title', $post_object->post_title, $post_object->ID );
- $parent = $post_object->post_parent;
- $post_type = $post_object->post_type;
- $post_id = $post_object->ID;
- $post_link = $before . $title . $after;
- $parent_string = '';
- $post_type_link = '';
- if ( 'post' === $post_type )
- {
- // Get the post categories
- $categories = get_the_category( $post_id );
- if ( $categories ) {
- // Lets grab the first category
- $category = $categories[0];
- $category_links = get_category_parents( $category, true, $delimiter );
- $category_links = str_replace( '<a', $link_before . '<a' . $link_attr, $category_links );
- $category_links = str_replace( '</a>', '</a>' . $link_after, $category_links );
- }
- }
- if ( !in_array( $post_type, ['post', 'page', 'attachment'] ) )
- {
- $post_type_object = get_post_type_object( $post_type );
- $archive_link = esc_url( get_post_type_archive_link( $post_type ) );
- $post_type_link = sprintf( $link, $archive_link, $post_type_object->labels->singular_name );
- }
- // Get post parents if $parent !== 0
- if ( 0 !== $parent )
- {
- $parent_links = [];
- while ( $parent ) {
- $post_parent = get_post( $parent );
- $parent_links[] = sprintf( $link, esc_url( get_permalink( $post_parent->ID ) ), get_the_title( $post_parent->ID ) );
- $parent = $post_parent->post_parent;
- }
- $parent_links = array_reverse( $parent_links );
- $parent_string = implode( $delimiter, $parent_links );
- }
- // Lets build the breadcrumb trail
- if ( $parent_string ) {
- $breadcrumb_trail = $parent_string . $delimiter . $post_link;
- } else {
- $breadcrumb_trail = $post_link;
- }
- if ( $post_type_link )
- $breadcrumb_trail = $post_type_link . $delimiter . $breadcrumb_trail;
- if ( $category_links )
- $breadcrumb_trail = $category_links . $breadcrumb_trail;
- }
- // Handle archives which includes category-, tag-, taxonomy-, date-, custom post type archives and author archives
- if( is_archive() )
- {
- if ( is_category()
- || is_tag()
- || is_tax()
- ) {
- // Set the variables for this section
- $term_object = get_term( $queried_object );
- $taxonomy = $term_object->taxonomy;
- $term_id = $term_object->term_id;
- $term_name = $term_object->name;
- $term_parent = $term_object->parent;
- $taxonomy_object = get_taxonomy( $taxonomy );
- $current_term_link = $before . $taxonomy_object->labels->singular_name . ': ' . $term_name . $after;
- $parent_term_string = '';
- if ( 0 !== $term_parent )
- {
- // Get all the current term ancestors
- $parent_term_links = [];
- while ( $term_parent ) {
- $term = get_term( $term_parent, $taxonomy );
- $parent_term_links[] = sprintf( $link, esc_url( get_term_link( $term ) ), $term->name );
- $term_parent = $term->parent;
- }
- $parent_term_links = array_reverse( $parent_term_links );
- $parent_term_string = implode( $delimiter, $parent_term_links );
- }
- if ( $parent_term_string ) {
- $breadcrumb_trail = $parent_term_string . $delimiter . $current_term_link;
- } else {
- $breadcrumb_trail = $current_term_link;
- }
- } elseif ( is_author() ) {
- $breadcrumb_trail = $before . esc_html__( 'Author archive for', 'taskereasy') . $before . $queried_object->data->display_name . $after;
- } elseif ( is_date() ) {
- // Set default variables
- $year = $wp_the_query->query_vars['year'];
- $monthnum = $wp_the_query->query_vars['monthnum'];
- $day = $wp_the_query->query_vars['day'];
- // Get the month name if $monthnum has a value
- if ( $monthnum ) {
- $date_time = DateTime::createFromFormat( '!m', $monthnum );
- $month_name = $date_time->format( 'F' );
- }
- if ( is_year() ) {
- $breadcrumb_trail = $before . $year . $after;
- } elseif( is_month() ) {
- $year_link = sprintf( $link, esc_url( get_year_link( $year ) ), $year );
- $breadcrumb_trail = $year_link . $delimiter . $before . $month_name . $after;
- } elseif( is_day() ) {
- $year_link = sprintf( $link, esc_url( get_year_link( $year ) ), $year );
- $month_link = sprintf( $link, esc_url( get_month_link( $year, $monthnum ) ), $month_name );
- $breadcrumb_trail = $year_link . $delimiter . $month_link . $delimiter . $before . $day . $after;
- }
- } elseif ( is_post_type_archive() ) {
- $post_type = $wp_the_query->query_vars['post_type'];
- $post_type_object = get_post_type_object( $post_type );
- $breadcrumb_trail = $before . $post_type_object->labels->singular_name . $after;
- }
- }
- // Handle the search page
- if ( is_search() ) {
- $breadcrumb_trail = $before . esc_html__( ' Search query for: ', 'taskereasy' ) . get_search_query() . $after;
- }
- // Handle 404's
- if ( is_404() ) {
- $breadcrumb_trail = $before . esc_html__( ' Error 404', 'taskereasy' ) . $after;
- }
- // Handle paged pages
- if ( is_paged() ) {
- $current_page = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : get_query_var( 'page' );
- $page_addon = $before . sprintf( esc_html__( ' ( Page %s )', 'taskereasy' ), number_format_i18n( $current_page ) ) . $after;
- }
- $breadcrumb_output_link = '';
- $breadcrumb_output_link .= '<nav aria-label="breadcrumb"><ol class="breadcrumb">';
- if ( is_home() || is_front_page() ) {
- $breadcrumb_output_link .= '<li class="breadcrumb-item"><a href="' . esc_url($home_link) . '">' . $home_text . '</a></li>';
- // Do not show breadcrumbs on page one of home and frontpage
- if ( is_paged() ) {
- $breadcrumb_output_link = '';
- $breadcrumb_output_link .= '<li class="breadcrumb-item"><a href="' . esc_url($home_link) . '">' . $home_text . '</a></li>';
- $breadcrumb_output_link .= $page_addon;
- }
- } else {
- $breadcrumb_output_link .= '<li class="breadcrumb-item"><a href="' . esc_url($home_link) . '">' . $home_text . '</a></li>';
- $breadcrumb_output_link .= $delimiter;
- $breadcrumb_output_link .= $breadcrumb_trail;
- $breadcrumb_output_link .= $page_addon;
- }
- $breadcrumb_output_link .= '</ol></nav><!-- .breadcrumbs -->';
- return $breadcrumb_output_link;
- }
- /* Comment Form */
- if( ! function_exists( 'taskereasy_comment_form' ) ){
- function taskereasy_comment_form( $comment, $args, $depth ){
- $GLOBALS['comment'] = $comment;
- extract($args, EXTR_SKIP);
- ?>
- <li id="comment-<?php comment_ID(); ?>" class="comment">
- <?php
- if( get_avatar( $comment ) != '' ){
- ?>
- <div class="comment-avatar">
- <?php
- echo get_avatar( $comment, 70 );
- ?>
- </div>
- <?php } ?>
- <div class="comment-body">
- <h4 class="comment-header">
- <span class="author-name"><?php comment_author_link(); ?></span>
- <span class="comment-date"><?php the_time(get_option( 'date_format' )); ?></span>
- </h4>
- <div class="comment-entry">
- <?php comment_text(); ?>
- </div>
- <?php comment_reply_link(
- array_merge(
- $args,
- array(
- 'depth' => $depth,
- 'max_depth' => $args['max_depth'],
- 'reply_text'=>'<i class="fa fa-comment"></i>' . esc_html__( 'Reply', 'taskereasy' )
- )
- )
- ); ?>
- </div>
- </li>
- <?php
- }
- }
- /*************End of category page*****************/
- // Additional feature of the template
- define('TASKEREASY_CORE_REDUX_FRAMEWORK_ACTIVED', in_array( 'redux-framework/redux-framework.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) )));
- if (TASKEREASY_CORE_REDUX_FRAMEWORK_ACTIVED) {
- require_once get_template_directory() . '/inc/theme-options.php';
- }
- /**
- * Theme option configaretion
- */
- function taskereasy_get_config( $name, $default = '' ){
- global $taskereasy_options;
- if( isset( $taskereasy_options[ $name ] ) ){
- return $taskereasy_options[ $name ];
- }
- return $default;
- }
- function taskereasy_isset_config(){
- global $taskereasy_options;
- return !empty($taskereasy_options);
- }
- //function for convert color code in rgb
- function hex2rgb($hex) {
- $hex = str_replace("#", "", $hex);
- if(strlen($hex) == 3) {
- $r = hexdec(substr($hex,0,1).substr($hex,0,1));
- $g = hexdec(substr($hex,1,1).substr($hex,1,1));
- $b = hexdec(substr($hex,2,1).substr($hex,2,1));
- } else {
- $r = hexdec(substr($hex,0,2));
- $g = hexdec(substr($hex,2,2));
- $b = hexdec(substr($hex,4,2));
- }
- $rgb = array($r, $g, $b);
- return $rgb; // returns an array with the rgb values
- }
- if( ! function_exists( 'taskereasy_post_pagination' ) ) {
- function taskereasy_post_pagination(){
- the_posts_pagination( array(
- 'prev_text' => esc_html__( '«', 'taskereasy' ),
- 'next_text' => esc_html__( '»', 'taskereasy' ),
- 'mid_size' => 2,
- 'screen_reader_text' => ' ',
- ) );
- }
- }
- //Exclude pages from WordPress Search
- if (!is_admin()) {
- function taskereasy_search_filter($query) {
- if ($query->is_search) {
- $query->set('post_type', 'post');
- }
- return $query;
- }
- add_filter('pre_get_posts','taskereasy_search_filter');
- }
- // Define excerpt length
- if( ! function_exists( 'taskereasy_custom_excerpt_length' ) ){
- function taskereasy_custom_excerpt_length( $limit ){
- $excerpt = explode(' ', get_the_excerpt(), $limit);
- if (count($excerpt)>=$limit) {
- array_pop($excerpt);
- $excerpt = implode(" ",$excerpt).'';
- } else {
- $excerpt = implode(" ",$excerpt);
- }
- $excerpt = preg_replace('`[[^]]*]`','',$excerpt);
- return $excerpt;
- }
- }
- // For recommended plugin
- require get_parent_theme_file_path( '/inc/class-tgm-plugin-activation.php');
- // Require Custom style
- require get_template_directory(). '/inc/dynamic-style.php';
- /**
- * Require Plugin
- */
- function taskereasy_register_required_plugins() {
- $plugins = array(
- array(
- 'name' => esc_html__('Redux Framework','taskereasy'),
- 'slug' => 'redux-framework',
- 'required' => true,
- ),
- array(
- 'name' => esc_html__('Contact Form 7','taskereasy'),
- 'slug' => 'contact-form-7',
- 'required' => false,
- ),
- array(
- 'name' => esc_html__('Newsletter','taskereasy'),
- 'slug' => 'newsletter',
- 'required' => false,
- ),
- array(
- 'name' => esc_html__('WPBakery Visual Composer','taskereasy'),
- 'slug' => 'js_composer',
- 'source' => esc_url('https://slidesigma.com/themes/wp/taskereasy/plugins/js_composer.zip'),
- 'required' => true,
- 'external_url' => esc_url('https://slidesigma.com/themes/wp/taskereasy/plugins/js_composer.zip'),
- ),
- array(
- 'name' => esc_html__('Slider Revolution','taskereasy'),
- 'slug' => 'revslider',
- 'source' => esc_url('https://slidesigma.com/themes/wp/taskereasy/plugins/revslider.zip'),
- 'required' => true,
- 'external_url' => esc_url('https://slidesigma.com/themes/wp/taskereasy/plugins/revslider.zip'),
- ),
- array(
- 'name' => esc_html__('Taskereasy Plugin','taskereasy'),
- 'slug' => 'taskereasy-plugin',
- 'source' => esc_url('https://slidesigma.com/themes/wp/taskereasy/plugins/taskereasy-plugin.zip'),
- 'required' => true,
- 'external_url' => esc_url('https://slidesigma.com/themes/wp/taskereasy/plugins/taskereasy-plugin.zip'),
- ),
- );
- /**
- * Array of configuration settings. Amend each line as needed.
- * If you want the default strings to be available under your own theme domain,
- * leave the strings uncommented.
- * Some of the strings are added into a sprintf, so see the comments at the
- * end of each line for what each argument will be.
- */
- $config = array(
- 'id' => 'taskereasy', // Text domain - likely want to be the same as your theme.
- 'menu' => 'tgmpa-install-plugins', // Menu slug
- 'has_notices' => true, // Show admin notices or not
- 'dismissable' => true, // If false, a user cannot dismiss the nag message.
- 'dismiss_msg' => '', // If 'dismissable' is false, this message will be output at top of nag.
- 'is_automatic' => false, // Automatically activate plugins after installation or not
- 'message' => '', // Message to output right before the plugins table
- 'strings' => array(
- 'page_title' => esc_html__( 'Install Required Plugins', 'taskereasy' ),
- 'menu_title' => esc_html__( 'Install Plugins', 'taskereasy' ),
- 'installing' => esc_html__( 'Installing Plugin: %s', 'taskereasy' ), // %1$s = plugin name
- 'oops' => esc_html__( 'Something went wrong with the plugin API.', 'taskereasy' ),
- '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)
- '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)
- '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)
- '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)
- '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)
- '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)
- '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)
- '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)
- 'install_link' => _n_noop( 'Begin installing plugin', 'Begin installing plugins', 'taskereasy' ),
- 'activate_link' => _n_noop( 'Activate installed plugin', 'Activate installed plugins', 'taskereasy' ),
- 'return' => esc_html__( 'Return to Required Plugins Installer', 'taskereasy' ),
- 'plugin_activated' => esc_html__( 'Plugin activated successfully.', 'taskereasy' ),
- 'complete' => esc_html__( 'All plugins installed and activated successfully. %s', 'taskereasy' ), // %1$s = dashboard link
- 'nag_type' => 'updated' // Determines admin notice type - can only be 'updated' or 'error'
- )
- );
- tgmpa( $plugins, $config );
- }
- add_action( 'tgmpa_register', 'taskereasy_register_required_plugins' );
- /**
- * Activation Key function.
- *
- * @since 2.0.0
- */
- if (!function_exists('taskereasy_activation')) {
- function taskereasy_activation() {
- $status = get_option( 'theme_activation' );
- $user_license = get_option('user_license');
- if(empty($status) && $status != 'none'){
- update_option( 'theme_activation', 'none' );
- }
- ?>
- <form action="" method="post">
- <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>
- <p><?php esc_html__('Verify your purchase code to unlock all features', 'taskereasy'); ?></p>
- <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">
- <?php echo wp_nonce_field( 'api_nonce', 'api_nonce_field' ,true, false ); ?>
- <?php if(empty($user_license)){ ?>
- <input type="submit" name="verify" class="btn" value="<?php echo esc_html__('Activate', 'taskereasy') ?>"/>
- <?php }else{ ?>
- <input type="submit" class="btn" name="unlink-domain" value="<?php echo esc_html__('Unlink Domain', 'taskereasy') ?>">
- <?php } ?>
- </form>
- <?php
- if( isset( $_POST['verify'] ) && wp_verify_nonce( $_POST['api_nonce_field'], 'api_nonce' ) && !empty($_POST['key'])){
- $purchase_key = trim($_POST['key']);
- $purchase_data = verify_envato_purchase_code( $purchase_key );
- if(empty($purchase_data->error)){
- if( $purchase_data->item->id != '23832008' ) {
- echo '<p class="error-color bold"> '.__( 'Invalid License Key!', 'taskereasy' ).' </p>';
- } else{
- update_option( 'user_license', $_POST['key'] );
- update_option( 'theme_activation', 'activated' );
- echo '<p class="success-color bold"> '.__( 'Valid license key, please refresh your page.', 'taskereasy' ).' </p>';
- }
- }else{
- echo '<p class="error-color bold"> '.__( 'Invalid License Key!', 'taskereasy' ).' </p>';
- }
- }elseif( isset( $_POST['unlink-domain'] ) && wp_verify_nonce( $_POST['api_nonce_field'], 'api_nonce' ) && !empty($user_license) ){
- update_option( 'user_license', '' );
- update_option( 'theme_activation', 'none' );
- echo '<p class="success-color bold"> '.__( 'Domain Unlinked successfully, please refresh your page.', 'taskereasy' ).' </p>';
- }
- }
- }
- function verify_envato_purchase_code($code_to_verify) {
- $url = "https://api.envato.com/v3/market/author/sale?code=".$code_to_verify;
- $personal_token = "0xwVOzxFyTMvX1SIJdErkgUhe6kuv8GY";
- $headers = array(
- 'Authorization' => 'Bearer ' . $personal_token,
- 'Accept' => 'application/json;ver=1.0',
- 'Content-Type' => 'application/json; charset=UTF-8',
- 'timeout' => 20,
- );
- $request = array(
- 'headers' => $headers,
- );
- $response = wp_remote_request( $url, $request );
- $envatoRes = json_decode($response['body']);
- // Return output
- return $envatoRes;
- }
|