WordPress – Elegant themes – Extra – Autoriser Extra Settings pour les custom post types – Enable Extra Settings for CPTs

Ajouter Extra Settings pour les custom post types

Add Extra Settings for Custom Post Types for Extra from elegant themes

NOT WORKING YET

sur le thème parent…
Parent theme
wp-content/Extra/includes/admin/admin.php

Pour rajouter « Sidebar location » et « Choose Sidebar/Widget Area »
ligne 1502
To add « Sidebar Location » and « Choose Sidebar/Widget area » text
line 1502

class Extra_Page_Post_Settings_Meta_Box extends ET_Meta_Box {
public function __construct(){
parent::__construct( 'extra-page-post-settings', esc_html__( 'Extra Settings', 'extra' ), array(
'post_type' => array(
'post',
'page',
'formations-gratuites',
'formations-membres',

EXTRA_LAYOUT_POST_TYPE,
EXTRA_PROJECT_POST_TYPE,
'product',
),
'context' => 'side',
) );
}

ligne 1569
find line 1569
trouver

if ( 'post' == $post->post_type ) {
$this->fields['_extra_featured_post'] = array(
'title' => esc_html__( 'Featured Post', 'extra' ),
);
// Display Author Box field depending on ePanel value.
if ( 'on' == et_get_option( 'extra_show_author_box', 'on' ) ) {
$this->fields['_extra_hide_author_box'] = array(
'title' => esc_html__( 'Hide Author Box', 'extra' ),
);
} else {
$this->fields['_extra_show_author_box'] = array(
'title' => esc_html__( 'Show Author Box', 'extra' ),
);
}
// Display Related Posts field depending on ePanel value.
if ( 'on' == et_get_option( 'extra_show_related_posts', 'on' ) ) {
$this->fields['_extra_hide_related_posts'] = array(
'title' => esc_html__( 'Hide Related Posts', 'extra' ),
);
} else {
$this->fields['_extra_show_related_posts'] = array(
'title' => esc_html__( 'Show Related Posts', 'extra' ),
);
}
}

rajouter le code suivant juste après
add the following code right after the previous code


if ( 'formations-gratuites' == $post->post_type ) {
$this->fields['_extra_featured_post'] = array(
'title' => esc_html__( 'Featured Post', 'extra' ),
);
// Display Author Box field depending on ePanel value.
if ( 'on' == et_get_option( 'extra_show_author_box', 'on' ) ) {
$this->fields['_extra_hide_author_box'] = array(
'title' => esc_html__( 'Hide Author Box', 'extra' ),
);
} else {
$this->fields['_extra_show_author_box'] = array(
'title' => esc_html__( 'Show Author Box', 'extra' ),
);
}
// Display Related Posts field depending on ePanel value.
if ( 'on' == et_get_option( 'extra_show_related_posts', 'on' ) ) {
$this->fields['_extra_hide_related_posts'] = array(
'title' => esc_html__( 'Hide Related Posts', 'extra' ),
);
} else {
$this->fields['_extra_show_related_posts'] = array(
'title' => esc_html__( 'Show Related Posts', 'extra' ),
);
}
}
if ( 'formations-membres' == $post->post_type ) {
$this->fields['_extra_featured_post'] = array(
'title' => esc_html__( 'Featured Post', 'extra' ),
);
// Display Author Box field depending on ePanel value.
if ( 'on' == et_get_option( 'extra_show_author_box', 'on' ) ) {
$this->fields['_extra_hide_author_box'] = array(
'title' => esc_html__( 'Hide Author Box', 'extra' ),
);
} else {
$this->fields['_extra_show_author_box'] = array(
'title' => esc_html__( 'Show Author Box', 'extra' ),
);
}
// Display Related Posts field depending on ePanel value.
if ( 'on' == et_get_option( 'extra_show_related_posts', 'on' ) ) {
$this->fields['_extra_hide_related_posts'] = array(
'title' => esc_html__( 'Hide Related Posts', 'extra' ),
);
} else {
$this->fields['_extra_show_related_posts'] = array(
'title' => esc_html__( 'Show Related Posts', 'extra' ),
);
}
}

trouver vers la ligne 1718
find line 1718
<?php
if ( 'post' == $post->post_type ) {
?>
<div class="form-field">
<label>
<input type="checkbox" name="_extra_featured_post" value="1" <?php checked( $this->fields['_extra_featured_post']['value'], '1' ); ?> />
<?php echo esc_html( $this->fields['_extra_featured_post']['title'] ); ?>
</label>
</div>

changer en
Modify to
<?php
if ( 'formations-gratuites' == $post->post_type || 'formations-membres' == $post->post_type || 'post' == $post->post_type ) {
?>
<div class="form-field">
<label>
<input type="checkbox" name="_extra_featured_post" value="1" <?php checked( $this->fields['_extra_featured_post']['value'], '1' ); ?> />
<?php echo esc_html( $this->fields['_extra_featured_post']['title'] ); ?>
</label>
</div>

_____

ouvrir
open
wp-content/Extra/includes/ratings.php

ligne 217
line 217

function extra_get_rating_post_types() {
return apply_filters( 'extra_rating_post_types', array(
'post',
'formations-gratuites',
'
formations-membres',
) );
}

ouvrir
open
wp-content/Extra/framework/admin/admin.php

ligne 31
line 31

$args = wp_parse_args( $args, array(
'post_type' => array( 'post', 'formations-gratuites', 'formations-membres' ),
'context' => 'advanced',
'priority' => 'default',
) );

ligne 55, dupliquer le code de cette façon
line 55, duplicate the code like so
if ( isset( $_GET['post'] ) ) {
$this->post_id = intval( $_GET['post'] );
$this->post_data = $this->get_meta();
}
add_action( 'add_meta_boxes', array( $this, 'register' ) );
add_action( 'save_post', array( $this, '_save_post' ), 10, 2 );
$this->pre_register_after();
if ( ! in_array( get_current_screen()->post_type, $this->post_types ) ) {
return;
}
if ( isset( $_GET['formations-gratuites'] ) ) {
$this->post_id = intval( $_GET['
formations-gratuites'] );
$this->post_data = $this->get_meta();
}
add_action( 'add_meta_boxes', array( $this, 'register' ) );
add_action( 'save_post', array( $this, '_save_post' ), 10, 2 );
$this->pre_register_after();
if ( ! in_array( get_current_screen()->post_type, $this->post_types ) ) {
return;
}
if ( isset( $_GET['
formations-gratuites'] ) ) {
$this->post_id = intval( $_GET['
formations-gratuites'] );
$this->post_data = $this->get_meta();
}
add_action( 'add_meta_boxes', array( $this, 'register' ) );
add_action( 'save_post', array( $this, '_save_post' ), 10, 2 );
$this->pre_register_after();
if ( ! in_array( get_current_screen()->post_type, $this->post_types ) ) {
return;
}

Revenir sur
back to
wp-content/Extra/includes/admin/admin.php

Trouver vers la ligne 1673
find roughly at line 1673

if ( et_get_post_meta_setting( 'all', 'rating_stars' ) && in_array( $post->post_type, extra_get_rating_post_types() ) ) {
$this->fields['_post_extra_rating_hide'] = array(
'title' => esc_html__( 'Hide Post Rating', 'extra' ),
'value_sanitize_function' => 'wp_validate_boolean',
'type' => 'checkbox',
);
}

changer en …
modify to
Trouver vers la ligne 1787
find around line 1787

if ( et_get_post_meta_setting( 'all', 'rating_stars' ) && in_array( $post->post_type, extra_get_rating_post_types() ) ) {
$force_display_rating = $this->fields['_post_extra_rating_hide'];
?>

changer en …
modify to

Trouver vers la ligne 1895
find around line 1895
if ( in_array( $hook, array( 'post.php', 'post-new.php' ) ) ) {
// load every post and post edit page, i.e. posts, pages, CPTs
wp_enqueue_script( 'extra_admin_gallery_images_js', $template_dir . '/includes/admin/scripts/gallery-images' . $suffix, array( 'jquery', 'jquery-ui-sortable' ), $theme_version, true );
if ( 'page' == $typenow ) {
wp_enqueue_script( 'extra_admin_page_template_js', $template_dir . '/includes/admin/scripts/page-template' . $suffix, array( 'jquery', 'jquery-effects-highlight' ), $theme_version, true );
}
if ( 'post' == $typenow || EXTRA_PROJECT_POST_TYPE == $typenow ) {
wp_enqueue_script( 'extra_admin_posts_js', $template_dir . '/includes/admin/scripts/posts' . $suffix, array( 'jquery' ), $theme_version, true );
wp_localize_script( 'extra_admin_posts_js', 'EXTRA', array(
'label_breakdown_title' => esc_html__( 'Title:', 'extra' ),
'label_breakdown_rating' => esc_html__( 'Rating (%):', 'extra' ),
'label_breakdown_number' => esc_html__( 'Breakdown #', 'extra' ),
) );
}
if ( 'post' == $typenow ) {
wp_enqueue_script( 'extra_admin_post_format_js', $template_dir . '/includes/admin/scripts/post-format' . $suffix, array( 'jquery', 'jquery-effects-highlight' ), $theme_version, true );
}
if ( EXTRA_LAYOUT_POST_TYPE == $typenow ) {
wp_enqueue_script( 'extra_admin_post_layout_js', $template_dir . '/includes/admin/scripts/post-layout' . $suffix, array( 'jquery' ), $theme_version, true );
wp_localize_script( 'extra_admin_post_layout_js', 'EXTRA', array(
'category_description' => esc_html__( 'Use this layout on the categories selected above.', 'extra' ),
) );
}

changer en …
modify to

if ( in_array( $hook, array( 'post.php', 'post-new.php', 'single-formations-gratuites.php', 'single-formations-membres.php' ) ) ) {
// load every post and post edit page, i.e. posts, pages, CPTs
wp_enqueue_script( 'extra_admin_gallery_images_js', $template_dir . '/includes/admin/scripts/gallery-images' . $suffix, array( 'jquery', 'jquery-ui-sortable' ), $theme_version, true );
if ( 'page' == $typenow ) {
wp_enqueue_script( 'extra_admin_page_template_js', $template_dir . '/includes/admin/scripts/page-template' . $suffix, array( 'jquery', 'jquery-effects-highlight' ), $theme_version, true );
}
if ( 'post' == $typenow || EXTRA_PROJECT_POST_TYPE == $typenow || 'formations-gratuites' == $typenow || 'formations-membres' == $typenow ) {
wp_enqueue_script( 'extra_admin_posts_js', $template_dir . '/includes/admin/scripts/posts' . $suffix, array( 'jquery' ), $theme_version, true );
wp_localize_script( 'extra_admin_posts_js', 'EXTRA', array(
'label_breakdown_title' => esc_html__( 'Title:', 'extra' ),
'label_breakdown_rating' => esc_html__( 'Rating (%):', 'extra' ),
'label_breakdown_number' => esc_html__( 'Breakdown #', 'extra' ),
) );
}
if ( 'post' == $typenow || 'formations-gratuites' == $typenow || 'formations-membres' == $typenow ) {
wp_enqueue_script( 'extra_admin_post_format_js', $template_dir . '/includes/admin/scripts/post-format' . $suffix, array( 'jquery', 'jquery-effects-highlight' ), $theme_version, true );
}

Trouver vers la ligne 2032
Find around line 2032

function extra_set_post_default_meta( $post_id, $post ) {
if ( 'post' == $post->post_type ) {

changer en …
Modify to

function extra_set_post_default_meta( $post_id, $post ) {
if ( 'formations-gratuites' == $post->post_type || 'formations-membres' == $post->post_type || 'post' == $post->post_type ) {

trouver… ligne 170
find line 170
class Extra_Post_Review_Meta_Box extends ET_Meta_Box {
public function __construct() {
parent::__construct( 'post-review-box', esc_html__( 'Review Box Contents', 'extra' ), array(
'post_type' => 'post',

changer en…
modify to
class Extra_Post_Review_Meta_Box extends ET_Meta_Box {
public function __construct() {
parent::__construct( 'post-review-box', esc_html__( 'Review Box Contents', 'extra' ), array(
'post_type' => array('post','formations-gratuites','formations-membres'),

$post_id = array( absint( sanitize_text_field( $_POST['extra_post_id'] ) ) || the_ID() );

NOT WORKING YET

Author: bejisan

Share This Post On