-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
first pass at autoloading core classes
- Loading branch information
Showing
19 changed files
with
458 additions
and
456 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
class P2P_Item_Any extends P2P_Item { | ||
|
||
function __construct() {} | ||
|
||
function get_permalink() {} | ||
|
||
function get_title() {} | ||
|
||
function get_object() { | ||
return 'any'; | ||
} | ||
|
||
function get_id() { | ||
return false; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
class P2P_Item_Attachment extends P2P_Item_Post { | ||
|
||
function get_title() { | ||
if( wp_attachment_is_image( $this->item->ID ) ) | ||
return wp_get_attachment_image( $this->item->ID, 'thumbnail', false ); | ||
|
||
return get_the_title( $this->item ); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
class P2P_Item_Post extends P2P_Item { | ||
|
||
function get_title() { | ||
return get_the_title( $this->item ); | ||
} | ||
|
||
function get_permalink() { | ||
return get_permalink( $this->item ); | ||
} | ||
|
||
function get_editlink() { | ||
return get_edit_post_link( $this->item ); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
class P2P_Item_User extends P2P_Item { | ||
|
||
function get_title() { | ||
return $this->item->display_name; | ||
} | ||
|
||
function get_permalink() { | ||
return get_author_posts_url( $this->item->ID ); | ||
} | ||
|
||
function get_editlink() { | ||
return get_edit_user_link( $this->item->ID ); | ||
} | ||
} | ||
|
||
|
||
// WP < 3.5 | ||
if ( !function_exists( 'get_edit_user_link' ) ) : | ||
function get_edit_user_link( $user_id = null ) { | ||
if ( ! $user_id ) | ||
$user_id = get_current_user_id(); | ||
|
||
if ( empty( $user_id ) || ! current_user_can( 'edit_user', $user_id ) ) | ||
return ''; | ||
|
||
$user = new WP_User( $user_id ); | ||
|
||
if ( ! $user->exists() ) | ||
return ''; | ||
|
||
if ( get_current_user_id() == $user->ID ) | ||
$link = get_edit_profile_url( $user->ID ); | ||
else | ||
$link = add_query_arg( 'user_id', $user->ID, self_admin_url( 'user-edit.php' ) ); | ||
|
||
return apply_filters( 'get_edit_user_link', $link, $user->ID ); | ||
} | ||
endif; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
class P2P_Shortcodes { | ||
|
||
static function init() { | ||
add_shortcode( 'p2p_connected', array( __CLASS__, 'connected' ) ); | ||
add_shortcode( 'p2p_related', array( __CLASS__, 'related' ) ); | ||
} | ||
|
||
static function connected( $attr ) { | ||
return self::get_list( $attr, 'get_connected' ); | ||
} | ||
|
||
static function related( $attr ) { | ||
return self::get_list( $attr, 'get_related' ); | ||
} | ||
|
||
private static function get_list( $attr, $method ) { | ||
global $post; | ||
|
||
$attr = shortcode_atts( array( | ||
'type' => '', | ||
'mode' => 'ul', | ||
), $attr ); | ||
|
||
return _p2p_get_list( array( | ||
'ctype' => $attr['type'], | ||
'method' => $method, | ||
'item' => $post, | ||
'mode' => $attr['mode'], | ||
'context' => 'shortcode' | ||
) ); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
class P2P_Side_Attachment extends P2P_Side_Post { | ||
|
||
protected $item_type = 'P2P_Item_Attachment'; | ||
|
||
function __construct( $query_vars ) { | ||
$this->query_vars = $query_vars; | ||
|
||
$this->query_vars['post_type'] = array( 'attachment' ); | ||
} | ||
|
||
function can_create_item() { | ||
return false; | ||
} | ||
|
||
function get_base_qv( $q ) { | ||
return array_merge( parent::get_base_qv( $q ), array( | ||
'post_status' => 'inherit' | ||
) ); | ||
} | ||
} | ||
|
Oops, something went wrong.