Exemplo n.º 1
0
/**
 * Displays the Sociable admin menu, first section (re)stores the settings.
 */
function sociable_submenu() {
	global $sociable_known_sites, $sociable_date, $sociablepluginpath;

	$sociable_known_sites = apply_filters('sociable_known_sites',$sociable_known_sites);
	
	if (isset($_REQUEST['restore']) && $_REQUEST['restore']) {
		check_admin_referer('sociable-config');
		sociable_restore_config(true);
		sociable_message(__("Restored all settings to defaults.", 'sociable'));
	} else if (isset($_REQUEST['save']) && $_REQUEST['save']) {
		check_admin_referer('sociable-config');
		$active_sites = Array();
		if (!$_REQUEST['active_sites'])
			$_REQUEST['active_sites'] = Array();
		foreach($_REQUEST['active_sites'] as $sitename=>$dummy)
			$active_sites[] = $sitename;
		update_option('sociable_active_sites', $active_sites);
		/**
		 * Have to delete and re-add because update doesn't hit the db for identical arrays
		 * (sorting does not influence associated array equality in PHP)
		 */
		delete_option('sociable_active_sites', $active_sites);
		add_option('sociable_active_sites', $active_sites);

		foreach ( array('usetargetblank', 'useiframe', 'disablealpha', 'disablesprite', 'awesmenable', 'usecss', 'usetextlinks', 'disablewidget') as $val ) {
			if ( isset($_POST[$val]) && $_POST[$val] )
				update_option('sociable_'.$val,true);
			else
				update_option('sociable_'.$val,false);
		}
		
		if (isset($_POST['iframewidth']) && is_numeric($_POST['iframewidth'])) {
			update_option('sociable_iframewidth',$_POST['iframewidth']);
		} else {
			update_option('sociable_iframewidth',900);
		}
		if (isset($_POST['iframeheight']) && is_numeric($_POST['iframeheight'])) {
			update_option('sociable_iframeheight',$_POST['iframeheight']);
		} else {
			update_option('sociable_iframeheight',500);
		}
		
		foreach ( array('awesmapikey', 'tagline', 'imagedir') as $val ) {
			if ( !$_POST[$val] )
				update_option( 'sociable_'.$val, '');
			else
				update_option( 'sociable_'.$val, $_POST[$val] );
		}
		
		if (isset($_POST["imagedir"]) && !trim($_POST["imagedir"]) == "") {
			update_option('sociable_disablesprite',true);
		}
		
		/**
		 * Update conditional displays
		 */
		$conditionals = Array();
		if (!$_POST['conditionals'])
			$_POST['conditionals'] = Array();
		
		$curconditionals = get_option('sociable_conditionals');
		if (!array_key_exists('is_feed',$curconditionals)) {
			$curconditionals['is_feed'] = false;
		}
		foreach($curconditionals as $condition=>$toggled)
			$conditionals[$condition] = array_key_exists($condition, $_POST['conditionals']);
			
		update_option('sociable_conditionals', $conditionals);

		sociable_message(__("Saved changes.", 'sociable'));
	}
	
	/**
	 * Show active sites first and in the right order.
	 */
	$active_sites = get_option('sociable_active_sites');
	$active = Array(); 
	$disabled = $sociable_known_sites;
	foreach( $active_sites as $sitename ) {
		$active[$sitename] = $disabled[$sitename];
		unset($disabled[$sitename]);
	}
	uksort($disabled, "strnatcasecmp");
	
	/**
	 * Display options.
	 */
?>
<form action="<?php echo attribute_escape( $_SERVER['REQUEST_URI'] ); ?>" method="post">
<?php
	if ( function_exists('wp_nonce_field') )
		wp_nonce_field('sociable-config');
?>

<div class="wrap">
	<?php screen_icon(); ?>
	<h2><?php _e("Sociable Options", 'sociable'); ?></h2>
	<table class="form-table">
	<tr>
		<th>
			<?php _e("Sites", "sociable"); ?>:<br/>
			<small><?php _e("Check the sites you want to appear on your site. Drag and drop sites to reorder them.", 'sociable'); ?></small>
		</th>
		<td>
			<div style="width: 100%; height: 100%">
			<ul id="sociable_site_list">
				<?php foreach (array_merge($active, $disabled) as $sitename=>$site) { ?>
					<li id="<?php echo $sitename; ?>"
						class="sociable_site <?php echo (in_array($sitename, $active_sites)) ? "active" : "inactive"; ?>">
						<input
							type="checkbox"
							id="cb_<?php echo $sitename; ?>"
							name="active_sites[<?php echo $sitename; ?>]"
							<?php echo (in_array($sitename, $active_sites)) ? ' checked="checked"' : ''; ?>
						/>
						<?php
						$imagepath = get_option('sociable_imagedir');
						
						if ($imagepath == "") {
							$imagepath = $sociablepluginpath.'images/';
						} else {		
							$imagepath .= (substr($imagepath,strlen($imagepath)-1,1)=="/") ? "" : "/";
						}
						
						if (!isset($site['spriteCoordinates']) || get_option('sociable_disablesprite')) {
							if (strpos($site['favicon'], 'http') === 0) {
								$imgsrc = $site['favicon'];
							} else {
								$imgsrc = $imagepath.$site['favicon'];
							}
							echo "<img src=\"$imgsrc\" width=\"16\" height=\"16\" />";
						} else {
							$imgsrc = $imagepath."services-sprite.gif";
							$services_sprite_url = $imagepath . "services-sprite.png";
							$spriteCoords = $site['spriteCoordinates'];
							echo "<img src=\"$imgsrc\" width=\"16\" height=\"16\" style=\"background: transparent url($services_sprite_url) no-repeat; background-position:-$spriteCoords[0]px -$spriteCoords[1]px\" />";
						}
						
						echo $sitename; ?>
					</li>
				<?php } ?>
			</ul>
			</div>
			<input type="hidden" id="site_order" name="site_order" value="<?php echo join('|', array_keys($sociable_known_sites)) ?>" />
		</td>
	</tr>
	<tr>
		<th scope="row" valign="top">
			<?php _e("Disable sprite usage for images?", "sociable"); ?>
		</th>
		<td>
			<input type="checkbox" name="disablesprite" <?php checked( get_option('sociable_disablesprite'), true ) ; ?> />
		</td>
	</tr>	
	<tr>
		<th scope="row" valign="top">
			<?php _e("Disable alpha mask on share toolbar?", "sociable"); ?>
		</th>
		<td>
			<input type="checkbox" name="disablealpha" <?php checked( get_option('sociable_disablealpha'), true ) ; ?> />
		</td>
	</tr>	
	<tr>
		<th scope="row" valign="top">
			<?php _e("Tagline", "sociable"); ?>
		</th>
		<td>
			<?php _e("Change the text displayed in front of the icons below. For complete customization, copy the contents of <em>sociable.css</em> in the Sociable plugin directory to your theme's <em>style.css</em> and disable the use of the sociable stylesheet below.", 'sociable'); ?><br/>
			<input size="80" type="text" name="tagline" value="<?php echo attribute_escape(stripslashes(get_option('sociable_tagline'))); ?>" />
		</td>
	</tr>
	<tr>
		<th scope="row" valign="top">
			<?php _e("Position:", "sociable"); ?>
		</th>
		<td>
			<?php _e("The icons appear at the end of each blog post, and posts may show on many different types of pages. Depending on your theme and audience, it may be tacky to display icons on all types of pages.", 'sociable'); ?><br/>
			<br/>
			<?php
			/**
			 * Load conditions under which Sociable displays
			 */
			$conditionals 	= get_option('sociable_conditionals');
			?>
			<input type="checkbox" name="conditionals[is_home]"<?php checked($conditionals['is_home']); ?> /> <?php _e("Front page of the blog", 'sociable'); ?><br/>
			<input type="checkbox" name="conditionals[is_single]"<?php checked($conditionals['is_single']); ?> /> <?php _e("Individual blog posts", 'sociable'); ?><br/>
			<input type="checkbox" name="conditionals[is_page]"<?php checked($conditionals['is_page']); ?> /> <?php _e('Individual WordPress "Pages"', 'sociable'); ?><br/>
			<input type="checkbox" name="conditionals[is_category]"<?php checked($conditionals['is_category']); ?> /> <?php _e("Category archives", 'sociable'); ?><br/>
			<input type="checkbox" name="conditionals[is_tag]"<?php checked($conditionals['is_tag']); ?> /> <?php _e("Tag listings", 'sociable'); ?><br/>
			<input type="checkbox" name="conditionals[is_date]"<?php checked($conditionals['is_date']); ?> /> <?php _e("Date-based archives", 'sociable'); ?><br/>
			<input type="checkbox" name="conditionals[is_author]"<?php checked($conditionals['is_author']); ?> /> <?php _e("Author archives", 'sociable'); ?><br/>
			<input type="checkbox" name="conditionals[is_search]"<?php checked($conditionals['is_search']); ?> /> <?php _e("Search results", 'sociable'); ?><br/>
			<input type="checkbox" name="conditionals[is_feed]"<?php checked($conditionals['is_feed']); ?> /> <?php _e("RSS feed items", 'sociable'); ?><br/>
		</td>
	</tr>
	<tr>
		<th scope="row" valign="top">
			<?php _e("Use CSS:", "sociable"); ?>
		</th>
		<td>
			<input type="checkbox" name="usecss" <?php checked( get_option('sociable_usecss'), true ); ?> /> <?php _e("Use the sociable stylesheet?", "sociable"); ?>
		</td>
	</tr>
	<tr>
		<th scope="row" valign="top">
			<?php _e("Use Text Links:", "sociable"); ?>
		</th>
		<td>
			<input type="checkbox" name="usetextlinks" <?php checked( get_option('sociable_usetextlinks'), true ); ?> /> <?php _e("Use text links without images?", "sociable"); ?>
		</td>
	</tr>
	<tr>
		<th scope="row" valign="top">
			<?php _e("Image directory", "sociable"); ?>
		</th>
		<td>
			<?php _e("Sociable comes with a nice set of images, if you want to replace those with your own, enter the URL where you've put them in here, and make sure they have the same name as the ones that come with Sociable.", 'sociable'); ?><br/>
			<input size="80" type="text" name="imagedir" value="<?php echo attribute_escape(stripslashes(get_option('sociable_imagedir'))); ?>" /><br />
			(automatically disables sprite usage)
		</td>
	</tr>
	<tr>
		<th scope="row" valign="top">
			<?php _e("Use thickbox/iframe on links?:", "sociable"); ?>
		</th>
		<td>
			<input type="checkbox" name="useiframe" <?php checked( get_option('sociable_useiframe'), true ); ?> />
			<?php _e("width:", "sociable")?> <input type="text" name="iframewidth" value="<?php echo attribute_escape(stripslashes(get_option('sociable_iframewidth',900))); ?>" />
			<?php _e("height:", "sociable")?> <input type="text" name="iframeheight" value="<?php echo attribute_escape(stripslashes(get_option('sociable_iframeheight',500))); ?>" />
		</td>		
	</tr>
	<tr>
		<th scope="row" valign="top">
			<?php _e("Open in new window:", "sociable"); ?>
		</th>
		<td>
			<input type="checkbox" name="usetargetblank" <?php checked( get_option('sociable_usetargetblank'), true ); ?> /> <?php _e("Use <code>target=_blank</code> on links? (Forces links to open a new window)", "sociable"); ?>
		</td>		
	</tr>
	<tr>
		<th scope="row" valign="top">
			<?php _e("awe.sm:", "sociable"); ?>
		</th>
		<td>
			<?php _e("You can choose to automatically have the links posted to certain sites shortened via awe.sm and encoded with the channel info and your API Key.", 'sociable'); ?><br/>
			<input type="checkbox" name="awesmenable" <?php checked( get_option('sociable_awesmenable'), true ); ?> /> <?php _e("Enable awe.sm URLs?", "sociable"); ?><br/>
			<?php _e("awe.sm API Key:", 'sociable'); ?> <input size="65" type="text" name="awesmapikey" value="<?php echo get_option('sociable_awesmapikey'); ?>" />
		</td>
	</tr>
	<tr>
		<th scope="row" valign="top">
			<?php _e("Disable Blogplay's widget from dashboard:", "sociable"); ?>
		</th>
		<td>
			<input type="checkbox" name="disablewidget" <?php checked( get_option('sociable_disablewidget'), true ); ?> />
		</td>		
	</tr>	
	<tr>
		<td>&nbsp;</td>
		<td>
			<span class="submit"><input name="save" value="<?php _e("Save Changes", 'sociable'); ?>" type="submit" /></span>
			<span class="submit"><input name="restore" value="<?php _e("Restore Built-in Defaults", 'sociable'); ?>" type="submit"/></span>
		</td>
	</tr>
</table>

<h2><?php _e('Like this plugin?','sociable'); ?></h2>
<p><?php _e('Why not do any of the following:','sociable'); ?></p>
<ul class="sociablemenu">
	<li><?php _e('Link to it so other folks can find out about it.','sociable'); ?></li>
	<li><?php _e('<a href="http://wordpress.org/extend/plugins/sociable/">Give it a good rating</a> on WordPress.org.','sociable'); ?></li>
</ul>
<h2><?php _e('Need support?','sociable'); ?></h2>
<p><?php _e('If you have any problems or good ideas, please talk about them in the <a href="http://wordpress.org/tags/sociable">Support forums</a>.', 'sociable'); ?></p>

<h2><?php _e('Credits','sociable'); ?></h2>
<p><?php _e('<a href="http://blogplay.com/plugin/">Sociable</a> was originally developed by <a href="http://push.cx/">Peter Harkins</a> and was been maintained by <a href="http://yoast.com/">Joost de Valk</a> since the beginning of 2008. On September of 2009, the new home of Sociable is <a href="http://blogplay.com">BlogPlay.com</a>. It\'s released under the GNU GPL version 2.','Sociable'); ?></p>


</div>
</form>
<?php
}
Exemplo n.º 2
0
function sociable_submenu()
{
    global $sociable_known_sites, $sociable_date, $sociable_files;
    // update options in db if requested
    if ($_REQUEST['restore']) {
        sociable_restore_config(True);
        sociable_message(__("Restored all settings to defaults.", 'sociable'));
    } else {
        if ($_REQUEST['save']) {
            // update active sites
            $active_sites = array();
            if (!$_REQUEST['active_sites']) {
                $_REQUEST['active_sites'] = array();
            }
            foreach ($_REQUEST['active_sites'] as $sitename => $dummy) {
                $active_sites[] = $sitename;
            }
            update_option('sociable_active_sites', $active_sites);
            // have to delete and re-add because update doesn't hit the db for identical arrays
            // (sorting does not influence associated array equality in PHP)
            delete_option('sociable_active_sites', $active_sites);
            add_option('sociable_active_sites', $active_sites);
            // update conditional displays
            $conditionals = array();
            if (!$_REQUEST['conditionals']) {
                $_REQUEST['conditionals'] = array();
            }
            foreach (get_option('sociable_conditionals') as $condition => $toggled) {
                $conditionals[$condition] = array_key_exists($condition, $_REQUEST['conditionals']);
            }
            update_option('sociable_conditionals', $conditionals);
            // update tagline
            if (!$_REQUEST['tagline']) {
                $_REQUEST['tagline'] = "";
            }
            update_option('sociable_tagline', $_REQUEST['tagline']);
            if (!$_REQUEST['usecss']) {
                $usecss = false;
            } else {
                $usecss = true;
            }
            update_option('sociable_usecss', $usecss);
            sociable_message(__("Saved changes.", 'sociable'));
        }
    }
    if ($str = sociable_upload_errors()) {
        sociable_message("{$str}</p><p>" . __("In your plugins/sociable folder, you must have these files:", 'sociable') . ' <pre>' . implode("\n", $sociable_files));
    }
    // show active sites first and in order
    $active_sites = get_option('sociable_active_sites');
    $active = array();
    $disabled = $sociable_known_sites;
    foreach ($active_sites as $sitename) {
        $active[$sitename] = $disabled[$sitename];
        unset($disabled[$site]);
    }
    uksort($disabled, "strnatcasecmp");
    // load options from db to display
    $tagline = stripslashes(get_option('sociable_tagline'));
    $conditionals = get_option('sociable_conditionals');
    $updated = get_option('sociable_updated');
    // display options
    ?>
<form action="<?php 
    echo $_SERVER['REQUEST_URI'];
    ?>
" method="post">

<div class="wrap">
	<h2><?php 
    _e("Sociable Options", 'sociable');
    ?>
</h2>
	<table class="form-table">
	<tr>
		<th style="margin-bottom:0; border-bottom-width:0;"><?php 
    _e("Sites", "sociable");
    ?>
</th>
		<td style="margin-bottom:0; border-bottom-width:0;"><?php 
    _e("Drag and drop sites to reorder them. Only the sites you check will appear publicly.", 'sociable');
    ?>
</td>
	</tr>
	<tr>
		<td colspan="2">
			<ul id="sociable_site_list">
				<?php 
    foreach (array_merge($active, $disabled) as $sitename => $site) {
        ?>
					<li style="font-size:10px;"
						id="<?php 
        echo $sitename;
        ?>
"
						class="sociable_site <?php 
        echo in_array($sitename, $active_sites) ? "active" : "inactive";
        ?>
"
						onmouseup="javascript:save_reorder('cb_<?php 
        echo $sitename;
        ?>
');"
					>
						<input
							type="checkbox"
							id="cb_<?php 
        echo $sitename;
        ?>
"
							class="checkbox"
							name="active_sites[<?php 
        echo $sitename;
        ?>
]"
							onclick="javascript:toggle_checkbox('cb_<?php 
        echo $sitename;
        ?>
');"
							<?php 
        echo in_array($sitename, $active_sites) ? ' checked="checked"' : '';
        ?>
						/>
						<img src="../wp-content/plugins/sociable/images/<?php 
        echo $site['favicon'];
        ?>
" width="16" height="16" alt="" />
						<?php 
        print $sitename;
        ?>
					</li>
				<?php 
    }
    ?>
			</ul>
			<input type="hidden" id="site_order" name="site_order" value="<?php 
    echo join('|', array_keys($sociable_known_sites));
    ?>
" />
			<script language="JavaScript" type="text/javascript"><!--
				dragsort.makeListSortable(document.getElementById("sociable_site_list"));
			--></script>
		</td>
	</tr>
	<tr>
		<th scope="row" valign="top">
			Tagline:
		</th>
		<td>
			<?php 
    _e("Change the text displayed in front of the icons below. For complete customization, edit <kbd>sociable.css</kbd> in the Sociable plugin directory.", 'sociable');
    ?>
<br/>
			<input type="text" name="tagline" value="<?php 
    echo htmlspecialchars($tagline);
    ?>
" />
		</td>
	</tr>
	<tr>
		<th scope="row" valign="top">
			<?php 
    _e("Position:", "sociable");
    ?>
		</th>
		<td>
			<?php 
    _e("The icons appear at the end of each blog post, and posts may show on many different types of pages. Depending on your theme and audience, it may be tacky to display icons on all types of pages.", 'sociable');
    ?>
<br/>
			<br/>
			<input type="checkbox" name="conditionals[is_home]"<?php 
    echo $conditionals['is_home'] ? ' checked="checked"' : '';
    ?>
 /> <?php 
    _e("Front page of the blog", 'sociable');
    ?>
<br/>
			<input type="checkbox" name="conditionals[is_single]"<?php 
    echo $conditionals['is_single'] ? ' checked="checked"' : '';
    ?>
 /> <?php 
    _e("Individual blog posts", 'sociable');
    ?>
<br/>
			<input type="checkbox" name="conditionals[is_page]"<?php 
    echo $conditionals['is_page'] ? ' checked="checked"' : '';
    ?>
 /> <?php 
    _e('Individual WordPress "Pages"', 'sociable');
    ?>
<br/>
			<input type="checkbox" name="conditionals[is_category]"<?php 
    echo $conditionals['is_category'] ? ' checked="checked"' : '';
    ?>
 /> <?php 
    _e("Category archives", 'sociable');
    ?>
<br/>
			<input type="checkbox" name="conditionals[is_date]"<?php 
    echo $conditionals['is_date'] ? ' checked="checked"' : '';
    ?>
 /> <?php 
    _e("Date-based archives", 'sociable');
    ?>
<br/>
			<input type="checkbox" name="conditionals[is_search]"<?php 
    echo $conditionals['is_search'] ? ' checked="checked"' : '';
    ?>
 /> <?php 
    _e("Search results", 'sociable');
    ?>
<br/>
		</td>
	</tr>
	<tr>
		<th scope="row" valign="top">
			<?php 
    _e("Use CSS:", "sociable");
    ?>
		</th>
		<td>
			<input type="checkbox" name="usecss" <?php 
    echo get_option('sociable_usecss') ? ' checked="checked"' : '';
    ?>
 /> <?php 
    _e("Use the sociable stylesheet?", "sociable");
    ?>
		</td>
	</tr>
	<tr>
		<td>&nbsp;</td>
		<td>
			<span class="submit"><input name="save" value="<?php 
    _e("Save Changes", 'sociable');
    ?>
" type="submit" /></span>
			<span class="submit"><input name="restore" value="<?php 
    _e("Restore Built-in Defaults", 'sociable');
    ?>
" type="submit"/></span>
		</td>
	</tr>
	<tr>
		<th colspan="2">
			<?php 
    _e('<a href="http://www.joostdevalk.nl/wordpress/sociable/">Sociable</a> is copyright 2006 by <a href="http://push.cx/">Peter Harkins</a> and has been maintained by <a href="http://www.joostdevalk.nl/">Joost de Valk</a> since 2008. It\'s released under the GNU GPL version 2. If you like Sociable, please send a link my way so other folks can find out about it, or <a href="http://www.joostdevalk.nl/donate/">donate a token of your appreciation</a>. If you have any problems or good ideas, <a href="http://www.joostdevalk.nl/contact/">contact me</a>.', 'sociable');
    ?>
		</th>
	</tr>
</table>
</div>

</form>

<?php 
}