1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
function my_assets() { // BOOTSTRAP AND MAIN CSS wp_enqueue_style( 'bootstrap', get_stylesheet_directory_uri() . '/vendor/bootstrap/css/bootstrap.min.css' ); wp_enqueue_style( 'ThemeStyles', get_stylesheet_directory_uri() . '/css/business-frontpage.css' ); // DEREGISTER AND REGISTER JQUERY wp_deregister_script( 'jquery' ); wp_enqueue_script( 'jquery', get_stylesheet_directory_uri() . '/vendor/jquery/jquery.min.js' ); wp_enqueue_script( 'bsbundle', get_stylesheet_directory_uri() . '/vendor/bootstrap/js/bootstrap.bundle.min.js' ); // FONT AWESOME wp_enqueue_style( 'load-fa', 'https://use.fontawesome.com/releases/v5.4.1/css/all.css' ); //GOOGLE FONTS wp_enqueue_style( 'NunitoSans', 'https://fonts.googleapis.com/css?family=Nunito+Sans:300,300i,400,400i,700,700i&subset=latin-ext', false ); wp_enqueue_style( 'PlayfairDisplay', 'https://fonts.googleapis.com/css?family=Playfair+Display:400,700&subset=cyrillic,latin-ext', false ); } add_action( 'wp_enqueue_scripts', 'my_assets' ); |
1 2 3 4 5 6 7 |
// Do motywu function jquery() { wp_deregister_script('jquery'); wp_register_script('jquery', '//code.jquery.com/jquery-3.4.1.min.js', false, null); wp_enqueue_script('jquery'); } add_action( 'wp_enqueue_scripts', 'jquery' ); |
1 2 3 4 5 6 7 |
// Do admin panelu function jquery_admin() { wp_deregister_script('jquery'); wp_register_script('jquery', '//code.jquery.com/jquery-3.4.1.min.js', false, null); wp_enqueue_script('jquery'); } add_action( 'admin_enqueue_scripts', 'jquery_admin' ); |
1 2 3 4 5 6 7 |
// POST THUMBNAILS add_theme_support( 'post-thumbnails' ); add_image_size( 'category-thumb', 728, 9999 ); // 728 pixels wide (and unlimited height) add_image_size( 'related', 9999, 300 ); // 150 pixels wide (and 250px height) add_image_size( 'full-page', 1000, 99999 ); // 150 pixels wide (and 250px height) add_image_size( 'mascara', 200, 350 ); // 150 pixels wide (and 250px height) |
1 2 3 4 5 6 7 8 9 10 |
// THEME LOGO add_theme_support( 'custom-logo' ); add_theme_support( 'custom-logo', array( 'height' => 42, 'width' => 75, 'flex-height' => true, 'flex-width' => true, 'header-text' => array( 'site-title', 'site-description' ), ) ); |
1 2 3 4 |
// Bs4NavWalker require_once('bs4navwalker.php'); // Bs3NavWalker require_once(dirname(__FILE__).'/lib/wp-bootstrap-navwalker.php'); |
1 |
register_nav_menu('top', 'Top menu'); |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
// RGISTER SIDEBAR function _s_widgets_init() { register_sidebar( array( 'name' => esc_html__( 'Sidebar', '_s' ), 'id' => 'sidebar-1', 'description' => esc_html__( 'Add widgets here.', '_s' ), 'before_widget' => '<div id="%1$s" class="widget %2$s row my-4">', 'after_widget' => '</div>', 'before_title' => '<h2 class="widget-title">', 'after_title' => '</h2>', ) ); } add_action( 'widgets_init', '_s_widgets_init' ); |
1 2 3 4 |
function custom_excerpt_length( $length ) { return 10; } add_filter( 'excerpt_length', 'custom_excerpt_length', 999 ); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
/** * Create Logo Setting and Upload Control */ add_action( 'customize_register', 'cd_customizer_settings' ); function cd_customizer_settings( $wp_customize ) { // Add section to personaize options ============================================================================================== $wp_customize->add_section( 'customize_me' , array( 'title' => 'Zarządzaj motywem', 'priority' => 30, ) ); // Add Settings =================================================================================================================== $wp_customize->add_setting( 'ranking_category' , array( // Set Ranking Category 'default' => 'ranking', 'transport' => 'refresh', ) ); // Add Settings Control ============================================================================================================ $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'ranking_category', array( // Ranking Category Callback 'label' => 'Slug kategorii z mascarami.', 'section' => 'customize_me', // Section Name 'settings' => 'ranking_category', // Setting Name 'type' => 'text', ) ) ); } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
// Create Shortcode review // Shortcode: [review type="pros"] function create_review_shortcode($atts, $content = null) { $atts = shortcode_atts( array( 'type' => 'pros', ), $atts, 'review' ); $type = $atts['type']; return '<div class="'.$type.'">'.$content.'</div>'; } add_shortcode( 'review', 'create_review_shortcode' ); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
/* Theme options Settings Page */ class themeoptions_Settings_Page { public function __construct() { add_action( 'admin_menu', array( $this, 'wph_create_settings' ) ); add_action( 'admin_init', array( $this, 'wph_setup_sections' ) ); add_action( 'admin_init', array( $this, 'wph_setup_fields' ) ); } public function wph_create_settings() { $page_title = 'Ustawienia Szablonu "Ranking 10335"'; $menu_title = 'Theme options'; $capability = 'edit_theme_options'; $slug = 'themeoptions'; $callback = array($this, 'wph_settings_content'); $icon = 'dashicons-schedule'; add_theme_page($page_title, $menu_title, $capability, $slug, $callback); } public function wph_settings_content() { ?> <div class="wrap"> <h1>Ustawienia Szablonu "Ranking 10335"</h1> <?php settings_errors(); ?> <form method="POST" action="options.php"> <?php settings_fields( 'themeoptions' ); do_settings_sections( 'themeoptions' ); submit_button(); ?> </form> </div> <?php } public function wph_setup_sections() { add_settings_section( 'themeoptions_section', 'Weź i ustaw sobie kilka rzeczy', array(), 'themeoptions' ); } public function wph_setup_fields() { $fields = array( array( 'label' => 'Tekst do wyświetlenia w headerze strony', 'id' => 'site-header-text', 'type' => 'textarea', 'section' => 'themeoptions_section', 'desc' => 'ze znacznikami HTML', 'placeholder' => 'Przychylnym okiem: ...', ), array( 'label' => 'Logo tekstowe', 'id' => 'site-text-logo', 'type' => 'text', 'section' => 'themeoptions_section', 'desc' => 'Znajduje się obok nawigacji', 'placeholder' => 'np. Ranking', ), array( 'label' => 'Wstęp do rankingu', 'id' => 'ranking-intro', 'type' => 'textarea', 'section' => 'themeoptions_section', 'desc' => 'Zdanie tuż nad rankingiem', 'placeholder' => 'Oto lista...', ), array( 'label' => 'Sortowanie pozycji w rankingu', 'id' => 'ranking-order', 'type' => 'select', 'section' => 'themeoptions_section', 'options' => array( 'ASC' => 'Od najstarszego', 'DESC' => 'Od najmłodszego', ), 'desc' => 'Sortowanie wg dat', 'placeholder' => 'Wybierz sortowanie', ), array( 'label' => 'Kategoria z rankingiem', 'id' => 'ranking-cat', 'type' => 'text', 'section' => 'themeoptions_section', 'desc' => 'Wpisz ID kategorii (po przecinku jeśli jest więcej niż jedna)', 'placeholder' => 'np. 14, 12', ), ); foreach( $fields as $field ){ add_settings_field( $field['id'], $field['label'], array( $this, 'wph_field_callback' ), 'themeoptions', $field['section'], $field ); register_setting( 'themeoptions', $field['id'] ); } } public function wph_field_callback( $field ) { $value = get_option( $field['id'] ); switch ( $field['type'] ) { case 'select': case 'multiselect': if( ! empty ( $field['options'] ) && is_array( $field['options'] ) ) { $attr = ''; $options = ''; foreach( $field['options'] as $key => $label ) { $options.= sprintf('<option value="%s" %s>%s</option>', $key, selected($value[array_search($key, $value, true)], $key, false), $label ); } if( $field['type'] === 'multiselect' ){ $attr = ' multiple="multiple" '; } printf( '<select name="%1$s[]" id="%1$s" %2$s>%3$s</select>', $field['id'], $attr, $options ); } break; case 'textarea': printf( '<textarea name="%1$s" id="%1$s" placeholder="%2$s" rows="5" cols="50">%3$s</textarea>', $field['id'], $field['placeholder'], $value ); break; default: printf( '<input name="%1$s" id="%1$s" type="%2$s" placeholder="%3$s" value="%4$s" />', $field['id'], $field['type'], $field['placeholder'], $value ); } if( $desc = $field['desc'] ) { printf( '<p class="description">%s </p>', $desc ); } } } new themeoptions_Settings_Page(); |
1 |
<?php echo get_option('ranking-intro'); ?> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
add_action( 'customize_register', 'cd_customizer_settings' ); function cd_customizer_settings( $wp_customize ) { // Add section to personaize options ============================================================================================== $wp_customize->add_section( 'customize_me' , array( 'title' => 'Zarządzaj motywem', 'priority' => 30, ) ); // Add Settings =================================================================================================================== $wp_customize->add_setting( 'category_name', //No need to use a SERIALIZED name, as `theme_mod` settings already live under one db record array( 'default' => 'default', //Default setting/value to save 'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'? 'transport' => 'refresh', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)? ) ); $wp_customize->add_setting( 'more_text' , array( // Set Read More text 'default' => 'więcej', 'transport' => 'refresh', ) ); $wp_customize->add_setting( 'new_posts' , array( // Next Posts Text 'default' => 'Nowsze', 'transport' => 'refresh', ) ); $wp_customize->add_setting( 'prev_posts' , array( // Previous Posts Text 'default' => 'Starsze', 'transport' => 'refresh', ) ); $wp_customize->add_setting( 'order' , array( // Set Read More text 'default' => 'ASC', 'transport' => 'refresh', ) ); $wp_customize->add_setting( 'search_results' , array( // Set Read More text 'default' => 'Wyniki wyszukiwania dla: ', 'transport' => 'refresh', ) ); $wp_customize->add_setting( 'nothing_text' , array( // Set Read More text 'default' => 'Nic nie znaleziono. Prosimy spróbwac ponownie używając innych słów kluczowych.', 'transport' => 'refresh', ) ); // Add Settings Control ============================================================================================================ $all_categories = get_categories(); $args_categories = []; foreach($all_categories as $c) { $args_categories[$c->slug] = $c->name; } $wp_customize->add_control( new WP_Customize_Control($wp_customize, //Pass the $wp_customize object (required) 'category_name', //Set a unique ID for the control array( 'label' => 'Wybierz kategorię z rankingiem', //Admin-visible name of the control 'settings' => 'category_name', //Which setting to load and manipulate (serialized is okay) 'priority' => 10, //Determines the order this control appears in for the specified section 'section' => 'customize_me', //ID of the section this control should render in (can be one of yours, or a WordPress default section) 'type' => 'select', 'choices' => $args_categories, ) ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'more_text', array( // Read More Callback 'label' => 'więcej - tłumaczenie (widok rankingu).', 'section' => 'customize_me', 'settings' => 'more_text', 'type' => 'text', ) ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'new_posts', array( // Next Posts Text Callback 'label' => 'Nowsze wpisy - tłumaczenie', 'section' => 'customize_me', 'settings' => 'new_posts', 'type' => 'text', ) ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'prev_posts', array( // Previous Posts Text Callback 'label' => 'Starsze wpisy - tłumaczenie', 'section' => 'customize_me', 'settings' => 'prev_posts', 'type' => 'text', ) ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'order', array( // Previous Posts Text Callback 'label' => 'Kolejność wyswietlania elementów rankingu(ASC/DESC)', 'section' => 'customize_me', 'settings' => 'order', 'type' => 'text', ) ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'search_results', array( // Previous Posts Text Callback 'label' => 'Wyniki wyszukiwania dla: - tłumaczenie ', 'section' => 'customize_me', 'settings' => 'search_results', 'type' => 'text', ) ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'nothing_text', array( // Previous Posts Text Callback 'label' => 'Nic nie znaleziono. Prosimy spróbować ponownie używając innych słów kluczowych - tłumaczenie', 'section' => 'customize_me', 'settings' => 'nothing_text', 'type' => 'text', ) ) ); } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
function remove_post_slug( $post_link, $post, $leavename ) { if ( 'products' != $post->post_type || 'publish' != $post->post_status ) { return $post_link; } $post_link = str_replace( '/' . $post->post_type . '/', '/', $post_link ); return $post_link; } add_filter( 'post_type_link', 'remove_post_slug', 10, 3 ); function parse_request_trick( $query ) { if ( ! $query->is_main_query() || 2 != count( $query->query ) || ! isset( $query->query['page'] ) ) { return; } if ( ! empty( $query->query['name'] ) ) { $query->set( 'post_type', array( 'post', 'products', 'page' ) ); } } add_action( 'pre_get_posts', 'parse_request_trick' ); |