hook)
return WP_CONTENT_URL . '/plugins/' . plugin_basename(dirname($filename)). '/'.$this->ozhicon;
return $hook;
}
function config_page_styles() {
if (isset($_GET['page']) && $_GET['page'] == $this->hook) {
wp_enqueue_style('dashboard');
wp_enqueue_style('thickbox');
wp_enqueue_style('global');
wp_enqueue_style('wp-admin');
wp_enqueue_style('blogicons-admin-css', WP_CONTENT_URL . '/plugins/' . plugin_basename(dirname(__FILE__)). '/mlb_plugin_tools.css');
}
}
function register_settings_page() {
add_options_page($this->longname, $this->shortname, $this->accesslvl, $this->hook, array(&$this,'config_page'));
}
function plugin_options_url() {
return admin_url( 'options-general.php?page='.$this->hook );
}
/**
* Add a link to the settings page to the plugins list
*/
function add_action_link( $links, $file ) {
static $this_plugin;
if( empty($this_plugin) ) $this_plugin = $this->filename;
if ( $file == $this_plugin ) {
$settings_link = '' . __('Settings') . ' ';
array_unshift( $links, $settings_link );
}
return $links;
}
function config_page() {
}
function config_page_scripts() {
if (isset($_GET['page']) && $_GET['page'] == $this->hook) {
wp_enqueue_script('postbox');
wp_enqueue_script('dashboard');
wp_enqueue_script('thickbox');
wp_enqueue_script('media-upload');
}
}
/**
* Create a Checkbox input field
*/
function checkbox($id, $label) {
$options = get_option($this->optionname);
return ' '.$label.' ';
}
/**
* Create a Text input field
*/
function textinput($id, $label) {
$options = get_option($this->optionname);
return ''.$label.': ';
}
/**
* Create a potbox widget
*/
function postbox($id, $title, $content) {
?>
';
foreach ($rows as $row) {
$content .= '';
if (isset($row['id']) && $row['id'] != '')
$content .= ''.$row['label'].': ';
else
$content .= $row['label'];
if (isset($row['desc']) && $row['desc'] != '')
$content .= ''.$row['desc'].' ';
$content .= ' ';
$content .= $row['content'];
$content .= ' ';
}
$content .= '';
return $content;
}
/**
* Create a "plugin like" box.
*/
function plugin_like() {
$content = ''.__('Why not do any or all of the following:','mlbplugin').'
';
$content .= '';
$content .= '';
$this->postbox($this->hook.'like', 'Like this plugin?', $content);
}
/**
* Info box with link to the support forums.
*/
function plugin_support() {
$content = ''.__('If you have any problems with this plugin or good ideas for improvements or new features, please talk about them in the','mlbplugin').' '.__("Support forums",'mlbplugin').' .
';
$this->postbox($this->hook.'support', 'Need support?', $content);
}
/**
* Box with latest news from minilibra.com
*/
function news() {
require_once(ABSPATH.WPINC.'/rss.php');
if ( $rss = fetch_rss( 'http://feeds.minilibra.com/minilibra' ) ) {
$content = '';
if( $rss && $rss->items && is_array($rss->items) ){
$rss->items = array_slice( $rss->items, 0, 3 );
foreach ( (array) $rss->items as $item ) {
$content .= '';
$content .= ' ';
$content .= ' ';
}
}
$content .= '';
$content .= 'Subscribe by email ';
$this->postbox('miniliblatest', 'Latest news from minilibra.com', $content);
} else {
$this->postbox('miniliblatest', 'Latest news from minilibra.com', 'Nothing to say...');
}
}
/**
* Box with latest news from plugin development rollup & support forum
*/
function plugindev_support_news() {
require_once(ABSPATH.WPINC.'/rss.php');
$rss1_ok = FALSE;
$rss2_ok = FALSE;
if ( $rss1 = fetch_rss( 'http://wordpress.org/support/rss/tags/async-google-analytics' ) ) $rss1_ok = TRUE;
if ( $rss2 = fetch_rss( 'http://plugins.trac.wordpress.org/log/async-google-analytics?limit=5&mode=stop_on_copy&format=rss' ) ) $rss2_ok = TRUE;
if ( $rss1_ok || $rss2_ok ) {
$content = '';
if( $rss1_ok && $rss1->items && is_array($rss1->items) ){
$rss1->items = array_slice( $rss1->items, 0, 3 );
foreach ( (array) $rss1->items as $item ) {
$content .= '';
$content .= ' ';
$content .= ' ';
}
}
if( $rss2_ok && $rss2 && $rss2->items && is_array($rss2->items) ){
$rss2->items = array_slice( $rss2->items, 0, 3 );
foreach ( (array) $rss2->items as $item ) {
$content .= '';
$content .= ' ';
$content .= ' ';
}
}
$content .= '';
$content .= '';
$this->postbox('pluginlatest', 'Plugin development news', $content);
} else {
$this->postbox('pluginlatest', 'Plugin development news', 'Nothing to say...');
}
}
function text_limit( $text, $limit, $finish = ' […]') {
if( strlen( $text ) > $limit ) {
$text = substr( $text, 0, $limit );
$text = substr( $text, 0, - ( strlen( strrchr( $text,' ') ) ) );
$text .= $finish;
}
return $text;
}
function db_widget() {
$options = get_option('minilibdbwidget');
if (isset($_POST['minilib_removedbwidget'])) {
$options['removedbwidget'] = true;
update_option('minilibdbwidget',$options);
}
if ($options['removedbwidget']) {
echo "If you reload, this widget will be gone and never appear again, unless you decide to delete the database option 'minilibdbwidget'.";
return;
}
require_once(ABSPATH.WPINC.'/rss.php');
if ( $rss = fetch_rss( 'http://feeds.minilibra.com/minilibra/' ) ) {
echo '';
}
}
function widget_setup() {
$options = get_option('minilibdbwidget');
if (!$options['removedbwidget'])
wp_add_dashboard_widget( 'minilib_db_widget' , 'The Latest news from minilibra.com' , array(&$this, 'db_widget'));
}
}
}
?>