Deux petites questions basiques de programmation…

  • Statut : non résolu
5 sujets de 1 à 5 (sur un total de 5)
  • Auteur
    Messages
  • #452807
    Archilatrik
    Participant
    Chevalier WordPress
    131 contributions

    Bonjour,

    Ma configuration WP actuelle
    – Version de WordPress : 2.0.5
    – Thème utilisé : Redoable 1.2
    – Plugins en place :
    – Nom de l’hebergeur :
    – Adresse du site : http://www.romaincorraze.com

    Problème(s) rencontré(s) :

    Bonsoir à tous,

    je souhaiterais faire deux petites modifications qui semblent basique, mais je m’arrache un peu les cheveux à trouver quel code HTML rentrer sans faire tout planter..

    Voici donc mes deux requêtes :

    1) J’aimerais créer un espace entre « janvier 2007 » (en haut de la sidebar du milieu dans « archives ») et « dans mes oreilles » qui marque le titre de mon plugin Lastfm.

    2) J’aimerais également recentrer l’image de mon plugin lastfm, dont voici le code en entier :

    <?php
    /*
    Plugin Name: Last.fm widget - New style
    Description: Adds a sidebar widget to show your last.fm widget.
    Author: James Wilson
    Version: 1.0
    Author URI: http://nothingoutoftheordinary.com
    */
    
    // _Very_ largely based on the gsearch widget by Automattic
    // Currently weekly doesn't work
    
    
    // Put functions into one big function we'll call at the plugins_loaded
    // action. This ensures that all required plugin functions are defined.
    function widget_lastfm_init() {
    
    	// Check for the required plugin functions. This will prevent fatal
    	// errors occurring when you deactivate the dynamic-sidebar plugin.
    	if ( !function_exists('register_sidebar_widget') )
    		return;
    
    	// This is the function that outputs our little Google search form.
    	function widget_lastfm($args) {
    		
    		// $args is an array of strings that help widgets to conform to
    		// the active theme: before_widget, before_title, after_widget,
    		// and after_title are the array keys. Default tags: li and h2.
    		extract($args);
    		
    		$widget = <<<LFM
    <style type="text/css">table.lastfmWidget td {margin:0 !important;padding:0 !important;border:0 !important;}tr.lastfmHead a:hover {background-position:0 0 !important;}tr.lastfmEmbed object {float:left;}tr.lastfmFoot td.config a:hover {background-position:0 0 !important;}tr.lastfmFoot td.view a:hover {background-position:-85px 0 !important;}tr.lastfmFoot td.popup a:hover {background-position:-159px 0 !important;}</style>
    <table class="lastfmWidget" cellpadding="0" cellspacing="0" border="0" style="width:184px;">
    	<tr class="lastfmHead"><br>
    		<td><a title="%user%: %title%" href="http://www.last.fm/user/%user%/charts/?charttype=%type%" target="_blank" style="display:block;overflow:hidden;height:20px;width:184px;background:url(%backgroundheader%) no-repeat 0 -20px;text-decoration:none;"></a></td>
    	</tr>
    	<tr class="lastfmEmbed">
    		<td>
    			<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="184" height="179" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab%23version=7,0,0,0" style="float:left;">
    				<param name="bgcolor" value="d01f3c" /><param name="movie" value="http://panther1.last.fm/widgets/chart/2.swf" />
    				<param name="quality" value="high" /><param name="allowScriptAccess" value="sameDomain" />
    				<param name="FlashVars" value="type=%type%&user=%user%&theme=%colorname%" />
    				<embed src="http://panther1.last.fm/widgets/chart/2.swf" type="application/x-shockwave-flash" name="widgetPlayer" bgcolor="%colorhex%" width="184" height="179" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer"  FlashVars="type=%type%&user=%user%&theme=%colorname%" allowScriptAccess="sameDomain"></embed>
    			</object>
    		</td>
    	</tr>
    	<tr class="lastfmFoot">
    		<td style="background:url(%backgroundfooter%) repeat-x 0 0;text-align:right;">
    			<table cellspacing="0" cellpadding="0" border="0" style="width:184px;">
    				<tr>
    					<td class="config"><a href="http://www.last.fm/tools/widgets/?widget=chart&colour=%colorname%&chartType=%type%&user=%user%&from=widget" title="Get your own" target="_blank" style="display:block;overflow:hidden;width:85px;height:20px;float:right;background:url(%backgroundfooterother%) no-repeat 0 -20px;text-decoration:none;"></a></td>
    					<td class="view" style="width:74px;"><a href="http://www.last.fm/user/%user%/" title="View %user%'s profile" target="_blank" style="display:block;overflow:hidden;width:74px;height:20px;background:url(%backgroundfooterother%) no-repeat -85px -20px;text-decoration:none;"></a></td>
    					<td class="popup"style="width:25px;"><a href="http://www.last.fm/tools/widgets/popup/?widget=chart&colour=%colorname%&chartType=%type%&user=%user%&from=widget&resize=1" title="Load this chart in a pop up" target="_blank" style="display:block;overflow:hidden;width:25px;height:20px;background:url(%backgroundfooterother%) no-repeat -159px -20px;text-decoration:none;" onclick="window.open(this.href + '&resize=0','lastfm_popup','height=279,width=234,resizable=yes,scrollbars=yes'); return false;"></a></td>
    				</tr>
    			</table>
    		</td>
    	</tr>
    </table>
    LFM;
    	
    		
    		// Each widget can store its own options. We keep strings here.
    		$options = get_option(‘widget_lastfm’);
    		$type = $options[‘type’];
    		$user = $options[‘user’];
    		$color = $options[‘color’];
    		// Hex values for the certain colors. Needed for one of the params
    		$colortohex = array( ‘red’ => ‘d01f3c’, ‘blue’ => ‘6598cd’, ‘black’ => ‘000000’, ‘grey’ => ‘999999’ );
    		$title = ($options[‘title’] != «  ») ? $before_title.$options[‘title’].$after_title : «  »;  // ($options[‘title’] != «  ») ? $options[‘title’] : « Compete Rankings »;
    		// Convert name to the title
    		$typetotitle = array( 
    			‘recenttracks’ => ‘Recently Played’, 
    			‘toptracks’ => ‘My Top Tracks’, 
    			‘topartists’ => ‘My Top Artists’, 
    			‘weeklytracks’ => ‘My Weekly Top Tracks’, 
    			‘weeklyartists’ => ‘My Weekly Top Artists’ 
    		);
    		$widgettitle = $typetotitle[$type];
    		// These lines generate our output. Widgets can be very complex
    		// but as you can see here, they can also be very, very simple.
    		//echo $before_widget . $before_title . $title . $after_title;
    		
    		$content = str_replace(
    			array(
    				« %backgroundheader% »,
    				« %backgroundfooter% »,
    				« %backgroundfooterother% »,
    				« %title% »,
    				« %user% »,
    				« %colorname% »,
    				« %colorhex% »,
    				« %type% »
    			), 
    			array(
    				‘http://panther1.last.fm/widgets/images/en/header/chart/%type%_regular_%colorname%.gif’,
    				‘http://panther1.last.fm/widgets/images/footer_bg/%colorname%.gif’, 
    				‘http://panther1.last.fm/widgets/images/en/footer/%colorname%.gif’, 
    				$widgettitle,
    				$user,
    				$color,
    				$colorhex,
    				$type
    			), 
    			$widget
    		);
    		
    		echo $before_widget . $title;
    		echo $content;
    		echo $after_widget;
    	
    	}
    
    	// This is the function that outputs the form to let the users edit
    	// the widget’s title. It’s an optional feature that users cry for.
    	function widget_lastfm_control() {
    
    		// Get our options and see if we’re handling a form submission.
    		$options = get_option(‘widget_lastfm’);
    		if ( !is_array($options) )
    			$options = array(‘title’=> », 
    				‘type’=> ‘recenttracks’,
    				‘user’ => ‘ah_skeet’,
    				‘color’ => ‘red’
    			);
    		if ( $_POST[‘lastfm-submit’] ) {
    
    			// Remember to sanitize and format use input appropriately.
    			$options[‘title’] = strip_tags(stripslashes($_POST[‘lastfm-title’]));
    			$options[‘user’] = strip_tags(stripslashes($_POST[‘lastfm-user’]));
    			$options[‘type’] = strip_tags(stripslashes($_POST[‘lastfm-type’]));
    			$options[‘color’] = strip_tags(stripslashes($_POST[‘lastfm-color’]));
    			update_option(‘widget_lastfm’, $options);
    		}
    
    		// Be sure you format your options to be valid HTML attributes.
    		$title = htmlspecialchars($options[‘title’], ENT_QUOTES);
    		$user = htmlspecialchars($options[‘user’], ENT_QUOTES);
    		$type = htmlspecialchars($options[‘type’], ENT_QUOTES);
    		$color = htmlspecialchars($options[‘color’], ENT_QUOTES);
    		
    		// Here is our little form segment. Notice that we don’t need a
    		// complete form. This will be embedded into the existing form.
    		echo ‘<p style="text-align:right;"><label for="lastfm-title">‘ . __(‘Title:’) . ‘ <input style="width: 200px;" id="lastfm-title" name="lastfm-title" type="text" value="'.$title.'" /></label></p>‘;
    		echo ‘<p style="text-align:right;"><label for="lastfm-user">‘ . __(‘User:’, ‘widgets’) . ‘ <input style="width: 200px;" id="lastfm-user" name="lastfm-user" type="text" value="'.$user.'" /></label></p>‘;
    		echo ‘<p style="text-align:right;"><label for="lastfm-type">‘ . __(‘Type:’, ‘widgets’) . ‘ <select name="lastfm-type" style="width:200px;" id="lastfm-type">
    			<option value="recenttracks" '.( ($type == 'recenttracks') ? "selected="selected"" : "").'>Recent Tracks</option>
    			<option value="toptracks" '.( ($type == 'toptracks') ? "selected="selected"" : "").'>Top Tracks</option>
    			<option value="topartists" '.( ($type == 'topartists') ? "selected="selected"" : "").'>Top Artists</option>
    			<!--<option value="weeklytracks" '.( ($type == 'weeklytracks') ? "selected="selected"" : "").'>Weekly Top Tracks</option>
    			<option value="weeklyartists" '.( ($type == 'weeklyartists') ? "selected="selected"" : "").'>Weekly Top Artists</option>-->
    		</select></label></p>‘;
    		echo ‘<p style="text-align:right;"><label for="lastfm-color">‘ . __(‘Color:’, ‘widgets’) . ‘ <select name="lastfm-color" style="width:200px;" id="lastfm-color">
    			<option value="red" '.( ($color == "red") ? "selected="selected"" : "").'>Red</option>
    			<option value="blue" '.( ($color == "blue") ? "selected="selected"" : "").'>Blue</option>
    			<option value="black" '.( ($color == "black") ? "selected="selected"" : "").'>Black</option>
    			<option value="grey" '.( ($color == "grey") ? "selected="selected"" : "").'>Grey</option>
    		</label></p>‘;
    		//echo ‘<p style="text-align:right;"><label for="compete-imagesize">‘ . __(‘Image Size:’,’widgets’) . ‘ <select style="width: 200px;" id="compete-imagesize" name="compete-imagesize"><option value="large" ' . ( ($imagesize == "large") ? "selected="selected"" : "" ) . '>Large</option><option value="small" ' . ( ($iamgesize == "small") ? "selected="selected"" : "") . '>Small</option></select></label></p>‘;
    		//echo ‘<p style="text-align:right;"><label for="compete-content">‘ . __(‘Widget Format:’, ‘widgets’) . ‘ <textarea style="width: 200px;" id="compete-content" name="compete-content" row="5" cols="20">‘.$content.’</textarea></label></p>‘;
    		echo ‘<input type="hidden" id="lastfm-submit" name="lastfm-submit" value="1" />‘;
    	}
    	
    	// This registers our widget so it appears with the other available
    	// widgets and can be dragged and dropped into any active sidebars.
    	register_sidebar_widget(array(‘Last.fm’, ‘widgets’), ‘widget_lastfm’);
    
    	// This registers our optional widget control form. Because of this
    	// our widget will have a button that reveals a 300×100 pixel form.
    	register_widget_control(array(‘Last.fm’, ‘widgets’), ‘widget_lastfm_control’, 300, 200);
    }
    
    // Run our code later in case this loads prior to any required plugins.
    add_action(‘widgets_init’, ‘widget_lastfm_init’);
    
    ?>

    J’ai cherché pendant presque 3h, je suis à bout, un grand merci aux personnes qui pourront m’aider.

    Cordialement,

    #603860
    Archilatrik
    Participant
    Chevalier WordPress
    131 contributions

    et je rajoueterais…

    3) Comment rajouter un espace entre mes badges et « et en ce moment ? » qui marque le titre de mon widget twitter ? Une balise
    ne fonctionne pas…

    Merci d’avance,

    #603861
    Archilatrik
    Participant
    Chevalier WordPress
    131 contributions

    Super, merci beaucoup Aaxane. Ca marche parfaitement pour l’espacement. En revanche, je n’ai pas réussi à recentrer mon plugin lastfm. J’ai tenté de le faire via l’editeur de plugin, sans succès..une autre idée ?

    #603862
    Archilatrik
    Participant
    Chevalier WordPress
    131 contributions

    En fait, je pense qu’il peut rentrer dedans (il n’est pas si gros que ça quand même 🙂 )

    Une balise serait-elle appropriée ?

    #603863
    Archilatrik
    Participant
    Chevalier WordPress
    131 contributions

    Autant pour moi Aaxane, j’avais sous-estimé la taille du plugin.

    Puisque c’est trop galère pour le moment en terme de style.css, je l’ai placé dans ma sidebar1, et plus de problèmes !

5 sujets de 1 à 5 (sur un total de 5)
  • Vous devez être connecté pour répondre à ce sujet.