Yoast Breadcrumbs - Version 0.8

Version Description

  • Switched to new Yoast Plugin Backend.
  • Prevented issues with double declaration of breadcrumbs.
  • Added automatic support for Thematic, Hybrid and Thesis frameworks.
Download this release

Release Info

Developer joostdevalk
Plugin Icon wp plugin Yoast Breadcrumbs
Version 0.8
Comparing to
See all releases

Code changes from version 0.7.5 to 0.8

Files changed (4) hide show
  1. readme.txt +9 -3
  2. yoast-breadcrumbs.php +134 -103
  3. yoast-posts.php +0 -63
  4. yst_plugin_tools.php +192 -0
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: joostdevalk
3
  Donate link: http://yoast.com/donate/
4
  Tags: rss, footer
5
  Requires at least: 2.2
6
- Tested up to: 2.7
7
- stable tag: 0.7.5
8
 
9
  Easily add breadcrumbs to your template!
10
 
@@ -20,7 +20,13 @@ More info:
20
 
21
  == Changelog ==
22
 
23
- * 0.7.5 Aded support for custom taxonomies
 
 
 
 
 
 
24
 
25
  == Installation ==
26
 
3
  Donate link: http://yoast.com/donate/
4
  Tags: rss, footer
5
  Requires at least: 2.2
6
+ Tested up to: 2.8.2
7
+ stable tag: 0.8
8
 
9
  Easily add breadcrumbs to your template!
10
 
20
 
21
  == Changelog ==
22
 
23
+ = 0.8 =
24
+ * Switched to new Yoast Plugin Backend.
25
+ * Prevented issues with double declaration of breadcrumbs.
26
+ * Added automatic support for Thematic, Hybrid and Thesis frameworks.
27
+
28
+ = 0.7.5 =
29
+ * Added support for custom taxonomies.
30
 
31
  == Installation ==
32
 
yoast-breadcrumbs.php CHANGED
@@ -2,7 +2,7 @@
2
  Plugin Name: Yoast Breadcrumbs
3
  Plugin URI: http://yoast.com/wordpress/breadcrumbs/
4
  Description: Outputs a fully customizable breadcrumb path.
5
- Version: 0.7.6
6
  Author: Joost de Valk
7
  Author URI: http://yoast.com/
8
 
@@ -32,37 +32,15 @@ add_option("yoast_breadcrumbs",$opt);
32
 
33
  if ( ! class_exists( 'YoastBreadcrumbs_Admin' ) ) {
34
 
35
- class YoastBreadcrumbs_Admin {
36
 
37
- function add_config_page() {
38
- global $wpdb;
39
- if ( function_exists('add_submenu_page') ) {
40
- add_options_page('Yoast Breadcrumbs Configuration', 'Breadcrumbs', 10, basename(__FILE__),array('YoastBreadcrumbs_Admin','config_page'));
41
- add_filter( 'plugin_action_links', array( 'YoastBreadcrumbs_Admin', 'filter_plugin_actions'), 10, 2 );
42
- add_filter( 'ozh_adminmenu_icon', array( 'YoastBreadcrumbs_Admin', 'add_ozh_adminmenu_icon' ) );
43
- }
44
- }
45
 
46
- function add_ozh_adminmenu_icon( $hook ) {
47
- static $breadcrumbsicon;
48
- if (!$breadcrumbsicon) {
49
- $breadcrumbsicon = WP_CONTENT_URL . '/plugins/' . plugin_basename(dirname(__FILE__)). '/script_link.png';
50
- }
51
- if ($hook == 'yoast-breadcrumbs.php') return $breadcrumbsicon;
52
- return $hook;
53
- }
54
-
55
- function filter_plugin_actions( $links, $file ){
56
- //Static so we don't call plugin_basename on every plugin row.
57
- static $this_plugin;
58
- if ( ! $this_plugin ) $this_plugin = plugin_basename(__FILE__);
59
-
60
- if ( $file == $this_plugin ){
61
- $settings_link = '<a href="options-general.php?page=yoast-breadcrumbs.php">' . __('Settings') . '</a>';
62
- array_unshift( $links, $settings_link ); // before other links
63
- }
64
- return $links;
65
- }
66
 
67
  function config_page() {
68
  if ( isset($_POST['submit']) ) {
@@ -75,7 +53,7 @@ if ( ! class_exists( 'YoastBreadcrumbs_Admin' ) ) {
75
  }
76
  }
77
 
78
- foreach (array('boldlast', 'nofollowhome', 'singlecatprefix') as $option_name) {
79
  if (isset($_POST[$option_name])) {
80
  $opt[$option_name] = true;
81
  } else {
@@ -89,57 +67,101 @@ if ( ! class_exists( 'YoastBreadcrumbs_Admin' ) ) {
89
  $opt = get_option('yoast_breadcrumbs');
90
  ?>
91
  <div class="wrap">
 
92
  <h2>Yoast Breadcrumbs Configuration</h2>
93
- <form action="" method="post" id="yoastbreadcrumbs-conf">
94
- <table class="form-table">
95
- <?php if (function_exists('wp_nonce_field')) { wp_nonce_field('yoast-breadcrumbs-updatesettings'); } ?>
96
- <tr>
97
- <th scope="row" valign="top"><label for="sep">Separator between breadcrumbs:</label></th>
98
- <td><input type="text" name="sep" id="sep" value="<?php echo htmlentities($opt['sep']); ?>"/></td>
99
- </tr>
100
- <tr>
101
- <th scope="row" valign="top"><label for="home">Anchor text for the Homepage:</label></th>
102
- <td><input type="text" name="home" id="home" value="<?php echo $opt['home']; ?>"/></td>
103
- </tr>
104
- <tr>
105
- <th scope="row" valign="top"><label for="blog">Anchor text for the Blog:</label></th>
106
- <td><input type="text" name="blog" id="blog" value="<?php echo $opt['blog']; ?>"/></td>
107
- </tr>
108
- <tr>
109
- <th scope="row" valign="top"><label for="prefix">Prefix for the breadcrumb path:</label></th>
110
- <td><input type="text" name="prefix" id="prefix" value="<?php echo $opt['prefix']; ?>"/></td>
111
- </tr>
112
- <tr>
113
- <th scope="row" valign="top"><label for="archiveprefix">Prefix for Archive breadcrumbs:</label></th>
114
- <td><input type="text" name="archiveprefix" id="archiveprefix" value="<?php echo $opt['archiveprefix']; ?>"/></td>
115
- </tr>
116
- <tr>
117
- <th scope="row" valign="top"><label for="searchprefix">Prefix for Search Page breadcrumbs:</label></th>
118
- <td><input type="text" name="searchprefix" id="searchprefix" value="<?php echo $opt['searchprefix']; ?>"/></td>
119
- </tr>
120
- <tr>
121
- <th scope="row" valign="top"><label for="singlecatprefix">Show category in post breadcrumbs? <small style="font-weight: normal;">(Shows the category inbetween Home and the blogpost)</small></label></th>
122
- <td><input type="checkbox" id="singlecatprefix" name="singlecatprefix" <?php if ($opt['singlecatprefix']) { echo 'checked="checked"'; } ?>/></td>
123
- </tr>
124
- <tr>
125
- <th scope="row" valign="top"><label for="singleparent">Show Parent Page for Blog posts?</label> <small style="font-weight: normal;">(Adds another page inbetween Home and the blogpost)</small></th>
126
- <td><?php wp_dropdown_pages("depth=0&name=singleparent&show_option_none=-- None --&selected=".$opt['singleparent']); ?></td>
127
- </tr>
128
- <tr>
129
- <th scope="row" valign="top"><label for="boldlast">Bold the last page in the breadcrumb?</label></th>
130
- <td><input type="checkbox" id="boldlast" name="boldlast" <?php if ($opt['boldlast']) { echo 'checked="checked"'; } ?>/></td>
131
- </tr>
132
- <tr>
133
- <th scope="row" valign="top"><label for="nofollowhome">Nofollow the link to the home page?</label></th>
134
- <td><input type="checkbox" id="nofollowhome" name="nofollowhome" <?php if ($opt['nofollowhome']) { echo 'checked="checked"'; } ?>/></td>
135
- </tr>
136
- </table>
137
- <br/>
138
- <span class="submit" style="border: 0;"><input type="submit" name="submit" value="Save Settings" /></span>
139
- </form>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
140
  </div>
 
141
  <?php }
142
  }
 
 
143
  }
144
 
145
  function yoast_breadcrumb($prefix = '', $suffix = '', $display = true) {
@@ -147,32 +169,36 @@ function yoast_breadcrumb($prefix = '', $suffix = '', $display = true) {
147
 
148
  $opt = get_option("yoast_breadcrumbs");
149
 
150
- function bold_or_not($input) {
151
- $opt = get_option("yoast_breadcrumbs");
152
- if ($opt['boldlast']) {
153
- return '<strong>'.$input.'</strong>';
154
- } else {
155
- return $input;
156
- }
 
 
157
  }
158
 
159
- // Copied and adapted from WP source
160
- function yoast_get_category_parents($id, $link = FALSE, $separator = '/', $nicename = FALSE){
161
- $chain = '';
162
- $parent = &get_category($id);
163
- if ( is_wp_error( $parent ) )
164
- return $parent;
 
165
 
166
- if ( $nicename )
167
- $name = $parent->slug;
168
- else
169
- $name = $parent->cat_name;
170
 
171
- if ( $parent->parent && ($parent->parent != $parent->term_id) )
172
- $chain .= get_category_parents($parent->parent, true, $separator, $nicename);
173
 
174
- $chain .= bold_or_not($name);
175
- return $chain;
 
176
  }
177
 
178
  $nofollow = ' ';
@@ -282,7 +308,12 @@ function yoast_breadcrumb($prefix = '', $suffix = '', $display = true) {
282
  }
283
  }
284
 
285
- add_action('admin_menu', array('YoastBreadcrumbs_Admin','add_config_page'));
286
-
287
- require("yoast-posts.php");
288
- ?>
 
 
 
 
 
2
  Plugin Name: Yoast Breadcrumbs
3
  Plugin URI: http://yoast.com/wordpress/breadcrumbs/
4
  Description: Outputs a fully customizable breadcrumb path.
5
+ Version: 0.8
6
  Author: Joost de Valk
7
  Author URI: http://yoast.com/
8
 
32
 
33
  if ( ! class_exists( 'YoastBreadcrumbs_Admin' ) ) {
34
 
35
+ require_once('yst_plugin_tools.php');
36
 
37
+ class YoastBreadcrumbs_Admin extends Yoast_Plugin_Admin {
 
 
 
 
 
 
 
38
 
39
+ var $hook = 'breadcrumbs';
40
+ var $longname = 'Yoast Breadcrumbs Configuration';
41
+ var $shortname = 'Breadcrumbs';
42
+ var $filename = 'breadcrumbs/yoast-breadcrumbs.php';
43
+ var $ozhicon = 'script_link.png';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
 
45
  function config_page() {
46
  if ( isset($_POST['submit']) ) {
53
  }
54
  }
55
 
56
+ foreach (array('boldlast', 'nofollowhome', 'singlecatprefix', 'trytheme') as $option_name) {
57
  if (isset($_POST[$option_name])) {
58
  $opt[$option_name] = true;
59
  } else {
67
  $opt = get_option('yoast_breadcrumbs');
68
  ?>
69
  <div class="wrap">
70
+ <a href="http://yoast.com/"><div id="yoast-icon" style="background: url(http://cdn.yoast.com/theme/yoast-32x32.png) no-repeat;" class="icon32"><br /></div></a>
71
  <h2>Yoast Breadcrumbs Configuration</h2>
72
+ <div class="postbox-container" style="width:70%;">
73
+ <div class="metabox-holder">
74
+ <div class="meta-box-sortables">
75
+ <form action="" method="post" id="yoastbreadcrumbs-conf">
76
+ <?php if (function_exists('wp_nonce_field'))
77
+ wp_nonce_field('yoast-breadcrumbs-updatesettings');
78
+
79
+ $rows = array();
80
+ $rows[] = array(
81
+ "id" => "sep",
82
+ "label" => __('Separator between breadcrumbs'),
83
+ "content" => '<input type="text" name="sep" id="sep" value="'.htmlentities($opt['sep']).'"/>',
84
+ );
85
+ $rows[] = array(
86
+ "id" => "home",
87
+ "label" => __('Anchor text for the Homepage'),
88
+ "content" => '<input type="text" name="home" id="home" value="'.$opt['home'].'"/>',
89
+ );
90
+ $rows[] = array(
91
+ "id" => "blog",
92
+ "label" => __('Anchor text for the Blog'),
93
+ "content" => '<input type="text" name="blog" id="blog" value="'.$opt['blog'].'"/>',
94
+ );
95
+ $rows[] = array(
96
+ "id" => "prefix",
97
+ "label" => __('Prefix for the breadcrumb path'),
98
+ "content" => '<input type="text" name="prefix" id="prefix" value="'.$opt['prefix'].'"/>',
99
+ );
100
+ $rows[] = array(
101
+ "id" => "archiveprefix",
102
+ "label" => __('Prefix for Archive breadcrumbs'),
103
+ "content" => '<input type="text" name="archiveprefix" id="archiveprefix" value="'.$opt['archiveprefix'].'"/>',
104
+ );
105
+ $rows[] = array(
106
+ "id" => "searchprefix",
107
+ "label" => __('Prefix for Search Page breadcrumbs'),
108
+ "content" => '<input type="text" name="searchprefix" id="searchprefix" value="'.$opt['searchprefix'].'"/>',
109
+ );
110
+ $rows[] = array(
111
+ "id" => "singlecatprefix",
112
+ "label" => __('Show category in post breadcrumbs?'),
113
+ "desc" => __('Shows the category inbetween Home and the blogpost'),
114
+ "content" => '<input type="checkbox" name="singlecatprefix" id="singlecatprefix" '.checked($opt['singlecatprefix'],true,false).'/>',
115
+ );
116
+ $rows[] = array(
117
+ "id" => "singleparent",
118
+ "label" => __('Show Parent Page for Blog posts'),
119
+ "desc" => __('Adds another page inbetween Home and the blogpost'),
120
+ "content" => wp_dropdown_pages("echo=0&depth=0&name=singleparent&show_option_none=-- None --&selected=".$opt['singleparent']),
121
+ );
122
+ $rows[] = array(
123
+ "id" => "boldlast",
124
+ "label" => __('Bold the last page in the breadcrumb'),
125
+ "content" => '<input type="checkbox" name="boldlast" id="boldlast" '.checked($opt['boldlast'],true,false).'/>',
126
+ );
127
+ $rows[] = array(
128
+ "id" => "nofollowhome",
129
+ "label" => __('Nofollow the link to the home page'),
130
+ "content" => '<input type="checkbox" name="nofollowhome" id="nofollowhome" '.checked($opt['nofollowhome'],true,false).'/>',
131
+ );
132
+ $rows[] = array(
133
+ "id" => "trytheme",
134
+ "label" => __('Try to add automatically'),
135
+ "desc" => __('If you\'re using Hybrid, Thesis or Thematic, check this box for some lovely simple action'),
136
+ "content" => '<input type="checkbox" name="trytheme" id="trytheme" '.checked($opt['trytheme'],true,false).'/>',
137
+ );
138
+
139
+ $table = $this->form_table($rows);
140
+
141
+ $this->postbox('breadcrumbssettings',__('Setting for Yoast Breadcrumbs'), $table.'<div class="submit"><input type="submit" class="button-primary" name="submit" value="Save Breadcrumbs Settings" /></div>')
142
+ ?>
143
+ </form>
144
+ </div>
145
+ </div>
146
+ </div>
147
+ <div class="postbox-container" style="width:20%;">
148
+ <div class="metabox-holder">
149
+ <div class="meta-box-sortables">
150
+ <?php
151
+ $this->plugin_like();
152
+ $this->plugin_support();
153
+ $this->news();
154
+ ?>
155
+ </div>
156
+ <br/><br/><br/>
157
+ </div>
158
+ </div>
159
  </div>
160
+
161
  <?php }
162
  }
163
+
164
+ $ybc = new YoastBreadcrumbs_Admin();
165
  }
166
 
167
  function yoast_breadcrumb($prefix = '', $suffix = '', $display = true) {
169
 
170
  $opt = get_option("yoast_breadcrumbs");
171
 
172
+ if (!function_exists('bold_or_not')) {
173
+ function bold_or_not($input) {
174
+ $opt = get_option("yoast_breadcrumbs");
175
+ if ($opt['boldlast']) {
176
+ return '<strong>'.$input.'</strong>';
177
+ } else {
178
+ return $input;
179
+ }
180
+ }
181
  }
182
 
183
+ if (!function_exists('yoast_get_category_parents')) {
184
+ // Copied and adapted from WP source
185
+ function yoast_get_category_parents($id, $link = FALSE, $separator = '/', $nicename = FALSE){
186
+ $chain = '';
187
+ $parent = &get_category($id);
188
+ if ( is_wp_error( $parent ) )
189
+ return $parent;
190
 
191
+ if ( $nicename )
192
+ $name = $parent->slug;
193
+ else
194
+ $name = $parent->cat_name;
195
 
196
+ if ( $parent->parent && ($parent->parent != $parent->term_id) )
197
+ $chain .= get_category_parents($parent->parent, true, $separator, $nicename);
198
 
199
+ $chain .= bold_or_not($name);
200
+ return $chain;
201
+ }
202
  }
203
 
204
  $nofollow = ' ';
308
  }
309
  }
310
 
311
+ function yoast_breadcrumb_output() {
312
+ if ($opt['trytheme'])
313
+ yoast_breadcrumb('<div id="yoastbreadcrumb">','</div>');
314
+ return;
315
+ }
316
+ add_action('thesis_hook_before_content','yoast_breadcrumb_output',10,1);
317
+ add_action('hybrid_before_content','yoast_breadcrumb_output',10,1);
318
+ add_action('thematic_belowheader','yoast_breadcrumb_output',10,1);
319
+ ?>
yoast-posts.php DELETED
@@ -1,63 +0,0 @@
1
- <?php
2
-
3
- if (!class_exists('YoastPosts')) {
4
- class YoastPosts {
5
-
6
- // Class initialization
7
- function YoastPosts() {
8
- if (isset($_GET['show_yoast_widget'])) {
9
- if ($_GET['show_yoast_widget'] == "true") {
10
- update_option( 'show_yoast_widget', 'noshow' );
11
- } else {
12
- update_option( 'show_yoast_widget', 'show' );
13
- }
14
- }
15
-
16
- // Add the widget to the dashboard
17
- add_action( 'wp_dashboard_setup', array(&$this, 'register_widget') );
18
- add_filter( 'wp_dashboard_widgets', array(&$this, 'add_widget') );
19
- }
20
-
21
- // Register this widget -- we use a hook/function to make the widget a dashboard-only widget
22
- function register_widget() {
23
- wp_register_sidebar_widget( 'yoast_posts', __( 'Yoast - Tweaking Websites', 'yoast-posts' ), array(&$this, 'widget'), array( 'all_link' => 'http://yoast.com/', 'feed_link' => 'http://yoast.com/feed/', 'edit_link' => 'options.php' ) );
24
- }
25
-
26
- // Modifies the array of dashboard widgets and adds this plugin's
27
- function add_widget( $widgets ) {
28
- global $wp_registered_widgets;
29
- if ( !isset($wp_registered_widgets['yoast_posts']) ) return $widgets;
30
- array_splice( $widgets, 2, 0, 'yoast_posts' );
31
- return $widgets;
32
- }
33
-
34
- function widget($args = array()) {
35
- $show = get_option('show_yoast_widget');
36
- if ($show != 'noshow') {
37
- if (is_array($args))
38
- extract( $args, EXTR_SKIP );
39
- echo $before_widget.$before_title.$widget_name.$after_title;
40
- echo '<a href="http://yoast.com/"><img style="margin: 0 0 5px 5px;" src="http://yoast.com/images/yoast-logo-rss.png" align="right" alt="Yoast"/></a>';
41
- include_once(ABSPATH . WPINC . '/rss.php');
42
- $rss = fetch_rss('http://feeds2.feedburner.com/joostdevalk');
43
- if ($rss) {
44
- $items = array_slice($rss->items, 0, 2);
45
- if (empty($items))
46
- echo '<li>No items</li>';
47
- else {
48
- foreach ( $items as $item ) { ?>
49
- <a style="font-size: 14px; font-weight:bold;" href='<?php echo $item['link']; ?>' title='<?php echo $item['title']; ?>'><?php echo $item['title']; ?></a><br/>
50
- <p style="font-size: 10px; color: #aaa;"><?php echo date('j F Y',strtotime($item['pubdate'])); ?></p>
51
- <p><?php echo substr($item['summary'],0,strpos($item['summary'], "This is a post from")); ?></p>
52
- <?php }
53
- }
54
- }
55
- echo $after_widget;
56
- }
57
- }
58
- }
59
-
60
- // Start this plugin once all other plugins are fully loaded
61
- add_action( 'plugins_loaded', create_function( '', 'global $YoastPosts; $YoastPosts = new YoastPosts();' ) );
62
- }
63
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
yst_plugin_tools.php ADDED
@@ -0,0 +1,192 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if (!class_exists('Yoast_Plugin_Admin')) {
4
+ class Yoast_Plugin_Admin {
5
+
6
+ var $hook = '';
7
+ var $filename = '';
8
+ var $longname = '';
9
+ var $shortname = '';
10
+ var $ozhicon = '';
11
+ var $accesslvl = 'manage_options';
12
+
13
+ function Yoast_Plugin_Admin() {
14
+ add_action( 'admin_menu', array(&$this, 'register_settings_page') );
15
+ add_filter( 'plugin_action_links', array(&$this, 'add_action_link'), 10, 2 );
16
+ add_filter( 'ozh_adminmenu_icon', array(&$this, 'add_ozh_adminmenu_icon' ) );
17
+
18
+ add_action('admin_print_scripts', array(&$this,'config_page_scripts'));
19
+ add_action('admin_print_styles', array(&$this,'config_page_styles'));
20
+
21
+ add_action('wp_dashboard_setup', array(&$this,'widget_setup'));
22
+ }
23
+
24
+ function add_ozh_adminmenu_icon( $hook ) {
25
+ if ($hook == $this->hook)
26
+ return WP_CONTENT_URL . '/plugins/' . plugin_basename(dirname($filename)). '/'.$this->ozhicon;
27
+ return $hook;
28
+ }
29
+
30
+ function config_page_styles() {
31
+ if (isset($_GET['page']) && $_GET['page'] == $this->hook) {
32
+ wp_enqueue_style('dashboard');
33
+ wp_enqueue_style('thickbox');
34
+ wp_enqueue_style('global');
35
+ wp_enqueue_style('wp-admin');
36
+ wp_enqueue_style('blogicons-admin-css', WP_CONTENT_URL . '/plugins/' . plugin_basename(dirname(__FILE__)). '/yst_plugin_tools.css');
37
+ }
38
+ }
39
+
40
+ function register_settings_page() {
41
+ add_options_page($this->longname, $this->shortname, $this->accesslvl, $this->hook, array(&$this,'config_page'));
42
+ }
43
+
44
+ function plugin_options_url() {
45
+ return admin_url( 'options-general.php?page='.$this->hook );
46
+ }
47
+
48
+ /**
49
+ * Add a link to the settings page to the plugins list
50
+ */
51
+ function add_action_link( $links, $file ) {
52
+ static $this_plugin;
53
+ if( empty($this_plugin) ) $this_plugin = $this->filename;
54
+ if ( $file == $this_plugin ) {
55
+ $settings_link = '<a href="' . $this->plugin_options_url() . '">' . __('Settings') . '</a>';
56
+ array_unshift( $links, $settings_link );
57
+ }
58
+ return $links;
59
+ }
60
+
61
+ function config_page() {
62
+
63
+ }
64
+
65
+ function config_page_scripts() {
66
+ if (isset($_GET['page']) && $_GET['page'] == $this->hook) {
67
+ wp_enqueue_script('postbox');
68
+ wp_enqueue_script('dashboard');
69
+ wp_enqueue_script('thickbox');
70
+ wp_enqueue_script('media-upload');
71
+ }
72
+ }
73
+
74
+ /**
75
+ * Create a potbox widget
76
+ */
77
+ function postbox($id, $title, $content) {
78
+ ?>
79
+ <div id="<?php echo $id; ?>" class="postbox">
80
+ <div class="handlediv" title="Click to toggle"><br /></div>
81
+ <h3 class="hndle"><span><?php echo $title; ?></span></h3>
82
+ <div class="inside">
83
+ <?php echo $content; ?>
84
+ </div>
85
+ </div>
86
+ <?php
87
+ }
88
+
89
+
90
+ /**
91
+ * Create a form table from an array of rows
92
+ */
93
+ function form_table($rows) {
94
+ $content = '<table class="form-table">';
95
+ foreach ($rows as $row) {
96
+ $content .= '<tr valign="top"><th scrope="row">';
97
+ if ($row['id'] != '')
98
+ $content .= '<label for="'.$row['id'].'">'.$row['label'].':</label>';
99
+ else
100
+ $content .= $row['label'];
101
+ if (isset($row['desc']) && $row['desc'] != '')
102
+ $content .= '<br/><small>'.$row['desc'].'</small>';
103
+ $content .= '</th><td>';
104
+ $content .= $row['content'];
105
+ $content .= '</td></tr>';
106
+ }
107
+ $content .= '</table>';
108
+ return $content;
109
+ }
110
+
111
+ /**
112
+ * Create a "plugin like" box.
113
+ */
114
+ function plugin_like() {
115
+ $content = '<p>'.__('Why not do any or all of the following:','ystplugin').'</p>';
116
+ $content .= '<ul>';
117
+ $content .= '<li>'.__('Link to it so other folks can find out about it.','ystplugin').'</li>';
118
+ $content .= '<li><a href="http://wordpress.org/extend/plugins/'.$this->hook.'/">'.__('Give it a good rating on WordPress.org.','ystplugin').'</a></li>';
119
+ $content .= '<li><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=2017947">'.__('Donate a token of your appreciation.','ystplugin').'</a></li>';
120
+ $content .= '</ul>';
121
+ $this->postbox($this->hook.'like', 'Like this plugin?', $content);
122
+ }
123
+
124
+ /**
125
+ * Info box with link to the support forums.
126
+ */
127
+ function plugin_support() {
128
+ $content = '<p>'.__('If you have any problems with this plugin or good ideas for improvements or new features, please talk about them in the','ystplugin').' <a href="http://wordpress.org/tags/'.$this->hook.'">'.__("Support forums",'ystplugin').'</a>.</p>';
129
+ $this->postbox($this->hook.'support', 'Need support?', $content);
130
+ }
131
+
132
+ /**
133
+ * Box with latest news from Yoast.com
134
+ */
135
+ function news() {
136
+ require_once(ABSPATH.WPINC.'/rss.php');
137
+ if ( $rss = fetch_rss( 'http://feeds2.feedburner.com/joostdevalk' ) ) {
138
+ $content = '<ul>';
139
+ $rss->items = array_slice( $rss->items, 0, 3 );
140
+ foreach ( (array) $rss->items as $item ) {
141
+ $content .= '<li class="yoast">';
142
+ $content .= '<a class="rsswidget" href="'.clean_url( $item['link'], $protocolls=null, 'display' ).'">'. htmlentities($item['title']) .'</a> ';
143
+ $content .= '</li>';
144
+ }
145
+ $content .= '<li class="rss"><a href="http://yoast.com/feed/">Subscribe with RSS</a></li>';
146
+ $content .= '<li class="email"><a href="http://yoast.com/email-blog-updates/">Subscribe by email</a></li>';
147
+ Yoast_Plugin_Admin::postbox('yoastlatest', 'Latest news from Yoast', $content);
148
+ } else {
149
+ Yoast_Plugin_Admin::postbox('yoastlatest', 'Latest news from Yoast', 'Nothing to say...');
150
+ }
151
+ }
152
+
153
+ function text_limit( $text, $limit, $finish = ' [&hellip;]') {
154
+ if( strlen( $text ) > $limit ) {
155
+ $text = substr( $text, 0, $limit );
156
+ $text = substr( $text, 0, - ( strlen( strrchr( $text,' ') ) ) );
157
+ $text .= $finish;
158
+ }
159
+ return $text;
160
+ }
161
+
162
+ function db_widget() {
163
+ require_once(ABSPATH.WPINC.'/rss.php');
164
+ if ( $rss = fetch_rss( 'http://feeds2.feedburner.com/joostdevalk' ) ) {
165
+ echo '<div class="rss-widget">';
166
+ echo '<a href="http://yoast.com/" title="Go to Yoast.com"><img src="http://cdn.yoast.com/yoast-logo-rss.png" class="alignright" alt="Yoast"/></a>';
167
+ echo '<ul>';
168
+ $rss->items = array_slice( $rss->items, 0, 3 );
169
+ foreach ( (array) $rss->items as $item ) {
170
+ echo '<li>';
171
+ echo '<a class="rsswidget" href="'.clean_url( $item['link'], $protocolls=null, 'display' ).'">'. htmlentities($item['title']) .'</a> ';
172
+ echo '<span class="rss-date">'. date('F j, Y', strtotime($item['pubdate'])) .'</span>';
173
+ echo '<div class="rssSummary">'. $this->text_limit($item['summary'],250) .'</div>';
174
+ echo '</li>';
175
+ }
176
+ echo '</ul>';
177
+ echo '<div style="border-top: 1px solid #ddd; padding-top: 10px; text-align:center;">';
178
+ echo '<a href="http://feeds2.feedburner.com/joostdevalk"><img src="'.get_bloginfo('wpurl').'/wp-includes/images/rss.png" alt=""/> Subscribe with RSS</a>';
179
+ echo ' &nbsp; &nbsp; &nbsp; ';
180
+ echo '<a href="http://yoast.com/email-blog-updates/"><img src="http://cdn.yoast.com/email_sub.png" alt=""/> Subscribe by email</a>';
181
+ echo '</div>';
182
+ echo '</div>';
183
+ }
184
+ }
185
+
186
+ function widget_setup() {
187
+ wp_add_dashboard_widget( 'yoast_db_widget' , 'The Latest news from Yoast (Tools)' , array(&$this, 'db_widget'));
188
+ }
189
+ }
190
+ }
191
+
192
+ ?>