Changeset 1575328
- Timestamp:
- 01/15/2017 11:36:43 PM (9 years ago)
- Location:
- org-frontpage/trunk
- Files:
-
- 3 edited
-
org-frontpage-plugin-admin.php (modified) (4 diffs)
-
org-frontpage.php (modified) (10 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
org-frontpage/trunk/org-frontpage-plugin-admin.php
r1575156 r1575328 4 4 5 5 6 // Nombre de posts en frontpage 7 global $nb_posts_frontpage; 8 //Nombre de posts en tête de page 9 global $nb_posts_lead; 10 11 if (isset($_REQUEST['action'] )) { 12 13 if ( 'save' == $_REQUEST['action'] ) { 6 if (isset($_REQUEST['save'] )) { 14 7 if( !isset( $_POST['nb_posts_frontpage_nonce'] ) || !wp_verify_nonce( $_POST['nb_posts_frontpage_nonce'], basename( __FILE__ ).'_truc' ) ){ 15 8 _e("Action denied", 'org-frontpage'); 16 9 } 17 10 else { 18 19 11 // Mise à jour des paramètres 20 12 if ($_REQUEST[ 'nb_posts_frontpage' ]>0) { 21 13 update_option( 'ofp_nb_posts_frontpage', $_REQUEST[ 'nb_posts_frontpage' ] ); 22 $ nb_posts_frontpage = $_REQUEST[ 'nb_posts_frontpage' ];14 $this->_nb_posts_frontpage = $_REQUEST[ 'nb_posts_frontpage' ]; 23 15 } 24 16 if ($_REQUEST[ 'nb_posts_lead' ]>-1) { 25 17 update_option( 'ofp_nb_posts_lead', $_REQUEST[ 'nb_posts_lead' ] ); 26 $ nb_posts_lead = $_REQUEST[ 'nb_posts_lead' ];18 $this->_nb_posts_lead = $_REQUEST[ 'nb_posts_lead' ]; 27 19 } 28 20 } 29 21 unset($_REQUEST['action'] ); 30 22 31 // header("Location: themes.php?page=functions.php&saved=true"); die; }32 33 }34 23 } 35 24 ?> … … 49 38 <table class="optiontable"> 50 39 <tr valign="top"><th scope="row"><?php _e("Total number of posts on the home page", 'org-frontpage'); ?>:</th><td> 51 <input type="number" name=" <?php echo "nb_posts_frontpage"; ?>" id="<?php echo "nb_posts_frontpage" ?>"; min="1" value="<?php echo $nb_posts_frontpage; ?>">40 <input type="number" name="nb_posts_frontpage" id="nb_posts_frontpage" min="1" value="<?php echo $this->_nb_posts_frontpage; ?>"> 52 41 </td></tr> 53 42 <tr valign="top"><th scope="row"><?php _e("Number of posts at the top of the home page", 'org-frontpage'); ?>:</th><td> 54 <input type="number" name=" <?php echo "nb_posts_lead"; ?>" id="<?php echo "nb_posts_lead" ?>"; min="0" value="<?php echo $nb_posts_lead; ?>">43 <input type="number" name="nb_posts_lead" id="nb_posts_lead" min="0" value="<?php echo $this->_nb_posts_lead; ?>"> 55 44 </td></tr> 56 45 </table> … … 60 49 <?php 61 50 // Affichage des articles de la page d'accueil 62 for ($i=1;$i<=$ nb_posts_frontpage;$i++) {51 for ($i=1;$i<=$this->_nb_posts_frontpage;$i++) { 63 52 $nom_option = "ofp_post_frontpage_".$i; 64 53 $post_id = get_option($nom_option); … … 78 67 79 68 </table> 80 <p class="submit"><input name="save" type="submit" value=<?php _e("Save changes",'org-frontpage'); ?> /><input type="hidden" name="action" value=<?php _e("Save changes",'org-frontpage'); ?> /></p></form> 69 <p class="submit"><input name="save" type="submit" value=<?php _e("Save changes",'org-frontpage'); ?> /></p> 70 </form> 81 71 -
org-frontpage/trunk/org-frontpage.php
r1575156 r1575328 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 5 Version: 1.4.1 6 6 Author: B Gineste 7 7 Text Domain: org-frontpage … … 15 15 class org_frontpage { 16 16 // constantes 17 p ublic $nb_posts_frontpage_std = 5; //nombre de posts à afficher en page d'accueil18 p ublic $nb_posts_lead_std = 0; //nombre de posts en entête en page d'accueil17 private $_nb_posts_frontpage_std = 5; //nombre de posts à afficher en page d'accueil 18 private $_nb_posts_lead_std = 0; //nombre de posts en entête en page d'accueil 19 19 //variables globales 20 20 // Nombre de posts en frontpage (méta donnée dans wp_options) 21 p ublic $nb_posts_frontpage;21 private $_nb_posts_frontpage; 22 22 // nombre de posts en entête en page d'accueil 23 p ublic $nb_posts_lead;23 private $_nb_posts_lead; 24 24 // tableau des noms des metadonnées de la table wp_options (option_name) 25 p ublic $option_names = array();25 private $_option_names = array(); 26 26 // tableau des valeurs dans wp_options (option_value) 27 p ublic $option_values = array();27 private $_option_values = array(); 28 28 // tableau des libellés (pour la saisie dans la méta box) 29 //public $libelles = array();29 private $_libelles = array(); 30 30 31 31 function __construct() { 32 32 33 global $nb_posts_frontpage;34 global $nb_posts_lead;35 global $option_names;36 global $option_values;37 //global $libelles;38 39 33 add_action( 'plugins_loaded', array($this,'org_frontpage_load_plugin_textdomain') ); 40 34 41 35 //définition des variables globales 42 36 // Nombre de posts en frontpage (méta donnée dans wp_options) 43 if (!get_option('ofp_nb_posts_frontpage')) {update_option('ofp_nb_posts_frontpage',$ nb_posts_frontpage_std);}44 $ nb_posts_frontpage = get_option('ofp_nb_posts_frontpage');45 if (!$ nb_posts_frontpage) {46 $ nb_posts_frontpage = $nb_posts_frontpage_std;47 update_option('ofp_nb_posts_frontpage',$ nb_posts_frontpage);37 if (!get_option('ofp_nb_posts_frontpage')) {update_option('ofp_nb_posts_frontpage',$this->_nb_posts_frontpage_std);} 38 $this->_nb_posts_frontpage = get_option('ofp_nb_posts_frontpage'); 39 if (!$this->_nb_posts_frontpage) { 40 $this->_nb_posts_frontpage = $this->_nb_posts_frontpage_std; 41 update_option('ofp_nb_posts_frontpage',$this->_nb_posts_frontpage); 48 42 } 49 43 // nombre de posts en entête en page d'accueil 50 if (!get_option('ofp_nb_posts_lead')) {update_option('ofp_nb_posts_lead',$ nb_posts_lead_std);}51 $ nb_posts_lead = get_option('ofp_nb_posts_lead');52 if (!$ nb_posts_lead) {53 $ nb_posts_lead = $nb_posts_lead_std;54 update_option('ofp_nb_posts_lead',$ nb_posts_lead);44 if (!get_option('ofp_nb_posts_lead')) {update_option('ofp_nb_posts_lead',$this->_nb_posts_lead_std);} 45 $this->_nb_posts_lead = get_option('ofp_nb_posts_lead'); 46 if (!$this->_nb_posts_lead) { 47 $this->_nb_posts_lead = $this->_nb_posts_lead_std; 48 update_option('ofp_nb_posts_lead',$this->_nb_posts_lead); 55 49 } 56 50 // tableau des noms des metadonnées de la table wp_options (option_name) 57 for ($i=1;$i<=$ nb_posts_frontpage;$i++) {$option_names[$i] = "ofp_post_frontpage_".$i; }51 for ($i=1;$i<=$this->_nb_posts_frontpage;$i++) {$this->_option_names[$i] = "ofp_post_frontpage_".$i; } 58 52 // tableau des valeurs dans wp_options (option_value) 59 foreach ($ option_names as $option_name) {$option_values[$option_name]=get_option($option_name); }53 foreach ($this->_option_names as $option_name) {$this->_option_values[$option_name]=get_option($option_name); } 60 54 // 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 61 55 /* 62 56 $libelles["pas_sur_frontpage"]="Pas sur la page d'accueil"; 63 57 $i=1; 64 foreach ($ option_names as $option_name) {$libelles[$option_name]="N° ".$i." / page d'accueil"; $i++;}58 foreach ($this->_option_names as $option_name) {$libelles[$option_name]="N° ".$i." / page d'accueil"; $i++;} 65 59 */ 66 60 add_action('add_meta_boxes', array($this,'rang_post_meta_box_add' )); … … 76 70 } 77 71 78 functionles_libelles() {72 private function generer_les_libelles() { 79 73 // tableau des libellés (pour la saisie dans la combobox de la méta box) 80 global $option_names;81 74 82 $ libelles["pas_sur_frontpage"]=__("Not on the homepage", 'org-frontpage' );75 $this->_libelles["pas_sur_frontpage"]=__("Not on the homepage", 'org-frontpage' ); 83 76 $i=1; 84 foreach ($ option_names as $option_name) {85 $ libelles[$option_name]=__("#", 'org-frontpage' ).$i." / ".__("Home Page", 'org-frontpage' ); $i++;}86 return $libelles;77 foreach ($this->_option_names as $option_name) { 78 $this->_libelles[$option_name]=__("#", 'org-frontpage' ).$i." / ".__("Home Page", 'org-frontpage' ); $i++;} 79 // return $libelles; 87 80 } 88 81 … … 103 96 function rang_post_meta_box_callback($post) 104 97 { 105 global $option_values;98 //global $option_values; 106 99 //Rang de l'article (défini par le nom de la méta donnée de wp-options) 107 $ libelles = $this->les_libelles();100 $this->generer_les_libelles(); 108 101 // déterminer le rang de l'article sur la frontpage (par son option_name) 109 $rang_post = array_search($post->ID,$ option_values);102 $rang_post = array_search($post->ID,$this->_option_values); 110 103 if ($rang_post == false) {$rang_post="pas_sur_frontpage";} 111 104 ?><div class="form-field"> … … 117 110 <label for="rang_frontpage"><?php _e( 'Post location', 'org-frontpage' ); ?> </label> 118 111 <select name="rang_frontpage" id="rang_frontpage"> 119 <?php foreach ($ libelles as $libelle) { ?><option<?php if ( array_search($libelle,$libelles) == $rang_post) { echo ' selected="selected"'; } ?>><?php echo $libelle; ?></option>112 <?php foreach ($this->_libelles as $libelle) { ?><option<?php if ( array_search($libelle,$this->_libelles) == $rang_post) { echo ' selected="selected"'; } ?>><?php echo $libelle; ?></option> 120 113 <?php } ?> 121 114 </select> … … 131 124 function rang_post_meta_box_save( $post_id ) 132 125 { 133 global $option_values; 134 $libelles = $this->les_libelles(); 126 $this->generer_les_libelles(); 135 127 // Bail if we're doing an auto save 136 128 if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return; … … 146 138 $libelle_frontpage=stripslashes($_POST['rang_frontpage']); 147 139 // rang du post sur la frontpage 148 $name_option_post = array_search($libelle_frontpage,$ libelles);140 $name_option_post = array_search($libelle_frontpage,$this->_libelles); 149 141 // déterminer le rang précédent de l'article sur la frontpage 150 $name_option_post_prec = array_search($post_id,$ option_values);142 $name_option_post_prec = array_search($post_id,$this->_option_values); 151 143 if ($name_option_post_prec == false) {$name_option_post_rec="pas_sur_frontpage";} 152 144 … … 171 163 172 164 function data_colonne($name) { 173 global $post , $option_values, $option_names;174 $libelles = $this->les_libelles();165 global $post; 166 // $this->generer_les_libelles(); 175 167 switch ($name) { 176 168 case 'rang_frontpage': … … 178 170 179 171 // déterminer le rang de l'article sur la frontpage (par son option_name) 180 $rang_post = array_search(array_search($post->ID,$ option_values),$option_names);172 $rang_post = array_search(array_search($post->ID,$this->_option_values),$this->_option_names); 181 173 if ($rang_post == false) {$rang_post="---";} 182 174 … … 195 187 */ 196 188 function org_frontpage_plugin_menu(){ 197 add_options_page( 'Organisation de la page d\'accueil', 'Org Frontpage', 'manage_options', 'org-frontpage-menu', array($this,'org_frontpage_plugin_options'));189 add_options_page(__('Front page organization','org-frontpage'), __('Org Frontpage','org-frontpage'), 'manage_options', 'org-frontpage-menu', array($this,'org_frontpage_plugin_options')); 198 190 } 199 191 -
org-frontpage/trunk/readme.txt
r1575156 r1575328 106 106 107 107 = 1.4 = 108 * plugin convertien programmation objet108 * Réécriture du plugin en programmation objet 109 109 * Langage natif : anglais US 110 110 * Traduction en français fr_FR 111 111 112 = 1.4.1 = 113 * Correction d'un bug
Note: See TracChangeset
for help on using the changeset viewer.