Skip to content

Commit

Permalink
Merge pull request #98 from dshanske/2.6.1
Browse files Browse the repository at this point in the history
2.6.1
  • Loading branch information
dshanske authored Jun 17, 2017
2 parents 12c25f6 + ae61027 commit 33d9649
Show file tree
Hide file tree
Showing 20 changed files with 395 additions and 200 deletions.
4 changes: 2 additions & 2 deletions includes/class-kind-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public static function query_var($vars) {
public static function admin_menu() {
// If the IndieWeb Plugin is installed use its menu.
if ( class_exists( 'IndieWeb_Plugin' ) ) {
add_submenu_page(
add_submenu_page(
'indieweb',
__( 'Post Kinds', 'indieweb-post-kinds' ), // page title
__( 'Post Kinds', 'indieweb-post-kinds' ), // menu title
Expand Down Expand Up @@ -196,7 +196,7 @@ public static function textbox_callback( array $args ) {
public static function termcheck_callback() {
$terms = Kind_Taxonomy::get_kind_info( 'all', 'all' );
// Hide these terms until ready for use for now.
$hide = array( 'note', 'weather', 'exercise', 'travel', 'itinerary', 'tag', 'follow', 'drink', 'eat', 'trip', 'checkin', 'recipe', 'mood' );
$hide = array( 'note', 'weather', 'exercise', 'travel', 'itinerary', 'event', 'tag', 'follow', 'drink', 'eat', 'trip', 'checkin', 'recipe', 'mood', 'issue' );
foreach ( $hide as $hid ) {
unset( $terms[ $hid ] );
}
Expand Down
2 changes: 1 addition & 1 deletion includes/class-kind-meta.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public function set_url( $url ) {
$url = self::sanitize_text( $url );
$kind = get_post_kind_slug( $this->post );
$property = Kind_Taxonomy::get_kind_info( $kind, 'property' );
if ( ! empty ( $property ) ) {
if ( ! empty( $property ) ) {
$this->meta[ $property ] = array( $url );
}
if ( ! array_key_exists( 'cite', $this->meta ) ) {
Expand Down
16 changes: 8 additions & 8 deletions includes/class-kind-plugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,16 @@ public static function micropub_set_kind( $input, $wp_args ) {
}

if ( isset( $input['properties']['repost-of'] ) ) {
set_post_kind( $wp_args['ID'], 'repost' );
set_post_kind( $wp_args['ID'], 'repost' );
return;
}
}

if ( isset( $input['properties']['like-of'] ) ) {
set_post_kind( $wp_args['ID'], 'like' );
set_post_kind( $wp_args['ID'], 'like' );
return;
}
}
if ( isset( $input['properties']['photo'] ) ) {
set_post_kind( $wp_args['ID'], 'photo' );
set_post_kind( $wp_args['ID'], 'photo' );
return;
}

Expand All @@ -122,9 +122,9 @@ public static function micropub_set_kind( $input, $wp_args ) {
}
if ( ! empty( $input['properties']['name'] ) ) {
$name = trim( $input['properties']['name'] );
$content = trim( $input['properties']['content']);
$content = trim( $input['properties']['content'] );
if ( 0 !== strpos( $content, $name ) ) {
set_post_kind( $wp_args['ID'], 'article' );
set_post_kind( $wp_args['ID'], 'article' );
return;
}
}
Expand Down
49 changes: 24 additions & 25 deletions includes/class-kind-tabmeta.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ public static function enqueue_admin_scripts() {
wp_localize_script( 'kindmeta-response', 'rest_object',
array(
'api_nonce' => wp_create_nonce( 'wp_rest' ),
'api_url' => rest_url('/link-preview/1.0/'),
'link_preview_success_message' => __( 'Your URL has been successfully retrieved and parsed', 'indieweb-post-kinds' )
'api_url' => rest_url( '/link-preview/1.0/' ),
'link_preview_success_message' => __( 'Your URL has been successfully retrieved and parsed', 'indieweb-post-kinds' ),
)
);

Expand All @@ -82,18 +82,18 @@ public static function kind_get_timezones() {
foreach ( $t_zones as $a ) {
$t = '';
try {
// this throws exception for 'US/Pacific-New'
$zone = new DateTimeZone( $a );
// this throws exception for 'US/Pacific-New'
$zone = new DateTimeZone( $a );
$seconds = $zone->getOffset( new DateTime( 'now' , $zone ) );
$o[] = self::tz_seconds_to_offset( $seconds );
} // exceptions must be catched, else a blank page
catch (Exception $e) {
// die("Exception : " . $e->getMessage() . '<br />');
// what to do in catch ? , nothing just relax
}
}
$o = array_unique( $o );
asort( $o );
$o[] = self::tz_seconds_to_offset( $seconds );
} // exceptions must be catched, else a blank page
catch (Exception $e) {
// die("Exception : " . $e->getMessage() . '<br />');
// what to do in catch ? , nothing just relax
}
}
$o = array_unique( $o );
asort( $o );
return $o;
}

Expand Down Expand Up @@ -130,7 +130,7 @@ public static function rsvp_select( $selected ) {
'yes' => __( 'Yes', 'indieweb-post-kinds' ),
'no' => __( 'No', 'indieweb-post-kinds' ),
'maybe' => __( 'Maybe', 'indieweb-post-kinds' ),
'interested' => __( 'Interested', 'indieweb-post-kinds' )
'interested' => __( 'Interested', 'indieweb-post-kinds' ),
);
$string = '<label for="mf2_rsvp">' . __( 'RSVP', 'indieweb-post-kinds' ) . '</label><br/>';
$string .= '<select name="mf2_rsvp" id="mf2_rsvp">';
Expand Down Expand Up @@ -160,16 +160,16 @@ public static function metabox_text( $property, $label, $default = '', $type = '


public static function tz_seconds_to_offset($seconds) {
return ($seconds < 0 ? '-' : '+') . sprintf( '%02d:%02d', abs( $seconds / 60 / 60 ), abs( $seconds / 60 ) % 60 );
return ($seconds < 0 ? '-' : '+') . sprintf( '%02d:%02d', abs( $seconds / 60 / 60 ), abs( $seconds / 60 ) % 60 );
}

public static function tz_offset_to_seconds($offset) {
if ( preg_match( '/([+-])(\d{2}):?(\d{2})/', $offset, $match ) ) {
$sign = ($match[1] == '-' ? -1 : 1);
return (($match[2] * 60 * 60) + ($match[3] * 60)) * $sign;
} else {
return 0;
}
if ( preg_match( '/([+-])(\d{2}):?(\d{2})/', $offset, $match ) ) {
$sign = ($match[1] == '-' ? -1 : 1);
return (($match[2] * 60 * 60) + ($match[3] * 60)) * $sign;
} else {
return 0;
}
}

/* Create one or more meta boxes to be displayed on the post editor screen. */
Expand All @@ -195,7 +195,7 @@ public static function display_metabox( $object, $box ) {
$url = $_GET['kindurl'];
}
}
$time = array(); // $meta->get_time();
$time = array(); // $meta->get_time();
include_once( 'tabs/tab-navigation.php' );
}

Expand Down Expand Up @@ -268,8 +268,7 @@ public static function save_post( $post_id, $post ) {
$duration = $meta->calculate_duration( $start, $end );
if ( $duration && ! isset( $_POST['cite_duration'] ) ) {
$meta->set( 'duration', $duration );
}
else {
} else {
$meta->del( 'duration' );
}
$meta->set( 'rsvp' , $_POST['mf2_rsvp' ] );
Expand All @@ -285,7 +284,7 @@ public static function save_post( $post_id, $post ) {
if ( isset( $_POST['cite_tags'] ) ) {
$cite['category'] = explode( ';', $_POST['cite_tags'] );
}
$cite['publication'] = ifset ( $_POST['cite_publication'] );
$cite['publication'] = ifset( $_POST['cite_publication'] );
$cite['featured'] = ifset( $_POST['cite_featured'] );

$meta->set_cite( array_filter( $cite ) );
Expand Down
38 changes: 38 additions & 0 deletions includes/class-kind-taxonomy.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,25 @@ public static function get_kind_info( $kind, $property ) {
'description' => __( 'a post with an embedded image/photo as its primary focus', 'indieweb-post-kinds' ),
'description-url' => 'http://indieweb.org/photo',
),
'video' => array(
'singular_name' => _x( 'Video', 'indieweb-post-kinds' ), // Name for one instance of the kind
'name' => _x( 'Videos', 'indieweb-post-kinds' ), // General name for the kind plural
'verb' => _x( ' ', 'indieweb-post-kinds' ), // The string for the verb or action (liked this)
'property' => 'video', // microformats 2 property
'format' => 'video', // Post Format that maps to this
'description' => __( 'a post with an embedded video as its primary focus', 'indieweb-post-kinds' ),
'description-url' => 'http://indieweb.org/video',
),
'audio' => array(
'singular_name' => _x( 'Audio', 'indieweb-post-kinds' ), // Name for one instance of the kind
'name' => _x( 'Audios', 'indieweb-post-kinds' ), // General name for the kind plural
'verb' => _x( ' ', 'indieweb-post-kinds' ), // The string for the verb or action (liked this)
'property' => 'audio', // microformats 2 property
'format' => 'audio', // Post Format that maps to this
'description' => __( 'a post with an embedded audio file as its primary focus', 'indieweb-post-kinds' ),
'description-url' => 'http://indieweb.org/audio',
),

'tag' => array(
'singular_name' => _x( 'Tag', 'indieweb-post-kinds' ), // Name for one instance of the kind
'name' => _x( 'Tags', 'indieweb-post-kinds' ), // General name for the kind plural
Expand Down Expand Up @@ -440,8 +459,27 @@ public static function get_kind_info( $kind, $property ) {
'description' => __( 'list of ingredients and directions for making food or drink', 'indieweb-post-kinds' ),
'description-url' => 'https://indieweb.org/recipe',
),
'issue' => array(
'singular_name' => _x( 'Issue', 'indieweb-post-kinds' ), // Name for one instance of the kind
'name' => _x( 'Issues', 'indieweb-post-kinds' ), // General name for the kind plural
'verb' => _x( 'Filed an Issue', 'indieweb-post-kinds' ), // The string for the verb or action (liked this)
'property' => 'u-in-reply-to', // microformats 2 property
'format' => '', // Post Format that maps to this
'description' => __( 'Issue is a special kind of article post that is a reply to typically some source code, though potentially anything at a source control repository.', 'indieweb-post-kinds' ),
'description-url' => 'https://indieweb.org/issue',
),
'event' => array(
'singular_name' => _x( 'Event', 'indieweb-post-kinds' ), // Name for one instance of the kind
'name' => _x( 'Eventss', 'indieweb-post-kinds' ), // General name for the kind plural
'verb' => _x( 'Planned', 'indieweb-post-kinds' ), // The string for the verb or action (liked this)
'property' => 'h-event', // microformats 2 property
'format' => '', // Post Format that maps to this
'description' => __( 'An event is a type of post that in addition to a post name (event title) has a start datetime (likely end datetime), and a location.', 'indieweb-post-kinds' ),
'description-url' => 'https://indieweb.org/event',
),
);
$kinds = apply_filters( 'kind_info', $kinds );
ksort( $kinds );
if ( 'all' === $kind ) {
return $kinds;
}
Expand Down
71 changes: 52 additions & 19 deletions includes/class-kind-view.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,20 @@ class Kind_View {
public static function init() {
add_filter( 'the_content', array( 'Kind_View', 'content_response' ), 20 );
add_filter( 'the_excerpt', array( 'Kind_View', 'excerpt_response' ), 20 );
add_filter( 'wp_get_attachment_image_attributes', array( 'Kind_View', 'wp_get_attachment_image_attributes' ), 10 );
add_filter( 'wp_get_attachment_image_attributes', array( 'Kind_View', 'wp_get_attachment_image_attributes' ), 10, 2 );
}

public static function wp_get_attachment_image_attributes( array $attr ) {
public static function wp_get_attachment_image_attributes( array $attr, WP_Post $attachment ) {
$parents = get_post_ancestors( $attachment );
$id = $parents[ count( $parents ) -1 ];
if ( 'photo' !== get_post_kind_slug( $id ) ) {
return $attr;
}
if ( isset( $attr['class'] ) ) {
$class = explode( " ", $attr['class'] );
$class = explode( ' ', $attr['class'] );
$class[] = 'u-photo';
$attr['class'] = implode( " ", array_unique( $class ) );
}
else{
$attr['class'] = implode( ' ', array_unique( $class ) );
} else {
$attr['class'] = 'u-photo';
}
return $attr;
Expand Down Expand Up @@ -48,7 +52,7 @@ public static function get_view_part($slug, $name = null) {
}
}
ob_start();
include ( $located );
include( $located );
$return = ob_get_contents();
ob_end_clean();
return wp_make_content_images_responsive( $return );
Expand Down Expand Up @@ -130,10 +134,39 @@ public static function get_embed( $url ) {
return '';
}
$host = self::extract_domain_name( $url );
$whitelist = array(
'animoto.com', 'blip.tv', 'cloudup.com', 'collegehumor.com', 'dailymotion.com', 'facebook.com', 'flickr.com', 'funnyordie.com', 'hulu.com', 'imgur.com', 'instagram.com',
'issuu.com', 'kickstarter.com', 'meetup.com', 'mixcloud.com', 'photobucket.com', 'polldaddy.com', 'reddit.com', 'reverbnation.com', 'scribd.com', 'slideshare.net', 'smugmug.com',
'soundcloud.com', 'speakerdeck.com', 'spotify.com', 'ted.com', 'tumblr.com', 'twitter.com', 'videopress.com', 'vimeo.com', 'wordpress.tv', 'youtube.com'
$whitelist = array(
'animoto.com',
'blip.tv',
'cloudup.com',
'collegehumor.com',
'dailymotion.com',
'facebook.com',
'flickr.com',
'funnyordie.com',
'hulu.com',
'imgur.com',
'instagram.com',
'issuu.com',
'kickstarter.com',
'meetup.com',
'mixcloud.com',
'photobucket.com',
'polldaddy.com',
'reddit.com',
'reverbnation.com',
'scribd.com',
'slideshare.net',
'smugmug.com',
'soundcloud.com',
'speakerdeck.com',
'spotify.com',
'ted.com',
'tumblr.com',
'twitter.com',
'videopress.com',
'vimeo.com',
'wordpress.tv',
'youtube.com',
);
$whitelist = apply_filters( 'post_kind_embed_whitelist', $whitelist );
if ( ! in_array( $host, $whitelist ) ) {
Expand Down Expand Up @@ -190,7 +223,7 @@ public static function get_hcard($author, $args = null) {
$default = array(
'height' => 32,
'width' => 32,
'display' => 'both'
'display' => 'both',
);
$args = wp_parse_args( $args, $default );
/**
Expand Down Expand Up @@ -283,7 +316,7 @@ public static function rsvp_text( $type ) {
'yes' => __( 'Attending <a href="%1s" class="u-in-reply-to">%2s</a>', 'indieweb-post-kinds' ),
'maybe' => __( 'Might be attending <a href="%1s" class="u-in-reply-to">%2s</a>', 'indieweb-post-kinds' ),
'no' => __( 'Unable to Attend <a href="%1s" class="u-in-reply-to">%2s</a>', 'indieweb-post-kinds' ),
'interested' => __( 'Interested in Attending %s', 'indieweb-post-kinds' )
'interested' => __( 'Interested in Attending %s', 'indieweb-post-kinds' ),
);
return $rsvp[ $type ];
}
Expand All @@ -303,22 +336,22 @@ public static function display_duration( $duration ) {
);
$return = '';
if ( $bits['year'] > 0 ) {
$return .= sprintf( _n( '%d year', '%d years', $bits['year'], 'indieweb-post-kinds' ), $bits['year'] );
$return .= sprintf( _n( '%d year', '%d years', $bits['year'], 'indieweb-post-kinds' ), $bits['year'] );
}
if ( $bits['month'] > 0 ) {
$return .= sprintf( _n( ' %d month', ' %d months', $bits['month'], 'indieweb-post-kinds' ), $bits['month'] );
$return .= sprintf( _n( ' %d month', ' %d months', $bits['month'], 'indieweb-post-kinds' ), $bits['month'] );
}
if ( $bits['day'] > 0 ) {
$return .= sprintf( _n( ' %d day', ' %d days', $bits['day'], 'indieweb-post-kinds' ), $bits['day'] );
$return .= sprintf( _n( ' %d day', ' %d days', $bits['day'], 'indieweb-post-kinds' ), $bits['day'] );
}
if ( $bits['hour'] > 0 ) {
$return .= sprintf( _n( ' %d hour', ' %d hours', $bits['hour'], 'indieweb-post-kinds' ), $bits['hour'] );
$return .= sprintf( _n( ' %d hour', ' %d hours', $bits['hour'], 'indieweb-post-kinds' ), $bits['hour'] );
}
if ( $bits['minute'] > 0 ) {
$return .= sprintf( _n( ' %d minute', ' %d minutes', $bits['minute'], 'indieweb-post-kinds' ), $bits['minute'] );
$return .= sprintf( _n( ' %d minute', ' %d minutes', $bits['minute'], 'indieweb-post-kinds' ), $bits['minute'] );
}
if ( $bits['second'] > 0 ) {
$return .= sprintf( _n( ' %d second', ' %d seconds', $bits['second'], 'indieweb-post-kinds' ), $bits['second'] );
$return .= sprintf( _n( ' %d second', ' %d seconds', $bits['second'], 'indieweb-post-kinds' ), $bits['second'] );
}
return trim( $return );
}
Expand Down
8 changes: 4 additions & 4 deletions includes/class-link-preview.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ public static function register_routes() {
'methods' => WP_REST_Server::READABLE,
'callback' => array( 'Link_Preview', 'parse' ),
'args' => array(
'kindurl' => array(
'kindurl' => array(
'required' => true,
'validate_callback' => array( 'Link_Preview', 'is_valid_url' ),
'sanitize_callback' => 'esc_url_raw'
'sanitize_callback' => 'esc_url_raw',
),
),
'permission_callback' => function () {
return current_user_can( 'edit_posts' );
}
},
),
) );
}
Expand Down Expand Up @@ -108,7 +108,7 @@ public static function localparse( $url ) {
$content = Parse_Mf2::fetch( $url );
return self::mergeparse( $content, $url );
}



}
Expand Down
Loading

0 comments on commit 33d9649

Please sign in to comment.