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

wildmank on "Release 3.9.2"

$
0
0

So, ok, I'm a bit irritated after working 30 hrs over the last two days without any notice from WordPress until I received the "email". Granted, WordPress and Drupal have provided a tremendous service by allowing the masses to implement their open source programs. While they have been gracious in providing their development expertise (25% of all websites posted to the internet are WordPress based and over 5% are Drupal = 30%), why do they not have a representable proportion of individuals who are skulking about finding security issues? Since the WordPress initial release of WordPress 2003, there were 46 subsequent releases until 2010. Approximately 6.5 per year over a 7 year period. Since 2010, there have been 28 releases at an average of 7 per year over a FOUR year period. Almost a 50% increase? Yes? If web developers are to continue offering such services to our clients, I'm afraid that we will have to include an "upgrade clause". This is more problematic than what it seems, since many of the plugin developers do not upgrade their plugins appropriately to the current version. I'm very disappointed. What are your suggestions?


3Pinter on "remove editor option for userrole author (and lower)"

$
0
0

So basicly if a user is author or lower there is no need for them to have the editor.

Im using the latest version of WP in a multisite environment.

I have a function that states all the unneeded stuff, which I will hook into WP the correct way. So far so good.

function dio_removals() {
		if ( !current_user_can('manage_links') ) {
		// remove post types
		remove_post_type_support( 'post', 'editor' );
		// remove meta WP version
		}
		remove_action('wp_head', 'wp_generator');
	}

manage_links is something an author-role isn't allowed to do so I thought this should work. But it doesn't. As a superadmin I don't have the editor either now.

What goes wrong / what should I do?

rajagopalpalani on "About hooks"

$
0
0

write a hook to add code, which will delete the existing content in any page after 20 seconds, when refreshing the page, same content to be displayed and delete process should be continue.

Recently i faced one interview for wordpress developer. I am not able to understand this question. Can anyone please explain above question?

KarmaCS on "Altering post display shortcode"

$
0
0

I am currently using the Extensio theme on my site. I had a blog shortcode that displays posts on a page, but only offers a couple of variables.

I would like to be able to specify a post category, or multiple post categories to all ow me to separate my sales messages from the educational portion of my website. I want to display my sales messages only on the Current Specials page.

Is there an easy way to alter the code below to make this possible? Any help would be appreciated.

Thanks,
KarmaCS

[latestposts title="Current Specials" count="4" mainpost_contentlength="190" otherposts_contentlength="190"]

The code behind it is:

//[latestposts title="latest from the blog" count="4" mainpost_contentlength="80" otherposts_contentlength="190"]
function theme_latestposts($atts, $content=null){
    extract(shortcode_atts(array(
		"title" => "",
		"count" => "4",
		"mainpost_contentlength" => "80",
		"otherposts_contentlength" => "190",
    ), $atts));

	global $wp_query, $post;

	$type = 'post';
	$args=array(
		'post_type' => $type,
		'post_status' => 'publish',
		'posts_per_page' => $count,
		'sort_column' => 'menu_order',
		'order' => 'desc'
	);

	$temp = $wp_query;  // assign original query to temp variable for later use
	$wp_query = null;
	$wp_query = new WP_Query($args); 

	$i = 0;
	$blog_items_output = '';
	if ($wp_query->have_posts()) : while($wp_query->have_posts()) : $wp_query->the_post();							

		// get full image from featured image if was not see full image url in blog post
		$get_custom_options = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), '', false );
		$image_preview_url = $get_custom_options[0];
		$blog_image_thumb = get_the_post_thumbnail($post->ID, 'portfolio_3', array('alt' => the_title_attribute('echo=0')));

		/*$custom = get_post_custom($post->ID);
		$blog_video_url = $custom["blog_video_url"][0];
		if ($blog_video_url) $image_preview_url = $blog_video_url;*/

		$blog_content_excerpt_length = 78;
		if ($post->post_excerpt) { $post_description = $post->post_excerpt; } else { $post_description = $post->post_content; }
		if ( strlen($post_description) > $blog_content_excerpt_length ) {
			$post_description = substr($post_description, 0, $blog_content_excerpt_length).'...';
		}

		$write_comments = '0 '.__('Comments','extensio');
		$num_comments = 0;
		$num_comments = get_comments_number($post->ID);
		if ( comments_open() ) {
		if($num_comments == 0) {
		  $comments ='0 '.__('Comments','extensio');
			} elseif($num_comments > 1) {
			  $comments = $num_comments.__(' Comments','extensio');
			} else {
			   $comments ='1 '.__('Comment','extensio');
			}
			$write_comments = $comments;
		}

		$i++;

		if ($i == 1) {
			$content_length = $mainpost_contentlength;
		} else { $content_length = $otherposts_contentlength; }

		//$content = $post->post_content;
		if (!$excerpt = trim($post->post_excerpt)) {
			$excerpt = $post->post_content;
			$excerpt = strip_shortcodes( $excerpt );
			$excerpt = apply_filters('the_content', $excerpt);
			$excerpt = str_replace(']]>', ']]>', $excerpt);
			$excerpt = strip_tags($excerpt);
			$excerpt_length = apply_filters('excerpt_length', 55);
			$excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');

			$words = preg_split("/[\n\r\t ]+/", $excerpt, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY);
			if ( count($words) > $excerpt_length ) {
				array_pop($words);
				$excerpt = implode(' ', $words);
				$excerpt = $excerpt . $excerpt_more;
			} else {
				$excerpt = implode(' ', $words);
			}
		}
		$content = $excerpt;

		//$content = apply_filters('the_content', $content);
		$excerpt = str_replace(']]>', ']]>', $content);
		if ( strlen( $excerpt ) > $content_length ) {
			$subex = substr( $excerpt, 0, $content_length - 5 );
			$exwords = explode( ' ', $subex );
			$excut = - ( strlen( $exwords[ count( $exwords ) - 1 ] ) );
			if ( $excut < 0 ) {
				$content = substr( $subex, 0, $excut ).' ...';
			} else {
				$content = $subex.' ...';
			}
		} else {
			$content = $excerpt;
		}
		$content = str_replace('<p>','',$content);
		$content = str_replace('</p>','',$content);

		$article_post_class = ' style="margin-bottom:25px;"';

		if ($i == 1) {
			$blog_items_output .= '
				<article class="post"'.$article_post_class.'>
					<figure class="visual">'.$blog_image_thumb.'</figure>
					<h3><a href="'.get_permalink().'">'.get_the_title().'</a></h3>
					<p>'.$content.'</p>
					<nav class="nav-blog">
						<ul>
							<li><a href="'.get_permalink().'">'.__('Read more','extensio').'</a></li>
							<li><a href="'.get_permalink().'#comments">'.$write_comments.'</a></li>
						</ul>
					</nav>
				</article>
				<div class="container">
			';
		} else {
			$article_post_class = ($i == $count) ? ' style="margin-bottom:25px;"' : '';
			$blog_items_output .= '
					<article class="post"'.$article_post_class.'>
						<h3><a href="'.get_permalink().'">'.get_the_title().'</a></h3>
						<p>'.do_shortcode($content).'</p>
						<nav class="nav-blog">
							<ul>
								<li><a href="'.get_permalink().'">'.__('Read more','extensio').'</a></li>
								<li><a href="'.get_permalink().'#comments">'.$write_comments.'</a></li>
							</ul>
						</nav>
					</article>
			';
		}

	endwhile;
	endif;	

	$wp_query = null;
	$wp_query = $temp;

	$title = ($title) ? '<h3>'.$title.'</h3>' : '';

	return '
		<section class="latest-blog">
			<div class="headline center solid">
				'.$title.'
			</div>
			<div class="area">
				'.$blog_items_output.'
				</div>
			</div>
		</section>
	';
}
add_shortcode('latestposts', 'theme_latestposts');

prof611 on "Always show the full content feed, even in Firefox"

$
0
0

For several years now, I have been using my own hacked version of feed-rss2.php, so that the full content feed would always be shown, even in the Firefox browser. I know that the original version of the feed shows the full content in a REAL feed reader ( see http://wordpress.org/support/topic/rss-feed-wont-show-full-text-1 ), but since many of my viewers ( including me ) use Firefox to view their feeds, I wanted the feed to show the full content, even in this browser.

The problem with hacking the feed file directly is that every time I update WordPress, I must re-copy the hacked file - since it's in wp-admin, and this is updated every time WordPress puts out a new version. Since I have many blogs, this task was becoming odious.

So I decided to put my hacked version of rss2 into my child theme. After a lot of research ( I am a tyro at PHP coding ), I finally succeeded in doing this. Here is the contents of the functions.php file I added to my child theme:

<?php
// Include This Feed Function
// basic outline from http://codex.wordpress.org/Customizing_Feeds
// specific function code from http://themeshaper.com/2009/05/25/action-hooks-wordpress-child-themes/
remove_all_actions( 'do_feed_rss2' );
add_action( 'do_feed_rss2', 'full_content_feed_rss2' );

function full_content_feed_rss2() {
/* RSS2 Feed Template for displaying RSS2 Posts feed
   modified by the Professor to always show the FULL CONTENT - never the excerpt
   so that Firefox is forced to show the full content - as it should anyway */
header('Content-Type: ' . feed_content_type('rss-http') . '; charset=' . get_option('blog_charset'), true);
$more = 1;
echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>

<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	<?php do_action('rss2_ns'); ?>
>

<channel>
	<title><?php bloginfo_rss('name'); wp_title_rss(); ?></title>
	<atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
	<link><?php bloginfo_rss('url') ?></link>
	<description><?php bloginfo_rss("description") ?></description>
	<lastBuildDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?></lastBuildDate>
	<language><?php bloginfo_rss( 'language' ); ?></language>
	<sy:updatePeriod><?php echo apply_filters( 'rss_update_period', 'hourly' ); ?></sy:updatePeriod>
	<sy:updateFrequency><?php echo apply_filters( 'rss_update_frequency', '1' ); ?></sy:updateFrequency>
	<?php do_action('rss2_head'); ?>
        <?php while( have_posts()) : the_post(); ?>
        <item>
		<title><?php the_title_rss() ?></title>
		<link><?php the_permalink_rss() ?></link>
		<comments><?php comments_link_feed(); ?></comments>
		<pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?></pubDate>
		<dc:creator><![CDATA[<?php the_author() ?>]]></dc:creator>
		<?php the_category_rss('rss2') ?>
		<guid isPermaLink="false"><?php the_guid(); ?></guid>

                <!-- Replaced unwanted 'excerpt' code -->
                <description><![CDATA[<?php the_content_feed('rss2') ?>]]></description>
		<content:encoded><![CDATA[<?php the_content_feed('rss2') ?>]]></content:encoded>

		<wfw:commentRss><?php echo esc_url( get_post_comments_feed_link(null, 'rss2') ); ?></wfw:commentRss>
		<slash:comments><?php echo get_comments_number(); ?></slash:comments>
                <?php rss_enclosure(); ?>
	        <?php do_action('rss2_item'); ?>
        </item>

        <?php endwhile; ?>
</channel>
</rss>
<?php }

I am posting this in the WordPress forum, so that others don't have to re-invent this themselves. Please comment if you find any mistakes or make any useful changes to my code.

---
Professor
This code is now being used in http://valentinesgiftsformen.professorsopportunities.com/

ConduciveMammal on "Edit PHP code of the Visual Editor textbox"

$
0
0

I'm trying to add the following code to my Visual Editor so that it effects only that textbox and shows as a typical HTML placeholder containing text that disappears when you click on it:

<div id="quote"><?php random_make (); ?></div>

But I can't seem to find any code for the Visual Editor, I've looked in functions.php but I must be missing it.

Can anyone tell me where I can place this code so that I get my desired results?

Regards,
Liam.

jrcayal on "send mail or create restricted access user role? experts advice needed"

$
0
0

Hi there, i'm a complete newbie here, it's my first time on anything about Wordpress coding (php, wordpress itself) and i'm developing a plugin for a client that shows a weekly sales report for a store.
The thing is done, queries are coded and results shown in beautiful tables.
Now, the client (site administrator) asks me for one more thing. The store sells products from different producers so, for the sake of easier re-stockig management he wants either one of these features:
(1) the weekly report generates a file (csv, pdf, whatever) that is automatically sent by mail to each producer with his products sold list
(2) create a new role and user accounts for the producers so they can log in and check (and print/download) that same information, so they would only have acces to that specific plugin page.
the question:
what would be easier to do/code?
many thanks in advance!!

jvwekken on "Register Page Redirection"

$
0
0

I am running the latest version of Wordpress and Buddypress with a heavily customized version of the DynamiX Child theme. I have also created a custom register page with a custom register form on one of my pages using a theme template rather than setting one of my pages as the register page in Buddypress.

I have noticed that if I try to visit this registration page when I am logged in, Wordpress or Buddypress recognizes that I am logged in and automatically redirects me back to the homepage. I am fine with redirecting users away from the register page if they are already logged in, but I’d like to change where they get redirected to. I cannot seem to find the function that controls this though. Does anybody know how to override this behaviour and change where logged in users get redirected to when trying to view the register page? Can I create a hook that will override this function and send users who are trying to view this page while logged in somewhere else?

Thanks


harshad dehmukh on "Redirect to listing page after post save"

$
0
0

Hi,
Can anyone tell me
Is it possible to redirect to listing page after post save
instead staying on same edit form?
please let me know if anyone has done before.

Regards
Harshad

felideo on "Edit Categories, Tags Front End"

$
0
0

First, sorry for my bad english!

Hi, I'm trying create a page to edit categories, tags and custom taxonomies front and. But can't find the correct function to update fields on submit.

The code:

<?php

/*Template Name: Page Template Editar Cetegoria*/
get_header(); ?>

<section class="conteudo-geral">
<section class="conteudo" style="width: 990px" role="main">

<?php
$pid = $_REQUEST [ 'pid' ];
$taxonomia = get_term_by('id', $pid, 'category', 'ARRAY_A');

$nome_taxonomia = $taxonomia->name;
$descrição_taxonomia = $taxonomia->description;
?>		

<form action="" method="post">

<tr class="form-field form-required">
<th scope="row" valign="top"><label for="name">Nome</label></th>
<td><input name="name" id="name" type="text" value="4Cast" size="40" aria-required="true">
</td>
</tr>

<tr class="form-field">
<th scope="row" valign="top"><label for="description">Descrição</label></th>
<td><textarea name="description" id="description" rows="5" cols="50" class="large-text"></textarea><br>
</td>
</tr>

<p class="submit"><input type="submit" name="submit" id="submit" class="button button-primary" value="Atualizar"></p>
</form>

</section>
</secrion>

<?php get_footer(); ?>

c13303 on "How to query_posts categories AND and OR at the same time ?"

$
0
0

Hi !
Starting from this :
query_posts( array( 'category__and' => array(1,2), 'posts_per_page' => 2, 'orderby' => 'title', 'order' => 'DESC' ) );

I'm wondering if I can make a request with query_posts
getting all posts belonging to
(category 1 AND 2) OR (category 2 AND 3)
?

Thanks a lot

Pete on "Can I get the date/time of a post's updated taxonomy?"

$
0
0

Can I get/echo the date-time that a specific post/CPT's taxonomy is updated/changed?

mariz_p on "add user notification in bbpress moderation"

$
0
0

I have modified the bbpress moderation plugin since I'm not getting any response from it's author.
Please see this link: http://pastebin.com/EMmZK1Zt
for my code.

Now, my problem is I cannot make it work. I have checked the structure of wp mail and I know I'm in the right path. It's just why it's still not working.

I hope someone here can help me as I've been struggling on this for months now.

Thanks and have a great day ahead.

Best regards,
Mariz

benwainwright on "Auth cookie not always recognised by my theme"

$
0
0

Hi there

I posted the following in the 'themes' forum a few days ago, but I got no replies and just realised that what I am doing here probably falls more into the remit of this forum. I am absolutely desperate to fix this problem; I thought it had resolved itself (as the stack exchange question indicates), but it is back again.

Original thread - mods feel free to delete it: http://wordpress.org/support/topic/authentication-cookie-not-always-recognised-by-my-theme?replies=1

I am currently developing a custom WordPress theme for my rugby team. I am trying to create a members area for my site using custom post types and the following code included into my functions.php:

<?php

function redirect_restricted_areas( $query )
{
    if ( !is_admin() && $query->is_main_query() )
    {
          if ( ! current_user_can( 'view_players_area' ) && (
               $query->is_singular ('player-page') ||
               $query->is_post_type_archive ('player-page')
          ) ) 

          header('Location: ' . wp_login_url( "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" ) );
    }

}

add_action ( 'pre_get_posts', 'redirect_restricted_areas' );
The problem is that it works, but NOT consistently. If I click login, it redirects to the login page and then back to my members area where I am now logged in. If however, I am not logged in and I type url/players-area/ into the browser, more often than not it redirects me to login.php and then BACK there when I am logged in. If I then type /wp-admin/ into the browser, the dashboard works fine.

I have documented this problem in more detail here.

I would *really* appreciate some help with this matter as soon as is possible because I am at my wits end here.

davistom on "Per-page ajax configuration in child theme functions.php"

$
0
0

I have a pages only Wordpress 3.9.2 site with a child theme. A subset of the pages require custom stylesheets, javascript and ajax features. I know how to implement all of these requirements via various Wordpress action hooks, etc. implemented in the child theme functions file. However, straightforward, direct implementation results in configuring everything for all site pages, including those which don't require any of this custom functionality. Is there an accepted way to conditionally implement the custom stuff on a per-page basis?


Lesley Ward on "Brute Force Attack"

$
0
0

I appear to be under attack by someone trying to hack my website. :-(

I've put in a really complicated password which WP thinks is strong but I'm wondering if there's anything else I can do to stop these attacks?

I saw somewhere that you can install a plug in to limit the number of incorrect login attempts but the link was very out of date.

Does anyone have a more up to date plug in or any more suggestions?

Thanks for your help.

Andi Lee Davis on "reset have_posts after unsetting a post"

$
0
0

Hi there,

We have a specific event that is scheduled that grabs an alert post and gets certain jobs.
This then runs through a function that removes posts from these if they have been sent out to a specific user.

This works fine by unsetting the post in the object according to the index. However after this and sorting the posts, when the function have_posts() is called this results in NULL returned.

Can someone please help ecxplain why this would then be null if there are still posts within the query object?

Thanks

Andi

Here is the code...

protected function filter_jobs_for_send_once_only($jobs, $user, $alert){
			$i = 0;
			$user_id = $user->ID;
			$alert_id = $alert->ID;

			$original_post_count = $jobs->post_count;

			error_log ("\n\nPRE alert count jobs " . $jobs->post_count . " != " . $original_post_count . " HAVE POSTS: " . $jobs->have_posts() . "\n\r" . print_r($jobs,true) , 3 , '/var/www/vhosts/websitetest.com/httpdocs/websitetest/testCountJobs.log', NULL );

			while ( $jobs->have_posts() ) {
				$jobs->the_post();
				$post_id = get_the_ID();
				$meta_send_check = get_post_meta( $post_id, 'send_once_only', true);
				$meta_send_date_check = get_post_meta( $post_id, 'last_date_sent', true);
				$meta_user_data_check = get_post_meta( $post_id, 'user_sent_list');
				$dateNow = new DateTime('now');
				/* Multidimensional array
				*
				*/
				$user_list = (empty($meta_user_data_check[0]) ? array() : $meta_user_data_check[0]);
				$user_alert_list = (empty($user_list[$user_id]) ? array() : $user_list[$user_id]);

				switch($meta_send_check) {

					case true:
						/**	Case true: Send once only is set to true we then want to see if it has a last_date_sent meta data set.
						 *	If it has then we unset it from the jobs array, if not we do not unset it but add a last_date_sent
						 *	so that it can be filtered out next time round, stopping the list from growing
						 *
						 * However we now ignore it if this job has not yet been sent to a new user
						 *
						 */

						if(in_array($user_id, array_keys($user_list)) && in_array($alert_id, $user_alert_list) ) {
							/// Unset as has been sent already in the past and we don't want to again
							unset($jobs->posts[$i]);
							$jobs->found_posts--;
							$jobs->post_count--;
						}
						break;

					case false:
						/**	keep in list, but Set a last_date_sent, so if an admin sets the job to only_send_once = true then the case above will be respected
						*	for this job
						*/
						break;

				} /// End Switch

				///test array increases
				if(!in_array($alert_id, $user_alert_list)){
					array_push($user_alert_list, $alert_id);
					$user_list[$user_id] = $user_alert_list;
				}

				/// Sort the array
				ksort($user_list);

				update_post_meta($post_id, 'last_date_sent', $dateNow->format('Y-m-d H:i:s'));
				update_post_meta($post_id, 'user_sent_list', $user_list);	

				$i++;

			} /// End while loop

			if($jobs->post_count != $original_post_count) {
				///sort($jobs->posts);
				$jobs->posts = array_values($jobs->posts);
///// No have_post... can't work out why
				error_log ("\n\nalert count jobs " . $jobs->post_count . " != " . $original_post_count . " HAVE POSTS: " . $jobs->have_posts() . "\n\r" . print_r($jobs,true) , 3 , '/var/www/vhosts/websitetest.com/httpdocs/websitetest/testCountJobs.log', NULL );

			}

		return $jobs;

	}

keirgarth on "2014 theme need to scale slider"

$
0
0

I am doing a class project and want to scale the slider to fit the images that I have chosen. I am not real familiar with wordpress so any advice would be great. Currently the slider is the full width of the site minus the sidebar and I would like it to be half width and shorter. Site is jcdesigns.us

realmattbender on "Using an Array as a post title"

$
0
0

I am looking to store multiple elements as an array, and then call them based on one of the element's size. For example-
We have a page titled:
Pet Assure | Daily Pet Calendar - Smoke (Bloodhound) Jun 23
I would like to store
"Pet Assure | " as value 0
"Daily " as value 1
"Pet Calendar- " as value 2
"<?php single_post_title(); ?> " or "Smoke (Bloodhound)" as value 3
"<?php the_time('M j') ?>" as value 4.

I would then like to dynamically set the page title.
If "Value 3" is less than or equal to 21, display the full string: "0" "1" "2" "3" "4"
Val 3=22-34 display "1" "2" "3" "4"
Val 3=35-40 display "2" "3" "4"
Val 3=41+ display "3" "4"

We have a blog with approx 1350 post with page title exceeding 100+ characters, and we are trying to remedy this.

Any help able to be provided would be awesome!

999ghosts999 on "Hacked, cannot enter site"

$
0
0

Hello.

My page is hacked and I can't enter my dashboard either

I get:
An appropriate representation of the requested resource /home/wp-login.php could not be found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

I get this also when I try to reset my PW

Site url is: http://turning-point-balletschool.be/home/

I can see all subpages. Just not the mainpage.

Our new season is starting soon. Need urgent help!

Viewing all 8245 articles
Browse latest View live




Latest Images