Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Flat initiation
- *
- * Initializes Flat's features and includes all necessary files.
- *
- * @package Flat
- */
- # Prevent direct access to this file
- if ( 1 == count( get_included_files() ) ) {
- header( 'HTTP/1.1 403 Forbidden' );
- die( 'Direct access of this file is prohibited. Thank you.' );
- }
- /**
- * File inclusions
- */
- require get_template_directory() . '/inc/customize.php'; # Enables user customization via admin panel
- require get_template_directory() . '/inc/hooks.php'; # Enables user customization via WordPress plugin API
- require get_template_directory() . '/inc/template-tags.php'; # Contains functions that output HTML
- if(!class_exists('Flat_Plus')){
- require_once(get_template_directory() . '/inc/customizer-info/class/class-singleton-customizer-info-section.php' );
- }
- /**
- * Set the max width for embedded content
- *
- * @link http://codex.wordpress.org/Content_Width
- */
- if ( ! isset( $content_width ) ) {
- $content_width = 720;
- }
- if ( ! function_exists( 'flat_setup' ) ) :
- /**
- * Sets up theme defaults and registers support for various WordPress features.
- */
- function flat_setup() {
- # Localization
- load_theme_textdomain( 'flat', get_template_directory() . '/languages' );
- # Enable WordPress theme features
- add_theme_support( 'automatic-feed-links' ); # @link http://codex.wordpress.org/Automatic_Feed_Links
- $custom_background_support = array(
- 'default-color' => '',
- 'default-image' => get_template_directory_uri() . '/assets/img/default-background.jpg',
- 'wp-head-callback' => '_custom_background_cb',
- 'admin-head-callback' => '',
- 'admin-preview-callback' => '',
- );
- /* tgm-plugin-activation */
- require_once get_template_directory() . '/class-tgm-plugin-activation.php';
- add_theme_support( 'custom-background', $custom_background_support ); # @link http://codex.wordpress.org/Custom_Backgrounds
- add_theme_support( 'post-formats', array( 'aside', 'audio', 'chat', 'gallery', 'image', 'quote', 'status' ) ); # @link http://codex.wordpress.org/Post%20Formats
- add_theme_support( 'post-thumbnails' ); # @link http://codex.wordpress.org/Post%20Thumbnails
- add_theme_support( 'structured-post-formats', array( 'link', 'video' ) );
- add_theme_support( 'title-tag' ); # @link http://codex.wordpress.org/Title_Tag
- add_theme_support( 'tha-hooks', array( 'all' ) ); # @link https://github.com/zamoose/themehookalliance
- # Add style to the post editor for a more WYSIWYG experience
- add_editor_style( array( 'assets/css/editor-style.css' ) );
- # Flat has one navigation menu; register it with WordPress
- register_nav_menu( 'primary', __( 'Navigation Menu', 'flat' ) );
- # Add filters
- add_filter( 'comments_popup_link_attributes', function() { return ' itemprop="discussionUrl"'; } ); # schema.org property on comments links
- add_filter( 'current_theme_supports-tha_hooks', '__return_true' ); # Enables checking for THA hooks
- add_filter( 'style_loader_tag', 'flat_filter_styles', 10, 2 ); # Filters style tags as needed
- add_filter( 'the_content_more_link', 'flat_modify_read_more_link' ); # Enhances appearance of "Read more..." link
- add_filter( 'use_default_gallery_style', '__return_false' ); # Disable default WordPress gallery styling
- remove_filter( 'the_content','cwp_pac_before_content');
- # Add actions
- add_action( 'flat_html_before', 'flat_doctype' ); # Outputs HTML doctype
- add_action( 'flat_404_content', 'flat_output_404_content' ); # Outputs a helpful message on 404 pages
- add_action( 'widgets_init', 'flat_widgets_init' ); # Registers Flat's sidebar
- add_action( 'wp_enqueue_scripts', 'flat_scripts_styles' ); # Enqueue's Flat's scripts & styles
- add_action( 'admin_enqueue_scripts', 'flat_admin_styles', 10 );
- }
- endif;
- add_action( 'after_setup_theme', 'flat_setup' );
- // unregister all widgets
- function flat_remove_review_widgets() {
- unregister_widget('cwp_latest_products_widget');
- unregister_widget('cwp_top_products_widget');
- }
- add_action('widgets_init', 'flat_remove_review_widgets', 11);
- if ( ! function_exists( 'flat_widgets_init' ) ) :
- /**
- * Registers our sidebar with WordPress
- */
- function flat_widgets_init() {
- register_sidebar( array(
- 'name' => __( 'Main Widget Area', 'flat' ),
- 'id' => 'sidebar-1',
- 'description' => __( 'Appears in the sidebar section of the site', 'flat' ),
- 'before_widget' => "\t\t\t\t\t" . '<aside id="%1$s" class="widget %2$s">' . "\n",
- 'after_widget' => "\t\t\t\t\t</aside>\n",
- 'before_title' => "\t\t\t\t\t\t<h3 class='widget-title'>",
- 'after_title' => "</h3>\n",
- ) );
- }
- endif;
- if ( ! function_exists( 'flat_scripts_styles' ) ) :
- /**
- * Sets up necessary scripts and styles
- */
- function flat_scripts_styles() {
- global $wp_version;
- # Get the current version of Flat, even if a child theme is being used
- $version = wp_get_theme( wp_get_theme()->template )->get( 'Version' );
- # When needed, enqueue comment-reply script
- if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
- wp_enqueue_script( 'comment-reply' );
- }
- # Minified versions of CSS & JS are used, unless a development constant is set
- if ( defined( 'WP_ENV' ) && 'development' === WP_ENV ) {
- $assets = array(
- 'css' => '/assets/css/flat.css',
- 'js' => '/assets/js/flat.js',
- );
- } else {
- $assets = array(
- 'css' => '/assets/css/flat.min.css',
- 'js' => '/assets/js/flat.min.js',
- );
- }
- wp_enqueue_style( 'flat-fonts', flat_fonts_url(), array(), null ); # Web fonts
- wp_enqueue_style( 'flat-theme', get_template_directory_uri() . $assets['css'], array(), $version ); # Flat's styling
- wp_enqueue_script( 'flat-js', get_template_directory_uri() . $assets['js'], array( 'jquery' ), $version, false ); # Flat's scripting
- wp_enqueue_style( 'flat-style', get_stylesheet_uri() ); # Load main stylesheet, for child theme supports
- if(class_exists('Flat_Plus')){
- $flat_plus_sidebar_position = get_theme_mod('flat_plus_sidebar_position');
- $inline_style = '';
- if( !empty($flat_plus_sidebar_position) && $flat_plus_sidebar_position === 'right' ){
- $inline_style .= '@media (max-width: 1199px) { '.
- '#secondary .toggle-sidebar{ '.
- 'float:right; border-width: 0 0 0 1px; } '.
- '#secondary .toggle-navigation { '.
- 'float:left; border-width: 0 1px 0 0;} '.
- '.row-offcanvas-left.active {'.
- 'left: auto; right: 300px;}'.
- '.row-offcanvas-left .sidebar-offcanvas {'.
- 'right: -300px; left: auto; }'.
- '}';
- }
- wp_add_inline_style( 'flat-style', $inline_style );
- }
- # If the `script_loader_tag` filter is unavailable, this script will be added via the `wp_head` hook
- if ( version_compare( '4.1', $wp_version, '<=' ) ) {
- wp_enqueue_script( 'html5shiv', get_template_directory_uri() . '/assets/js/html5shiv.min.js', array(), '3.7.2', false );
- }
- }
- endif;
- function flat_admin_styles() {
- wp_enqueue_style( 'flat_admin_stylesheet', get_template_directory_uri() . '/assets/css/admin-style.css', array(), '1.1', false );
- }
- # The following function uses a filter introduced in WP 4.1
- if ( version_compare( '4.1', $wp_version, '<=' ) ) :
- if ( ! function_exists( 'flat_filter_scripts' ) ) :
- /**
- * Filters enqueued script output to better suit Flat's needs
- */
- function flat_filter_scripts( $tag, $handle, $src ) {
- # Remove `type` attribute (unneeded in HTML5)
- $tag = str_replace( ' type=\'text/javascript\'', '', $tag );
- # Apply conditionals to html5shiv for legacy IE
- if ( 'html5shiv' === $handle ) {
- $tag = "<!--[if lt IE 9]>\n$tag<![endif]-->\n";
- }
- return $tag;
- }
- endif;
- add_filter( 'script_loader_tag', 'flat_filter_scripts', 10, 3 );
- else : # If the `script_loader_tag` filter is unavailable...
- /**
- * Adds html5shiv the "old" way (WP < 4.1)
- */
- function flat_add_html5shiv() {
- echo "<!--[if lt IE 9]>\n<scr" . 'ipt src="' . esc_url( get_template_directory_uri() ) . '/assets/js/html5shiv.min.js"></scr' . "ipt>\n<![endif]-->"; # This is a hack to disguise adding the script without using WordPress' enqueue function
- }
- add_action( 'wp_head', 'flat_add_html5shiv' );
- endif;
- if ( ! function_exists( 'flat_filter_styles' ) ) :
- /**
- * Filter enqueued style output to better suit HTML5
- */
- function flat_filter_styles( $tag, $handle ) {
- # Get rid of unnecessary `type` attribute
- $tag = str_replace( ' type=\'text/css\'', '', $tag );
- # Get rid of double-spaces
- $tag = str_replace( ' ', ' ', $tag );
- return $tag;
- }
- endif;
- add_action('tgmpa_register', 'flat_register_required_plugins');
- function flat_register_required_plugins()
- {
- $plugins = array(
- array(
- 'name' => 'WP Product Review',
- 'slug' => 'wp-product-review',
- 'required' => false,
- )
- );
- $config = array(
- 'default_path' => '',
- 'menu' => 'tgmpa-install-plugins',
- 'has_notices' => true,
- 'dismissable' => true,
- 'dismiss_msg' => '',
- 'is_automatic' => false,
- 'message' => '',
- 'strings' => array(
- 'page_title' => __('Install Required Plugins', 'flat'),
- 'menu_title' => __('Install Plugins', 'flat'),
- 'installing' => __('Installing Plugin: %s', 'flat'),
- 'oops' => __('Something went wrong with the plugin API.', 'flat'),
- 'notice_can_install_required' => _n_noop('This theme requires the following plugin: %1$s.', 'This theme requires the following plugins: %1$s.','flat'),
- 'notice_can_install_recommended' => _n_noop('This theme recommends the following plugin: %1$s.', 'This theme recommends the following plugins: %1$s.','flat'),
- '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.','flat'),
- 'notice_can_activate_required' => _n_noop('The following required plugin is currently inactive: %1$s.', 'The following required plugins are currently inactive: %1$s.','flat'),
- 'notice_can_activate_recommended' => _n_noop('The following recommended plugin is currently inactive: %1$s.', 'The following recommended plugins are currently inactive: %1$s.','flat'),
- '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.','flat'),
- '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.','flat'),
- '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.','flat'),
- 'install_link' => _n_noop('Begin installing plugin', 'Begin installing plugins','flat'),
- 'activate_link' => _n_noop('Begin activating plugin', 'Begin activating plugins','flat'),
- 'return' => __('Return to Required Plugins Installer', 'flat'),
- 'plugin_activated' => __('Plugin activated successfully.', 'flat'),
- 'complete' => __('All plugins installed and activated successfully. %s', 'flat'),
- 'nag_type' => 'updated'
- )
- <div id="fb-root"></div>
- <script>(function(d, s, id) {
- var js, fjs = d.getElementsByTagName(s)[0];
- if (d.getElementById(id)) return;
- js = d.createElement(s); js.id = id;
- js.src = 'https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.12&appId=467845883260663&autoLogAppEvents=1';
- fjs.parentNode.insertBefore(js, fjs);
- }(document, 'script', 'facebook-jssdk'));</script>
- <div class="fb-page" data-href="https://www.facebook.com/gaatablog/" data-adapt-container-width="true" data-hide-cover="false" data-show-facepile="true"><blockquote cite="https://www.facebook.com/gaatablog/" class="fb-xfbml-parse-ignore"><a href="https://www.facebook.com/gaatablog/">Gaata.pl</a></blockquote></div>
- );
- tgmpa($plugins, $config);
- }
- /**
- * Enhances "Read more..." links with Bootstrap button styling
- */
- function flat_modify_read_more_link() {
- return '<a class="btn btn-default btn-sm" href="' . esc_url( get_permalink() ) . '">' . sprintf( __( 'Continue reading %s', 'flat' ), '<i class="fa fa-angle-double-right"></i></a>' );
- }
Advertisement
Add Comment
Please, Sign In to add comment