English flagItalian flagKorean flagChinese (Simplified) flagChinese (Traditional) flagPortuguese flagGerman flagFrench flagSpanish flagJapanese flagArabic flagRussian flagGreek flagDutch flagBulgarian flagCzech flagCroatian flagDanish flagFinnish flagHindi flagPolish flagRomanian flagSwedish flagNorwegian flagCatalan flagFilipino flagHebrew flagIndonesian flagLatvian flagLithuanian flagSerbian flagSlovak flagSlovenian flagUkrainian flagVietnamese flagAlbanian flagEstonian flagGalician flagMaltese flagThai flagTurkish flagHungarian flagBelarus flagIrish flagIcelandic flagMacedonian flagMalay flagPersian flag

Author Archive


Okay, we all remember is_supporter, but things aren’t that easy with pro -sites anymore… I have been reading all over the web people trying to get info on these. They want to do things like wrap a admin menu in a check so that if there not a premium user, the menu isnt shown. They want to display a custom nag to non-paid up users.. So after alot of googling and a jackpot in the code, Here are the functions and parameters. THanks to well documented code..

 

/**
* Check if a given site is Pro or at a given Pro level
*
* @since 3.0
*
* @param int $blog_id optional – The ID of the site to check. Defaults to current blog.
* @param int $level optional – Check if site is at this level or below. If ommited checks if at any level.
* @return bool
*/
function is_pro_site($blog_id = false, $level = false) {
global $psts;
return $psts->is_pro_site($blog_id, $level);
}

/**
* Check if a given user is a member of a Pro site (at any level)
*
* @since 3.0
*
* @param int $user_id optional – The ID of the user to check. Defaults to current user.
* @return bool
*/
function is_pro_user($user_id = false) {
global $psts;
return $psts->is_pro_user($user_id);
}

/**
* Check if a given site is in an active trial
*
* @since 3.0
*
* @param int $blog_id required – The ID of the site to check.
* @return bool
*/
function is_pro_trial($blog_id) {
global $psts;
return $psts->is_trial( $blog_id );
}

/*
* function psts_levels_select
* Print an html select field to choose level for an external plugin
*
* @param string $name Name of the form field
* @param int $selected the level number to select by default
*
* @return echo html select
*/
function psts_levels_select($name, $selected) {
global $psts;
$psts->levels_select($name, $selected);
}

//depreciated!
function is_supporter($blog_id = false) {
return is_pro_site( $blog_id, apply_filters( ‘psts_supporter_level’, false ) );
}

//depreciated!
function is_supporter_user($user_id = ”) {
return is_pro_user( $user_id );
}

//depreciated!
function supporter_feature_notice() {
global $psts;
$psts->feature_notice();
}

//depreciated!
function supporter_get_expire($blog_id = false) {
global $psts;
return $psts->get_expire($blog_id);
}

 

Embeds all albums from a facebook page into a wordpress page. Simply drop the shortcode and have all albums displayed automatically

Manage your wordpress photo gallery via your facebook page.
Add a photo or album to your facebook page, and have this automatically reflected on your website!

Other plugins require you to specify album id numbers to embed. This requires updating your site each time you add a new album! Use this plugin to AUTOMATICALLY embed new albums and photographs directly to your photo gallery inside wordpress.

Also works with lightbox to create lightbox effect around your facebook images while never leaving your website!

 

-In Final Development- -Coming Soon to the WP repository!-

 

I wanted Analytics360 to be visible to the editors of a particular website. I found the appropriate threat on the net that explained it, and set about doing it. But then I noticed that the code had changed a bit since the last post, thusly making the workaround display the api settings page to editors (no good!).  So, what I did, was change all instances of ‘manage_options’ to ‘moderate_comments’, inside analytics360.php but then I duplicated the function that created the menu, and put it and the original behind an IF/ELSE statement and removed the creation of the settings page in the appropriate place, and voila. settings page for admin, analytics page for admin and editors!..

The code to replace is the a360_admin_menu function in analytics360.php starting at line #635.. Replace that function with this modified function

function a360_admin_menu() {
	if (current_user_can('manage_options')) {
		add_options_page(
			__('Settings', 'analytics360'),
			__('Analytics360°', 'analytics360'),
			'manage_options',
			basename(__FILE__),
			'a360_settings_form'
		);
		add_dashboard_page(
			__('Dashboard', 'analytics360'),
			__('Analytics360°', 'analytics360'),
			'manage_options',
			basename(__FILE__),
			'a360_dashboard'
		);
	} else {
	if (current_user_can('publish_posts')) {
		add_options_page(
			__('Analytics360°', 'analytics360'),
			'publish_posts',
			basename(__FILE__),
			'a360_settings_form'
		);
		add_dashboard_page(
			__('Dashboard', 'analytics360'),
			__('Analytics360°', 'analytics360'),
			'publish_posts',
			basename(__FILE__),
			'a360_dashboard'
		);
	}
	}
}

 

 

So, to modify the href tag for the image widget plugin output. just open up /views/widget.php and add rel=”nofollow” inside the echo string on the 6th line. Here is a copy of my code

<?php
echo $before_widget;
if ( !empty( $title ) ) { echo $before_title . $title . $after_title; }
if ( !empty( $image ) ) {
	if ( $link ) {
		echo '<a rel="nofollow" class="'.$this->widget_options['classname'].'-image-link" href="'.$link.'" target="'.$linktarget.'">';
	}
	if ( $imageurl ) {
		echo "<img src=\"{$imageurl}\" style=\"";
		if ( !empty( $width ) && is_numeric( $width ) ) {
			echo "max-width: {$width}px;";
		}
		if ( !empty( $height ) && is_numeric( $height ) ) {
			echo "max-height: {$height}px;";
		}
		echo "\"";
		if ( !empty( $align ) && $align != 'none' ) {
			echo " class=\"align{$align}\"";
		}
		if ( !empty( $alt ) ) {
			echo " alt=\"{$alt}\"";
		} else {
			echo " alt=\"{$title}\"";					
		}
		echo " />";
	}

	if ( $link ) { echo '</a>'; }
}
if ( !empty( $description ) ) {
	$text = apply_filters( 'widget_text', $description );
	echo '<div class="'.$this->widget_options['classname'].'-description" >';
	echo wpautop( $text );			
	echo "</div>";
}
echo "<div>";
echo $after_widget;
?>
 

So, I found that my wordpress Image Widget plugin by Shane and Peter inc, was having an issue aligning in my sidebar. I noticed that when I added multiple instances of the widget, they wouldn’t line up vertically. this naturally bugged the shit out of me, so I took a look at what was going on. Turns out the widget was actually closing a div that it hadn’t opened. Basically this update (3.2.8) is creating validation errors and prematuraly closing my themes sidebar div. So, I opened up the plugin files and took a look. I started with the /views/widget.php file that the readme mentions as being the output for the frontend widget display. Looking in the file I couldn’t see where the close div tag was. it looks like it is part of the $after_widget string thats generated elsewhere in the code. so rather than spend forever looking for it. I decided to simple OPEN a new div, right in front of the call to the string. That way, I could open the div and the string would close it. Check the frontend. VERTICAL ALIGNMENT ACHIEVED! check validation, NO ERRORS! wicked….. Here is my code for the /views/widget.php file..

Note the

echo "<div>";

3rd to last line is what i added. You’ll see its right above the echo to the $after_widget string..

<?php
echo $before_widget;
if ( !empty( $title ) ) { echo $before_title . $title . $after_title; }
if ( !empty( $image ) ) {
	if ( $link ) {
		echo '<a class="'.$this->widget_options['classname'].'-image-link" href="'.$link.'" target="'.$linktarget.'">';
	}
	if ( $imageurl ) {
		echo "<img src=\"{$imageurl}\" style=\"";
		if ( !empty( $width ) && is_numeric( $width ) ) {
			echo "max-width: {$width}px;";
		}
		if ( !empty( $height ) && is_numeric( $height ) ) {
			echo "max-height: {$height}px;";
		}
		echo "\"";
		if ( !empty( $align ) && $align != 'none' ) {
			echo " class=\"align{$align}\"";
		}
		if ( !empty( $alt ) ) {
			echo " alt=\"{$alt}\"";
		} else {
			echo " alt=\"{$title}\"";
		}
		echo " />";
	}

	if ( $link ) { echo '</a>'; }
}
if ( !empty( $description ) ) {
	$text = apply_filters( 'widget_text', $description );
	echo '<div class="'.$this->widget_options['classname'].'-description" >';
	echo wpautop( $text );
	echo "</div>";
}
echo "<div>";
echo $after_widget;
?>
 

So here is the steps I used to call the GD star rating for a post and display it where I wanted. In my case it was in the LI tags of a list of all posts in a category.
You could use this to post the rating right up next to your post title with a little modification to your template.

So, What I did was I called a new wp_query and sorted it based upon the gd star rating. Then while inside the loop I used wp_gdsr_render_article where I wanted the rating to display.
Next, I went and created a custom template for the GD article rating, and I removed all the tags and header information till I was just left with the %RATING% . Next I went back to my call to wp_gdsr_render_article, and I specified my custom template ID (in my case 46) number using the argument.
My code looked like this: wp_gdsr_render_article($template_id = 46, $read_only = false, $stars_set = “”, $stars_size = 0, $stars_set_ie6 = “”, $echo = true

hopes this helps!

 

Lock All Subscribers Out Of The Dashboard!

Redirect Profile.php To Buddypress Profile!

Force Your Buddypress Users To Use The BP Profile Pages!

!FIND OUT MORE!

 

WordPress 3 Compatible

I have seen several plugins that “hide” the dashboard from subscribers, but none that functions as I want.
I don’t want it to allow only the tools, and profile page. I want it to straight kick the user out of the dashboard!

So, I wrote my own plugin that does that. If anyone that is not an admin (cannot activate plugins) attempts to access the dashboard via url or link, they are redirected to the front of the site. sorry, access denied..

Here is my code. Just drop this in your themes functions.php file and edit the url of the redirect to whatever you want.

{code type=php}
//hook onto dashboard and redirect all non admin to front site
add_action(“admin_init”,”redirect_nonadmin_fromdash”);
function redirect_nonadmin_fromdash(){
if (!current_user_can(‘activate_plugins’)) {
// Edit Line Below For Your Own Redirect
header( ‘Location: http://www.erikshosting.com’ ) ;
}
}
{/code}
 

So I installed the wpmu dev teams blogs directory and their members directory plugins on the wpmu triden theme. I noticed that when I clicked on the link and went to one of the directory pages, the page spacing in the navbar got way big. I figured their was some spacing issue coming from the plugin, but it turns out its a little different than that. Looks like the ‘current_page_item’ was generating an empty href link before the actual link. So their were two links per <li> tag for the members directory page nav link when on that page. same with the blogs directory. Also, when you remove this filter, you stop the plugin from renaming the page, so you can edit the title of the page in the wp editor, and have the on page title actually reflect that, rather than letting the plugin rename the page ‘blogs’ or ‘members’.

So how do you fix it?

Open up the blogs directory plugins php file, and find and remove the following line:

{code type=php}
add_filter(‘the_title’, ‘blogs_directory_title_output’, 99, 2);
{/code}

Now in the Members Directory, Find and remove this line:

{code type=php}
add_filter(‘the_title’, ‘members_directory_title_output’, 99, 2);
{/code}
 

Want to add all your pages into your buddypress admin bar automatically?

It’s easy as pie! Just add wp_list_pages to your buddypress bar with the following code!

Create a file called erocks-admin-bar-mod.php in your /plugins/ dir, put in the following code, then activate the BP Nav Bar Mods Plugin on the plugin control panel

{code type=php}
<?php
/*
Plugin Name: BP Nav Bar Mods – Add All Pages
Plugin URI: http://erikshosting.com
Description: Add All Your Pages To The Buddypress Admin Bar Automatically!
Author: Erock
Version: 1.0
Author URI: http://erikshosting.com
*/

//Links and Menus Added To The Following Function Are Always Visible On The BP Bar
function bp_adminbar_currentsite_menu() {
global $bp;
?>

<!– Call All Pages Via A WordPress Shortcode! –>
<?php wp_list_pages(‘title_li=’); ?>

<?php
}

// Call The Function Above
add_action(‘bp_adminbar_menus’, ‘bp_adminbar_currentsite_menu’, 999);

?>
{/code}

Or How About As A Drop Down Menu?

{code type=php}
<?php
/*
Plugin Name: BP Nav Bar Mods – Add All Pages
Plugin URI: http://erikshosting.com
Description: Add All Your Pages To The Buddypress Admin Bar Automatically!
Author: Erock
Version: 1.0
Author URI: http://erikshosting.com
*/

//Links and Menus Added To The Following Function Are Always Visible On The BP Bar
function bp_adminbar_currentsite_menu() {
global $bp;
?>

<!– Call All Pages Via A WordPress Shortcode As A Drop Down! –>
<li><a href=”#”>Pages</a>
<ul>
<?php wp_list_pages(‘title_li=’); ?>
</ul>
</li>

<?php
}

// Call The Function Above
add_action(‘bp_adminbar_menus’, ‘bp_adminbar_currentsite_menu’, 999);

?>
{/code}

 

Now, How About We Remove The Arrow Images From Our Non- Drop Down Menu Items

All you have to do is override the <li> tags background css attribute. It’s easy, watch..

{code type=php}
&lt;li style=”background:none;”&gt;
//Insert your link url or relative url, and your link text below
&lt;a href=”http://EXAMPLE.COM”&gt;EXAMPLE LINK TEXT&lt;/a&gt;
&lt;/li&gt;
{/code}

& Bam, those drop down arrows are gone from the link.

 

It is entirely possible to add your own links to the buddypress bar without modifying core files. It is also possible to add your own drop down menus complete with flyout menus. Let me show you how..

First, lets tackle adding a simple link to the buddypress admin bar.

What I’m going to do is tap into the buddypress admin bar and add a link using a php file placed in the ‘/wp-content/plugins/’ folder and activated via the plugins menu. Create a file in your /plugins/ dir and name it erocks-admin-bar-mods.php then drop the following code into it. After this, go to your plugins page, and activate the BP Nav Bar Mods Plugin.

Lets create that simple link!

{code type=php}
<?php
/*
Plugin Name: BP Nav Bar Mods – Add Link
Plugin URI: http://erikshosting.com
Description: Add A Simple Link To The Buddypress Admin Bar
Author: Erock
Version: 1.0
Author URI: http://erikshosting.com
*///Links and Menus Added To The Following Function Are Always Visible On The BP Bar
function bp_adminbar_currentsite_menu() {
global $bp;
?>

<li>
<!– Insert your link url or relative url, and your link text below –>
<a href=”http://EXAMPLE.COM”>EXAMPLE LINK TEXT</a>
</li>

<?php
}

// Call The Function Above
add_action(‘bp_adminbar_menus’, ‘bp_adminbar_currentsite_menu’, 999);

?>
{/code}

Now Lets Add Multiple Links To The Buddypress Bar..

Pay Special Attention to Enclosing The Href In <li> Tags Each Time.

{code type=php}

<?php
/*
Plugin Name: BP Nav Bar Mods – Add Multiple Links
Plugin URI: http://erikshosting.com
Description: Add Multiple Link To The Buddypress Admin Bar
Author: Erock
Version: 1.0
Author URI: http://erikshosting.com
*/

//Links and Menus Added To The Following Function Are Always Visible On The BP Bar
function bp_adminbar_currentsite_menu() {
global $bp;
?>
<li>
<!– Insert your 1st link url or relative url, and your link text below –>
<a href=”http://EXAMPLE1.COM”>EXAMPLE LINK TEXT1</a>
</li>
<li>
<!– Insert your 2nd link url or relative url, and your link text below –>
<a href=”http://EXAMPLE2.COM”>EXAMPLE LINK TEXT2</a>
</li>

<li>
<!– Insert your 3nd link url or relative url, and your link text below –>
<a href=”http://EXAMPLE3.COM”>EXAMPLE LINK TEXT3</a>
</li>

<?php
}

//Call The Function Above
add_action(‘bp_adminbar_menus’, ‘bp_adminbar_currentsite_menu’, 999);

?>
{/code}

So you see its easy to add multiple links, you just have to repeat the format..

Next Lets Add A Drop Down Menu To The Buddypress Bar

All we gotta do is make use of a <ul> tag inside of your parent items <li> tag. Just like this..

{code type=php}

<?php
/*
Plugin Name: BP Nav Bar Mods – Add Drop Down Menu
Plugin URI: http://erikshosting.com
Description: Add A Drop Down Menu To The Buddypress Admin Bar
Author: Erock
Version: 1.0
Author URI: http://erikshosting.com
*/

//Links and Menus Added To The Following Function Are Always Visible On The BP Bar
function bp_adminbar_currentsite_menu() {
global $bp;
?>

<li>
<!– Insert your parent link url or relative url, and your link text below –>
<a href=”http://EXAMPLE1.COM”>TOP PARENT MENU LINK TEXT</a>

//Start The Drop Down Menu By Not Closing The LI Tag From The Item Above, & By Starting A UL Tag Below
<ul>

<li>
<!– Insert your 1st dropdown menu sub item link url or relative url, and your link text below –>
<a href=”http://EXAMPLE2.COM”>EXAMPLE LINK TEXT2</a>
</li>

<li>
<!– Insert your 2nd dropdown menu sub item l link url or relative url, and your link text below –>
<a href=”http://EXAMPLE3.COM”>EXAMPLE LINK TEXT3</a>
</li>

<!– Below Ends The Drop Down Menu By Closing The UL and LI Tags –>
</ul>
</li>

<?php
}

//Call The Function Above
add_action(‘bp_adminbar_menus’, ‘bp_adminbar_currentsite_menu’, 999);

?>
{/code}

Pretty Easy.

What About Flyout Menus? You Know, Sub-Sub-Menus?

No Problem, thats just more easy work with the <li> and <ul> tags.. We just repeat what we did above, but go another level with the <ul> and <li> tags. Watch..

{code type=php}
<?php
/*
Plugin Name: BP Nav Bar Mods – Add Drop Down With Flyout
Plugin URI: http://erikshosting.com
Description: Add Drop Down With Flyout Menu To The Buddypress Admin Bar
Author: Erock
Version: 1.0
Author URI: http://erikshosting.com
*///Links and Menus Added To The Following Function Are Always Visible On The BP Bar
function bp_adminbar_currentsite_menu() {
global $bp;
?>

<li>
<!– Insert your parent link url or relative url, and your link text below –>
<a href=”http://EXAMPLE.COM”>TOP PARENT MENU LINK TEXT</a>

<!– Start The Drop Down Menu By Not Closing The LI Tag From The Item Above, & By Starting A UL Tag Below –>
<ul>

<li>
<!– Insert your 1st dropdown menu sub item link url or relative url, and your link text below –>
<a href=”http://EXAMPLE.COM”>EXAMPLE LINK TEXT</a>
</li>

<li>
<!– Insert your 2st dropdown menu sub item link url or relative url, and your link text below –>
<a href=”http://EXAMPLE.COM”>EXAMPLE LINK TEXT</a>
</li>

<li>
<!– Start The Flyout Menu Off The Item Below –>
<a href=”http://EXAMPLE.COM”>EXAMPLE LINK TEXT</a>

<!– Instead of Closing the LI tag, Start a UL tag To Create The Flyout Menu –>
<ul>

<li>
<!– Insert your 1st flyout menu sub- sub item link url or relative url, and your link text below –>
<a href=”http://EXAMPLE.COM”>EXAMPLE LINK TEXT</a>
</li>

<li>
<!– Insert your 2st flyout menu sub- sub item link url or relative url, and your link text below –>
<a href=”http://EXAMPLE.COM”>EXAMPLE LINK TEXT</a>
</li>

<!– Below Ends The Flyout Menu By Closing The UL And LI Tags –>
</ul>
</li>

<!– Go Back To The Drop Down Menu And Add Another Item –>
<li>
<a href=”http://EXAMPLE4.COM”>EXAMPLE LINK TEXT4</a>
</li>

<!– Below Ends The Drop Down Menu By Closing The UL and LI Tags –>
</ul>
</li>

<?php
}

//Call The Function Above
add_action(‘bp_adminbar_menus’, ‘bp_adminbar_currentsite_menu’, 999);

?>
{/code}

Real easy. You can add multiple flyout menus, just continue repeat the format.

 

So I noticed that when embedding an Iframe, Google Chrome (and Safari) failed to respond to scrolling=no.

I went to look and see if this syntax was deprecated, but its not.

Basically webkit (safari and chrome are based on them) values css styles on the html, body, and others, higher than the actual iframe style itself.

what that means is that if their is an ‘overflow’ attribute as anything other than ‘hidden’ in your applicable css, and you place scrolling=no onto an iframe style or place it in the html itself, chrome and safari will show scroll bars. firefox and IE will not. WTF?

What can you do..

Well you can place the iframe inside a div, call larger than width and heights to eleminate the ‘auto’ scroll bars in chrome and safari, then use a div outside of it with a set height and width as well as overflow=hidden to trim the iframe.

The Cause…

There is an attribute inside your css that calls overflow: scroll, or overflow: auto, or overflow-x: scroll, or overflow-y: scroll, or auto or whatever… If you are lucky enough to be able to pull this css style attribute out, it will fix your problem…

 

Sometimes it is difficult to locate your server path.

Drop this string into a .php file called ‘locate-path’ or something, and then navigate to it in a browser to see your full server path!

{code type=php}
<p><?php echo $_SERVER[‘PATH_TRANSLATED’];?></p>
{/code}