par
Jrm » 24 oct. 2013, 01:03
Bonsoir à tous,
Je viens vers vous, car après tout une après-midi, je désespère totalement sur un petit problème en PHP.
Voilà, via les options d'un article sous "Wordpress", j'ai une fonction me permettant de mettre en place un système de note. Voici en image :

J'ai une box qui me sert à activer ou désactiver la fonction (contenant aussi d'autres options) :

En dessous, j'ai recréé exactement la même fonction (sans étoiles), sauf qu'il m'arrive un gros souci au niveau de la box.
Celle-ci est bien présente, mais inutilisable. Exemple, lorsque je souhaite désactiver ou bien activer la fonction, les options de celle-ci restent systématiquement ouverts. Voici en image :
(Même sur "Disable" les options restent ouverts.)
En espérant avoir été assez précis dans mon explication.
Voici le code qui fonctionne impeccablement :
?php
add_action("admin_init", "posts_init");
function posts_init(){
add_meta_box("post_options", theme_name ." - Post Options", "post_options", "post", "normal", "high");
add_meta_box("page_options", theme_name ." - Page Options", "page_options", "page", "normal", "high");
}
function post_options(){
global $post ;
$get_meta = get_post_custom($post->ID);
$tie_sidebar_pos = $get_meta["tie_sidebar_pos"][0];
$tie_review_criteria = unserialize($get_meta["tie_review_criteria"][0]);
$tie_movie_criteria = unserialize($get_meta["tie_movie_criteria"][0]);
wp_enqueue_script( 'tie-admin-slider' );
?>
<div class="tiepanel-item">
<h3>Review Post Options</h3>
<?php
tie_post_options(
array( "name" => "Review Box Position",
"id" => "tie_review_position",
"type" => "select",
"options" => array( "" => "Disable" ,
"top" => "Top of the post" ,
"bottom" => "Bottom of the post",
"both" => "Top and Bottom of the post",
"custom" => "Custom position")));
?>
<div id="reviews-options">
<?php
tie_post_options(
array( "name" => "Review Style",
"id" => "tie_review_style",
"type" => "select",
"options" => array( "stars" => "Stars" ,
"percentage" => "Percentage",
"points" => "Points")));
tie_post_options(
array( "name" => "Review Summary",
"id" => "tie_review_summary",
"type" => "textarea"));
tie_post_options(
array( "name" => "Text appears under the total score",
"id" => "tie_review_total",
"type" => "text"));
?>
<?php for($i=0 ; $i<=10 ; $i++ ){ ?>
<div class="option-item review-item">
<span class="label">Review Criteria <?php echo $i ?></span>
<input name="tie_review_criteria[<?php echo $i ?>][name]" type="text" value="<?php echo $tie_review_criteria[$i]['name'] ?>" />
<div class="clear"></div>
<span class="label">Criteria Score <?php echo $i ?></span>
<div id="criteria<?php echo $i ?>-slider"></div>
<input type="text" id="criteria<?php echo $i ?>" value="<?php if( $tie_review_criteria[$i]['score'] ) echo $tie_review_criteria[$i]['score']; else echo 0; ?>" name="tie_review_criteria[<?php echo $i ?>][score]" style="width:50px; opacity: 0.7;" />
<script>
jQuery(document).ready(function() {
jQuery("#criteria<?php echo $i ?>-slider").slider({
range: "min",
min: 0,
max: 100,
value: <?php if( $tie_review_criteria[$i]['score'] ) echo $tie_review_criteria[$i]['score']; else echo 0; ?>,
slide: function(event, ui) {
jQuery('#criteria<?php echo $i ?>').attr('value', ui.value );
}
});
});
</script>
</div>
<?php
}
?>
</div>
</div>
<div class="tiepanel-item">
Maintenant, le code où survient mon problème :
<h3>Movie Post Options</h3>
<?php
tie_post_options(
array( "name" => "Movie Box Position",
"id" => "tie_movie_position",
"type" => "select",
"options" => array( "" => "Disable",
"top" => "Top of the post",
"bottom" => "Bottom of the post",
"both" => "Top and Bottom of the post",
"custom" => "Custom position")));
?>
<div id="movies-options">
<?php
tie_post_options(
array( "name" => "Movie Style",
"id" => "tie_movie_style",
"type" => "select",
"options" => array( "stars" => "Stars" ,
"percentage" => "Percentage",
"points" => "Points")));
tie_post_options(
array( "name" => "Movie Summary",
"id" => "tie_movie_summary",
"type" => "textarea"));
tie_post_options(
array( "name" => "Text appears under the total score",
"id" => "tie_movie_total",
"type" => "text"));
?>
<?php for($i=0 ; $i<=10 ; $i++ ){ ?>
<div class="option-item movie-item">
<span class="label">Movie Criteria <?php echo $i ?></span>
<input name="tie_movie_criteria[<?php echo $i ?>][name]" type="text" value="<?php echo $tie_movie_criteria[$i]['name'] ?>" />
<div class="clear"></div>
<span class="label">Criteria Movie Score<?php echo $i ?></span>
<div id="criteria-movie<?php echo $i ?>-slider"></div>
<input type="text" id="criteria-movie<?php echo $i ?>" value="<?php if( $tie_movie_criteria[$i]['score'] ) echo $tie_movie_criteria[$i]['score']; else echo 0; ?>" name="tie_movie_criteria[<?php echo $i ?>][score]" style="width:50px; opacity: 0.7;" />
<script>
jQuery(document).ready(function() {
jQuery("#criteria-movie<?php echo $i ?>-slider").slider({
range: "min",
min: 0,
max: 100,
value: <?php if( $tie_movie_criteria[$i]['score'] ) echo $tie_movie_criteria[$i]['score']; else echo 0; ?>,
slide: function(event, ui) {
jQuery('#criteria-movie<?php echo $i ?>').attr('value', ui.value );
}
});
});
</script>
</div>
<?php
}
?>
</div>
Si une personne pouvait me venir en aide.
Salutation.
Jrm
Bonsoir à tous,
Je viens vers vous, car après tout une après-midi, je désespère totalement sur un petit problème en PHP.
Voilà, via les options d'un article sous "Wordpress", j'ai une fonction me permettant de mettre en place un système de note. Voici en image : [img]http://nsa34.casimages.com/img/2013/10/24/131024123850630938.png[/img]
J'ai une box qui me sert à activer ou désactiver la fonction (contenant aussi d'autres options) : [img]http://nsa33.casimages.com/img/2013/10/24/131024124519312184.jpg[/img]
En dessous, j'ai recréé exactement la même fonction (sans étoiles), sauf qu'il m'arrive un gros souci au niveau de la box.
Celle-ci est bien présente, mais inutilisable. Exemple, lorsque je souhaite désactiver ou bien activer la fonction, les options de celle-ci restent systématiquement ouverts. Voici en image : [img]http://nsa33.casimages.com/img/2013/10/24/131024124918577035.png[/img]
(Même sur "Disable" les options restent ouverts.)
En espérant avoir été assez précis dans mon explication.
Voici le code qui fonctionne impeccablement :
[php]?php
add_action("admin_init", "posts_init");
function posts_init(){
add_meta_box("post_options", theme_name ." - Post Options", "post_options", "post", "normal", "high");
add_meta_box("page_options", theme_name ." - Page Options", "page_options", "page", "normal", "high");
}
function post_options(){
global $post ;
$get_meta = get_post_custom($post->ID);
$tie_sidebar_pos = $get_meta["tie_sidebar_pos"][0];
$tie_review_criteria = unserialize($get_meta["tie_review_criteria"][0]);
$tie_movie_criteria = unserialize($get_meta["tie_movie_criteria"][0]);
wp_enqueue_script( 'tie-admin-slider' );
?>
<div class="tiepanel-item">
<h3>Review Post Options</h3>
<?php
tie_post_options(
array( "name" => "Review Box Position",
"id" => "tie_review_position",
"type" => "select",
"options" => array( "" => "Disable" ,
"top" => "Top of the post" ,
"bottom" => "Bottom of the post",
"both" => "Top and Bottom of the post",
"custom" => "Custom position")));
?>
<div id="reviews-options">
<?php
tie_post_options(
array( "name" => "Review Style",
"id" => "tie_review_style",
"type" => "select",
"options" => array( "stars" => "Stars" ,
"percentage" => "Percentage",
"points" => "Points")));
tie_post_options(
array( "name" => "Review Summary",
"id" => "tie_review_summary",
"type" => "textarea"));
tie_post_options(
array( "name" => "Text appears under the total score",
"id" => "tie_review_total",
"type" => "text"));
?>
<?php for($i=0 ; $i<=10 ; $i++ ){ ?>
<div class="option-item review-item">
<span class="label">Review Criteria <?php echo $i ?></span>
<input name="tie_review_criteria[<?php echo $i ?>][name]" type="text" value="<?php echo $tie_review_criteria[$i]['name'] ?>" />
<div class="clear"></div>
<span class="label">Criteria Score <?php echo $i ?></span>
<div id="criteria<?php echo $i ?>-slider"></div>
<input type="text" id="criteria<?php echo $i ?>" value="<?php if( $tie_review_criteria[$i]['score'] ) echo $tie_review_criteria[$i]['score']; else echo 0; ?>" name="tie_review_criteria[<?php echo $i ?>][score]" style="width:50px; opacity: 0.7;" />
<script>
jQuery(document).ready(function() {
jQuery("#criteria<?php echo $i ?>-slider").slider({
range: "min",
min: 0,
max: 100,
value: <?php if( $tie_review_criteria[$i]['score'] ) echo $tie_review_criteria[$i]['score']; else echo 0; ?>,
slide: function(event, ui) {
jQuery('#criteria<?php echo $i ?>').attr('value', ui.value );
}
});
});
</script>
</div>
<?php
}
?>
</div>
</div>
<div class="tiepanel-item">[/php]
Maintenant, le code où survient mon problème :
[php]<h3>Movie Post Options</h3>
<?php
tie_post_options(
array( "name" => "Movie Box Position",
"id" => "tie_movie_position",
"type" => "select",
"options" => array( "" => "Disable",
"top" => "Top of the post",
"bottom" => "Bottom of the post",
"both" => "Top and Bottom of the post",
"custom" => "Custom position")));
?>
<div id="movies-options">
<?php
tie_post_options(
array( "name" => "Movie Style",
"id" => "tie_movie_style",
"type" => "select",
"options" => array( "stars" => "Stars" ,
"percentage" => "Percentage",
"points" => "Points")));
tie_post_options(
array( "name" => "Movie Summary",
"id" => "tie_movie_summary",
"type" => "textarea"));
tie_post_options(
array( "name" => "Text appears under the total score",
"id" => "tie_movie_total",
"type" => "text"));
?>
<?php for($i=0 ; $i<=10 ; $i++ ){ ?>
<div class="option-item movie-item">
<span class="label">Movie Criteria <?php echo $i ?></span>
<input name="tie_movie_criteria[<?php echo $i ?>][name]" type="text" value="<?php echo $tie_movie_criteria[$i]['name'] ?>" />
<div class="clear"></div>
<span class="label">Criteria Movie Score<?php echo $i ?></span>
<div id="criteria-movie<?php echo $i ?>-slider"></div>
<input type="text" id="criteria-movie<?php echo $i ?>" value="<?php if( $tie_movie_criteria[$i]['score'] ) echo $tie_movie_criteria[$i]['score']; else echo 0; ?>" name="tie_movie_criteria[<?php echo $i ?>][score]" style="width:50px; opacity: 0.7;" />
<script>
jQuery(document).ready(function() {
jQuery("#criteria-movie<?php echo $i ?>-slider").slider({
range: "min",
min: 0,
max: 100,
value: <?php if( $tie_movie_criteria[$i]['score'] ) echo $tie_movie_criteria[$i]['score']; else echo 0; ?>,
slide: function(event, ui) {
jQuery('#criteria-movie<?php echo $i ?>').attr('value', ui.value );
}
});
});
</script>
</div>
<?php
}
?>
</div>[/php]
Si une personne pouvait me venir en aide.
Salutation.
Jrm