This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<p><?php $syntax = get_object_taxonomies('snip'); | |
$syntaxterms=get_terms($syntax, 'orderby=count&offset=1&hide_empty=0&fields=all'); | |
// var_dump($syntaxterms); die; ?> | |
<select name='syntax' id='syntax' tabindex="4"> | |
<option value='' <?php if (!count( $names )) echo "selected";?>>Select syntax</option> | |
<?php foreach ( $syntaxterms as $code ) { echo '<option value="' . $code->slug . '" selected>' . $code->name . '</option>',"\n"; } ?> | |
</select></p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//For the functions.php file | |
function my_bp_activity_is_favorite($activity_id) { | |
global $bp, $activities_template; | |
return apply_filters( 'bp_get_activity_is_favorite', in_array( $activity_id, (array)$activities_template->my_favs ) ); | |
} | |
function my_bp_activity_favorite_link($activity_id) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. The first thing I did was find out how BuddyPress adds activities in core code when a blog posts is published. I found out that this is done in bp_blogs_record_activity method of bp-blogs.php. Inside this method I found that I can actually retrieve an activity id of a single blog post by calling the method bp_activity_get_activity_id(). If I have the id of an activity, I can easily add it as my favorite from any place on my site. | |
2. With the above knowledge in hand, I went to my single.php theme template file and added the following inside my the_post loop: | |
global $bp; | |
$activity_id = bp_activity_get_activity_id( array( | |
'user_id' => $post->author_id, | |
'type' => 'new_blog_post', | |
'component' => 'blogs', | |
'item_id' => 1, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://wordpress.org/extend/plugins/easy-post-types/ | |
Step 1: Download this plugin WP easy post types and activate. | |
Step 2: Create a post type called Groups | |
Click the drop down and add new. Add a new post type with the title of a groups slug. Example: say you have a group slug like this groups/bp-tricks, you would then create a group custom type post titled bp-tricks. Add something to the post editor box and hit save. | |
Important: If you’ve changed the slug of your Groups make sure to use the same name for your Post type! | |
What we are essentially doing is tricking WP and BP into using the same URL. So by creating a custom post type with the exact URL of a group we can override the front page with a WP page and then use the post editor to create anything. | |
Step 4: Edit a Template |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter('the_content', 'styleBlogName'); | |
function styleBlogName($content) { | |
$blogTitle = get_bloginfo('name'); | |
$content = str_replace($blogTitle, '<span style="color: Red;">' . $blogTitle . '</span>', $content); | |
return $content; | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// add_filter('get_terms', 'restrict_categories'); | |
function restrict_categories($categories) { | |
// If we are in the new/edit post page and not an admin, then restrict the categories | |
$onPostPage = (strpos($_SERVER['PHP_SELF'], 'post.php') || strpos($_SERVER['PHP_SELF'], 'post-new.php')); | |
if (is_admin() && $onPostPage && !current_user_can('level_10')) { | |
$size = count($categories); | |
for ($i = 0; $i < $size; $i++) { | |
if ($categories[$i]->slug != 'site_news') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter('upload_dir', 'my_upload_dir'); | |
$upload = wp_upload_dir(); | |
remove_filter('upload_dir', 'my_upload_dir'); | |
funcion my_upload_dir($upload) { | |
$upload['subdir'] = '/sub-dir-to-use' . $upload['subdir']; | |
$upload['path'] = $upload['basedir'] . $upload['subdir']; | |
$upload['url'] = $upload['baseurl'] . $upload['subdir']; | |
return $upload; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? php | |
// Class example (inside ex. filename.php): | |
if ( ! class_exists('YourPluginNameInit' ) ) : | |
/** | |
* This class triggers functions that run during activation/deactivation & uninstallation | |
* NOTE: All comments are just my *suggestions*. | |
*/ | |
class YourPluginNameInit | |
{ | |
// Set this to true to get the state of origin, so you don't need to always uninstall during development. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? php | |
function insert_term($term, $taxonomy, $args = array()) { | |
if (isset ( $args ['parent'] )) { | |
$parent = $args ['parent']; | |
} else { | |
$parent = 0; | |
} | |
$result = term_exists ( $term, $taxonomy, $parent ); | |
if ($result == false || $result == 0) { | |
return wp_insert_term ( $term, $taxonomy, $args ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? php | |
add_filter("manage_upload_columns", 'upload_columns'); | |
add_action("manage_media_custom_column", 'media_custom_columns', 0, 2); | |
function upload_columns($columns) { | |
unset($columns['parent']); | |
$columns['better_parent'] = "Parent"; | |
return $columns; |
OlderNewer