Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- add_action( 'after_setup_theme', 'premaman_theme_setup', 11 );
- function premaman_theme_setup() {
- //remove the built-in SEO functions
- remove_theme_support('hybrid-core-seo');
- //removing and improving the excerpt
- remove_filter('get_the_excerpt', 'wp_trim_excerpt');
- add_filter('get_the_excerpt', 'improved_trim_excerpt');
- /*modify breadcrumb trail for show pages*/
- add_filter( 'breadcrumb_trail_args', 'my_breadcrumb_trail_args' );
- /*preparing the theme for woocommerce*/
- add_action( 'wp_head', 'mytheme_prepare_woocommerce_wrappers' );
- // Remove WooCommerce sidebar
- remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10 );
- //remove http links in the admin bar
- add_action( 'wp_before_admin_bar_render', 'remove_admin_bar_links' );
- /*hide stuff from the profile page*/
- add_action( 'admin_print_scripts-profile.php', 'hideUserChoice' );
- add_filter('user_contactmethods','hide_profile_fields',10,1);
- add_filter( 'hybrid_byline', 'my_byline' );
- add_filter( 'loop_shop_per_page', create_function( '$cols', 'return 12;' ), 20 );
- add_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 20 );
- remove_action('woocommerce_pagination', 'woocommerce_catalog_ordering', 20 );
- add_filter( 'woocommerce_states', 'SA_woocommerce_states' );
- add_filter( 'gettext', 'my_gettext', 10, 3 );
- //customizing the PDFs
- add_filter('sod_pdf_header', 'sod_pdf_header_filter', 1, 4);
- }
- /*improve the excerpt, keep HTML in there*/
- function improved_trim_excerpt($text) {
- global $post;
- if ( '' == $text ) {
- $text = get_the_content('');
- $text = apply_filters('the_content', $text);
- $text = str_replace(']]>', ']]>', $text);
- /*uncomment the following line to strip javascript*/
- $text = preg_replace('@<script[^>]*?>.*?</script>@si', '', $text);
- /*$text = strip_tags($text, '<p><a><img><ul><ol><li>[php][css][text][perl][shell]');*/
- $text = strip_tags($text, '<p><a><ul><ol><li>[php][css][text][perl][shell]');
- $excerpt_length = 500;
- $words = explode(' ', $text, $excerpt_length + 1);
- if (count($words)> $excerpt_length) {
- array_pop($words);
- array_push($words, '[...]');
- $text = implode(' ', $words);
- }
- }
- return $text;
- }
- function my_breadcrumb_trail_args( $args ) {
- $args['singular_product_taxonomy'] = 'product_category';
- return $args;
- }
- /*themeing wocommerce*/
- function mytheme_open_woocommerce_content_wrappers()
- {
- echo '<div id="content" class="hfeed content">';
- }
- function mytheme_close_woocommerce_content_wrappers()
- {
- echo '</div>';
- }
- function mytheme_prepare_woocommerce_wrappers()
- {
- remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 );
- remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10);
- add_action( 'woocommerce_before_main_content', 'mytheme_open_woocommerce_content_wrappers', 10 );
- add_action( 'woocommerce_after_main_content', 'mytheme_close_woocommerce_content_wrappers', 10 );
- }
- //removing stuff from the admin bar
- function remove_admin_bar_links() {
- global $wp_admin_bar;
- $wp_admin_bar->remove_menu('wp-logo');
- $wp_admin_bar->remove_menu('updates');
- }
- //don't show the user any choice about the admin bar in the back end
- function hideUserChoice() { ?>
- <style type="text/css">
- .show-admin-bar { display: none; }
- </style>
- <?php
- }
- // remove aim, jabber, yim from the profile page
- function hide_profile_fields( $contactmethods ) {
- unset($contactmethods['aim']);
- unset($contactmethods['jabber']);
- unset($contactmethods['yim']);
- return $contactmethods;
- }
- //custom byline
- //my custom byline
- function my_byline( $byline ) {
- global $post;
- $byline = '<p class="byline">on the [entry-published] [entry-edit-link before="| "]</p>';
- return $byline;
- }
- //trying to show 4 related products and only one row of them
- // Redefine woocommerce_output_related_products()
- function woocommerce_output_related_products() {
- woocommerce_related_products(4,1); // Display 3 products in rows of 3
- }
- //add ZA provinces to woocommerce
- function SA_woocommerce_states( $states ) {
- $states['ZA'] = array(
- 'EC' => __('Eastern Cape', 'woocommerce') ,
- 'FS' => __('Free State', 'woocommerce') ,
- 'GP' => __('Gauteng', 'woocommerce') ,
- 'KZN' => __('KwaZulu-Natal', 'woocommerce') ,
- 'LP' => __('Limpopo', 'woocommerce') ,
- 'MP' => __('Mpumalanga', 'woocommerce') ,
- 'NC' => __('Northern Cape', 'woocommerce') ,
- 'NW' => __('North West', 'woocommerce') ,
- 'WC' => __('Western Cape', 'woocommerce')
- );
- return $states;
- }
- //change Sort code into Branch code for woocommerce
- function my_gettext( $translation, $text, $domain ) {
- if ( 'woocommerce' === $domain ) {
- $translations = &get_translations_for_domain( $domain );
- if ( 'Sort Code' === $text )
- $translation = $translations->translate( 'Branch Code' );
- }
- return $translation;
- }
- //customizing the PDFs
- function sod_pdf_header_filter($html, $logo, $woo, $order_num){
- $html = '<table class="header">' .
- '<tr>' .
- '<td class="logo left half">' . $logo . '</td>' .
- '<td class="right half">
- <h3 class="labels" style="margin-right:73px;">Invoice</h3>
- <table>
- <tr>
- <td class="right">'.__('Date: ', 'sod_wc_pdf_invoices').'</td>
- <td><span class="left">' . gmdate( "d.m.Y" , strtotime( $woo->order_date ) ) . '</span></td>
- </tr>
- <tr>
- <td class="right">'.__('Invoice: ', 'sod_wc_pdf_invoices').'</td>
- <td>'.$order_num.'</td>
- </tr>
- </table>
- </td>
- </tr>
- </table>';
- return $html;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement