Wsparcie » Używanie i konfiguracja WordPressa » Motyw potomny i functions.php + CSS

  • Chcę edytować plik CSS z głownego motywu który dotyczy zakładki #color schemes w lokalizacji /color-schemes/’ są umieszczone css.
    Jak zrobic aby były one zastąpione w motywie potomnym?

    Próbowałem to zrobic za pomocą functions.php ale mam problem z modyfikacją w motywie potomnym w pliku functions.php
    To jest funkcja: (jak sie nie myle odpowiada ona za zaciąganie zew. css, js itd do wordpress)

    
    function vega_wp_scripts() {
        
        /** CSS **/
        
        #bootstrap, fontawesome, bootstrapsocial
        wp_register_style('bootstrap', get_template_directory_uri() . '/assets/css/bootstrap.min.css' );
        wp_register_style('font-awesome', get_template_directory_uri().'/assets/css/font-awesome.min.css' );
        wp_register_style('bootstrap-social', get_template_directory_uri().'/assets/css/bootstrap-social.css' );
        
        #animate.css
        wp_enqueue_style('animate-css', get_template_directory_uri().'/assets/css/animate.css');
        
        #fonts
        wp_enqueue_style('vega-wp-googlefont1', 
        '//fonts.googleapis.com/css?family=Lato:400,400i,700,700i,900,900i&subset=latin-ext');
    
        #default stylesheet
        $vega_wp_theme = wp_get_theme();
        $deps = array('bootstrap', 'font-awesome', 'bootstrap-social');
        wp_enqueue_style('vega-wp-style', get_stylesheet_uri(), $deps, $vega_wp_theme->get( 'Version' ));
            
        #color scheme
        $vega_wp_color_stylesheet = vega_wp_get_option('vega_wp_color_stylesheet');
        wp_enqueue_style('vega-wp-color', get_template_directory_uri() . '/color-schemes/' . strtolower($vega_wp_color_stylesheet) . '.css', array() );
        
        // Load html5shiv.js
    	wp_enqueue_script( 'vega-html5', get_template_directory_uri() . '/assets/js/html5shiv.js', array('vega-wp-style'), '3.7.0' );
    	wp_script_add_data( 'vega-html5', 'conditional', 'lt IE 9' );
        
        // Load respond.min.js
    	wp_enqueue_script( 'vega-respond', get_template_directory_uri() . '/assets/js/respond.min.js', array('vega-wp-style'), '1.3.0' );
    	wp_script_add_data( 'vega-html5', 'conditional', 'lt IE 9' );
        
        /** Javascript **/
        
        #bootstrap
        wp_enqueue_script('bootstrap', get_template_directory_uri().'/assets/js/bootstrap.min.js', array('jquery'), '', true );
        wp_enqueue_script('jquery-smartmenus', get_template_directory_uri() . '/assets/js/jquery.smartmenus.min.js', array('jquery'), '', true );
        wp_enqueue_script('jquery-smartmenus-bootstrap', get_template_directory_uri() . '/assets/js/jquery.smartmenus.bootstrap.min.js', array('jquery'), '', true );
            
        #animation
        $vega_wp_animations = vega_wp_get_option('vega_wp_animations');
        if($vega_wp_animations == 'Y') {
            wp_enqueue_script('wow', get_template_directory_uri() . '/assets/js/wow.min.js', array('jquery'), '', true );
            wp_enqueue_script('vega-wp-themejs-anim', get_template_directory_uri() . '/assets/js/vega-wp-anim.js', array('jquery'), '', true );
        }
        
        #parallax
        wp_enqueue_script('parallax', get_template_directory_uri() . '/assets/js/parallax.min.js', array('jquery'), '', true );
        
        #theme javascript
        $vega_this_theme = wp_get_theme();
        wp_enqueue_script('vega-wp-themejs', get_template_directory_uri() . '/assets/js/vega-wp.js', array('jquery'), $vega_this_theme->get( 'Version' ), true );
        
        #comments
        if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
            wp_enqueue_script( 'comment-reply' );
        }
        
    }
    add_action( 'wp_enqueue_scripts', 'vega_wp_scripts' );

    Dokładnie chodzi o czesc #color scheme chce aby mi zaciągało plik z motywu potomnego.

    • This topic was modified 6 years, 3 months temu by mateusz1wp.
Viewing 3 replies - 1 through 3 (of 3 total)
  • np.

    function child_custom_enqueue() {
      wp_dequeue_style( 'vega-wp-color' );
      $vega_wp_color_stylesheet = vega_wp_get_option('vega_wp_color_stylesheet');
      wp_enqueue_style('vega-wp-color', get_stylesheet_directory_uri() . '/color-schemes/' . strtolower($vega_wp_color_stylesheet) . '.css', array() );
    }
    add_action( 'wp_enqueue_scripts', 'child_custom_enqueue', 20 );
    Thread Starter mateusz1wp

    (@mateusz1wp)

    a mogę prosić o objaśnienie linijka po linijce?

    Z poziomu motywu potomnego korzystając z akcji wp_enqueue_scripts dokonujesz podmiany styli. Kolejno – usuwasz z kolejki arkusz styli rodzica (wp_dequeue_style), potem pobierasz aktualny schemat kolorów z ustawień motywu (vega_wp_get_option) i na końcu dodajesz ponownie do kolejki arkusz styli (wp_enqueue_style) z właściwym schematem, tyle że już motywu potomnego (get_stylesheet_directory_uri).

Viewing 3 replies - 1 through 3 (of 3 total)
  • Temat ‘Motyw potomny i functions.php + CSS’ jest zamknięty na nowe odpowiedzi.