Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all 8245 articles
Browse latest View live

Mart89 on "customising custom field format"

$
0
0

Hi basically i need to override the code below in funcitons php

/**
 * Display list of post custom fields.
 *
 * @internal This will probably change at some point...
 * @since 1.2.0
 * @uses apply_filters() Calls 'the_meta_key' on list item HTML content, with key and value as separate parameters.
 */
function the_meta() {
	if ( $keys = get_post_custom_keys() ) {
		echo "<ul class='post-meta'>\n";
		foreach ( (array) $keys as $key ) {
			$keyt = trim($key);
			if ( is_protected_meta( $keyt, 'post' ) )
				continue;
			$values = array_map('trim', get_post_custom_values($key));
			$value = implode($values,', ');
			echo apply_filters('the_meta_key', "<li><span class='post-meta-key'>$key:</span> $value</li>\n", $key, $value);
		}
		echo "</ul>\n";
	}
}

i know it involves add_filter or something but when i do this:

add_filter('the_meta_key', 'modified_meta_matt', $priority = 1, $accepted_args = 1 ); 

function modified_meta_matt() {
	if ( $keys = get_post_custom_keys() ) {
		echo "<ul class='post-meta'>\n";
		foreach ( (array) $keys as $key ) {
			$keyt = trim($key);
			if ( is_protected_meta( $keyt, 'post' ) )
				continue;
			$values = array_map('trim', get_post_custom_values($key));
			$value = implode($values,', ');
			echo apply_filters('modified_meta_matt', "<li><span class='post-meta-key-3'>$key:</span> $value</li>\n", $key, $value);
		}
		echo "</ul>\n";
	}
}

?>

It does work, but it displays the custom fields repeated like 6 times!
thanks for your help!


polarte on "site hacked, fix please?"

$
0
0

There does not seem to be much information on this robot hack so i thought i would put it out there if anyone experienced the same hack.

website title changed to:
[ Please do not post that code here again. It's not safe. ]
Under Settings -> Reading:
swithced to utf-7. (fix: change to utf-8)

I have not seen any other issues so far. reset all passwords and tightening htaccess.

olddocks on "Strange issue with theme options page?"

$
0
0

I am struggling with a strange issue in my theme options page. I am trying to add a menu page under appearance for theme settings...

add_theme_page( 'Theme Option','softlights Options', 'edit_theme_options', 'theme_options.php', 'softlights_options_page');

As you can see, if i change the menu slug "theme_options.php" to "soft lights-theme-options", the the theme settings page crashes throwing this error

You do not have sufficient permissions to access this page.

What is causing the issue? How do i fix it?

erfg12 on "Hacked site. Fixed, but cant edit 1 page?"

$
0
0

My wordpress site was hacked, but I changed my cpanel passwords and remove bad .htaccess stuff.

There is a few pages that have their insignia on them, but I cannot remove this. I checked the database for the text, and for encode incase it was PHP encoded, but didn't find anything.

The path to the page is http://domain/2013/10 is there a way I can navigate to this page and modify it from the admin control panel?

Luke Janicke on "Walker class for comments"

$
0
0

Can anyone point me to any good (and by that I mean slightly “For Dummies”) guides on using a walker class for comments?

I just started writing a callback function to customize wp_list_comments() and I checked the codex where I noticed this…

'walker'
( Walker object ) Provide a custom Walker class object to use when rendering the comments. This is the primary method of customizing comment HTML.

Really? The primary method of customizing comment HTML. The Internet doesn’t agree. Mostly.

Anyone point me to a good introduction and example?

Mrurka on "Displaying parent, sub and sub-sub Categories, each on different pages."

$
0
0

Greetings all!

I have some data that I need to categorize in 3 parts. For example, one item may be in Category "Farm Products" / sub-Category "Dairy" / sub-sub-Category "Cheese".

I am looking to have all top-level Categories (Farm Products) display on a page and upon clicking one, it brings you to a page listing that top-level categories children (Dairy). And upon clicking that (Dairy), it brings you to a page listing the next line of children (Cheese).

I'm wondering how I can display this, page by page.

Any hints or suggestions on where to look or how to start is very much greatly appreciated. Thank you

romualdv on "Custom public profile page"

$
0
0

I want to create a custom public profile page for my shop customers. Has anyone done this before who can assist me please? I've searched MANY sites but to no avail. Any support would be much appreciated!

appleisle on "Post Author URL displays Username NOT Nickname"

$
0
0

I have found earlier requests on this Username appearing in the URL but no real answers & most were 4 to 5 years old - so here goes again:

PROBLEM: Posts are created and display the Nickname (Not Login Username) yet when you click on that Nickname to see a summary of all the posts by that person the URL that appears reverts to:www.??????/author/username/

ISSUE is this gives the "hacker" your real Log In Username. Yes I know we all should have good passwords but as a general WP user I could not believe this is a standard WP code action.

I have just last night had many attempts to hack in at Log In (protected by All In One WP Security & Firewall) and was amazed they had my Username to attempt to crack in (NO it is not Admin!).

That prompted me to think they had cracked into my DB to get the username, then I found via searching the Forum some notes about the problem and sure enough I check my site and bingo the Post Summary for a nickname provides the Username...!!!!

I saw there is a Plug-in SX_Username is this the ONLY OPTION or am I missing some standard WP code/setting issue?

Any help much appreciated.


hasanrang05 on "add_filter with get_search_query executing 4 times"

$
0
0

I am trying to get search query string to submit custom table and count how many time these string searched

my table column
id(int), keyword(varchar), count(int)

everything i made my way but problem is when submit search form its count 4 times code following bellow.

function search_count($search) {

		//table column id, keyword, count
		// intial value 1, wordpress, 1
		global $wpdb;
		$table = "wp_search_count";
		$wpdb->query("UPDATE $table SET count = count+1 WHERE keyword = '$search'");

return $search;

}
add_filter( 'get_search_query', 'search_count');

i have started count value 1 and after submit search form its should be 2 but i get 5 for count value

Please kick me on the way ...
Thanks in Advance.

picus on "Request for another php function"

$
0
0

Hi,
pardon the probably stupid question but I'm a newbie to plugin development.
I need to do a sort of product catalogue.
I've prepared the mysql tables, the db accessor php classes and the domain objects. Now I'm able to read and print (via Div tags) a list of products (picture, name, price).
This is realized using a shortcode in a static wp page.

Now the question is: which is the better way to invoke another php function that, after a product is clicked, print another list of the selected product features?

Thanks in advance
Fabio

dsteen on "Cannot insert terms"

$
0
0

Hi Everyone,

I have the following problem:

I have written a plugin which adds a custom post type with a custom toxonomy to my wordpress site. The plugin runs a cronjob every 10 minutes. When the cronjob is executed, data is fetched from a remote server. A part of the data contains terms that have to be associated with my custom post type. So i want to insert them as term in my custom taxonomy for my custom post type.

I tried to use wp_insert_term(), however after calling it nothing seems to be inserted. Did anyone face this problem aswell? and how did you solve it?

Thanks in advance.

wiresplus on "How do I redirect to another page after a short delay"

$
0
0

Hello,

I want to have a thankyou page, that redirects after a short pause.

The page id will be 432.

I tried to add the following 7 second delay/redirect

<?php if(is_page(432)){
<meta http-equiv="refresh" content="7;url=[homepage url]" />
}
?>

in page.php, but no good.

What should I be doing?

McShaman on "Make plugin page follow standard enqueueing procedures"

$
0
0

I am writing an administrator plugin that helps a user write some simple shortcodes. When the user clicks on a new button in the TinyMCE editor a ThickBox window appears and loads a PHP template I created with a heap of prompting fields.

If I want to access new scripts or stylesheets in this window I have to hard code them into the PHP template. I.e.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
        <script src="./scripts/myscript.js"></script>
        <style src="./css/mystyles.css"></style>
    </head>

I would much prefer to use best practice enqueuing methods as opposed to this method.

Is there a way to make this PHP document in my plugins folder do all the normal WordPress processes (e.g. enqueue script and styles) as if it were just another page?

artcoder on "pre_option_posts_per_page filter example code not correct"

$
0
0

The code in this codex page for "pre_option_posts_per_page" filter is not correct ...
http://codex.wordpress.org/Plugin_API/Filter_Reference/pre_option_(option_name)

Because I copied the code verbatim in attempt to alter the amount of displayed posts per page for a specific category. And the code did not take effect (although there was not error in output).

Can someone who knows enough about wordpress core tell me the correct code for doing this?

Scott Smith on "Making a Theme Customizer control class for .ico files"

$
0
0

While adding a theme option for users of my theme to upload favicons (due to [http://wordpress.org/support/topic/please-allow-standard-ico-favicon-file this request],) I realized that the WP_Customize_Image_Control class doesn't accept .ico image uploads. When the image upload dialogue was selected, .ico files would not be a selectable option, so I tried extending the WP_Customize_Image_Control class which was unsuccessful and then tried extending the WP_Customize_Upload_Control class in similar fashion to the WP_Customize_Image_Control class. Unfortunately, only png files are allowed and ice files are not. I've added both the mime type and file extension for the .ico file and neither allows the image to be selected.

This is what I ended up with:

{{{
class Decode_Customize_Favicon_Image_Control extends WP_Customize_Upload_Control {
public $extensions = array( 'ico', 'png', 'image/x-icon' );
}
}}}

This seems to be due to the fact that the JavaScript responsible for image uploads in wp-includes/js/plupload/plupload.js doesn't have .ico files in it's list of file types.

At this point, my abilities end. Thanks for hearing me out.


Luke Janicke on "$user_identity in comment_form_defaults filter not working"

$
0
0

In my comments template, I have customized the comment form using the two filters comment_form_defaults and comment_form_default_field.

It seems the variable $user_identity isn’t working. It’s returning an empty string. I’m using the filter, not arguments, so $user_identity is already set in the comment_form() function before the filter is performed.

Here’s my filter…

function my_comment_form_defaults( $defaults ) {
    $defaults['logged_in_as'] = '<p class="logged-in-as">' . sprintf( 'Logged in as <a href="%1$s">%2$s</a>. <a href="%3$s" title="Log out of this account">Log out?</a>', get_edit_user_link(), $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '</p>';
    return $defaults;
}
add_filter( 'comment_form_defaults', 'my_comment_form_defaults' );

Note:
The codex says to use admin_url( 'profile.php' ).
But in the code for comment_form() it now uses get_edit_user_link().
That’s not relevant to my question but I point it out in case anyone notices that difference.

The only difference between my filtered code and the default code is that I’ve removed the translation function __(). That will be restored later. Before I further customize my code, I need the variable $user_identity to work properly.

Here’s the HTML output…

<p class="logged-in-as">Logged in as <a href="http://www.mydomain.com/wp-admin/profile.php"></a>. …

Can anyone see why $user_identity is returning an empty string?

johnnymorriswp on "Help Adding Filter"

$
0
0

Hi All

I am using a Plugin that inserts url links into a template. I would like the links to open in a new window. I can modify the core Plugin template to do this as follows (see last line of code below). However I know this will be lost if the Plugin updates. I would therefore like to add a filter in the functions.php file in my child theme to do this instead, but am not sure how to do it. Any advice appreciated. By the way, site is currently only on local host so no link to include.

Thanks

// Begin templating logic.
			$tpl = '<div itemscope itemtype="http://schema.org/Person" class="%%CLASS%%">%%AVATAR%% %%TITLE%% <div id="team-member-%%ID%%"  class="team-member-text" itemprop="description">%%TEXT%% %%AUTHOR%%</div></div>';
			$tpl = apply_filters( 'woothemes_our_team_item_template', $tpl, $args );

			$count = 0;
			foreach ( $query as $post ) { $count++;
				$template = $tpl;

				$css_class = apply_filters( 'woothemes_our_team_member_class', $css_class = 'team-member' );
				if ( ( is_numeric( $args['per_row'] ) && ( 0 == ( $count - 1 ) % $args['per_row'] ) ) || 1 == $count ) { $css_class .= ' first'; }
				if ( ( is_numeric( $args['per_row'] ) && ( 0 == $count % $args['per_row'] ) ) ) { $css_class .= ' last'; }

				// Add a CSS class if no image is available.
				if ( isset( $post->image ) && ( '' == $post->image ) ) {
					$css_class .= ' no-image';
				}

				setup_postdata( $post );

				$title 		= '';
				$title_name = '';

				// If we need to display the title, get the data - JOHNNYM added to line 115 target=_blank
				if ( ( get_the_title( $post ) != '' ) && true == $args['display_author'] ) {
					$title .= '<h3 itemprop="name" class="member">';

					if ( true == $args['display_url'] && '' != $post->url && apply_filters( 'woothemes_our_team_member_url', true ) ) {
						$title .= '<a href="' . esc_url( $post->url ) . '" target="_blank">' . "\n";
					}

Luke Janicke on "comment_reply_link() not working"

$
0
0

I am calling comment_reply_link() in my custom callback function for wp_list_comment().

It isn’t working… at all.

<?php comment_reply_link( array( 'before' => '<li class="reply">', 'after' => '</li>' ) ); ?>

At this stage, I’m not using comment-reply.js to move the comment form. I’m just slowing building up from scratch my theme (a learning exercise). I want to implement threaded comments and the first step is to make the reply link work.

Is that JavaScript actually required for the reply link to work?
Why is there no output from this function in my code?

benutzerfreund on "Show only posts with specific keyword in title"

$
0
0

I want to show all posts of a specific category containing a custom keyword in the post title.

What works is:

<?php
		$args = array('category_name' => 'interviews', 'posts_per_page' => '999' );
	    $the_query = new WP_Query( $args );
		while ( $the_query->have_posts() ) {
			$the_query->the_post();
			?>
			<li><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
			<?php
		} ?>

But when I add `'s' => 'peter' to $args, nothing is found (to get only interviews with Peter). Using only 's=peter' does't do the trick also.
But searching for 'peter' with the standard search box does bring up the correct posts.

Any hints?

AlphaGolf_fr on "Adding a version number to CSS (and JS) files"

$
0
0

I'd like to append a build number to the CSS and JS file names of my plugin, instead of ?ver=3.8, so that the latest version of the files are sent to the browser with new releases of my plugin.

As per the Codex, I'm using this and it works fine, I do see the build number appended to my filename:
wp_enqueue_script( 'wp-symposium-toolbar', plugins_url( 'js/wp-symposium-toolbar.js', __FILE__ ), array( 'jquery' ), $wpst_buildnr );

But I'm using this and it doesn't work:
wp_enqueue_style( 'wp-symposium-toolbar_admin', $adminStyleUrl, array(), $wpst_buildnr );

Note that these variables are correctly set. Any suggestion why it doesn't work?

Thanks

Viewing all 8245 articles
Browse latest View live




Latest Images