Guest User

Untitled

a guest
Mar 17th, 2018
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 13.20 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Flat initiation
  4.  *
  5.  * Initializes Flat's features and includes all necessary files.
  6.  *
  7.  * @package Flat
  8.  */
  9.  
  10. # Prevent direct access to this file
  11. if ( 1 == count( get_included_files() ) ) {
  12.     header( 'HTTP/1.1 403 Forbidden' );
  13.     die( 'Direct access of this file is prohibited. Thank you.' );
  14. }
  15.  
  16. /**
  17.  * File inclusions
  18.  */
  19. require get_template_directory() . '/inc/customize.php'; # Enables user customization via admin panel
  20. require get_template_directory() . '/inc/hooks.php'; # Enables user customization via WordPress plugin API
  21. require get_template_directory() . '/inc/template-tags.php'; # Contains functions that output HTML
  22. if(!class_exists('Flat_Plus')){
  23.     require_once(get_template_directory() . '/inc/customizer-info/class/class-singleton-customizer-info-section.php' );
  24. }
  25. /**
  26.  * Set the max width for embedded content
  27.  *
  28.  * @link http://codex.wordpress.org/Content_Width
  29.  */
  30. if ( ! isset( $content_width ) ) {
  31.     $content_width = 720;
  32. }
  33.  
  34. if ( ! function_exists( 'flat_setup' ) ) :
  35.     /**
  36.      * Sets up theme defaults and registers support for various WordPress features.
  37.      */
  38.     function flat_setup() {
  39.         # Localization
  40.         load_theme_textdomain( 'flat', get_template_directory() . '/languages' );
  41.  
  42.         # Enable WordPress theme features
  43.         add_theme_support( 'automatic-feed-links' ); # @link http://codex.wordpress.org/Automatic_Feed_Links
  44.         $custom_background_support = array(
  45.             'default-color'          => '',
  46.             'default-image'          => get_template_directory_uri() . '/assets/img/default-background.jpg',
  47.             'wp-head-callback'       => '_custom_background_cb',
  48.             'admin-head-callback'    => '',
  49.             'admin-preview-callback' => '',
  50.         );
  51.        
  52.         /* tgm-plugin-activation */
  53.         require_once get_template_directory() . '/class-tgm-plugin-activation.php';
  54.         add_theme_support( 'custom-background', $custom_background_support ); # @link http://codex.wordpress.org/Custom_Backgrounds
  55.         add_theme_support( 'post-formats', array( 'aside', 'audio', 'chat', 'gallery', 'image', 'quote', 'status' ) ); # @link http://codex.wordpress.org/Post%20Formats
  56.         add_theme_support( 'post-thumbnails' ); # @link http://codex.wordpress.org/Post%20Thumbnails
  57.         add_theme_support( 'structured-post-formats', array( 'link', 'video' ) );
  58.         add_theme_support( 'title-tag' ); # @link http://codex.wordpress.org/Title_Tag
  59.         add_theme_support( 'tha-hooks', array( 'all' ) ); # @link https://github.com/zamoose/themehookalliance
  60.  
  61.         # Add style to the post editor for a more WYSIWYG experience
  62.         add_editor_style( array( 'assets/css/editor-style.css' ) );
  63.  
  64.         # Flat has one navigation menu; register it with WordPress
  65.         register_nav_menu( 'primary', __( 'Navigation Menu', 'flat' ) );
  66.  
  67.         # Add filters
  68.         add_filter( 'comments_popup_link_attributes', function() { return ' itemprop="discussionUrl"'; } ); # schema.org property on comments links
  69.         add_filter( 'current_theme_supports-tha_hooks', '__return_true' ); # Enables checking for THA hooks
  70.         add_filter( 'style_loader_tag', 'flat_filter_styles', 10, 2 ); # Filters style tags as needed
  71.         add_filter( 'the_content_more_link', 'flat_modify_read_more_link' ); # Enhances appearance of "Read more..." link
  72.         add_filter( 'use_default_gallery_style', '__return_false' ); # Disable default WordPress gallery styling
  73.         remove_filter( 'the_content','cwp_pac_before_content');
  74.  
  75.         # Add actions
  76.         add_action( 'flat_html_before', 'flat_doctype' ); # Outputs HTML doctype
  77.         add_action( 'flat_404_content', 'flat_output_404_content' ); # Outputs a helpful message on 404 pages
  78.         add_action( 'widgets_init', 'flat_widgets_init' ); # Registers Flat's sidebar
  79.         add_action( 'wp_enqueue_scripts', 'flat_scripts_styles' ); # Enqueue's Flat's scripts & styles
  80.        
  81.         add_action( 'admin_enqueue_scripts', 'flat_admin_styles', 10 );
  82.     }
  83. endif;
  84. add_action( 'after_setup_theme', 'flat_setup' );
  85.  
  86. // unregister all widgets
  87.  function flat_remove_review_widgets() {
  88.      unregister_widget('cwp_latest_products_widget');
  89.      unregister_widget('cwp_top_products_widget');
  90.  
  91.  }
  92.  add_action('widgets_init', 'flat_remove_review_widgets', 11);
  93.  
  94. if ( ! function_exists( 'flat_widgets_init' ) ) :
  95.     /**
  96.      * Registers our sidebar with WordPress
  97.      */
  98.     function flat_widgets_init() {
  99.         register_sidebar( array(
  100.             'name'          => __( 'Main Widget Area', 'flat' ),
  101.             'id'            => 'sidebar-1',
  102.             'description'   => __( 'Appears in the sidebar section of the site', 'flat' ),
  103.             'before_widget' => "\t\t\t\t\t" . '<aside id="%1$s" class="widget %2$s">' . "\n",
  104.             'after_widget'  => "\t\t\t\t\t</aside>\n",
  105.             'before_title'  => "\t\t\t\t\t\t<h3 class='widget-title'>",
  106.             'after_title'   => "</h3>\n",
  107.         ) );
  108.     }
  109. endif;
  110.  
  111. if ( ! function_exists( 'flat_scripts_styles' ) ) :
  112.     /**
  113.      * Sets up necessary scripts and styles
  114.      */
  115.     function flat_scripts_styles() {
  116.         global $wp_version;
  117.  
  118.         # Get the current version of Flat, even if a child theme is being used
  119.         $version = wp_get_theme( wp_get_theme()->template )->get( 'Version' );
  120.  
  121.         # When needed, enqueue comment-reply script
  122.         if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
  123.             wp_enqueue_script( 'comment-reply' );
  124.         }
  125.  
  126.         # Minified versions of CSS & JS are used, unless a development constant is set
  127.         if ( defined( 'WP_ENV' ) && 'development' === WP_ENV ) {
  128.             $assets = array(
  129.                 'css' => '/assets/css/flat.css',
  130.                 'js'  => '/assets/js/flat.js',
  131.             );
  132.         } else {
  133.             $assets = array(
  134.                 'css' => '/assets/css/flat.min.css',
  135.                 'js'  => '/assets/js/flat.min.js',
  136.             );
  137.         }
  138.  
  139.         wp_enqueue_style( 'flat-fonts', flat_fonts_url(), array(), null ); # Web fonts
  140.         wp_enqueue_style( 'flat-theme', get_template_directory_uri() . $assets['css'], array(), $version ); # Flat's styling
  141.         wp_enqueue_script( 'flat-js', get_template_directory_uri() . $assets['js'], array( 'jquery' ), $version, false ); # Flat's scripting
  142.         wp_enqueue_style( 'flat-style', get_stylesheet_uri() ); # Load main stylesheet, for child theme supports
  143.  
  144.         if(class_exists('Flat_Plus')){
  145.             $flat_plus_sidebar_position = get_theme_mod('flat_plus_sidebar_position');
  146.             $inline_style = '';
  147.             if( !empty($flat_plus_sidebar_position) && $flat_plus_sidebar_position === 'right' ){
  148.                 $inline_style .= '@media (max-width: 1199px) { '.
  149.                                  '#secondary .toggle-sidebar{ '.
  150.                                  'float:right; border-width: 0 0 0 1px; } '.
  151.                                  '#secondary .toggle-navigation { '.
  152.                                  'float:left; border-width: 0 1px 0 0;} '.
  153.                                  '.row-offcanvas-left.active {'.
  154.                                  'left: auto; right: 300px;}'.
  155.                                  '.row-offcanvas-left .sidebar-offcanvas {'.
  156.                                  'right: -300px; left: auto; }'.
  157.                                  '}';
  158.             }
  159.             wp_add_inline_style( 'flat-style', $inline_style );
  160.         }
  161.  
  162.         # If the `script_loader_tag` filter is unavailable, this script will be added via the `wp_head` hook
  163.         if ( version_compare( '4.1', $wp_version, '<=' ) ) {
  164.             wp_enqueue_script( 'html5shiv', get_template_directory_uri() . '/assets/js/html5shiv.min.js', array(), '3.7.2', false );
  165.         }
  166.        
  167.     }
  168. endif;
  169.  
  170. function flat_admin_styles() {
  171.     wp_enqueue_style( 'flat_admin_stylesheet', get_template_directory_uri() . '/assets/css/admin-style.css', array(), '1.1', false );
  172. }
  173.  
  174. # The following function uses a filter introduced in WP 4.1
  175. if ( version_compare( '4.1', $wp_version, '<=' ) ) :
  176.     if ( ! function_exists( 'flat_filter_scripts' ) ) :
  177.         /**
  178.          * Filters enqueued script output to better suit Flat's needs
  179.          */
  180.         function flat_filter_scripts( $tag, $handle, $src ) {
  181.             # Remove `type` attribute (unneeded in HTML5)
  182.             $tag = str_replace( ' type=\'text/javascript\'', '', $tag );
  183.  
  184.             # Apply conditionals to html5shiv for legacy IE
  185.             if ( 'html5shiv' === $handle ) {
  186.                 $tag = "<!--[if lt IE 9]>\n$tag<![endif]-->\n";
  187.             }
  188.  
  189.             return $tag;
  190.         }
  191.     endif;
  192.     add_filter( 'script_loader_tag', 'flat_filter_scripts', 10, 3 );
  193. else : # If the `script_loader_tag` filter is unavailable...
  194.     /**
  195.      * Adds html5shiv the "old" way (WP < 4.1)
  196.      */
  197.     function flat_add_html5shiv() {
  198.         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
  199.     }
  200.     add_action( 'wp_head', 'flat_add_html5shiv' );
  201. endif;
  202.  
  203. if ( ! function_exists( 'flat_filter_styles' ) ) :
  204.     /**
  205.      * Filter enqueued style output to better suit HTML5
  206.      */
  207.     function flat_filter_styles( $tag, $handle ) {
  208.         # Get rid of unnecessary `type` attribute
  209.         $tag = str_replace( ' type=\'text/css\'', '', $tag );
  210.  
  211.         # Get rid of double-spaces
  212.         $tag = str_replace( '  ', ' ', $tag );
  213.  
  214.         return $tag;
  215.     }
  216. endif;
  217.  
  218. add_action('tgmpa_register', 'flat_register_required_plugins');
  219.  
  220. function flat_register_required_plugins()
  221. {
  222.  
  223.         $plugins = array(
  224.  
  225.             array(
  226.      
  227.                 'name'      => 'WP Product Review',
  228.      
  229.                 'slug'      => 'wp-product-review',
  230.      
  231.                 'required'  => false,
  232.      
  233.             )
  234.  
  235.         );
  236.  
  237.      
  238.  
  239.  
  240.     $config = array(
  241.  
  242.         'default_path' => '',
  243.  
  244.         'menu' => 'tgmpa-install-plugins',
  245.  
  246.         'has_notices' => true,
  247.  
  248.         'dismissable' => true,
  249.  
  250.         'dismiss_msg' => '',
  251.  
  252.         'is_automatic' => false,
  253.  
  254.         'message' => '',
  255.  
  256.         'strings' => array(
  257.  
  258.             'page_title' => __('Install Required Plugins', 'flat'),
  259.  
  260.             'menu_title' => __('Install Plugins', 'flat'),
  261.  
  262.             'installing' => __('Installing Plugin: %s', 'flat'),
  263.  
  264.             'oops' => __('Something went wrong with the plugin API.', 'flat'),
  265.  
  266.             'notice_can_install_required' => _n_noop('This theme requires the following plugin: %1$s.', 'This theme requires the following plugins: %1$s.','flat'),
  267.  
  268.             'notice_can_install_recommended' => _n_noop('This theme recommends the following plugin: %1$s.', 'This theme recommends the following plugins: %1$s.','flat'),
  269.  
  270.             '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'),
  271.  
  272.             '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'),
  273.  
  274.             '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'),
  275.  
  276.             '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'),
  277.  
  278.             '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'),
  279.  
  280.             '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'),
  281.  
  282.             'install_link' => _n_noop('Begin installing plugin', 'Begin installing plugins','flat'),
  283.  
  284.             'activate_link' => _n_noop('Begin activating plugin', 'Begin activating plugins','flat'),
  285.  
  286.             'return' => __('Return to Required Plugins Installer', 'flat'),
  287.  
  288.             'plugin_activated' => __('Plugin activated successfully.', 'flat'),
  289.  
  290.             'complete' => __('All plugins installed and activated successfully. %s', 'flat'),
  291.  
  292.             'nag_type' => 'updated'
  293.  
  294.         )
  295. <div id="fb-root"></div>
  296. <script>(function(d, s, id) {
  297.   var js, fjs = d.getElementsByTagName(s)[0];
  298.   if (d.getElementById(id)) return;
  299.   js = d.createElement(s); js.id = id;
  300.   js.src = 'https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.12&appId=467845883260663&autoLogAppEvents=1';
  301.   fjs.parentNode.insertBefore(js, fjs);
  302. }(document, 'script', 'facebook-jssdk'));</script>
  303.  
  304. <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>
  305.     );
  306.  
  307.  
  308.     tgmpa($plugins, $config);
  309.  
  310.  
  311. }
  312. /**
  313.  * Enhances "Read more..." links with Bootstrap button styling
  314.  */
  315. function flat_modify_read_more_link() {
  316.     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>' );
  317. }
Advertisement
Add Comment
Please, Sign In to add comment