Lox | 17 Jul 01:29 2015

Contextual Customizer Option

Hello,

I need some contextual options in the customizer (related to the current
post in view)
Displaying a contextual panel/section/control is straight forward, but I
have issues saving/getting the option data from post metas.

My example is as simple as providing a page template dropdown for pages
(getting the control to display isn't the issue)

<?php

function customize_save_page_template ($value) {
    return update_post_meta( get_queried_object_id(), '_wp_page_template',
$value );
}
add_action( 'customize_save_page_template', 'customize_save_page_template');

function customize_update_page_template ($value) {
    return update_post_meta( get_queried_object_id(), '_wp_page_template',
$value );
}
add_action( 'customize_update_page_template',
'customize_update_page_template');

function customize_value_page_template ($default) {
    return get_post_meta( get_queried_object_id(), '_wp_page_template',
true );
}
add_action( 'customize_value_page_template',
(Continue reading)

Rarylson Freitas | 16 Jul 05:52 2015
Picon

Optimizing a SQL query used to get all custom post metakeys

Hi,

I am responsible for a Wordpress site with more than 500.000 posts (more
than half million posts).

Recently, I've discovered some performance problems in the function
meta_form, file wp-admin/includes/template.php. This function "Prints the
form in the Custom Fields meta box".

The problem was at line 674, where the SQL query was defined.

I'm putting the raw (already processed) SQL query here:

SELECT meta_key
    FROM wp_postmeta
    GROUP BY meta_key
    HAVING meta_key NOT LIKE '\_%'
    ORDER BY meta_key
    LIMIT 30

To run this query, MySQL will sort all meta_key lines, including all custom
fields and all the other fields (starting with '_'), unify them, select the
desired fields, and them return them.

The problem with its query is that it will run a sort over all of the
entries (due to the GROUP BY part), and select the desired entries after
the group by (HAVING part). A more efficient solution should consider
excluding unnecessary entries before sorting/unifying them.

A better query could be:
(Continue reading)

Joaquin Rodriguez Montero | 9 Jul 20:07 2015
Picon

Re: wp-hackers Digest, Vol 126, Issue 2

Hi guys!

This is a very strange case which I don't know how to solve or even know
what's going on.
I have 8.636 posts (post type 'document').  245 of them are published with
the same date (January 6th 2008).
When I filter by date: January 2008, I get all 245 (according the number
showed next to the pagination buttons) but the thing is I don't and plus I
get repeated posts! why?!
Funny thing is that when I change the "number of elements per page" to 50
(instead of 20) I get the proper list.. no repeated elements, etc.
Has anyone experienced this? It's super weird.
Thanks!
Haluk Karamete | 8 Jul 18:36 2015
Picon

identifying if a transient exists without the WordPress APIs

Hi guys,

I know this would have been an easy one using the WordPress API's - as the
answer to my question would be -> just use get_transient dude!

But I want to figure this out with straight mysql - as I need this
information at the mother of all pages, the index.php at the site root -
before it has loaded the blog-header.

If the name of the transient I'm after is 'my_transient', what mysql
statement would reliably get me its contents - if 'my_transient' has not
expired and still available?

Needless to say, that SQL statement cannot tap into the wpdb APIs for the
same very reason; WordPress has not loaded yet. So this has to be straight
mysql solution.

I know that the transients may not always be stored in the options table (
 it could be memory based ) but here we will assume that we use options
table for that.
Joaquin Rodriguez Montero | 7 Jul 15:26 2015
Picon

Repeated Posts In Backend

Hi guys!

This is a very strange case which I don't know how to solve or even know
what's going on.
I have 8.636 posts (post type 'document').  245 of them are published with
the same date (January 6th 2008).
When I filter by date: January 2008, I get all 245 (according the number
showed next to the pagination buttons) but the thing is I don't and plus I
get repeated posts! why?!
Funny thing is that when I change the "number of elements per page" to 50
(instead of 20) I get the proper list.. no repeated elements, etc.
Has anyone experienced this? It's super weird.
Thanks!

J
Haluk Karamete | 13 Jun 04:06 2015
Picon

$wpdb->prefix

I installed 2 WordPress sites but pointed the 2nd WordPress install to the
1st one's database. Since I used a different table prefix for the 2nd one,
everything works.

This results that  I got 2 set of WordPress tables in the same database
while the 2nd one uses just a different wpdb prefix.

The question is...

How can I use the get_posts() ( or WP_Query for that matter) to query to
1st WordPress's posts from the 2nd one?

Is there an argument that I can pass to the get_posts or to WP_query to
tell the WP to use a different prefix than the current installs
wpdb->prefix default?

Ideally, this ios what I'm looking for;

$args = array(
'db_prefix' => 'xyz',
'posts_per_page' => -1,
);

Is there something like the 'db_prefix' above ?
Luke Bryan | 13 Jun 00:37 2015

wp_get_image_editor

Greetings all,

I had noticed something odd in the documentation for wp_get_image_editor -
while it says "This function is the main function that you use when you
want to edit an image by url", the example doesn't give a url as the
parameter. Why is a url expected instead of a local file path?

It seems odd that it expects url and fetches them, as local file is more
efficient and less likely to be blocked. Any specific reason it is built
this way?

Best regards,
Luke
Stephen Rider | 5 Jun 00:37 2015

Customize Uploads directory?

Hi —

There used to be a simple setting within the Admin to change the uploads directory, but it’s gone in
current versions of WP.  So how are we supposed to do this, officially?

I see that there’s a constant that can be set, but that method appears to be frowned upon by TPtB.

--

-- 
Stephen Rider

wp-hackers <at> striderweb.com
http://striderweb.com/nerdaphernalia

_______________________________________________
wp-hackers mailing list
wp-hackers <at> lists.automattic.com
http://lists.automattic.com/mailman/listinfo/wp-hackers
Chris Rudzki | 4 Jun 21:49 2015

Re: wp-hackers Digest, Vol 125, Issue 1

You can also whitelist, or increase the threshold, on Automattic ranges 
if you like:
http://whois.arin.net/rest/org/AUTOM-93/nets

-Chris

> wp-hackers-request <at> lists.automattic.com 
> <mailto:wp-hackers-request <at> lists.automattic.com>
> June 2, 2015 at 8:00 AM
> Send wp-hackers mailing list submissions to
> wp-hackers <at> lists.automattic.com
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://lists.automattic.com/mailman/listinfo/wp-hackers
> or, via email, send a message with subject or body 'help' to
> wp-hackers-request <at> lists.automattic.com
>
> You can reach the person managing the list at
> wp-hackers-owner <at> lists.automattic.com
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of wp-hackers digest..."
>
>
> Today's Topics:
>
> 1. XML-RPC POST attack (Pavel Hejn)
> 2. Re: XML-RPC POST attack (Or Wilder)
> 3. Re: XML-RPC POST attack (Michael Van Winkle)
>
(Continue reading)

Pavel Hejn | 1 Jun 19:20 2015
Picon

XML-RPC POST attack

Hi,

I found many ideas how to protect website from XML-RPC attacks (POST hits).
They suggest .htaccess protection, using filter, delete file, use special security plugin, ban IP 
address, etc.
But I want to use this protocol on my website and wanted to ask if there is any way to protect 
XML-RPC from Ddos attacks directly on server side (Apache)?
I am searching for something which can be usable for many different websites on one server.
I do not want to allow only specific IP address, etc.
Do you have any working solution?

Thank you very much for ideas!

Pavel
Frank Bueltge | 20 May 17:08 2015
Picon

Customizer Return URL

Hello at all.

I work on examples to use the customizer as standard control for different
customization topics on front end. But I can't find a solution to change
the return url, the close icon/button on the customizer.

In the source was asked for a var $return. But how is it possible to change
this? Maybe a reader can help me.

From the Core, wp-admin/customize.php:

wp_reset_vars( array( 'url', 'return' ) );
$url = wp_unslash( $url );
$url = wp_validate_redirect( $url, home_url( '/' ) );
if ( $return ) {
    $return = wp_unslash( $return );
    $return = wp_validate_redirect( $return );
}
if ( ! $return ) {

I init the customizer via a menu item below Appearance menu item. I set the
url on add the menu with the hook 'admin_menu' and filter the link to set a
new url, my custom url. The url was set via the code below.

// Create specific url for login view
$login_url = wp_login_url();
$url = add_query_arg(
   'url',
   urlencode( $login_url ),
   admin_url( 'customize.php' )
(Continue reading)


Gmane