From 4e8a985340403ed5753c47faabc7ec3664f6db35 Mon Sep 17 00:00:00 2001 From: adam schweigert Date: Thu, 17 Jan 2013 17:36:18 -0500 Subject: [PATCH 1/7] add a sidebar widget to display most recent published links --- argo-links-widget.php | 116 ++++++++++++++++++++++++++++++++++++++ argo-links.php | 21 ++++--- css/argo-links.css | 15 +++++ img/link-roundup-icon.png | Bin 4 files changed, 145 insertions(+), 7 deletions(-) create mode 100644 argo-links-widget.php mode change 100644 => 100755 img/link-roundup-icon.png diff --git a/argo-links-widget.php b/argo-links-widget.php new file mode 100644 index 0000000..c07fc63 --- /dev/null +++ b/argo-links-widget.php @@ -0,0 +1,116 @@ + 'argo-links', + 'description' => 'Show your most recently saved links in a sidebar widget', 'argo-links' + ); + $this->WP_Widget( 'argo-links-widget', __('Argo Links Widget', 'argo-links'), $widget_ops); + } + + function widget( $args, $instance ) { + extract( $args ); + $title = apply_filters('widget_title', $instance['title'] ); + + echo $before_widget; + + if ( $title ) + echo $before_title . $title . $after_title;?> + + get_option( 'sticky_posts' ), + 'showposts' => $instance['num_posts'], + 'post_type' => 'argolinks', + 'post_status' => 'publish' + ); + $my_query = new WP_Query( $query_args ); + if ( $my_query->have_posts() ) { + while ( $my_query->have_posts() ) : $my_query->the_post(); + $custom = get_post_custom($post->ID); ?> + +
+
' . get_the_title() . '' : get_the_title(); ?>
+ + '; + echo ( function_exists( 'largo_trim_sentences' ) ) ? largo_trim_sentences($custom["argo_link_description"][0], $instance['num_sentences']) : $custom["argo_link_description"][0]; + echo '

'; + } + if ( isset($custom["argo_link_source"][0] ) ) { + echo '

' . __('Source: ', 'argo-links') . ''; + echo ( isset( $custom["argo_link_url"][0] ) ) ? '' . $custom["argo_link_source"][0] . '' : $custom["argo_link_source"][0]; + echo '

'; + } + ?> + +
+ You don\'t have any recent links or the argo links plugin is not active.

', 'argo-links'); + } // end recent links + + if ( $instance['linkurl'] !='' ) { ?> + + 'Recent Links', + 'num_posts' => 5, + 'num_sentences' => 2, + 'linktext' => '', + 'linkurl' => '' + ); + $instance = wp_parse_args( (array) $instance, $defaults ); + ?> + +

+ + +

+ +

+ + +

+ + +

+ + +

+ + +

More Link

+

+ + +

+ +

+ + +

+ +

Tools

- +

Argo Link This!

Argo Link This! is a bookmarklet: a little app that runs in your browser and lets you grab bits of the web.

- +

Use Argo Link This! to clip links to any web page. Then edit and add more straight from Argo Link This! before you save or publish it in a post on your site.

Drag-and-drop the following link to your bookmarks bar or right click it and add it to your favorites for a posting shortcut.

Argo Link This!

@@ -205,11 +208,15 @@ function build_argo_this_page() {

If your bookmarks toolbar is hidden: copy the code below, open your Bookmarks manager, create new bookmark, type Press This into the name field and paste the code into the URL field.

- + diff --git a/css/argo-links.css b/css/argo-links.css index 83c3ea6..c970f4d 100755 --- a/css/argo-links.css +++ b/css/argo-links.css @@ -34,3 +34,18 @@ div.display-argo-links div.pagination .current { background: none repeat scroll 0 0 #FFFFFF; color: #C7C7C7; } +.widget.argo-links h5 { + margin-bottom: 2px; + padding: 0 3px; + font-size: 16px; +} +.widget.argo-links p { + font-size: 10.672px; + margin-bottom: 12px; +} +.widget.argo-links p.description { + margin-bottom: 2px; +} +.widget.argo-links p.source span { + font-style: italic; +} diff --git a/img/link-roundup-icon.png b/img/link-roundup-icon.png old mode 100644 new mode 100755 From 23f7089ab1d3485992bcd42c17a39bc68eae44a8 Mon Sep 17 00:00:00 2001 From: adam schweigert Date: Mon, 16 Sep 2013 16:18:53 -0400 Subject: [PATCH 2/7] keep wordpress 3.6 from complaining --- argo-link-roundups.php | 29 ++++++++++++++--------------- argo-links.php | 26 +++++++++++++------------- 2 files changed, 27 insertions(+), 28 deletions(-) diff --git a/argo-link-roundups.php b/argo-link-roundups.php index cd610c7..ba0cc64 100755 --- a/argo-link-roundups.php +++ b/argo-link-roundups.php @@ -11,7 +11,7 @@ class ArgoLinkRoundups { /* Initialize the plugin */ - function init() { + public static function init() { /*Register the custom post type of argolinks */ add_action('init', array(__CLASS__, 'register_post_type' )); @@ -23,14 +23,14 @@ function init() { /*Save our custom post fields! Very important!*/ add_action('save_post', array(__CLASS__, 'save_custom_fields')); - + /*Make sure our custom post type gets pulled into the river*/ add_filter( 'pre_get_posts', array(__CLASS__,'my_get_posts') ); } /*Pull the argolinkroundups into the rivers for is_home, is_tag, is_category, is_archive*/ /*Merge the post_type query var if there is already a custom post type being pulled in, otherwise do post & argolinkroundups*/ - function my_get_posts( $query ) { + public static function my_get_posts( $query ) { // bail out early if suppress filters is set to true if ($query->get('suppress_filters')) return; @@ -44,9 +44,9 @@ function my_get_posts( $query ) { } } } - + /*Register the Argo Links post type */ - function register_post_type() { + public static function register_post_type() { $argolinkroundups_options = array( 'labels' => array( 'name' => 'Link Roundups', @@ -73,14 +73,14 @@ function register_post_type() { } register_post_type('argolinkroundups', $argolinkroundups_options); } - + /*Tell Wordpress where to put our custom fields for our custom post type*/ - function add_custom_post_fields() { + public static function add_custom_post_fields() { add_meta_box("argo_link_roundups_roundup", "Recent Roundup Links", array(__CLASS__,"display_custom_fields"), "argolinkroundups", "normal", "high"); } /*Show our custom post fields in the add/edit Argo Link Roundups admin pages*/ - function display_custom_fields() { + public static function display_custom_fields() { ?> @@ -93,7 +93,7 @@ function display_custom_fields() { } /*Save the custom post field data. Very important!*/ - function save_custom_fields($post_id) { + public static function save_custom_fields($post_id) { if (isset($_POST["argo_link_url"])){ update_post_meta((isset($_POST['post_id']) ? $_POST['post_ID'] : $post_id), "argo_link_url", $_POST["argo_link_url"]); } @@ -102,20 +102,19 @@ function save_custom_fields($post_id) { } } /*Add the Argo Link Roundup options sub menu*/ - function add_argo_link_roundup_options_page() { + public static function add_argo_link_roundup_options_page() { add_submenu_page( "edit.php?post_type=argolinkroundups", "Options", "Options", "edit_posts", "argo-link-roundups-options", array(__CLASS__, 'build_argo_link_roundups_options_page' ) ); //call register settings function add_action( 'admin_init', array(__CLASS__,'register_mysettings') ); } - - function register_mysettings() { + public static function register_mysettings() { //register our settings register_setting( 'argolinkroundups-settings-group', 'argo_link_roundups_custom_url' ); register_setting( 'argolinkroundups-settings-group', 'argo_link_roundups_custom_html' ); } - function build_argo_link_roundups_options_page() { ?> + public static function build_argo_link_roundups_options_page() { ?> #!TITLE!##!DESCRIPTION!# #!SOURCE!#

@@ -148,14 +147,14 @@ function build_argo_link_roundups_options_page() { ?> - +

- array( 'name' => 'Argo Links', @@ -93,17 +93,17 @@ function register_post_type() { } /*Tell Wordpress where to put our custom fields for our custom post type*/ - function add_custom_post_fields() { + public static function add_custom_post_fields() { add_meta_box("argo_links_meta", "Link Information", array(__CLASS__,"display_custom_fields"), "argolinks", "normal", "low"); } /*Register our custom taxonomy*/ - function register_argo_links_taxonomy() { + public static function register_argo_links_taxonomy() { register_taxonomy("argo-link-tags", array("argolinks"), array("hierarchical" => false, "label" => "Link Tags", "singular_label" => "Link Tag", "rewrite" => true)); } /*Show our custom post fields in the add/edit Argo Links admin pages*/ - function display_custom_fields() { + public static function display_custom_fields() { global $post; $custom = get_post_custom($post->ID); if (isset($custom["argo_link_url"][0])) { @@ -132,7 +132,7 @@ function display_custom_fields() { } /*Save the custom post field data. Very important!*/ - function save_custom_fields($post_id) { + public static function save_custom_fields($post_id) { if (isset($_POST["argo_link_url"])){ update_post_meta((isset($_POST['post_ID']) ? $_POST['post_ID'] : $post_id), "argo_link_url", $_POST["argo_link_url"]); @@ -146,7 +146,7 @@ function save_custom_fields($post_id) { } /*Create the new columns to display our custom post fields*/ - function display_custom_columns($columns){ + public static function display_custom_columns($columns){ $columns = array( "cb" => "", "title" => "Link Title", @@ -160,7 +160,7 @@ function display_custom_columns($columns){ } /*Fill in our custom data for the new columns*/ - function data_for_custom_columns($column){ + public static function data_for_custom_columns($column){ global $post; $custom = get_post_custom(); @@ -188,12 +188,12 @@ function data_for_custom_columns($column){ } /*Add the Argo Link This! sub menu*/ - function add_argo_this_sub_menu() { + public static function add_argo_this_sub_menu() { add_submenu_page( "edit.php?post_type=argolinks", "Argo Link This!", "Argo Link This!", "edit_posts", "argo-this", array(__CLASS__, 'build_argo_this_page' ) ); } /*Custom page for people to pull the Argo Link This! code from (similar to Press This!)*/ - function build_argo_this_page() { + public static function build_argo_this_page() { ?>

Tools

@@ -211,7 +211,7 @@ function build_argo_this_page() { Date: Tue, 24 Dec 2013 11:49:19 -0500 Subject: [PATCH 3/7] make argolinks searchable and archive-able --- argo-links.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/argo-links.php b/argo-links.php index 67daaef..f88dac0 100755 --- a/argo-links.php +++ b/argo-links.php @@ -85,9 +85,10 @@ public static function register_post_type() { 'description' => 'Argo Links', 'supports' => array( 'title' ), 'public' => true, - 'publicly_queryable' => false, + 'publicly_queryable' => true, 'menu_position' => 6, 'taxonomies' => array(), + 'has_archive' => true ) ); } From 7aafe132eb7f0411addbb0de8f151a9418ab3794 Mon Sep 17 00:00:00 2001 From: adam schweigert Date: Tue, 24 Dec 2013 11:55:53 -0500 Subject: [PATCH 4/7] activate post thumbnail support --- argo-links.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/argo-links.php b/argo-links.php index f88dac0..2691d8b 100755 --- a/argo-links.php +++ b/argo-links.php @@ -83,9 +83,8 @@ public static function register_post_type() { 'not_found_in_trash' => 'No Argo Links found in Trash', ), 'description' => 'Argo Links', - 'supports' => array( 'title' ), + 'supports' => array( 'title', 'thumbnail' ), 'public' => true, - 'publicly_queryable' => true, 'menu_position' => 6, 'taxonomies' => array(), 'has_archive' => true From 47c8f7b032db5db1fef1d9808a35beabb3b0b445 Mon Sep 17 00:00:00 2001 From: David Ryan Date: Thu, 4 Jun 2015 09:49:12 -0700 Subject: [PATCH 5/7] distinguish CPT in backend Add dash icons to link roundups and link post types --- argo-link-roundups.php | 1 + argo-links.php | 1 + 2 files changed, 2 insertions(+) diff --git a/argo-link-roundups.php b/argo-link-roundups.php index ba0cc64..4dd68ec 100755 --- a/argo-link-roundups.php +++ b/argo-link-roundups.php @@ -65,6 +65,7 @@ public static function register_post_type() { 'supports' => array( 'title', 'editor','author','thumbnail','excerpt','trackbacks','custom-fields','comments','revisions','page-attributes','post-formats'), 'public' => true, 'menu_position' => 7, + 'menu_icon' => 'dashicons-list-view', 'taxonomies' => apply_filters('argolinkroundups_taxonomies', array('category','post_tag')), 'has_archive' => true, ); diff --git a/argo-links.php b/argo-links.php index 2691d8b..1557fa9 100755 --- a/argo-links.php +++ b/argo-links.php @@ -86,6 +86,7 @@ public static function register_post_type() { 'supports' => array( 'title', 'thumbnail' ), 'public' => true, 'menu_position' => 6, + 'menu_icon' => 'dashicons-admin-links', 'taxonomies' => array(), 'has_archive' => true ) From 738016ae40e5e90226e803f350ba48cff3aa28ce Mon Sep 17 00:00:00 2001 From: David Ryan Date: Fri, 12 Jun 2015 14:48:11 -0700 Subject: [PATCH 6/7] argo-link-roundups-widget --- argo-link-roundups-widget.php | 125 ++++++++++++++++++++++++++++++++++ argo-links.php | 5 ++ 2 files changed, 130 insertions(+) create mode 100644 argo-link-roundups-widget.php diff --git a/argo-link-roundups-widget.php b/argo-link-roundups-widget.php new file mode 100644 index 0000000..5762ea7 --- /dev/null +++ b/argo-link-roundups-widget.php @@ -0,0 +1,125 @@ + 'argo-link-roundups', + 'description' => 'Show your most recent link roundups in the sidebar', 'argo-links' + ); + $this->WP_Widget( 'argo-link-roundups-widget', __('Argo Link Roundups Widget', 'argo-links'), $widget_ops); + } + + function widget( $args, $instance ) { + extract( $args ); + $title = apply_filters('widget_title', $instance['title'] ); + + echo $before_widget; + + if ( $title ) + echo $before_title . $title . $after_title;?> + + get_option( 'sticky_posts' ), + 'showposts' => $instance['num_posts'], + 'post_type' => 'post', + 'post_status' => 'publish' + ); + $my_query = new WP_Query( $query_args ); + if ( $my_query->have_posts() ) { + while ( $my_query->have_posts() ) : $my_query->the_post(); + $custom = get_post_custom($post->ID); ?> +
+ ' . get_the_date("F d Y") . ''; + + // the headline + $output .= '

' . get_the_title() . '

'; + + + // the excerpt + if ($excerpt == 'num_sentences') { + $output .= '

' . largo_trim_sentences( get_the_content(), $instance['num_sentences'] ) . '

'; + } elseif ($excerpt == 'custom_excerpt') { + $output .= '

' . get_the_excerpt() . '

'; + } + + echo $output; + ?> + +
+ You don\'t have any recent links or the argo links plugin is not active.

', 'argo-links'); + } // end recent links + + if ( $instance['linkurl'] !='' ) { ?> + + 'Recent Link Roundups', + 'num_posts' => 1, + 'num_sentences' => 0, + 'linktext' => '', + 'linkurl' => '' + ); + $showdate = $instance['show_date'] ? 'checked="checked"' : ''; + $instance = wp_parse_args( (array) $instance, $defaults ); + ?> + +

+ + +

+ +

+ + +

+ + +

+ + +

+ + +

+ id="get_field_id('show_date'); ?>" name="get_field_name('show_date'); ?>" /> +

+ +

More Link

+

+ + +

+ +

+ + +

+ + From c85ab908aa5187f000b9b549dea00f19bebc892b Mon Sep 17 00:00:00 2001 From: David Ryan Date: Tue, 16 Jun 2015 16:13:31 -0700 Subject: [PATCH 7/7] functional link roundups widget --- argo-link-roundups-widget.php | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/argo-link-roundups-widget.php b/argo-link-roundups-widget.php index 5762ea7..f0d9156 100644 --- a/argo-link-roundups-widget.php +++ b/argo-link-roundups-widget.php @@ -25,6 +25,7 @@ function widget( $args, $instance ) { $query_args = array ( 'post__not_in' => get_option( 'sticky_posts' ), 'showposts' => $instance['num_posts'], + 'exceprt' => $instance['show_excerpt'], 'post_type' => 'post', 'post_status' => 'publish' ); @@ -41,14 +42,9 @@ function widget( $args, $instance ) { // the headline $output .= '

' . get_the_title() . '

'; - // the excerpt - if ($excerpt == 'num_sentences') { - $output .= '

' . largo_trim_sentences( get_the_content(), $instance['num_sentences'] ) . '

'; - } elseif ($excerpt == 'custom_excerpt') { - $output .= '

' . get_the_excerpt() . '

'; - } - + $output .= '

' . get_the_excerpt() . '

'; + echo $output; ?> @@ -69,8 +65,6 @@ function update( $new_instance, $old_instance ) { $instance = $old_instance; $instance['title'] = strip_tags( $new_instance['title'] ); $instance['num_posts'] = strip_tags( $new_instance['num_posts'] ); - $instance['num_sentences'] = strip_tags( $new_instance['num_sentences'] ); - $instance['show_date'] = ! empty($new_instance['show_date']); $instance['linktext'] = $new_instance['linktext']; $instance['linkurl'] = $new_instance['linkurl']; return $instance; @@ -80,11 +74,10 @@ function form( $instance ) { $defaults = array( 'title' => 'Recent Link Roundups', 'num_posts' => 1, - 'num_sentences' => 0, 'linktext' => '', 'linkurl' => '' ); - $showdate = $instance['show_date'] ? 'checked="checked"' : ''; + $instance = wp_parse_args( (array) $instance, $defaults ); ?> @@ -98,16 +91,6 @@ function form( $instance ) {

- -

- - -

- - -

- id="get_field_id('show_date'); ?>" name="get_field_name('show_date'); ?>" /> -

More Link