MathSmath
Forum Replies Created
-
Forum: Plugins
In reply to: WordPress hook explorer applicationPretty neat! Could save me a lot of time hunting for stuff in the codex. Bookmarked.
Forum: Fixing WordPress
In reply to: Where is the admin template for creating or editing a post?There isn’t a single php “template” for the create/edit post form. But this codex article will definitely help you out–it contains info about the add_meta_box function, which does exactly what you need. It even contains some sample code that you can copy/paste and modify to suit your needs.
If you’re new to writing plugins, you should read the Writing a Plugin codex article.
Hope that helps!
Forum: Fixing WordPress
In reply to: Exclude content from excerpt.Got something working! Few caveats though:
1) This only acts on content entered into the “Excerpt” field in the post editor, and only works if you’re using the_excerpt() in your template. By default, if you don’t enter an excerpt, WordPress returns the first 55 words of your post as the_excerpt(), and it won’t contain any embed codes. In that case, this function will fall back to those 55 words.
2) This doesn’t account for multiple embeds in a single excerpt, and may choke on nested object tags (again, I’m not great at regex).
3) Getting it to be page-sensitive is still up to you. This code assumes you’re using a WP page with the slug ‘your-media-page’.
function my_filter_function($str_excerpt) { if(is_page('your-media-page')) { // if we're on the right page preg_match('/(<object[^>]*>)(.*?)(<\/object>)/si',$str_excerpt, $matches); // run the regex if($matches[0]) { // If we found an embed code return $matches[0]; // return the embed code } } return $str_excerpt; // otherwise, return the full, untouched excerpt } add_filter('the_excerpt', 'my_filter_function');
Forum: Fixing WordPress
In reply to: 2.9.2 – missing items in control panelDon’t panic–you’re probably not hacked. Looks like you just don’t have administrative permissions.
The account you’re logging in with mostly likely has the “Editor” role rather than the “Administrator” role.
To do things like add plugins and change settings, you need to be an administrator. Call up the person who developed the site and ask them to change your role to “Administrator”. That should do the trick.
Forum: Requests and Feedback
In reply to: security vulnerability in 2.9.2FYI, assuming WordPress is not installed in a folder you can just move your wp-config file out of the web root.
From the Hardending WordPress article in the Codex:
You can move the wp-config.php file to the directory above your WordPress install. This means for a site installed in the root of your webspace, you can store wp-config.php outside the web-root folder. Note that wp-config.php can be stored ONE directory level above the WordPress (where wp-includes resides) installation. Also, make sure that only you (and the web server) can read this file (it generally means a 750 permission).
Forum: Fixing WordPress
In reply to: Exclude content from excerpt.I have a partial answer, I think.
To do the actual replacing, you’d hook a function up to the the_excerpt filter. Then, get that function to only strip out the text when we’re on your “media” page (I don’t know how you’ve got that set up, but I’m assuming as a regular ol’ WP page). The actual stripping would probably have to be done with a regex (which, unfortunately I’m not good at so you’re on your own there).
I’d start with something along the lines of:
function my_filter_function($str_excerpt) { if(is_page('your-media-page-slug-or-id')) { // if we're on the right page preg_match('[wacky pattern to match]',$str_excerpt, $matches); // run the regex return $matches[0]; // return the important part of the match } return $str_excerpt; // otherwise, return the full, untouched excerpt } add_filter('the_excerpt', 'my_filter_function');
Does this make sense?
Forum: Plugins
In reply to: How do I update a custom database table?You’re looking for the wpdb class.
In your update function, do:
global $wpdb;
Then something like this (example taken from the codex article linked above):
$wpdb->update( 'table', array( 'column1' => 'value1', 'column2' => 'value2' ), array( 'ID' => 1 ), array( '%s', '%d' ), array( '%d' ) )
Plenty of other examples in the codex article.
Doing this cleanly would be surprisingly difficult.
Instead, can you just style based on the cat IDs instead of the slugs? For example, You know that the “Uncategorized” category will have the class “cat-item-1”.
Are you just trying to make the stylesheet more readable, or are you concerned that cat IDs will shift?
Forum: Everything else WordPress
In reply to: __(), _e() and _x()…what’s the difference. Are there more?https://phpdoc.www.ads-software.com/trunk/WordPress/i18n/_wp-includes—l10n.php.html#function_x
Looks like the only special thing about _x() is that it lets you provide a context for the untranslated string–I guess in circumstances where a word might translate differently in different contexts.
Forum: Fixing WordPress
In reply to: Redirect from quote page to thank you pageIf you’re using the latest version of cforms, there is a setting under “cformsII > Form Settings > Core form admin / email options” labeled “Redirect”. Check the box labeled “Enable alternative success page (redirect)” and enter the URL of your thank you page.
If you’re using an older version of cforms, I don’t know if those instructions apply–but you can probably try the cforms support forum, or upgrade to the newest version.
Forum: Fixing WordPress
In reply to: Redirect from quote page to thank you pageYou’ll have to provide more info.
How is your “quote page” set up? Using a plugin? If so, which one?
If you’re developing your own plugin to do this, look at the wp_redirect() function.
Forum: Developing with WordPress
In reply to: Exclude current user in SQLTry adding a NOT IN to your query. Something like:
global $user_ID; $results = $wpdb->get_results ( $wpdb->prepare( "SELECT like_uid FROM " . $wpdb->prefix . "likes WHERE like_pid=%d AND like_uid NOT IN(%d)", $pid, $user_ID), ARRAY_N );