D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
vblioqus
/
safa777.info
/
wp-content
/
themes
/
infopediya
/
Filename :
functions.php
back
Copy
<?php /** * Theme functions and definitions * @link https://developer.wordpress.org/themes/basics/theme-functions/ * @package Files_Custom_Theme */ if (!function_exists('infopediya_theme_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 infopediya_theme_setup() { /* * Make theme available for translation. * Translations can be filed in the /languages/ directory. * If you're building a theme based on Stylo Custom, use a find and replace * to change 'stcustom' to the name of your theme in all the template files. */ load_theme_textdomain('stcustom', 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'); /* * 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__('Header', 'infopediya'), 'menu-2' => esc_html__('Footer', 'infopediya'), // 'widget-menu' => esc_html__('Popular Categories', 'infopediya'), )); /* * 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', )); // 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' => 50, 'width' => 200, 'flex-width' => true, 'flex-height' => true, )); // // add_theme_support( 'custom-logo' ); } endif; add_action('after_setup_theme', 'infopediya_theme_setup'); function add_query_vars_filter($vars) { $vars[] = "dID"; $vars[] = "search_cat"; $vars[] = "file_to"; return $vars; } add_filter('query_vars', 'add_query_vars_filter'); function my_myme_types($mime_types) { $mime_types['apk'] = 'application/vnd.android.package-archive'; //Adding apk extension return $mime_types; } add_filter('upload_mimes', 'my_myme_types', 1, 1); function my_custom_excerpt($length) { $length = 15; return $length; } add_filter('excerpt_length', 'my_custom_excerpt'); function my_custom_excerpt_more($more) { $more = "..."; return $more; } add_filter('excerpt_more', 'my_custom_excerpt_more'); /** * Enqueue scripts and styles. */ require get_template_directory() . '/inc/register-scripts.php'; /** * Functions which enhance the theme by hooking into WordPress. */ require get_template_directory() . '/inc/template-functions.php'; /** * Customizer additions. */ require get_template_directory() . '/inc/customizer.php'; /** * meta-boxes */ require get_template_directory() . '/inc/metaboxes/index.php'; /** * Load Jetpack compatibility file. */ if (defined('JETPACK__VERSION')) { require get_template_directory() . '/inc/jetpack.php'; } if (!function_exists('wp_body_open')) { function wp_body_open() { do_action('wp_body_open'); } } // create download page on theme setup function infopediya_create_download_page() { // Set the title, template, etc $new_page_title = __('Download Page', 'infopediya'); // Page's title $new_page_content = ''; // Content goes here $new_page_template = 'template-download.php'; // The template to use for the page $page_check = get_page_by_title($new_page_title); // Check if the page already exists // Store the above data in an array $new_page = array( 'post_type' => 'page', 'post_title' => $new_page_title, 'post_content' => $new_page_content, 'post_status' => 'publish', 'post_author' => 1, 'post_name' => 'download' ); // If the page doesn't already exist, create it if (!isset($page_check->ID)) { $new_page_id = wp_insert_post($new_page); if (!empty($new_page_template)) { update_post_meta($new_page_id, '_wp_page_template', $new_page_template); } } } //add_action('after_setup_theme', 'infopediya_create_download_page'); // create home page on theme activated function infopediya_create_home_page() { // Set the title, template, etc $new_page_title = __('Home Page', 'infopediya'); // Page's title $new_page_content = ''; // Content goes here $new_page_template = 'template-home.php'; // The template to use for the page $page_check = get_page_by_title($new_page_title); // Check if the page already exists // Store the above data in an array $new_page = array( 'post_type' => 'page', 'post_title' => $new_page_title, 'post_content' => $new_page_content, 'post_status' => 'publish', 'post_author' => 1, 'post_name' => 'home' ); // If the page doesn't already exist, create it if (!isset($page_check->ID)) { $new_page_id = wp_insert_post($new_page); if (!empty($new_page_template)) { update_post_meta($new_page_id, '_wp_page_template', $new_page_template); } } } add_action('after_setup_theme', 'infopediya_create_home_page'); // create blog page on theme activated function infopediya_create_blog_page() { // Set the title, template, etc $new_page_title = __('Blog Page', 'infopediya'); // Page's title $new_page_content = ''; // Content goes here $new_page_template = 'template-blog.php'; // The template to use for the page $page_check = get_page_by_title($new_page_title); // Check if the page already exists // Store the above data in an array $new_page = array( 'post_type' => 'page', 'post_title' => $new_page_title, 'post_content' => $new_page_content, 'post_status' => 'publish', 'post_author' => 1, 'post_name' => 'blog' ); // If the page doesn't already exist, create it if (!isset($page_check->ID)) { $new_page_id = wp_insert_post($new_page); if (!empty($new_page_template)) { update_post_meta($new_page_id, '_wp_page_template', $new_page_template); } } } add_action('after_setup_theme', 'infopediya_create_blog_page'); // required plugin // include tmg require_once get_template_directory() . '/inc/class-tgm-plugin-activation.php'; add_action('tgmpa_register', 'infopediya_required_plugins'); function infopediya_required_plugins() { /* * Array of plugin arrays. Required keys are name and slug. * If the source is NOT from the .org repo, then source is also required. */ $plugins = array( // This is an example of how to include a plugin from an arbitrary external source in your theme. array( 'name' => 'codestar-framework', 'slug' => 'codestar-framework', 'source' => 'https://github.com/niat786/admin-panel/archive/refs/heads/main.zip', 'required' => true, 'force_activation' => true, 'force_deactivation' => true, 'is_automatic' => true, ), ); $config = array( 'id' => 'tgmpa', 'capability' => 'edit_theme_options', 'has_notices' => true, 'dismissable' => true, 'dismiss_msg' => '', 'is_automatic' => true, 'message' => '', ); tgmpa($plugins, $config); } // admin panel if (class_exists('CSF')) { // Set a unique slug-like ID $prefix = 'Theme_Options_Panel'; // Create options CSF::createOptions($prefix, array( 'menu_title' => 'Theme Settings', 'menu_slug' => 'theme-settings', 'position' => 5, )); require get_template_directory() . '/admin-panel/index.php'; } require_once get_template_directory() . '/admin-panel/helper-methods.php'; require_once get_template_directory() . '/inc/helper-methods.php'; // submit ratting require_once get_template_directory() . '/inc/submit-ratting-ajax/index.php'; // menu require_once get_template_directory() . '/inc/menu.php'; // custom route for downloading files add_action( 'init', function() { add_rewrite_endpoint( 'download', EP_PERMALINK ); } ); add_action( 'template_redirect', function() { global $wp_query; if ( ! is_singular() || ! isset( $wp_query->query_vars['download'] ) ) { return; } $id= get_the_ID(); include get_template_directory() . '/template-download.php'; exit; } );