Changeset 1782839
- Timestamp:
- 12/07/2017 05:02:16 PM (8 years ago)
- Location:
- org-frontpage/trunk
- Files:
-
- 3 edited
-
org-frontpage-plugin-admin.php (modified) (1 diff)
-
org-frontpage.php (modified) (11 diffs)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
org-frontpage/trunk/org-frontpage-plugin-admin.php
r1768819 r1782839 19 19 } 20 20 } 21 unset($_REQUEST[' action'] ); // ne faudrait-iil pas 'save' au lieu de 'action'21 unset($_REQUEST['save'] ); // remplacé 'action' par 'save' le 7/12/2017 ... à surveiller 22 22 23 23 } -
org-frontpage/trunk/org-frontpage.php
r1768819 r1782839 3 3 Plugin Name: Organisation FrontPage 4 4 Description: Adding a meta box in the post editor to set the rank of post in the home page 5 Version: 1. 4.75 Version: 1.5 6 6 Author: B Gineste 7 7 Text Domain: org-frontpage … … 11 11 */ 12 12 ?><?php 13 $en_test = true;13 $en_test = false; 14 14 15 15 class org_frontpage { … … 28 28 // tableau des libellés (pour la saisie dans la méta box) 29 29 private $_libelles = array(); 30 //fichier mouchard-org-fpg 31 private $_f; 32 private $_trace = false; 30 33 31 34 function __construct() { … … 33 36 add_action( 'plugins_loaded', array($this,'org_frontpage_load_plugin_textdomain') ); 34 37 38 //ouverture du mouchard 39 if ($this->_trace) { $this->_f=fopen($_SERVER['DOCUMENT_ROOT'].'\mouchard-org-fpg.txt','a+'); } 35 40 //définition des variables globales 36 41 // Nombre de posts en frontpage (méta donnée dans wp_options) … … 51 56 for ($i=1;$i<=$this->_nb_posts_frontpage;$i++) {$this->_option_names[$i] = "ofp_post_frontpage_".$i; } 52 57 // tableau des valeurs dans wp_options (option_value) 53 foreach ($this->_option_names as $option_name) {$this->_option_values[$option_name]=get_option($option_name); } 58 foreach ($this->_option_names as $option_name) { 59 //après une mise à jour du post, l'option_value prend la valeur de l'ID du post révision, il faut rétablir l'ID du post parent 60 //cet inconvénient ne semble pouvoir être évité, même si les options ont 'no' comme valeur du champ autoload 61 62 $thepost_id = get_option($option_name); 63 $thepost = get_post($thepost_id); 64 if ($thepost->post_parent > 0) { 65 $thepost_revision_id = $thepost_id; 66 $thepost_id = $thepost->post_parent; 67 update_option($option_name,$thepost_id); 68 if ($this->_trace) { 69 fwrite($this->_f,"Rétabli post parent"."\r\n"); 70 fwrite($this->_f,$thepost_revision_id." ".$thepost->post_parent."\r\n"); 71 } 72 } 73 $this->_option_values[$option_name]=$thepost_id; 74 } 54 75 // tableau des libellés (pour la saisie dans la méta box) : initialisé au moment de l'utiliser (fonction les_libelles) : ici, il n'est pas traduit 55 /* 56 $libelles["pas_sur_frontpage"]="Pas sur la page d'accueil"; 57 $i=1; 58 foreach ($this->_option_names as $option_name) {$libelles[$option_name]="N° ".$i." / page d'accueil"; $i++;} 59 */ 76 60 77 add_action('add_meta_boxes', array($this,'rang_post_meta_box_add' )); 61 78 add_action('save_post', array($this,'rang_post_meta_box_save' )); … … 80 97 } 81 98 82 99 function __destruct() { 100 if ($this->_trace) { fclose($this->_f); } 101 } 83 102 /* 84 103 ============================================================================================================================ … … 102 121 $this->generer_les_libelles(); 103 122 // déterminer le rang de l'article sur la frontpage (par son option_name) 123 // ici on pourrait vérifier que le post n'a pas de parent. Et le cas échéant remplacer l'ID du post par l'ID du parent (semble inutile) 124 //$post_id = $post->ID; 125 //if ($post->post_parent > 0) {$post_id = $post->post_parent; } 126 //$rang_post = array_search($post_id,$this->_option_values); 104 127 $rang_post = array_search($post->ID,$this->_option_values); 128 105 129 if ($rang_post == false) {$rang_post="pas_sur_frontpage";} 130 106 131 ?> 107 132 <div id="box-org-frontpage" style="display: flex; flex-wrap: wrap;"> … … 111 136 // We'll use this nonce field later on when saving. 112 137 wp_nonce_field( basename( __FILE__ ), 'organisation_frontpage' ); 138 //echo $post->ID; echo " - "; echo $post_id; echo " - "; echo $rang_post; 113 139 ?> 114 140 <label for="rang_frontpage"><?php _e( 'Post location', 'org-frontpage' ); ?> </label> … … 127 153 $nom_option = "ofp_post_frontpage_".$i; 128 154 $post_id = get_option($nom_option); 129 $titre=''; 130 $article=null; 131 if (!empty($post_id)) { 132 $article = get_post( $post_id ); 133 } 134 if (!empty($article)) { 135 $titre = $article->post_title; 155 if ($post_id != false) { 156 $article = get_post( $post_id ); 157 $titre = $article->post_title; 136 158 ?> 137 159 <!--Articles --> … … 158 180 function rang_post_meta_box_save( $post_id ) 159 181 { 182 if ($this->_trace) { fwrite($this->_f,"\r\n"."Début séquence save ".date('d/m/Y H:i')."\r\n"); } 183 160 184 $this->generer_les_libelles(); 161 185 // Bail if we're doing an auto save … … 175 199 // déterminer le rang précédent de l'article sur la frontpage 176 200 $name_option_post_prec = array_search($post_id,$this->_option_values); 177 if ($name_option_post_prec == false) {$name_option_post_rec="pas_sur_frontpage";} 201 fwrite($this->_f, "name_option_post_prec (devrait être false si pas sur la frontpage) :"); 202 fwrite($this->_f,$name_option_post_prec."\r\n"); 203 if (empty($name_option_post_prec)) {$name_option_post_rec="pas_sur_frontpage";} 204 if ($this->_trace) { 205 206 fwrite($this->_f, "Post ID :"); 207 fwrite($this->_f,$post_id."\r\n"); 208 209 fwrite($this->_f, "libelle_frontpage :"); 210 fwrite($this->_f,$libelle_frontpage."\r\n"); 211 fwrite($this->_f,"name_option_post :"); 212 fwrite($this->_f,$name_option_post."\r\n"); 213 fwrite($this->_f,"name_option_post_prec :"); 214 fwrite($this->_f,$name_option_post_prec."\r\n"); 215 fwrite($this->_f,"Id des stickés (courant ".$post_id.") : "."\r\n"); 216 217 //var_dump(get_post($post_id)); 218 foreach($this->_option_values as $opt) { 219 $article = get_post( $opt ); 220 fwrite($this->_f,$article->post_title." - "); 221 fwrite($this->_f,$opt."\r\n"); 222 } 223 224 foreach($this->_libelles as $lib) { 225 fwrite($this->_f,$lib."\r\n"); 226 } 227 } 178 228 179 229 if ($name_option_post != $name_option_post_prec) { 180 if ($name_option_post_prec != "pas_sur_frontpage") { update_option($name_option_post_prec,FALSE); } 181 if ($name_option_post != "pas_sur_frontpage") { update_option($name_option_post,$post_id); } 230 if ($name_option_post_prec == "pas_sur_frontpage") { 231 update_option($name_option_post,$post_id); 232 if ($this->_trace) { 233 fwrite($this->_f,"UPDATE name_option_post :"."\r\n"); 234 fwrite($this->_f,$name_option_post.' : '.$post_id."\r\n"); 235 } 236 } 237 if ($name_option_post == "pas_sur_frontpage") { 238 update_option($name_option_post_prec,FALSE); 239 if ($this->_trace) { 240 fwrite($this->_f,"UPDATE name_option_post_prec :"."\r\n"); 241 fwrite($this->_f,$name_option_post_prec.' : false'."\r\n"); 242 } 243 } 244 if ($name_option_post_prec != "pas_sur_frontpage" && $name_option_post != "pas_sur_frontpage") { 245 update_option($name_option_post_prec,FALSE); 246 update_option($name_option_post,$post_id); 247 if ($this->_trace) { 248 fwrite($this->_f,"UPDATE name_option_post_prec :"."\r\n"); 249 fwrite($this->_f,$name_option_post_prec.' : false'."\r\n"); 250 fwrite($this->_f,"UPDATE name_option_post :"."\r\n"); 251 fwrite($this->_f,$name_option_post.' : '.$post_id."\r\n"); 252 } 253 } 254 182 255 } 183 256 } 184 257 if ($this->_trace) { 258 fwrite($this->_f, "Post ID :"); 259 fwrite($this->_f,$post_id."\r\n"); 260 foreach($this->_option_values as $opt) { 261 $article = get_post( $opt ); 262 fwrite($this->_f,$article->post_title." - "); 263 fwrite($this->_f,$opt."\r\n"); 264 } 265 } 266 // fclose($f); 185 267 } 186 268 -
org-frontpage/trunk/readme.txt
r1768819 r1782839 4 4 Requires at least: 4.4.0 5 5 Tested up to: 4.9 6 Stable tag: 1. 46 Stable tag: 1.5 7 7 License: GPLv2 or later 8 8 License URI: https://www.gnu.org/licenses/gpl-2.0.html 9 9 10 Permet de choisir les posts qui doivent figurer surla frontpage.10 Permet de choisir et agencer les posts de la frontpage. 11 11 12 12 == Description == … … 61 61 = Ce plugin est-il nécessaire ? = 62 62 63 J 'ai éprouvé le besoin de marquer les posts à mettre en évidence sur la page d'accueil des blogs que je gère63 Je souhaitais choisir les posts à mettre sur la page d'accueil et les disposer selon leur niveau d'importance 64 64 et je n'ai pas trouvé le moyen de le faire simplement. 65 66 = Il existe un moyen simple de désigner les articles à mettre en avant (attribut sticky disponible dans le tableau de bord). Ne permet-il pas de faire la même chose sans plugin ? = 67 68 Hélas non ! 69 On pourrait en effet donner l'attribut sticky aux posts qu'on souhaite mettre sur la page d'accueil, mais cela ne permet pas de les agencer à sa convenance sur cette page : on peut en effet les récupérer classés par date et les afficher dans cet ordre, mais il est impossible de les classer à son gré. 70 Le plugin org-frontpage permet une mise en page fine car il introduit un attribut de classement (Numéro 1, 2, 3,...) des posts sélectionnés. Ce clasement pourra être exploité pour positionner les articles dans des emplacements dédiés au posts 1, 2, 3 ... 71 72 De plus, contrairement au système natif de mise en avant, les articles retenus pour la frontpage ne viennent pas automatiquement en tête des listes d'articles de type blog. 73 65 74 66 75 = Comment savoir quels sont les posts épinglés à la page d'accueil ? = 67 76 68 On peut évidemment les voir sur le blog, mais aussi à partir du tableau de bord, dans le sous-menu *Org frontpage* du menu *Réglages* . 77 On peut évidemment les voir sur le blog, mais aussi à partir du tableau de bord, dans le sous-menu *Org frontpage* du menu *Réglages* . Le rang des posts choisis apparaît également dans une colonne supplémentaire le la liste de tous les articles. 69 78 70 79 = Pourquoi ce readme est-il en français ? = … … 115 124 = 1.4.7 = 116 125 * Correction d'un bug 126 127 = 1.5 = 128 * Correction d'un dysfonctionnement : lorsque on procède à la mise à jour d'un post marqué pour la page d'accueil, la sélection était perdue et il fallait la rétablir.
Note: See TracChangeset
for help on using the changeset viewer.