Senin, 02 Maret 2020

01.54

application/x-httpd-php functions.php ( PHP script text )

<?php
/**
 * StructurePress functions and definitions
 *
 * @author Marko Prelec <marko.prelec@proteusnet.com>
 * @author Gregor Capuder <gregor.capuder@proteusnet.com>
 * @author Primoz Cigler <primoz@proteusnet.com>
 */

// Display informative message if PHP version is less than 5.3.2
if ( version_compare( phpversion(), '5.3.2', '<' ) ) {
 die( sprintf( esc_html_x( 'This theme requires %$2sPHP 5.3.2+%$3s to run. Please contact your hosting company and ask them to update the PHP version of your site to at least PHP 5.3.2.%$4s Your current version of PHP: %$2s%1$s%$3s', '%1$s - version ie. 5.4.0. %2$s, %3$s and %4$s  - html tags, must be included around the same words as original', 'structurepress-pt' ), phpversion(), '<strong>', '</strong>', '<br>' ) );
}


// Composer autoloader
require_once trailingslashit( get_template_directory() ) . 'vendor/autoload.php';


/**
 * Define the version variable to assign it to all the assets (css and js)
 */
define( 'STRUCTUREPRESS_WP_VERSION', wp_get_theme()->get( 'Version' ) );


/**
 * Define the development constant
 */
if ( ! defined( 'STRUCTUREPRESS_DEVELOPMENT' ) ) {
 define( 'STRUCTUREPRESS_DEVELOPMENT', false );
}


/**
 * Advanced Custom Fields calls to require the plugin within the theme
 */
require_once get_template_directory() . '/inc/acf.php';


/**
 * Theme support and thumbnail sizes
 */
if ( ! function_exists( 'structurepress_theme_setup' ) ) {
 function structurepress_theme_setup() {
  /*
   * Make theme available for translation.
   * Translations can be filed in the /languages/ directory.
   * If you're building a theme based on StructurePress, use a find and replace
   * to change 'structurepress-pt' to the name of your theme in all the template files
   */
  load_theme_textdomain( 'structurepress-pt', get_template_directory() . '/languages' );

  /**
   * Loads separate textdomain for the proteuswidgets which are included with composer.
   */
  load_theme_textdomain( 'proteuswidgets', get_template_directory() . '/languages/proteuswidgets' );

  // Add default posts and comments RSS feed links to head.
  add_theme_support( 'automatic-feed-links' );

  // WooCommerce basic support
  add_theme_support( 'woocommerce' );

  /**
   * 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 http://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails
   */
  add_theme_support( 'post-thumbnails' );
  add_image_size( 'structurepress-jumbotron-slider-l', 1920, 660, true );
  add_image_size( 'structurepress-jumbotron-slider-s', 425, 146, true );
  add_image_size( 'portfolio-gallery', 540, 540 );
  // set_post_thumbnail_size( 600, 400, true );

  // Menus
  add_theme_support( 'menus' );
  register_nav_menu( 'main-menu', _x( 'Main Menu', 'backend', 'structurepress-pt' ) );
  register_nav_menu( 'top-bar-menu', _x( 'Top Bar Menu', 'backend', 'structurepress-pt' ) );

  /**
   * 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 excerpt support for pages
  add_post_type_support( 'page', 'excerpt' );

  // Set up the WordPress core custom background feature.
  add_theme_support( 'custom-background', apply_filters( 'structurepress_custom_background_args', array(
   'default-color' => 'ffffff',
   'default-image' => '',
  ) ) );
 }
 add_action( 'after_setup_theme', 'structurepress_theme_setup' );
}


/**
 * Set the content width based on the theme's design and stylesheet.
 *
 * @see https://codex.wordpress.org/Content_Width
 */
if ( ! isset( $content_width ) ) {
 $content_width = 1140; /* pixels */
}


/**
 * Enqueue CSS stylesheets
 */
if ( ! function_exists( 'structurepress_enqueue_styles' ) ) {
 function structurepress_enqueue_styles() {
  wp_enqueue_style( 'structurepress-main', get_stylesheet_uri(), array(), STRUCTUREPRESS_WP_VERSION );

  // custom WooCommerce CSS (enqueue it only if the WooCommerce plugin is active)
  if ( StructurePressHelpers::is_woocommerce_active() ) {
   wp_enqueue_style( 'structurepress-woocommerce', get_template_directory_uri() . '/woocommerce.css' , array( 'structurepress-main' ) , STRUCTUREPRESS_WP_VERSION );
  }
 }
 add_action( 'wp_enqueue_scripts', 'structurepress_enqueue_styles' );
}


/**
 * Enqueue Google Web Fonts.
 */
if ( ! function_exists( 'structurepress_enqueue_google_web_fonts' ) ) {
 function structurepress_enqueue_google_web_fonts() {
  wp_enqueue_style( 'structurepress-google-fonts', StructurePressHelpers::google_web_fonts_url(), array(), null );
 }
 add_action( 'wp_enqueue_scripts', 'structurepress_enqueue_google_web_fonts' );
}


/**
 * Enqueue JS scripts
 */
if ( ! function_exists( 'structurepress_enqueue_scripts' ) ) {
 function structurepress_enqueue_scripts() {
  // modernizr for the frontend feature detection
  wp_enqueue_script( 'structurepress-modernizr', get_template_directory_uri() . '/assets/js/modernizr.custom.24530.js', array(), null );

  // picturefill for the support of the <picture> element today
  wp_enqueue_script( 'structurepress-picturefill', get_template_directory_uri() . '/bower_components/picturefill/dist/picturefill.min.js', array( 'structurepress-modernizr' ), '2.2.1' );

  // google maps
  wp_register_script( 'structurepress-gmaps', '//maps.google.com/maps/api/js', array(), null, true );

  // requirejs
  wp_register_script( 'structurepress-requirejs', get_template_directory_uri() . '/bower_components/requirejs/require.js', array(), null, true );

  // main JS file, conditionally
  if ( true === STRUCTUREPRESS_DEVELOPMENT ) {
   wp_enqueue_script( 'structurepress-main', get_template_directory_uri() . '/assets/js/main.js', array(
    'jquery',
    'underscore',
    'structurepress-requirejs',
    'structurepress-gmaps',
   ), STRUCTUREPRESS_WP_VERSION, true );
  }
  else {
   wp_enqueue_script( 'structurepress-main', get_template_directory_uri() . '/assets/js/main.min.js', array(
    'jquery',
    'underscore',
    'structurepress-gmaps',
   ), STRUCTUREPRESS_WP_VERSION, true );
  }

  // Pass data to the main script
  wp_localize_script( 'structurepress-main', 'StructurePressVars', array(
   'pathToTheme'  => get_template_directory_uri(),
  ) );

  // for nested comments
  if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
   wp_enqueue_script( 'comment-reply' );
  }
 }
 add_action( 'wp_enqueue_scripts', 'structurepress_enqueue_scripts' );
}


/**
 * Register admin JS scripts
 */
if ( ! function_exists( 'structurepress_admin_enqueue_scripts' ) ) {
 function structurepress_admin_enqueue_scripts() {
  // mustache for ProteusWidgets
  wp_register_script( 'structurepress-mustache.js', get_template_directory_uri() . '/bower_components/mustache/mustache.min.js' );

  // enqueue admin utils js
  wp_enqueue_script( 'structurepress-admin-utils', get_template_directory_uri() . '/assets/admin/js/admin.js', array( 'jquery', 'underscore', 'backbone', 'structurepress-mustache.js' ) );

  // register fa CSS
  wp_register_style( 'structurepress-font-awesome', get_template_directory_uri() . '/bower_components/font-awesome/css/font-awesome.min.css', array(), '4.4.0' );

  // enqueue CSS for admin area
  wp_enqueue_style( 'structurepress-admin-css', get_template_directory_uri() . '/assets/admin/css/admin.css' );

 }
 add_action( 'admin_enqueue_scripts', 'structurepress_admin_enqueue_scripts' );
}


/**
 * Require the files in the folder /inc/
 */
$structurepress_files_to_require = array(
 'helpers',
 'theme-widgets',
 'theme-vc-include',
 'theme-sidebars',
 'filters',
 'compat',
 'theme-customizer',
 'woocommerce',
);

// Conditionally require the includes files, based if they exist in the child theme or not
foreach ( $structurepress_files_to_require as $file ) {
 require_once trailingslashit( get_template_directory() ) . 'inc/' . $file . '.php';
}


/**
 * WIA-ARIA nav walker and accompanying JS file
 */

if ( ! function_exists( 'structurepress_wai_aria_js' ) ) {
 function structurepress_wai_aria_js() {
  wp_enqueue_script( 'structurepress-wp-wai-aria', get_template_directory_uri() . '/vendor/proteusthemes/wai-aria-walker-nav-menu/wai-aria.js', array( 'jquery' ), null, true );
 }
 add_action( 'wp_enqueue_scripts', 'structurepress_wai_aria_js' );
}


/**
 * Require some files only when in admin
 */
if ( is_admin() ) {
 // other files
 $structurepress_admin_files_to_require = array(
  // custom code
  'inc/tgm-plugin-activation',
  'inc/content-import',
  'inc/documentation-link',
  'inc/automatic-updates',
 );

 foreach ( $structurepress_admin_files_to_require as $file ) {
  require_once trailingslashit( get_template_directory() ) . $file . '.php';
 }
}
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart');
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
add_filter( 'woocommerce_product_tabs', 'woo_rename_tab', 98);
function woo_rename_tab($tabs) {
$tabs['description']['title'] = 'RINCIAN';return $tabs;
}
function my_text_strings( $translated_text, $text, $domain ) {
 switch ( $translated_text ) {
  case 'Related Products' :
   $translated_text = __( 'PILIHAN LAIN', 'woocommerce' );
   break;
 }
 return $translated_text;
}
add_filter( 'gettext', 'my_text_strings', 20, 3 );

add_filter( 'woocommerce_output_related_products_args', 'jk_related_products_args' );
  function jk_related_products_args( $args ) {
 $args['posts_per_page'] = 6; // 4 related products
 $args['columns'] = 3; // arranged in 2 columns
 return $args;
}
/** Start of Remove Date TimeStamp from blog posts */
function remove_post_dates() {
add_filter('the_time', '__return_false');
add_filter('get_the_time', '__return_false');
add_filter('the_modified_time', '__return_false');
add_filter('get_the_modified_time', '__return_false');
add_filter('the_date', '__return_false');
add_filter('get_the_date', '__return_false');
add_filter('the_modified_date', '__return_false');
add_filter('get_the_modified_date', '__return_false');
add_filter('get_comment_date', '__return_false');
add_filter('get_comment_time', '__return_false');
}
add_action('loop_start', 'remove_post_dates');
/** End of Remove Date TimeStamp from blog posts */




_____________________________________

Keterangan: 
Yang beri warna merah ada kode utama yang perlu di masukkan ke functions.php

functions.php terletak di wp content wp-content/themes/structurepress-pt
 


Untuk hidden melalui CSS:
pertama harus dihapus dulu dari functions.php
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart');
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );


Lalu masukkan CSS di wp admin

body.woocommerce-page ul.products li.product .button, .woocommerce ul.products li.product .button {
    display: none;
}

body.woocommerce-page div.product form.cart .button.single_add_to_cart_button {
    display: none;
}

body.woocommerce-page .quantity .qty {
    display: none;
}

0 komentar:

Posting Komentar