D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
etb1lp46s9ed
/
public_html
/
ashadeepadarshschool.site
/
wp-content
/
themes
/
dlear
/
Filename :
functions.php
back
Copy
<?php /** * @author Backtheme * @since 1.0.0 * @version 1.0.0 */ if ( ! function_exists( 'dlear_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. */ function dlear_setup() { /* * Make theme available for translation. * Translations can be filed in the /languages/ directory. * If you're building a theme based on dlear, use a find and replace * to change 'dlear' to the name of your theme in all the template files. */ load_theme_textdomain( 'dlear', get_template_directory() . '/languages' ); // 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' ); function dlear_change_excerpt( $text ) { $pos = strrpos( $text, '['); if ($pos === false) { return $text; } return rtrim (substr($text, 0, $pos) ) . '...'; } add_filter('get_the_excerpt', 'dlear_change_excerpt'); // Limit Excerpt Length by number of Words function dlear_custom_excerpt( $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; } function content($limit) { $content = explode(' ', get_the_content(), $limit); if (count($content)>=$limit) { array_pop($content); $content = implode(" ",$content).'...'; } else { $content = implode(" ",$content); } $content = preg_replace('/[.+]/','', $content); $content = apply_filters('the_content', $content); $content = str_replace(']]>', ']]>', $content); return $content; } /* * Enable support for Post Thumbnails on posts and pages. * * @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/ */ add_theme_support( 'post-thumbnails' ); // This theme uses wp_nav_menu() in one location. register_nav_menus( array( 'menu-1' => esc_html__( 'Primary Menu', 'dlear' ), 'menu-2' => esc_html__( 'Single Menu', 'dlear' ) ) ); /* * 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', ) ); // Set up the WordPress core custom background feature. add_theme_support( 'custom-background', apply_filters( 'dlear_custom_background_args', array( 'default-color' => 'ffffff', 'default-image' => '', ) ) ); // Add theme support for selective refresh for widgets. add_theme_support( 'customize-selective-refresh-widgets' ); /** * Add support for core custom logo. * * @link https://codex.wordpress.org/Theme_Logo */ add_theme_support( 'custom-logo', array( 'height' => 250, 'width' => 250, 'flex-width' => true, 'flex-height' => true, ) ); //add support posts format add_theme_support( 'post-formats', array( 'aside', 'gallery', 'audio', 'video', 'image', 'quote', 'link', ) ); add_theme_support( 'align-wide' ); } endif; add_action( 'after_setup_theme', 'dlear_setup' ); /** *Custom Image Size */ add_image_size( 'dlear_portfolio-slider', 520, 640, true ); add_image_size( 'dlear_portfolio-grid', 400, 600, true ); add_image_size( 'dlear_footer-post', 100, 100, true ); /** * Set the content width in pixels, based on the theme's design and stylesheet. * * Priority 0 to make it available to lower priority callbacks. * * @global int $content_width */ function dlear_content_width() { $GLOBALS['content_width'] = apply_filters( 'dlear_content_width', 640 ); } add_action( 'after_setup_theme', 'dlear_content_width', 0 ); require_once get_template_directory() . '/inc/custom-header.php'; require_once get_template_directory() . '/inc/theme-tags.php'; require_once get_template_directory() . '/inc/theme-scripts.php'; require_once get_template_directory() . '/inc/theme-functions.php'; require_once get_template_directory() . '/inc/theme-sidebar.php'; require_once get_template_directory() . '/inc/customizer.php'; if (class_exists( 'ReduxFramework')){ require_once get_template_directory() . '/framework/customs-style.php'; require_once get_template_directory() . '/libs/theme-option/config.php'; } // TGM Plugin Activation if (is_admin()) { require_once get_template_directory() . '/framework/class-tgm-plugin-activation.php'; require_once get_template_directory() . '/framework/tgm-config.php'; } if ( class_exists( 'WooCommerce' ) ) { require_once get_template_directory() . '/inc/woo-functions.php'; } //---------------------------------------------------------------------- // Remove Redux Framework NewsFlash //---------------------------------------------------------------------- if ( ! class_exists( 'reduxNewsflash' ) ): class reduxNewsflash { public function __construct( $parent, $params ) {} } endif; function dlear_remove_demo_mode_link() { // Be sure to rename this function to something more unique if ( class_exists('ReduxFrameworkPlugin') ) { remove_action( 'plugin_row_meta', array( ReduxFrameworkPlugin::get_instance(), 'plugin_metalinks'), null, 2 ); } if ( class_exists('ReduxFrameworkPlugin') ) { remove_action('admin_notices', array( ReduxFrameworkPlugin::get_instance(), 'admin_notices' ) ); } } add_action('init', 'dlear_remove_demo_mode_link'); /** * Registers an editor stylesheet for the theme. */ function dlear_theme_add_editor_styles() { add_editor_style( 'css/custom-editor-style.css' ); } add_action( 'admin_init', 'dlear_theme_add_editor_styles' ); function dlear_menu_add_description_to_menu($item_output, $item, $depth, $args) { if (strlen($item->description) > 0 ) { // append description after link $item_output .= sprintf('<span class="description">%s</span>', esc_html($item->description)); } return $item_output; } add_filter('walker_nav_menu_start_el', 'dlear_menu_add_description_to_menu', 10, 4); //------------------------------------------------------------------------ //Comments form field //----------------------------------------------------------------------- function dlear_wpb_move_comment_field_to_bottom( $fields ) { $comment_field = $fields['comment']; unset( $fields['comment'] ); $fields['comment'] = $comment_field; return $fields; } add_filter( 'comment_form_fields', 'dlear_wpb_move_comment_field_to_bottom' ); function dlear_update_post_cache( &$posts ) { if ( ! $posts ) { return; } foreach ( $posts as $post ) { wp_cache_add( $post->ID, $post, 'posts' ); } }