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

Demetrius Pop on "access JSON results from wordpress database with wpdb"

$
0
0

I have JSON results from Google API added to to wp_options table. At this point I just need to echo the specific elements. Namely, the coordinates. The option_name I have is py_menu_item. One of the option_value element is coords. That is what represents the JSON results. The code below yields this response: array(o){}

The code:

global $wpdb;
$myrows = $wpdb->get_results("SELECT coords FROM $wpdb->wp_options");
$lat = $myrows->results[0]->geometry->location->lat;    //latitude
$long = $myrows->results[0]->geometry->location->lng;   //longitude
echo $lat;
echo $long;
var_dump($myrows);

I am using this Codex page as a guide: Class_Reference/wpdb


pvijeh on "Fixing sql #1062 duplicate content error"

$
0
0

Hello,

I am trying to upload one of my site's sql databases using phpmyadmin-- however i get the following error:

#1062 - Duplicate entry '153' for key 'id'

Does anyone know how to solve this error?

AliceWonderFull on "Modifying behavior of wp-comments-post.php ??"

$
0
0

The wp-comments-post.php

within it is the following line of code:

$comment_author_email = ( isset($_POST['email']) )   ? trim($_POST['email']) : null;

I would like to run it through a filter that converts the domain part of an e-mail address to ASCII punycode so that people posting with IDN e-mail addresses won't be rejected by the core is_email function.

Is this possible?

-=-

Another possibility is to re-define is_email() using the PECL runkit module but I think that's kind of dirty, not sure it even builds on current php.

I would re-define is_email, after it splits the email into local@domain - it could add

if(function_exists('idn_to_ascii') {
  $domain=idn_to_ascii($domain);
  }

That would at least let IDN domains pass the is_email() test but I still would prefer the e-mail address by ASCII from the start (converted to UTF8 for display in pages), so the best way would be to just modify UTF8 e-mail when the $_POST['email'] is parsed.

Is that possible via a plugin?

Sorry, I am new to WordPress development and still trying to dig through the docs about what is and is not possible.

Thanks for suggestions.

MBWD on "Error after editing functions.php that won't go away"

$
0
0

I'm using twenty twelve, and am attempting to enqueue jquery so that I can experiment with using functions on a test site. The error I'm running into has happened to me nearly every time I've played around with jquery.

I pasted the following code into functions.php:

add_action( 'wp_enqueue_script', 'load_jquery' );
function load_jquery(#slider) {
wp_enqueue_script( 'jquery' );
}

I realize that adding the function name #slider where I did was a mistake. But what happens next is that I get this error:

Parse error: syntax error, unexpected '(', expecting '&' or T_VARIABLE in /homepages/25/d123900814/htdocs/Sample3/wp-content/themes/twentytwelve/functions.php on line 82

and I could live with that if it wasn't for the fact that going back, erasing ALL the above code I pasted into functions.php, and updating the file does not remove the error message. And it breaks the whole site.

http://sample3.mahonebaywebdesign.com/

Why doesn't fixing the mistake in functions.php cause the error to be resolved?

dealfiles on "Exclude admin from custom function"

$
0
0

I took over a WP site that was developed by another person. They created a custom function in functions.php named wp_authors_directory (see code below). They then created a page template to display the results of the function (see code below).

The problem is, it appears to me as though the function is designed to exclude the admin from the directory, but the admin is not being excluded. Both the user name and the nickname of the admin are "admin" but it is still not being excluded. Can someone help?

Here is a link to the directory page where the results are rendered, admin is displaying at the top:

http://networkoftacoma.com/member-directory/

Very much appreciated!

functions.php code:

function wp_authors_directory($args = '') {

	global $wpdb;
	$my_base = get_bloginfo('url');

	$defaults = array(
		'optioncount' => false, 'exclude_admin' => true,
		'show_fullname' => true, 'hide_empty' => false,
		'feed' => '', 'feed_image' => '', 'feed_type' => '', 'echo' => true
	);

	$r = wp_parse_args( $args, $defaults );
	extract($r, EXTR_SKIP);

	/** @todo Move select to get_authors(). */
//	$authors = $wpdb->get_results("SELECT ID, user_nicename from $wpdb->users " . ($exclude_admin ? "WHERE user_login <> 'admin' " : '') . "ORDER BY display_name");

	$authors = $wpdb->get_results("SELECT ID, user_login, meta_key, meta_value from {$wpdb->users} LEFT JOIN {$wpdb->usermeta} ON {$wpdb->usermeta}.user_id = {$wpdb->users}.ID WHERE {$wpdb->users}.user_login NOT LIKE 'unverified%' AND meta_key LIKE 'last_name' ORDER BY meta_value");

	foreach ( (array) $authors as $author ) {
		$author = get_userdata( $author->ID );
		$name = "$author->first_name $author->last_name";
		$image = $author->userphoto_thumb_file;
		$image_width = $author->userphoto_thumb_width;
		$image_height = $author->userphoto_thumb_height;
		$company = $author->company;
		$category = $author->business_category;
		$network_role = $author->network_of_tacoma_role;
		$phone = $author->phone;
		$fax = $author->fax;
		$email = $author->user_email;
		$website = $author->user_url;
    $link = '<a href="' . get_author_posts_url($author->ID, $author->user_nicename) . '" title="' . sprintf(__("Details About %s"), attribute_escape($author->display_name)) . '">' . $name . '</a>';

    if ($website == null ) {
      $website = 'mailto:' . $email;
    }

    if ($image == null ) {
      $image = 'no_photo.gif';
    }

    echo '<div class="member clearfix">
            <div class="member-thumb">
              <a href="' . get_author_posts_url($author->ID, $author->user_nicename) . '" title="' . sprintf(__("Details About %s"), attribute_escape($author->display_name)) . '"><img src="' . $base . '/wp-content/uploads/userphoto/' . $image .'" width="' . $image_width . '" height="' . $image_height . '" alt="' . $name . '" /></a>
            </div>
            <div class="member-details">
              <h3>' . $link . '</h3
              <dl class="clearfix">
                <dt>Company</dt>
                  <dd><a href="' . $website . '" target="_blank">' . $company . '</a></dd>
              </dl>
              <dl class="clearfix">
                <dt>Business Category</dt>
                  <dd><a href="' . $website . '" target="_blank">' . $category . '</a></dd>
              </dl>
              <dl class="clearfix">
                <dt>Network Role</dt>
                  <dd>' . $network_role . '</dd>
              </dl>
              <dl class="clearfix">
                <dt>Phone</dt>
                  <dd>' . $phone . '</dd>
              </dl>
              <dl class="clearfix">
                <dt>Email</dt>
                  <dd><a href="mailto:' . $email . '">' . $email . '</a></dd>
              </dl>
              <p><em>More about ' . $link . '</em></p>
            </div>
          </div>'
          ;

	}
}

Directory page template code:

<?php
/*
Template Name: Directory Template
*/
?>

<?php get_header(); ?>

			<div class="left-column">
<?php include('side-main.php'); ?>
			</div>
			<div class="right-column">
        <?php wp_authors_directory(); ?>
			</div>
		</div>
  </div>
<?php get_footer(); ?>

TCBarrett on "Default custom post column to 'off' in screen options"

$
0
0

Is it possible to add a custom column to a post type with a default setting 'off' (unticked) in screen options?

wazzaday on "Hiding certain posts based on a condition"

$
0
0

I have a custom post type, called users, when a post is generated (via front end) it is given a date 5 days in the future. I want to hide all posts in the dashboard that are not 5 days old yet, and only have them appear after that. Any ideas?

Guillotex on "Get Post Feature Image on my own homepage"

$
0
0

I built a homepage for my WordPress site from scratch, copying the style of the theme Reflex (which I actually bought). I'm doing this because this way the site is faster, and use a lot less bandwidth.

Original site and my build

But, I have trouble getting the featured images, I did something very 'strange' just to work it out, this is the code

<img src="'.$thumb_img.'-200x200.jpg">

I add "-200x200" at the end of the link which I got from the database. I understand this is not the best way to do this, so the question is:

How should I solve this?

Thanks in advance!


osterichs on "Zend Gdata Fatal Error on wordpress plugin directory"

$
0
0

hey, i have a question about gdata youtube.
i've devolp my plugin for wordpress and when add post it's getting error like this

Fatal error: Call to a member function resetParameters() on a non-object in /home/altereg1/demo_html/wp-content/plugins/osTube/Zend/Gdata/App.php
on line 644

and code on line 644 is

$this->_httpClient->resetParameters();

but when i try it on web root (outside wordpress) it's working good here the sample http://dev.alteregogi.com/Youtube/

zecke on "Echo do_shortcode with variable"

$
0
0

Hi

I got this code:

<?php $terms = get_the_terms( $post->ID , 'category' );foreach ( $terms as $term ) {$term_link = get_term_link( $term, 'category' ); echo $term_link;} ?>

That echo me category slug in $term_link variable

Now I want to put the variable in xxx place:

<?php echo do_shortcode( '[gallery category="xxx"]' ) ?>

Can You help me and span those two codes into one properly ?

Thank You in advance

artykajay on "Track one IP address -"

$
0
0

Does anyone know of a plugin / counter / code I can use to track one particular static IP address - don't wish to block him, just keep a count of visits & hopefully add a count to a page or sidebar somewhere to save wading through logs that are not always to hand.

Thanks

scdwb on "Custom users.php column to Order by user_meta"

$
0
0

Hello,

I've added a new sortable column to the Users.php page in the WordPress admin (Users > All Users).

This works really well and the new column is populated by a custom user_meta value. Here is the code:

// Register payment_pending_count sortable column
add_filter('manage_users_columns', 'add_payment_pending_column');
function add_payment_pending_column($columns) {
    $columns['payment_pending_count'] = 'Payment Pending Count';
    return $columns;
}

add_filter( 'manage_users_sortable_columns', 'add_payment_pending_column_sortable' );
function add_payment_pending_column_sortable( $columns ){
	$columns['payment_pending_count'] = 'payment_pending_count';
	return $columns;
}

add_action('manage_users_custom_column',  'show_payment_pending_column_content', 10, 3);
function show_payment_pending_column_content($value, $column_name, $user_id) {
if ( 'payment_pending_count' == $column_name )
return get_user_meta($user_id, 'payment_pending_count', true);
return $value;
}

This displays a nice new "sortable" column and I can click the column. However, the problem is finding a solution on how to tell WordPress to sort by this custom user_meta value. The following function doesn't work and WordPress still sorts by the default setting of the "username" when I try and sort this new custom column:

function payment_pending_column_orderby( $vars ) {
    if ( isset( $vars['orderby'] ) && 'payment_pending_count' == $vars['orderby'] ) {
        $vars = array_merge( $vars, array(
            'meta_key' => 'payment_pending_count',
            'meta_type'    => 'numeric',
        ) );
    }
    return $vars;
}
add_filter( 'request', 'payment_pending_column_orderby' );

I think I'm nearly there, I just need to be able to sort by this custom user meta. By default, the WordPress users.php page already lets us sort by the user's email, name and username. And these are all user_meta values. I've tried searching in the core code of WordPress to see if I can replicate how it's been done with these values but I've been unable to find the right code. I may just need pointing in the right direction.

Many thanks,
Steven

John Paul on "DDoS Attacks"

mysteryentry on "Uploading images + Video externally to Wordpress admin"

$
0
0

Hi all, I am hoping someone can point me in the right direction. I have paid a programmer in the past to develop a site however I am now looking to try to develop as much more on my own as possible.

Can someone point me in the direction of some information I could use to implement Image upload/video embed onto this page http://www.joketwist.com/submit.

You get the idea from the page it creates posts externally to wp-admin.

Thanks
Oliver

souleye on "image permalinks?"


LoaddNet on "Using PHP to return related post url."

$
0
0

Hello Forum!

I am working on something very simple I couldn't find anywhere on net so I decided I will try to do it for myself but have a little problem. I decided to ask this forum as I have been reading many things here and found people very nice and helpful.

I am in need to use a php function to return a link to one related post. The reason I am doing this is a plugin I am trying to create to create a shortcode which will return this link anywhere in the post.

Thanks,
Ivan

sai krishna on "How to block ip of a robot?"

$
0
0

Hello, this is sai krishna from Greenyweb
One of a blog owner is copying my articles as it is using a automatic plugin, Within seconds of publishing i'm seeing my article in his blog. After a little research i got to know that he is using wp robot plugin. How to find and block that ip using .htaaccess?

james_barrett on "Help with a loop"

$
0
0

I am working with a template that uses colour box. My problem is that the loop will only link to the featured image that I upload. I need to code the loop so that if I upload a video in the post the colorbox will open with a video player instead of the image. I need to add code to say if video display video link in colorbox. I hope this is clear.

loop.php

<?php if (have_posts()) : ?>

		<?php while (have_posts()) : the_post(); ?>

            <li><div id="post-<?php the_ID(); ?>">

                <div class="post-home">

                	 <?php
                        $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), '' );
                        $url = $thumb['0'];
                    ?>

                    <div class="view view-first">
                    <?php if ( has_post_thumbnail()) : ?>
                        <a href="<?php echo $url ?>" title="<?php the_title_attribute(); ?>">
                    <?php the_post_thumbnail('hp-thumb'); ?>
                        </a>
                    <?php endif; ?>
                    <div class="mask">
                        <h2><?php the_title(); ?></h2>
                    <p class="link-btn"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf(__('Permanent Link to %s', 'responsive'), the_title_attribute('echo=0')); ?>"><i class="icon-link"></i></a>
                        <a href="<?php echo $url ?>" title="<?php the_title_attribute(); ?>" rel="colorbox"><i class=" icon-camera"></i></a>
                    </p>
                    </div>
                    </div> 

                </div><!-- end of .post-home-->
            </div><!-- end of #post-<?php the_ID(); ?> -->

home.php

<script type="text/javascript">
    jQuery(document).ready(function($) {

        var count = 2;
        var total = <?php echo $wp_query->max_num_pages; ?>;
        $(window).scroll(function(){
                if  ($(window).scrollTop() == $(document).height() - $(window).height()){
                   if (count > total){
                   	  	return false;
                   }else{
                   		loadArticle(count);
                   }
                   count++;
                }
        }); 

        function loadArticle(pageNumber){ 

                $('a#inifiniteLoader').show('slow');

                $.ajax({
                    url: "<?php bloginfo('wpurl') ?>/wp-admin/admin-ajax.php",
                    type:'POST',
                    data: "action=infinite_scroll&page_no="+ pageNumber + '&loop_file=loop',
                    success: function(html){
                        $('a#inifiniteLoader').hide('1000');

                        $("#tiles").append(html);    // This will be the div where our content will be loaded
                        $("a[rel='colorbox']").colorbox({
                                transition:'elastic',
                                opacity:'0.7',
                                maxHeight:'90%'
                        });
                    }
                });
            return false;
        }

    });

</script>

mit.sarvesh on "Data fetch from wordpress page"

$
0
0

I am working on a project which requires the page to fetch data from another wordpress page and display the content fetched under the same page. I used ajax for this purpose but don't know how to fetch data from the page.

starbright on "Multiple categories posts and latest titles"

$
0
0

What is the best concept to call a list of selected categories, with 5 recent posts - displaying the most recent as a post and the other 4 with featured image and title?
Good example are magazine-themes.

Category A (1)       Category B (1)
---------            -----------
Feature image        Feature Image
Title                Title
content              content
---------------      ----------------
[]Category A (2)     []Category B (2)
[]Category A (3)     []Category B (3)
[]Category A (4)     []Category B (4)
[]Category A (5)     []Category B (5)

I can't grasp the whole multiple loop concept to put the whole structure together in one code.

[can this post be moved to correct place, thanks]

Viewing all 8245 articles
Browse latest View live


Latest Images