albertdiones
Forum Replies Created
-
Forum: Plugins
In reply to: [Code Snippets] Database Error (Debug mode on) upon plugin activationSeems like it works. thanks again!
Forum: Plugins
In reply to: [Code Snippets] Database Error (Debug mode on) upon plugin activationgreat!
I mistaken this plugin to be a code highlighter but I might need this today for another project
thanks!
Forum: Plugins
In reply to: [Code Snippets] Database Error (Debug mode on) upon plugin activationThe snippet won’t save after this error even though it tries to create the table again when I go to Snippets menu on admin
But I just ran the SQL manually:
CREATE TABLE wp_snippets ( id bigint(20) unsigned auto_increment not null , name tinytext not null, description text, code longtext not null, tags longtext, active tinyint(1) not null default 0, PRIMARY KEY (id) ) DEFAULT CHARACTER SET utf8
(repositioned “not null”)
Forum: Networking WordPress
In reply to: Function To Fetch Latest Posts From All Sites?Don’t wanna see you code something up that has been done.
funny but I already did XD
/** * wp_latest_posts * @param int $limit number of posts to get * @param string $fields the fields to fetch * @param string $blog_db the wordpress database name * @param string $blog_prefix the wordpress table prefix */ function wp_latest_posts($limit,$fields='<code>user_nicename</code>,<code>wp</code>.<code>ID</code>,<code>post_author</code>,<code>post_title</code>,<code>post_name</code>,<code>post_content</code>,<code>post_date</code>',$blog_db=NULL,$blog_prefix='wp_') { static $blog_sql_format=' SELECT <code>blog_id</code> FROM <code>%s</code>.<code>%sblogs</code> ORDER BY <code>last_updated</code> DESC LIMIT %u '; static $sql_format=' ( SELECT %s FROM <code>%s</code>.<code>%s%sposts</code> AS <code>wp</code>,<code>%s</code>.<code>%susers</code> AS <code>wu</code> WHERE <code>post_status</code>="publish" AND <code>post_type</code>="post" AND <code>wp</code>.<code>post_author</code>=<code>wu</code>.<code>ID</code> ORDER BY <code>post_date</code> DESC LIMIT 1 ) '; if (empty($blog_db)) $blog_db=wordpress_db(); $blog_sql=sprintf($blog_sql_format,$blog_db,$blog_prefix,$limit); $blogs=queryToArray($blog_sql); $post_queries=array(); foreach ($blogs as $blog) { $post_queries[]=sprintf( $sql_format, $fields, $blog_db, $blog_prefix, $blog->blog_id!=1 ? $blog->blog_id.'_' : '', $blog_db, $blog_prefix ); } $post_queries=implode(' UNION ',$post_queries); $sql=" SELECT * FROM ( $post_queries ) as <code>latest_posts</code> ORDER BY <code>post_date</code> DESC "; return queryToArray($sql); }
oops my backticks are everywhere and I can’t see a preview button I’ll try to post it first…
edit: lol all my backticks are converted to < code > </ code> I dunno how to fix that
One weakness of this code is, it can only show one post per blog, therefore if blogger1 has 2 posts that is newer than blogger2’s latest post, they would both show but only one post from blogger1 will show.
And hmmm some of the functions in there are on our company functions so if someone might wanna use this you need to replace those wordpress_db(), queryToArray()
Thanks for the reply again, I’ll check those plugins and gather some ideas to improve this on the future, and Why I did that is because we are using the latest posts on a non wordpress page and <div>’s would be preferrable than
< li >’s (saw this on a plugin earlier)
Forum: Networking WordPress
In reply to: create_empty_blog() bug?I didn’t really saw this on the backend,I just saw this on the codex, I was looking for a function that can enable me to create a blog without making the new user the admin of that blog so I used this function and add_user_blog().
wmpu_create_blog() makes the new user the admin of that new site but our project prefer the new user to be just and editor.
I fixed it just this day using update_blog_option, I was pretty sure the value is valid since I used create_empty_blog() and update_blog_option() using the same blogname parameter side by side on my code now (hoping create_empty_blog) would work right in the future.
Thinking about it, , maybe create_empty_blog() was kinda untested cause add site uses wpmu_create_blog
I’ll try to report it… I dunno where but I bet I can search it. Thanks for the reply ??
We just found out that $blog_id is being used as a global variable on switch_to_blog() function, after changing my code dramatically… so I guess that’s what’s wrong in this code.
Forum: Networking WordPress
In reply to: Multisite, Table limit and file system limitsI see. Thank you very much for the answer ??