IAmCosmin
(I Am Cosmin)
noiembrie 18, 2020, 3:30pm
1
Salut.
Incerc sa editez cateva fisiere din template-ul unei theme wordpress.
Am facut un folder thema-child, si am adaugat fisierele pe care vreau sa le editez, dar thema le foloseste tot pe cele din parent.
in thema-parent/functions.php avem
function et_setup_theme() {
global $themename, $shortname, $et_store_options_in_one_row, $default_colorscheme;
$themename = 'Divi';
$shortname = 'divi';
$et_store_options_in_one_row = true;
$default_colorscheme = "Default";
$template_directory = get_template_directory();
require_once( $template_directory . '/core/init.php' );
et_core_setup( get_template_directory_uri() );
if ( '3.0.61' === ET_CORE_VERSION ) {
require_once $template_directory . '/core/functions.php';
require_once $template_directory . '/core/components/init.php';
et_core_patch_core_3061();
}
require_once( $template_directory . '/epanel/custom_functions.php' );
require_once( $template_directory . '/includes/functions/choices.php' );
require_once( $template_directory . '/includes/functions/sanitization.php' );
///[++alte chestii]
}
add_action( 'after_setup_theme', 'et_setup_theme' );
Chiar daca e setata thema child sau parent , get_template_directory() o sa fie din thema parent; banuiesc ca aici e problema.
Cum as putea face un override la get_template_directory() sau et_setup_theme() in theme-child/functions.php ?
iamntz
(Ionuț Staicu)
noiembrie 18, 2020, 3:34pm
2
add_filter( 'template_directory', function($template_dir, $template, $theme_root) {
return $template_dir;
}, 10, 3 );
Cel mai probabil vei da în alte probleme, deci nu e chiar calea pe care aș merge eu.
Fix funcția aia nu o poți suprascrie DAR o poți înlocui:
remove_action( 'after_setup_theme', 'et_setup_theme' );
add_action('after_setup_theme', 'functia_ta');
1 Like
IAmCosmin
(I Am Cosmin)
noiembrie 18, 2020, 4:05pm
3
iamntz:
add_filter( 'template_directory', function($template_dir, $template, $theme_root) {
return $template_dir.'-child';
}, 10, 3 );
Asta am folosit si la prima vedere , pare ok.
poate mai vine cineva cu o solutie
iamntz
(Ionuț Staicu)
noiembrie 18, 2020, 7:44pm
4
Dacă funcția ta arată ca aici, nu cred că e o idee bună să faci treaba asta
<?php if ( ! isset( $content_width ) ) $content_width = 1080; function et_setup_theme() { global $themename, $shortname, $et_store_options_in_one_row, $default_colorscheme; $themename = 'Divi'; $shortname = 'divi'; $et_store_options_in_one_row = true; $default_colorscheme = "Default"; $template_directory = get_template_directory(); $theme_version = et_get_theme_version();
Mai devreme sau mai târziu o să ajungă să te bântuie artificiul ăsta și nici nu o să știi unde să cauți
La o primă strigare, uite un exemplu de ceva ce nu o să mai meargă:
$items->two_info_panels = $items->contact_info_defined && ( $items->show_header_social_icons || $items->secondary_nav ); return $items; } } function et_divi_activate_features(){ define( 'ET_SHORTCODES_VERSION', et_get_theme_version() ); /* activate shortcodes */ require_once( get_template_directory() . '/epanel/shortcodes/shortcodes.php' ); } add_action( 'init', 'et_divi_activate_features' ); require_once( get_template_directory() . '/et-pagebuilder/et-pagebuilder.php' ); function et_divi_sidebar_class( $classes ) { // Set Woo shop and taxonomies layout. if ( class_exists( 'woocommerce' ) && ( is_woocommerce() && ( is_shop() || is_tax() ) ) ) { $page_layout = et_get_option( 'divi_shop_page_sidebar', 'et_right_sidebar' );
<?php define( 'ET_BUILDER_THEME', true ); function et_setup_builder() { define( 'ET_BUILDER_DIR', get_template_directory() . '/includes/builder/' ); define( 'ET_BUILDER_URI', get_template_directory_uri() . '/includes/builder' ); define( 'ET_BUILDER_LAYOUT_POST_TYPE', 'et_pb_layout' ); $theme_version = et_get_theme_version(); define( 'ET_BUILDER_VERSION', $theme_version ); load_theme_textdomain( 'et_builder', ET_BUILDER_DIR . 'languages' ); require ET_BUILDER_DIR . 'framework.php'; et_pb_register_posttypes();
Dacă ai Woo Commerce, o să ai și acolo o grămadă de probleme
Poți spune ce încerci să faci? Poate că există totuși o metodă mai bună pentru asta.
IAmCosmin
(I Am Cosmin)
noiembrie 18, 2020, 9:02pm
5
Pe scurt, vreau sa modific html-ul de aici
<?php
if ( post_password_required() ) : ?>
<p class="nocomments container"><?php esc_html_e( 'This post is password protected. Enter the password to view comments.', 'et_builder' ); ?></p>
<?php
return;
endif;
?>
<!-- You can start editing here. -->
<section id="comment-wrap">
<h1 id="comments" class="page_title"><?php comments_number( esc_html__( '0 Comments', 'et_builder' ), esc_html__( '1 Comment', 'et_builder' ), '% ' . esc_html__( 'Comments', 'et_builder' ) ); ?></h1>
<?php if ( have_comments() ) : ?>
<?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // Are there comments to navigate through? ?>
<div class="comment_navigation_top clearfix">
<div class="nav-previous"><?php previous_comments_link( et_get_safe_localization( __( '<span class="meta-nav">←</span> Older Comments', 'et_builder' ) ) ); ?></div>
<div class="nav-next"><?php next_comments_link( et_get_safe_localization( __( 'Newer Comments <span class="meta-nav">→</span>', 'et_builder' ) ) ); ?></div>
</div> <!-- .navigation -->
<?php endif; // check for comment navigation ?>
This file has been truncated. show original
iamntz
(Ionuț Staicu)
noiembrie 19, 2020, 3:38am
6
În versiunile mai noi de Divi (sper că ai o versiune mai nouă de cinci ani ) fișierul ăla este încărcat din includes/builder/module/Comments.php
:
add_filter( 'comments_template', array( $this, 'et_pb_comments_template' ) );
Teoretic, ar trebui să poți suprascrie filtrul ăsta în functions.php
din child:
add_filter( 'comments_template', function($tpl) {
return STYLESHEETPATH . 'my-comments-template.php';
}, 10);
Practic… s-ar putea să fie nevoie să sapi un pic în Divi să înțelegi flow-ul.
1 Like
IAmCosmin
(I Am Cosmin)
noiembrie 19, 2020, 7:09am
7
Multumesc Ionut @iamntz
A mers!
remove_filter( 'comments_template','et_pb_comments_template' ,10 );
add_filter( 'comments_template', function($tpl) {
return STYLESHEETPATH . '/comments_template.php';
}, 20);
1 Like