Francis Crossen
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: How to use the_post action hookthe_post
action hook will pass an array of $posts to your function, not a single post.You need to return
array( '0' => $your_post )
Forum: Fixing WordPress
In reply to: StarttagsIt looks like complete spam.
At best it looks like an utterly useless site. It does smell suspiciously of some type of link farming though.
Forum: Plugins
In reply to: Mystst – errorIt looks like you might have something more serious going on here. Over 200MB memory usage is very unusual.
Forum: Plugins
In reply to: How do I redirect to the WP 404 page?Well, here is what I ended up using:
// set what we need to display a 404... global $wp_query; $wp_query->is_404 = true; $wp_query->is_single = false; $wp_query->is_page = false; include( get_query_template( '404' ) ); exit();
Forum: Plugins
In reply to: [Plugin: Tina MVC] Upgrade troubles in 0.1.5.x…I have released v0.1.6 which now includes the backup/restore functionality.
There is a new variable in
tina_mvc_app_settings.php
which sets what files and folders are backed up and restored on plugin upgrade. You can add your own folders and files to this variable. Read the comments intina_mvc_app_settings.php
.Important upgrade notice:
If you are upgrading from an older version of Tina, your customisations will NOT be migrated when you upgrade. You should manually backup the following from the
tina-mvc
directory:
–app/
–app_emails/
–tina_mvc_app_settings.php
and restore them after the plugin has been upgraded.You will also need to deactivate and reactivate the plugin to reflect the new settings in
tina_mvc_app_settings.php
.Fran.
Forum: Plugins
In reply to: [Plugin: Codecolorer] Be smart about stripping leading whitespaceGreat plugin thanks…
I’m having a problem with whitespace.
I used [ ccenl_PHP][/ccenl_PHP] and copied some code in. However if I switch from the ‘Visual’ editor to ‘HTML’ and back to ‘Visual’ the leading whitespace in front of each line is removed.
This is affecting my indentation.
Is it me, a feature or a bug?
Forum: Fixing WordPress
In reply to: WordPress keeps substituting & in URLs that have &Where (post/page/etc) and how are you adding the links? Are you using the WISYWIG editor to create the link or doing it in raw HTML?
Are you copy/pasting the link into a post as you did above? If so then WordPress treats it as text and will escape it.
Forum: Requests and Feedback
In reply to: adds <![CDATA[ to html pageForum: Requests and Feedback
In reply to: Possible Blind SQL Injection IssuesI’m getting a consistent 404 for each link (i.e. the same result)
Maybe it is not a core WordPress issue?
How do I reproduce?Forum: Fixing WordPress
In reply to: WordPress keeps substituting & in URLs that have &When you output X/HTML to a browser you should encode ampersands:
– https://example.com/?foo=a&bar=b
should be sent as:
– https://example.com/?foo=a & a m p =b (without spaces!)Forum: Fixing WordPress
In reply to: Get a user’s role by user ID@zeal: roles do not apply to guest users.
Forum: Plugins
In reply to: How do I create a new page with the plugin I’m buildingfunction my_plugin_page_filter( $posts ) { global $wp_query; if( $wp_query->get('my_plugin_page_is_called') ) { $posts[0]->post_title = 'The Page Title'; $posts[0]->post_content = 'The page contents.'; } return $posts; } add_filter( 'the_posts', 'my_plugin_page_filter' );
Forum: Plugins
In reply to: How do I create a new page with the plugin I’m buildingAnd here is the properly formatted code!
if( isset( $q->query_vars['page_id'] ) AND ( intval($q->query_vars['page_id']) == $the_page_id ) ) { // My page has been called - NO permalinks } elseif( isset( $q->query_vars['pagename'] ) AND ( ($q->query_vars['pagename'] == $the_page_name) OR ($_pos_found = strpos($q->query_vars['pagename'],$the_page_name.'/') === 0) ) ) { // My page has been called - with permalinks } else { // Just a normal WordPress page }
Forum: Plugins
In reply to: How do I create a new page with the plugin I’m building@andym4e: Sorry – didn’t see your post until now.
I came across a funny thing where $q->did_permalink was not being set when they were actually in use. I don’t know if it is a bug or a ‘feature’ – I didn’t have time to investigate.
Here’s what I do now:
Forum: Fixing WordPress
In reply to: Get a user’s role by user IDAs greenshady says the only gotcha you need to watch out for is that
$roles
is an array and if you have a user assigned to more than one role you will only get one returned to you.
I am coding a plugin which cannot assume a single role per user.
I recently used the following to address the problem:function tina_mvc_user_has_role( $roles_to_check=array() ) { if( ! $roles_to_check ) return FALSE; global $current_user; get_currentuserinfo(); $user_id = intval( $current_user->ID ); if( ! $user_id ) { return FALSE; } $user = new WP_User( $user_id ); // $user->roles return in_array( $roles_to_check, $user->roles, FALSE ); }
Example:
$user_role_exists = tina_mvc_user_has_role( array('Subscriber','MyRole') );