MBR Functions.php
My custom functions
<?php require_once get_theme_file_path('/inc/tgm.php'); // Declare our class if ( class_exists( 'Attachments' ) ) { require_once 'lib/attachments.php'; } require_once get_theme_file_path('/widgets/social-icons-widget.php'); if ( ! isset( $content_width ) ) $content_width = 960; if (site_url() == 'https://mostakim.com/') { define('VERSION', time()); } else { define('VERSION', wp_get_theme()->get('VERSION')); } // Theme Setup add_action( 'after_setup_theme', 'philosophy_theme_setup' ); function philosophy_theme_setup() { load_theme_textdomain( 'philosophy', get_template_directory() . '/languages' ); add_theme_support('post-thumbnails'); add_theme_support('title-tag'); add_theme_support('automatic-feed-links'); add_theme_support('custom-logo'); add_theme_support('html5', array("search-form", "comment-list")); add_theme_support('post-formats', array('image', 'gallery', 'link', 'quote', 'audio', 'video')); add_editor_style('/assets/css/editor-style.css' ); // Menu Register register_nav_menu( 'main-menu', __('Main Menu', 'philosophy') ); register_nav_menus(array( 'footer-left' => __('Footer Left Menu', 'philosophy'), 'footer-middle' => __('Footer Left Menu', 'philosophy'), 'footer-right' => __('Footer Right Menu', 'philosophy'), )); add_image_size( 'philosophy-home-square', 400, 400, true ); } // Style / Scripts add_action('wp_enqueue_scripts', 'philosophy_assets'); function philosophy_assets() { wp_enqueue_style( 'fontawesome-css', get_theme_file_uri('/assets/css/font-awesome/css/font-awesome.min.css'), null, '1.0'); wp_enqueue_style( 'fonts-css', get_theme_file_uri('/assets/css/fonts.css'), null, '1.0'); wp_enqueue_style( 'base-css', get_theme_file_uri('/assets/css/base.css'), null, '1.0'); wp_enqueue_style( 'vendor-css', get_theme_file_uri('/assets/css/vendor.css'), null, '1.0'); wp_enqueue_style( 'main-css', get_theme_file_uri('/assets/css/main.css'), null, '1.0'); wp_enqueue_style( 'philosophy-style', get_stylesheet_uri(), null, VERSION); wp_enqueue_script('modernizr-js', get_theme_file_uri('/assets/js/modernizr.js'), null, '1.0'); wp_enqueue_script('pace-js', get_theme_file_uri('/assets/js/pace.min.js'), null, '1.0'); wp_enqueue_script('plugins-js', get_theme_file_uri('/assets/js/plugins.js'), array('jquery'), '1.0', true); if ( is_singular() ) { wp_enqueue_script( "comment-reply" ); } wp_enqueue_script('main-js', get_theme_file_uri('/assets/js/main.js'), array('jquery'), '1.0', true); } // Custom Pagination function philosophy_pagination() { // find for total global $wp_query; $links = paginate_links(array( 'current' => max(1, get_query_var('paged')), // current page 'total' => $wp_query->max_num_pages, // total page 'type' => 'list', 'mid_size' => 1, )); $links = str_replace('page-numbers', 'pgn__num', $links); $links = str_replace("<ul class='pgn__num'>", '<ul>', $links); $links = str_replace("next pgn__num", 'pgn__next', $links); $links = str_replace("prev pgn__num", 'pgn__prev', $links); echo wp_kses_post($links); } // Category Description Paragraph Remove remove_action('term_description', 'wpautop'); add_action( 'widgets_init', 'philosophy_about_widgets' ); function philosophy_about_widgets() { register_sidebar(array( 'name' => __("About Us Sidebar", 'philosophy'), 'id' => 'about-sidebar', 'description' => __('Widgets in this area will be shown on about us page', 'philosophy'), 'before_widget' => '<div id="%1$s" class="col-block %2$s">', 'after_widget' => '</div>', 'before_title' => '<h3 class="quarter-top-margin">', 'after_title' => '</h3>', )); // Contact Us register_sidebar(array( 'name' => __("Contact Us Sidebar", 'philosophy'), 'id' => 'contact-sidebar', 'description' => __('Widgets in this area will be shown on contact us page', 'philosophy'), 'before_widget' => '<div id="%1$s" class="col-six tab-full %2$s">', 'after_widget' => '</div>', 'before_title' => '<h3>', 'after_title' => '</h3>', )); // Google Maps register_sidebar(array( 'name' => __("Google Maps", 'philosophy'), 'id' => 'contact-maps', 'description' => __('Widgets in this area will be shown on contact us page', 'philosophy'), 'before_widget' => '<div id="%1$s" class="%2$s">', 'after_widget' => '</div>', 'before_title' => '', 'after_title' => '', )); // Footer register_sidebar(array( 'name' => __("Footer Top Right", 'philosophy'), 'id' => 'footer-top-right', 'description' => __('Widgets in this area will be shown on Footer top right', 'philosophy'), 'before_widget' => '<div id="%1$s" class="%2$s">', 'after_widget' => '</div>', 'before_title' => '<h3>', 'after_title' => '</h3>', )); register_sidebar(array( 'name' => __("Footer Bottom Right", 'philosophy'), 'id' => 'footer-bottom-right', 'description' => __('Widgets in this area will be shown on Footer bottom right', 'philosophy'), 'before_widget' => '<div id="%1$s" class="%2$s">', 'after_widget' => '</div>', 'before_title' => '<h4>', 'after_title' => '</h4>', )); register_sidebar(array( 'name' => __("Footer Bottom", 'philosophy'), 'id' => 'footer-bottom', 'description' => __('Widgets in this area will be shown on Footer bottom right', 'philosophy'), 'before_widget' => '<div id="%1$s" class="%2$s">', 'after_widget' => '</div>', 'before_title' => '', 'after_title' => '', )); // Contact Us register_sidebar(array( 'name' => __("Header Section", 'philosophy'), 'id' => 'header-section', 'description' => __('Widgets in this area will be shown on header section', 'philosophy'), 'before_widget' => '<div id="%1$s" class="%2$s">', 'after_widget' => '</div>', 'before_title' => '<h3>', 'after_title' => '</h3>', )); } // philosophy_about_widgets // Search Form add_filter('get_search_form', 'philosophy_search_form'); function philosophy_search_form($form) { $homedir = home_url('/'); $label = __('Search For:', 'philosophy'); $button_label = __('Search', 'philosophy'); $post_type =<<<PT <input type="hidden" name="post_type" value="post"> PT; if(is_post_type_archive('book')) { $post_type =<<<PT <input type="hidden" name="post_type" value="book"> PT; } $newform = <<<FORM <form role="search" method="get" class="header__search-form" action="{$homedir}"> <label> <span class="hide-content">{$label}</span> {$post_type} <input type="search" class="search-field" placeholder="Type Keywords" value="" name="s" title="{$label}" autocomplete="off"> </label> <input type="submit" class="search-submit" value="{$button_label}"> </form> FORM; return $newform; }