Version Description
- fixed URL query handling. props ntns
- store
WP_Error
instance instead of callingtrigger_error()
. props MZAWeb - fixed warning when used with Multilingual Press. props dimadin
- introduced
p2p_connected_title
filter. props petitphp
Download this release
Release Info
Developer | scribu |
Plugin | Posts 2 Posts |
Version | 1.6.2 |
Comparing to | |
See all releases |
Code changes from version 1.6.1 to 1.6.2
- CONTRIBUTING.md +31 -5
- admin/box-factory.php +3 -0
- admin/box.php +2 -0
- core/init.php +2 -0
- core/query-post.php +1 -1
- core/query-user.php +1 -1
- core/url-query.php +0 -2
- posts-to-posts.php +2 -2
- readme.txt +8 -2
- scb/AdminPage.php +5 -6
- scb/Forms.php +1 -1
- scb/Table.php +0 -65
- scb/Util.php +67 -0
- scb/composer.json +22 -0
- scb/load-composer.php +11 -0
- scb/load.php +1 -1
CONTRIBUTING.md
CHANGED
@@ -28,10 +28,36 @@ and edit the `admin/box.coffee` file. To compile it, run:
|
|
28 |
coffee -c admin
|
29 |
```
|
30 |
|
31 |
-
###
|
32 |
|
33 |
-
|
34 |
|
35 |
-
|
36 |
-
|
37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
coffee -c admin
|
29 |
```
|
30 |
|
31 |
+
### Unit Tests
|
32 |
|
33 |
+
If you want to add a new feature, please consider adding a new test for it as well.
|
34 |
|
35 |
+
The following instructions assume a UNIX-like environment (OS X, Linux, etc.).
|
36 |
+
|
37 |
+
Step 1: Set un an environemt variable that defines the path to the test suite:
|
38 |
+
|
39 |
+
```bash
|
40 |
+
export WP_TESTS_DIR=/tmp/wordpress-tests/
|
41 |
+
```
|
42 |
+
|
43 |
+
This step will be needed each time you want to run the tests, so you might want to put it in your `.bashrc` file, to be executed automatically.
|
44 |
+
|
45 |
+
Step 2: Install and configure the official WordPress testing suite:
|
46 |
+
|
47 |
+
```bash
|
48 |
+
./bin/install-wp-tests
|
49 |
+
```
|
50 |
+
|
51 |
+
Note that all data in the test DB will be _deleted_ once you run the tests.
|
52 |
+
|
53 |
+
Step 4: Install PHPUnit via [Composer](https://getcomposer.org):
|
54 |
+
|
55 |
+
```bash
|
56 |
+
php composer.phar install --dev
|
57 |
+
```
|
58 |
+
|
59 |
+
Step 5: Run the tests:
|
60 |
+
|
61 |
+
```bash
|
62 |
+
./vendor/bin/phpunit
|
63 |
+
```
|
admin/box-factory.php
CHANGED
@@ -97,6 +97,9 @@ class P2P_Box_Factory extends P2P_Factory {
|
|
97 |
|
98 |
$connection = p2p_get_connection( $p2p_id );
|
99 |
|
|
|
|
|
|
|
100 |
$fields = p2p_type( $connection->p2p_type )->fields;
|
101 |
|
102 |
foreach ( $fields as $key => &$field ) {
|
97 |
|
98 |
$connection = p2p_get_connection( $p2p_id );
|
99 |
|
100 |
+
if ( ! $connection )
|
101 |
+
continue;
|
102 |
+
|
103 |
$fields = p2p_type( $connection->p2p_type )->fields;
|
104 |
|
105 |
foreach ( $fields as $key => &$field ) {
|
admin/box.php
CHANGED
@@ -158,6 +158,8 @@ class P2P_Box {
|
|
158 |
}
|
159 |
|
160 |
protected function connection_row( $p2p_id, $item, $render = false ) {
|
|
|
|
|
161 |
$data = array();
|
162 |
|
163 |
foreach ( $this->columns as $key => $field ) {
|
158 |
}
|
159 |
|
160 |
protected function connection_row( $p2p_id, $item, $render = false ) {
|
161 |
+
$item->post_title = apply_filters( 'p2p_connected_title', $item->get_title(), $item->get_object(), $this->ctype );
|
162 |
+
|
163 |
$data = array();
|
164 |
|
165 |
foreach ( $this->columns as $key => $field ) {
|
core/init.php
CHANGED
@@ -11,6 +11,8 @@ P2P_Storage::init();
|
|
11 |
P2P_Query_Post::init();
|
12 |
P2P_Query_User::init();
|
13 |
|
|
|
|
|
14 |
P2P_Widget::init();
|
15 |
P2P_Shortcodes::init();
|
16 |
|
11 |
P2P_Query_Post::init();
|
12 |
P2P_Query_User::init();
|
13 |
|
14 |
+
P2P_URL_Query::init();
|
15 |
+
|
16 |
P2P_Widget::init();
|
17 |
P2P_Shortcodes::init();
|
18 |
|
core/query-post.php
CHANGED
@@ -13,7 +13,7 @@ class P2P_Query_Post {
|
|
13 |
$r = P2P_Query::create_from_qv( $wp_query->query_vars, 'post' );
|
14 |
|
15 |
if ( is_wp_error( $r ) ) {
|
16 |
-
|
17 |
|
18 |
$wp_query->set( 'year', 2525 );
|
19 |
return;
|
13 |
$r = P2P_Query::create_from_qv( $wp_query->query_vars, 'post' );
|
14 |
|
15 |
if ( is_wp_error( $r ) ) {
|
16 |
+
$wp_query->_p2p_error = $r;
|
17 |
|
18 |
$wp_query->set( 'year', 2525 );
|
19 |
return;
|
core/query-user.php
CHANGED
@@ -12,7 +12,7 @@ class P2P_Query_User {
|
|
12 |
$r = P2P_Query::create_from_qv( $query->query_vars, 'user' );
|
13 |
|
14 |
if ( is_wp_error( $r ) ) {
|
15 |
-
|
16 |
|
17 |
$query->query_where = " AND 1=0";
|
18 |
return;
|
12 |
$r = P2P_Query::create_from_qv( $query->query_vars, 'user' );
|
13 |
|
14 |
if ( is_wp_error( $r ) ) {
|
15 |
+
$query->_p2p_error = $r;
|
16 |
|
17 |
$query->query_where = " AND 1=0";
|
18 |
return;
|
core/url-query.php
CHANGED
@@ -16,5 +16,3 @@ class P2P_URL_Query {
|
|
16 |
}
|
17 |
}
|
18 |
|
19 |
-
P2P_URL_Query::init();
|
20 |
-
|
16 |
}
|
17 |
}
|
18 |
|
|
|
|
posts-to-posts.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/*
|
3 |
Plugin Name: Posts 2 Posts
|
4 |
Description: Create many-to-many relationships between all types of posts.
|
5 |
-
Version: 1.6.
|
6 |
Author: scribu
|
7 |
Author URI: http://scribu.net/
|
8 |
Plugin URI: http://scribu.net/wordpress/posts-to-posts
|
@@ -10,7 +10,7 @@ Text Domain: posts-to-posts
|
|
10 |
Domain Path: /lang
|
11 |
*/
|
12 |
|
13 |
-
define( 'P2P_PLUGIN_VERSION', '1.6.
|
14 |
|
15 |
define( 'P2P_TEXTDOMAIN', 'posts-to-posts' );
|
16 |
|
2 |
/*
|
3 |
Plugin Name: Posts 2 Posts
|
4 |
Description: Create many-to-many relationships between all types of posts.
|
5 |
+
Version: 1.6.2
|
6 |
Author: scribu
|
7 |
Author URI: http://scribu.net/
|
8 |
Plugin URI: http://scribu.net/wordpress/posts-to-posts
|
10 |
Domain Path: /lang
|
11 |
*/
|
12 |
|
13 |
+
define( 'P2P_PLUGIN_VERSION', '1.6.2' );
|
14 |
|
15 |
define( 'P2P_TEXTDOMAIN', 'posts-to-posts' );
|
16 |
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
Contributors: scribu, ciobi
|
4 |
Tags: connections, custom post types, relationships, many-to-many, users
|
5 |
Requires at least: 3.5
|
6 |
-
Tested up to: 3.
|
7 |
-
Stable tag: 1.6.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -57,6 +57,12 @@ Additional info can be found on the [wiki](http://github.com/scribu/wp-posts-to-
|
|
57 |
|
58 |
== Changelog ==
|
59 |
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
= 1.6.1 =
|
61 |
* fixed user column handling. props versusbassz
|
62 |
* fixed PHP strict standards warnings. props meloniq
|
3 |
Contributors: scribu, ciobi
|
4 |
Tags: connections, custom post types, relationships, many-to-many, users
|
5 |
Requires at least: 3.5
|
6 |
+
Tested up to: 3.6
|
7 |
+
Stable tag: 1.6.2
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
57 |
|
58 |
== Changelog ==
|
59 |
|
60 |
+
= 1.6.2 =
|
61 |
+
* fixed URL query handling. props ntns
|
62 |
+
* store `WP_Error` instance instead of calling `trigger_error()`. props MZAWeb
|
63 |
+
* fixed warning when used with Multilingual Press. props dimadin
|
64 |
+
* introduced `p2p_connected_title` filter. props petitphp
|
65 |
+
|
66 |
= 1.6.1 =
|
67 |
* fixed user column handling. props versusbassz
|
68 |
* fixed PHP strict standards warnings. props meloniq
|
scb/AdminPage.php
CHANGED
@@ -114,8 +114,7 @@ abstract class scbAdminPage {
|
|
114 |
|
115 |
if ( isset( $this->option_name ) ) {
|
116 |
add_action( 'admin_init', array( $this, 'option_init' ) );
|
117 |
-
|
118 |
-
add_action( 'admin_notices', 'settings_errors' );
|
119 |
}
|
120 |
|
121 |
add_action( 'admin_menu', array( $this, 'page_init' ), $this->args['admin_action_priority'] );
|
@@ -140,7 +139,9 @@ abstract class scbAdminPage {
|
|
140 |
*
|
141 |
* Useful for calling $screen->add_help_tab() etc.
|
142 |
*/
|
143 |
-
function page_loaded() {
|
|
|
|
|
144 |
|
145 |
/**
|
146 |
* This is where the css and js go
|
@@ -211,7 +212,7 @@ abstract class scbAdminPage {
|
|
211 |
|
212 |
$this->options->set( $new_data );
|
213 |
|
214 |
-
$this
|
215 |
|
216 |
return true;
|
217 |
}
|
@@ -496,8 +497,6 @@ abstract class scbAdminPage {
|
|
496 |
}
|
497 |
|
498 |
function _page_content_hook() {
|
499 |
-
$this->form_handler();
|
500 |
-
|
501 |
$this->page_header();
|
502 |
$this->page_content();
|
503 |
$this->page_footer();
|
114 |
|
115 |
if ( isset( $this->option_name ) ) {
|
116 |
add_action( 'admin_init', array( $this, 'option_init' ) );
|
117 |
+
add_action( 'admin_notices', 'settings_errors' );
|
|
|
118 |
}
|
119 |
|
120 |
add_action( 'admin_menu', array( $this, 'page_init' ), $this->args['admin_action_priority'] );
|
139 |
*
|
140 |
* Useful for calling $screen->add_help_tab() etc.
|
141 |
*/
|
142 |
+
function page_loaded() {
|
143 |
+
$this->form_handler();
|
144 |
+
}
|
145 |
|
146 |
/**
|
147 |
* This is where the css and js go
|
212 |
|
213 |
$this->options->set( $new_data );
|
214 |
|
215 |
+
add_action( 'admin_notices', array( $this, 'admin_msg' ) );
|
216 |
|
217 |
return true;
|
218 |
}
|
497 |
}
|
498 |
|
499 |
function _page_content_hook() {
|
|
|
|
|
500 |
$this->page_header();
|
501 |
$this->page_content();
|
502 |
$this->page_footer();
|
scb/Forms.php
CHANGED
@@ -605,7 +605,7 @@ class scbTextField extends scbFormField {
|
|
605 |
* @return string
|
606 |
*/
|
607 |
public function validate( $value ) {
|
608 |
-
$sanitize = isset( $this->sanitize ) ? $this->sanitize : '
|
609 |
|
610 |
return call_user_func( $sanitize, $value, $this );
|
611 |
}
|
605 |
* @return string
|
606 |
*/
|
607 |
public function validate( $value ) {
|
608 |
+
$sanitize = isset( $this->sanitize ) ? $this->sanitize : 'wp_kses_data';
|
609 |
|
610 |
return call_user_func( $sanitize, $value, $this );
|
611 |
}
|
scb/Table.php
CHANGED
@@ -29,68 +29,3 @@ class scbTable {
|
|
29 |
}
|
30 |
}
|
31 |
|
32 |
-
/**
|
33 |
-
* Register a table with $wpdb
|
34 |
-
*
|
35 |
-
* @param string $key The key to be used on the $wpdb object
|
36 |
-
* @param string $name The actual name of the table, without $wpdb->prefix
|
37 |
-
*/
|
38 |
-
function scb_register_table( $key, $name = false ) {
|
39 |
-
global $wpdb;
|
40 |
-
|
41 |
-
if ( !$name )
|
42 |
-
$name = $key;
|
43 |
-
|
44 |
-
$wpdb->tables[] = $name;
|
45 |
-
$wpdb->$key = $wpdb->prefix . $name;
|
46 |
-
}
|
47 |
-
|
48 |
-
/**
|
49 |
-
* Runs the SQL query for installing/upgrading a table
|
50 |
-
*
|
51 |
-
* @param string $key The key used in scb_register_table()
|
52 |
-
* @param string $columns The SQL columns for the CREATE TABLE statement
|
53 |
-
* @param array $opts Various other options
|
54 |
-
*/
|
55 |
-
function scb_install_table( $key, $columns, $opts = array() ) {
|
56 |
-
global $wpdb;
|
57 |
-
|
58 |
-
$full_table_name = $wpdb->$key;
|
59 |
-
|
60 |
-
if ( is_string( $opts ) ) {
|
61 |
-
$opts = array( 'upgrade_method' => $opts );
|
62 |
-
}
|
63 |
-
|
64 |
-
$opts = wp_parse_args( $opts, array(
|
65 |
-
'upgrade_method' => 'dbDelta',
|
66 |
-
'table_options' => '',
|
67 |
-
) );
|
68 |
-
|
69 |
-
$charset_collate = '';
|
70 |
-
if ( $wpdb->has_cap( 'collation' ) ) {
|
71 |
-
if ( ! empty( $wpdb->charset ) )
|
72 |
-
$charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
|
73 |
-
if ( ! empty( $wpdb->collate ) )
|
74 |
-
$charset_collate .= " COLLATE $wpdb->collate";
|
75 |
-
}
|
76 |
-
|
77 |
-
$table_options = $charset_collate . ' ' . $opts['table_options'];
|
78 |
-
|
79 |
-
if ( 'dbDelta' == $opts['upgrade_method'] ) {
|
80 |
-
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
|
81 |
-
dbDelta( "CREATE TABLE $full_table_name ( $columns ) $table_options" );
|
82 |
-
return;
|
83 |
-
}
|
84 |
-
|
85 |
-
if ( 'delete_first' == $opts['upgrade_method'] )
|
86 |
-
$wpdb->query( "DROP TABLE IF EXISTS $full_table_name;" );
|
87 |
-
|
88 |
-
$wpdb->query( "CREATE TABLE IF NOT EXISTS $full_table_name ( $columns ) $table_options;" );
|
89 |
-
}
|
90 |
-
|
91 |
-
function scb_uninstall_table( $key ) {
|
92 |
-
global $wpdb;
|
93 |
-
|
94 |
-
$wpdb->query( "DROP TABLE IF EXISTS " . $wpdb->$key );
|
95 |
-
}
|
96 |
-
|
29 |
}
|
30 |
}
|
31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scb/Util.php
CHANGED
@@ -158,6 +158,73 @@ function scb_list_group_by( $list, $fn ) {
|
|
158 |
return $groups;
|
159 |
}
|
160 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
161 |
//_____Minimalist HTML framework_____
|
162 |
|
163 |
/**
|
158 |
return $groups;
|
159 |
}
|
160 |
|
161 |
+
//_____Database Table Utilities_____
|
162 |
+
|
163 |
+
/**
|
164 |
+
* Register a table with $wpdb
|
165 |
+
*
|
166 |
+
* @param string $key The key to be used on the $wpdb object
|
167 |
+
* @param string $name The actual name of the table, without $wpdb->prefix
|
168 |
+
*/
|
169 |
+
function scb_register_table( $key, $name = false ) {
|
170 |
+
global $wpdb;
|
171 |
+
|
172 |
+
if ( !$name )
|
173 |
+
$name = $key;
|
174 |
+
|
175 |
+
$wpdb->tables[] = $name;
|
176 |
+
$wpdb->$key = $wpdb->prefix . $name;
|
177 |
+
}
|
178 |
+
|
179 |
+
/**
|
180 |
+
* Runs the SQL query for installing/upgrading a table
|
181 |
+
*
|
182 |
+
* @param string $key The key used in scb_register_table()
|
183 |
+
* @param string $columns The SQL columns for the CREATE TABLE statement
|
184 |
+
* @param array $opts Various other options
|
185 |
+
*/
|
186 |
+
function scb_install_table( $key, $columns, $opts = array() ) {
|
187 |
+
global $wpdb;
|
188 |
+
|
189 |
+
$full_table_name = $wpdb->$key;
|
190 |
+
|
191 |
+
if ( is_string( $opts ) ) {
|
192 |
+
$opts = array( 'upgrade_method' => $opts );
|
193 |
+
}
|
194 |
+
|
195 |
+
$opts = wp_parse_args( $opts, array(
|
196 |
+
'upgrade_method' => 'dbDelta',
|
197 |
+
'table_options' => '',
|
198 |
+
) );
|
199 |
+
|
200 |
+
$charset_collate = '';
|
201 |
+
if ( $wpdb->has_cap( 'collation' ) ) {
|
202 |
+
if ( ! empty( $wpdb->charset ) )
|
203 |
+
$charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
|
204 |
+
if ( ! empty( $wpdb->collate ) )
|
205 |
+
$charset_collate .= " COLLATE $wpdb->collate";
|
206 |
+
}
|
207 |
+
|
208 |
+
$table_options = $charset_collate . ' ' . $opts['table_options'];
|
209 |
+
|
210 |
+
if ( 'dbDelta' == $opts['upgrade_method'] ) {
|
211 |
+
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
|
212 |
+
dbDelta( "CREATE TABLE $full_table_name ( $columns ) $table_options" );
|
213 |
+
return;
|
214 |
+
}
|
215 |
+
|
216 |
+
if ( 'delete_first' == $opts['upgrade_method'] )
|
217 |
+
$wpdb->query( "DROP TABLE IF EXISTS $full_table_name;" );
|
218 |
+
|
219 |
+
$wpdb->query( "CREATE TABLE IF NOT EXISTS $full_table_name ( $columns ) $table_options;" );
|
220 |
+
}
|
221 |
+
|
222 |
+
function scb_uninstall_table( $key ) {
|
223 |
+
global $wpdb;
|
224 |
+
|
225 |
+
$wpdb->query( "DROP TABLE IF EXISTS " . $wpdb->$key );
|
226 |
+
}
|
227 |
+
|
228 |
//_____Minimalist HTML framework_____
|
229 |
|
230 |
/**
|
scb/composer.json
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name" : "scribu/scb-framework",
|
3 |
+
"description": "A set of useful classes for faster plugin development",
|
4 |
+
"keywords" : ["wordpress"],
|
5 |
+
"homepage" : "https://github.com/scribu/wp-scb-framework",
|
6 |
+
"license" : "GPL-3.0+",
|
7 |
+
"authors" : [
|
8 |
+
{
|
9 |
+
"name" : "Cristi Burcă",
|
10 |
+
"homepage": "http://scribu.net/"
|
11 |
+
}
|
12 |
+
],
|
13 |
+
"support" : {
|
14 |
+
"issues": "https://github.com/scribu/wp-scb-framework/issues",
|
15 |
+
"source": "https://github.com/scribu/wp-scb-framework",
|
16 |
+
"wiki": "https://github.com/scribu/wp-scb-framework/wiki"
|
17 |
+
},
|
18 |
+
"autoload" : {
|
19 |
+
"classmap": ["."],
|
20 |
+
"files" : ["load-composer.php", "Util.php"]
|
21 |
+
}
|
22 |
+
}
|
scb/load-composer.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Pass through version to use when Composer handles classes load.
|
5 |
+
*
|
6 |
+
* @param callable $callback
|
7 |
+
*/
|
8 |
+
function scb_init( $callback = null ) {
|
9 |
+
if ( $callback )
|
10 |
+
call_user_func( $callback );
|
11 |
+
}
|
scb/load.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
$GLOBALS['_scb_data'] = array(
|
4 |
'scbUtil', 'scbOptions', 'scbForms', 'scbTable',
|
5 |
'scbWidget', 'scbAdminPage', 'scbBoxesPage', 'scbPostMetabox',
|
6 |
'scbCron', 'scbHooks',
|
1 |
<?php
|
2 |
|
3 |
+
$GLOBALS['_scb_data'] = array( 60, __FILE__, array(
|
4 |
'scbUtil', 'scbOptions', 'scbForms', 'scbTable',
|
5 |
'scbWidget', 'scbAdminPage', 'scbBoxesPage', 'scbPostMetabox',
|
6 |
'scbCron', 'scbHooks',
|