Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: mfields/mfields-bookmarks
base: 8a7fe98954
...
head fork: mfields/mfields-bookmarks
compare: 56de108416
Checking mergeability… Don't worry, you can still create the pull request.
  • 4 commits
  • 1 file changed
  • 0 commit comments
  • 1 contributor
Showing with 61 additions and 20 deletions.
  1. +61 −20 mfields-bookmarks.php
View
81 mfields-bookmarks.php
@@ -2,7 +2,7 @@
/*
Plugin Name: Mfields Bookmarks
Description: Enables a custom post_type for bookmarks.
-Version: 0.3
+Version: 0.4
Author: Michael Fields
Author URI: http://wordpress.mfields.org/
License: GPLv2 or later
@@ -27,7 +27,6 @@
class Mfields_Bookmarks {
- const prefix = 'Mfields_Bookmarks::';
const post_type = 'mfields_bookmark';
const meta_url = '_mfields_bookmark_url';
const meta_text = '_mfields_bookmark_link_text';
@@ -41,18 +40,18 @@ class Mfields_Bookmarks {
* @since 2011-02-20
*/
static public function init() {
- register_activation_hook( __file__, self::prefix . 'activate' );
- register_deactivation_hook( __file__, self::prefix . 'deactivate' );
- add_action( 'init', self::prefix . 'register_post_type', 0 );
- add_action( 'init', self::prefix . 'register_taxonomies', 2 );
- add_action( 'admin_menu', self::prefix . 'register_meta_boxen' );
- add_action( 'admin_head-post-new.php', self::prefix . 'process_bookmarklet' );
- add_action( 'save_post', self::prefix . 'meta_save', 10, 2 );
- add_filter( 'the_content', self::prefix . 'append_link_to_content', 0 );
+ register_activation_hook( __file__, 'Mfields_Bookmarks::activate' );
+ register_deactivation_hook( __file__, 'Mfields_Bookmarks::deactivate' );
+ add_action( 'init', 'Mfields_Bookmarks::register_post_type', 0 );
+ add_action( 'init', 'Mfields_Bookmarks::register_taxonomies', 2 );
+ add_action( 'admin_menu', 'Mfields_Bookmarks::register_meta_boxen' );
+ add_action( 'admin_head-post-new.php', 'Mfields_Bookmarks::process_bookmarklet' );
+ add_action( 'save_post', 'Mfields_Bookmarks::meta_save', 10, 2 );
+ add_filter( 'the_content', 'Mfields_Bookmarks::append_link_to_content', 0 );
/* Integrate with the Nighthawk theme. */
- add_filter( 'nighthawk_table_columns', self::prefix . 'nighthawk_table_columns' );
- add_filter( 'nighthawk_archive_meta_strings', self::prefix . 'nighthawk_archive_meta_strings' );
+ add_filter( 'nighthawk_table_columns', 'Mfields_Bookmarks::nighthawk_table_columns' );
+ add_filter( 'nighthawk_archive_meta_strings', 'Mfields_Bookmarks::nighthawk_archive_meta_strings' );
}
/**
@@ -335,23 +334,41 @@ static public function meta_save( $ID, $post ) {
update_post_meta( $ID, self::meta_text, esc_html( $_POST[self::meta_text] ) );
}
+ /**
+ * Define table columns for post_type and taxonomy archives.
+ *
+ * Compatibility with the Nighthawk theme.
+ * @see https://github.com/mfields/nighthawk
+ *
+ * This filter is attached to the "nighthawk_table_columns" hook.
+ * @see Nighthawk::filter_table_columns()
+ *
+ * @uses Nighthawk::td_title()
+ * @uses Nighthawk::td_permalink_icon()
+ * @uses Mfields_Bookmarks::nighthawk_td_bookmark_source()
+ *
+ * @param array $columns
+ * @return array modified table columns.
+ *
+ * @since Mfields Bookmarks 0.4
+ */
public static function nighthawk_table_columns( $columns ) {
if ( is_post_type_archive( self::post_type ) ) {
$columns = array(
array(
'label' => __( 'Post Title', 'nighthawk' ),
'class' => 'post-title',
- 'callback' => 'nighthawk_td_title',
+ 'callback' => 'Nighthawk::td_title',
),
array(
'label' => __( 'Source', 'nighthawk' ),
'class' => 'bookmark-source',
- 'callback' => self::prefix . 'nighthawk_td_bookmark_source',
+ 'callback' => 'Mfields_Bookmarks::nighthawk_td_bookmark_source',
),
array(
'label' => __( 'Permalink', 'nighthawk' ),
'class' => 'permalink',
- 'callback' => 'nighthawk_td_permalink_icon',
+ 'callback' => 'Nighthawk::td_permalink_icon',
),
);
} else if ( is_tax( self::post_type . '_source' ) ) {
@@ -359,12 +376,12 @@ public static function nighthawk_table_columns( $columns ) {
array(
'label' => __( 'Post Title', 'nighthawk' ),
'class' => 'post-title',
- 'callback' => 'nighthawk_td_title',
+ 'callback' => 'Nighthawk::td_title',
),
array(
'label' => __( 'Permalink', 'nighthawk' ),
'class' => 'permalink',
- 'callback' => 'nighthawk_td_permalink_icon',
+ 'callback' => 'Nighthawk::td_permalink_icon',
),
);
} else if ( is_tax( self::post_type . '_type' ) ) {
@@ -372,23 +389,36 @@ public static function nighthawk_table_columns( $columns ) {
array(
'label' => __( 'Post Title', 'nighthawk' ),
'class' => 'post-title',
- 'callback' => 'nighthawk_td_title',
+ 'callback' => 'Nighthawk::td_title',
),
array(
'label' => __( 'Source', 'nighthawk' ),
'class' => 'bookmark-source',
- 'callback' => self::prefix . 'nighthawk_td_bookmark_source',
+ 'callback' => 'Mfields_Bookmarks::nighthawk_td_bookmark_source',
),
array(
'label' => __( 'Permalink', 'nighthawk' ),
'class' => 'permalink',
- 'callback' => 'nighthawk_td_permalink_icon',
+ 'callback' => 'Nighthawk::td_permalink_icon',
),
);
}
return $columns;
}
+ /**
+ * Define strings to be used in post_type archives.
+ *
+ * Compatibility with the Nighthawk theme.
+ * @see https://github.com/mfields/nighthawk
+ *
+ * This filter is attached to the "nighthawk_archive_meta_strings" hook.
+ *
+ * @param array $string Default strings defined by Nighthawk.
+ * @return array Modified, internationalized strings.
+ *
+ * @since Mfields Bookmarks 0.4
+ */
function nighthawk_archive_meta_strings( $strings ) {
if ( is_post_type_archive( self::post_type ) ) {
$strings['count'] = _n_noop( 'There is %1$s bookmark in this section.', 'There are %1$s bookmarks in this section.' );
@@ -398,6 +428,17 @@ function nighthawk_archive_meta_strings( $strings ) {
return $strings;
}
+ /**
+ * Displays a link to the source of the bookmark.
+ *
+ * Compatibility with the Nighthawk theme.
+ * @see https://github.com/mfields/nighthawk
+ *
+ * @param array $column Configuration for the current column. "class" and "label" are available.
+ * @return void
+ *
+ * @since Mfields Bookmarks 0.4
+ */
function nighthawk_td_bookmark_source( $column = array() ) {
$taxonomy = self::post_type . '_source';
$sources = get_the_terms( get_the_ID(), $taxonomy );

No commit comments for this range

Something went wrong with that request. Please try again.