Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…eleases/tag/v1.2.0)

 * Fix plugin action link to use admin_url() function.
 * Rewrite option handling so defaults not stored in database on plugin initialisation.
 * Add plugin icon and banner.
 * Update azurecurve plugin menu.
  • Loading branch information
azurecurve committed Oct 29, 2020
1 parent 05b2e18 commit 2cfbe1b
Show file tree
Hide file tree
Showing 10 changed files with 76 additions and 88 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
# azrcrv-rss-suffix
RSS Suffix plugin for ClassicPress

Full plugin details available at [azurecurve Development](https://development.azurecurve.co.uk/classicpress-plugins/rss-suffix/)
[RSS Suffix plugin for ClassicPress](https://development.azurecurve.co.uk/classicpress-plugins/rss-suffix/)
2 changes: 2 additions & 0 deletions assets/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
// Whereof one cannot speak, thereof one must be silent.
Binary file added assets/pluginimages/banner-1544x500.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/pluginimages/banner-772x250.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/pluginimages/icon-128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/pluginimages/icon-256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions assets/pluginimages/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
// Whereof one cannot speak, thereof one must be silent.
116 changes: 34 additions & 82 deletions azrcrv-rss-suffix.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* ------------------------------------------------------------------------------
* Plugin Name: RSS Suffix
* Description: Provides opposite rss feed to that configured in ClassicPress
* Version: 1.1.4
* Version: 1.2.0
* Author: azurecurve
* Author URI: https://development.azurecurve.co.uk/classicpress-plugins/
* Plugin URI: https://development.azurecurve.co.uk/classicpress-plugins/rss-suffix/
Expand Down Expand Up @@ -36,7 +36,6 @@
*
*/
// add actions
add_action('admin_init', 'azrcrv_rsss_set_default_options');
add_action('admin_post_save_options', 'azrcrv_rsss_process_options');
add_action('network_admin_edit_save_network_options', 'azrcrv_rsss_process_network_options');
add_action('admin_menu', 'azrcrv_rsss_create_admin_menu');
Expand All @@ -47,6 +46,8 @@
add_filter('the_excerpt_rss', 'azrcrv_rsss_append_rss_suffix');
add_filter('the_content', 'azrcrv_rsss_append_rss_suffix');
add_filter('plugin_action_links', 'azrcrv_rsss_add_plugin_action_link', 10, 2);
add_filter('codepotent_update_manager_image_path', 'azrcrv_rsss_custom_image_path');
add_filter('codepotent_update_manager_image_url', 'azrcrv_rsss_custom_image_url');

/**
* Load language files.
Expand All @@ -69,7 +70,7 @@ function azrcrv_rsss_append_rss_suffix($content){
global $post;

if(is_feed()){
$options = get_option('azrcrv-rss');
$options = azrcrv_rsss_get_option('azrcrv-rss');

$rss_suffix = '';
if (strlen($options['rss_suffix']) > 0){
Expand All @@ -95,98 +96,49 @@ function azrcrv_rsss_append_rss_suffix($content){
}

/**
* Set default options
* Custom plugin image path.
*
* @since 1.0.0
* @since 1.2.0
*
*/
function azrcrv_rsss_set_default_options($networkwide){

$option_name = 'azrcrv-rss';
$old_option_name = 'azc-rsss-settings';

$new_options = array(
'rss_suffix' => '<p>Read original post <a href=\'$post_url\'>$post_title</a> at <a href=\'$site_url\'>$site_title|$site_tagline</a></p>',
'updated' => strtotime('2020-04-04'),
);

// set defaults for multi-site
if (function_exists('is_multisite') && is_multisite()){
// check if it is a network activation - if so, run the activation function for each blog id
if ($networkwide){
global $wpdb;

$blog_ids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs");
$original_blog_id = get_current_blog_id();

foreach ($blog_ids as $blog_id){
switch_to_blog($blog_id);

azrcrv_rsss_update_options($option_name, $new_options, false, $old_option_name);
}

switch_to_blog($original_blog_id);
}else{
azrcrv_rsss_update_options( $option_name, $new_options, false, $old_option_name);
}
if (get_site_option($option_name) === false){
azrcrv_rsss_update_options($option_name, $new_options, true, $old_option_name);
}
}
//set defaults for single site
else{
azrcrv_rsss_update_options($option_name, $new_options, false, $old_option_name);
}
function azrcrv_rsss_custom_image_path($path){
if (strpos($path, 'azrcrv-rss-suffix') !== false){
$path = plugin_dir_path(__FILE__).'assets/pluginimages';
}
return $path;
}

/**
* Update options.
* Custom plugin image url.
*
* @since 1.1.3
* @since 1.2.0
*
*/
function azrcrv_rsss_update_options($option_name, $new_options, $is_network_site, $old_option_name){
if ($is_network_site == true){
if (get_site_option($option_name) === false){
add_site_option($option_name, $new_options);
}else{
$options = get_site_option($option_name);
if (!isset($options['updated']) OR $options['updated'] < $new_options['updated'] ){
$options['updated'] = $new_options['updated'];
update_site_option($option_name, azrcrv_rsss_update_default_options($options, $new_options));
}
}
}else{
if (get_option($option_name) === false){
add_option($option_name, $new_options);
}else{
$options = get_option($option_name);
if (!isset($options['updated']) OR $options['updated'] < $new_options['updated'] ){
$options['updated'] = $new_options['updated'];
update_option($option_name, azrcrv_rsss_update_default_options($options, $new_options));
}
}
}
function azrcrv_rsss_custom_image_url($url){
if (strpos($url, 'azrcrv-rss-suffix') !== false){
$url = plugin_dir_url(__FILE__).'assets/pluginimages';
}
return $url;
}

/**
* Add default options to existing options.
* Get options including defaults.
*
* @since 1.1.3
* @since 1.2.0
*
*/
function azrcrv_rsss_update_default_options( &$default_options, $current_options ) {
$default_options = (array) $default_options;
$current_options = (array) $current_options;
$updated_options = $current_options;
foreach ($default_options as $key => &$value) {
if (is_array( $value) && isset( $updated_options[$key])){
$updated_options[$key] = azrcrv_rsss_update_default_options($value, $updated_options[$key]);
} else {
$updated_options[$key] = $value;
}
}
return $updated_options;
function azrcrv_rsss_get_option($option_name){

$defaults = array(
'rss_suffix' => '<p>Read original post <a href=\'$post_url\'>$post_title</a> at <a href=\'$site_url\'>$site_title|$site_tagline</a></p>',
);

$options = get_option($option_name, $defaults);

$options = wp_parse_args($options, $defaults);

return $options;

}

/**
Expand All @@ -203,7 +155,7 @@ function azrcrv_rsss_add_plugin_action_link($links, $file){
}

if ($file == $this_plugin){
$settings_link = '<a href="'.get_bloginfo('wpurl').'/wp-admin/admin.php?page=azrcrv-rsss"><img src="'.plugins_url('/pluginmenu/images/Favicon-16x16.png', __FILE__).'" style="padding-top: 2px; margin-right: -5px; height: 16px; width: 16px;" alt="azurecurve" />'.esc_html__('Settings' ,'rss-suffix').'</a>';
$settings_link = '<a href="'.admin_url('admin.php?page=azrcrv-rsss').'"><img src="'.plugins_url('/pluginmenu/images/Favicon-16x16.png', __FILE__).'" style="padding-top: 2px; margin-right: -5px; height: 16px; width: 16px;" alt="azurecurve" />'.esc_html__('Settings' ,'rss-suffix').'</a>';
array_unshift($links, $settings_link);
}

Expand Down Expand Up @@ -239,7 +191,7 @@ function azrcrv_rsss_settings(){
}

// Retrieve plugin configuration options from database
$options = get_option('azrcrv-rss');
$options = azrcrv_rsss_get_option('azrcrv-rss');
?>
<div id="azrcrv-rss-general" class="wrap">
<fieldset>
Expand Down
28 changes: 28 additions & 0 deletions pluginmenu/menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,13 @@ function azrcrv_populate_plugin_menu_rsss(){
'retired' => 0,
'updated' => '2020-04-04',
),
'Gallery From Folder' => array(
'plugin_link' => 'azrcrv-gallery-from-folder/azrcrv-gallery-from-folder.php',
'admin_URL' => 'admin.php?page=azrcrv-gff',
'dev_URL' => 'https://development.azurecurve.co.uk/classicpress-plugins/gallery-from-folder/',
'retired' => 0,
'updated' => '2020-10-26',
),
'Icons' => array(
'plugin_link' => 'azrcrv-icons/azrcrv-icons.php',
'admin_URL' => 'admin.php?page=azrcrv-i',
Expand Down Expand Up @@ -261,6 +268,13 @@ function azrcrv_populate_plugin_menu_rsss(){
'retired' => 0,
'updated' => '2020-04-04',
),
'Nearby' => array(
'plugin_link' => 'azrcrv-nearby/azrcrv-nearby.php',
'admin_URL' => 'admin.php?page=azrcrv-n',
'dev_URL' => 'https://development.azurecurve.co.uk/classicpress-plugins/nearby/',
'retired' => 0,
'updated' => '2020-08-05',
),
'Page Index' => array(
'plugin_link' => 'azrcrv-page-index/azrcrv-page-index.php',
'admin_URL' => 'admin.php?page=azrcrv-pi',
Expand Down Expand Up @@ -331,6 +345,13 @@ function azrcrv_populate_plugin_menu_rsss(){
'retired' => 0,
'updated' => '2020-04-04',
),
'Snippets' => array(
'plugin_link' => 'azrcrv-snippets/azrcrv-snippets.php',
'admin_URL' => 'admin.php?page=azrcrv-s',
'dev_URL' => 'https://development.azurecurve.co.uk/classicpress-plugins/snippets/',
'retired' => 0,
'updated' => '2020-10-28',
),
'Tag Cloud' => array(
'plugin_link' => 'azrcrv-tag-cloud/azrcrv-tag-cloud.php',
'admin_URL' => 'admin.php?page=azrcrv-tc',
Expand All @@ -345,6 +366,13 @@ function azrcrv_populate_plugin_menu_rsss(){
'retired' => 0,
'updated' => '2020-04-04',
),
'Taxonomy Order' => array(
'plugin_link' => 'azrcrv-taxonomy-order/azrcrv-taxonomy-order.php',
'admin_URL' => 'admin.php?page=azrcrv-to',
'dev_URL' => 'https://development.azurecurve.co.uk/classicpress-plugins/taxonomy-order/',
'retired' => 0,
'updated' => '2020-10-28',
),
'Theme Switcher' => array(
'plugin_link' => 'azrcrv-theme-switcher/azrcrv-theme-switcher.php',
'admin_URL' => 'admin.php?page=azrcrv-ts',
Expand Down
12 changes: 9 additions & 3 deletions readme.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
=== RSS Suffix ===

Description: Appends a suffix (such as a copyright notice or link back) to the RSS feed.
Version: 1.1.4
Version: 1.2.0
Tags: rss, feed
Author: azurecurve
Author URI: https://development.azurecurve.co.uk/
Plugin URI: https://development.azurecurve.co.uk/classicpress-plugins/rss-suffix/
Download link: https://github.com/azurecurve/azrcrv-rss-suffix/releases/download/v1.1.4/azrcrv-rss-suffix.zip
Download link: https://github.com/azurecurve/azrcrv-rss-suffix/releases/download/v1.2.0/azrcrv-rss-suffix.zip
Donate link: https://development.azurecurve.co.uk/support-development/
Requires PHP: 5.6
Requires: 1.0.0
Expand Down Expand Up @@ -49,6 +49,12 @@ This plugin is developed for ClassicPress, but will likely work on WordPress.

# Changelog

### [Version 1.2.0](https://github.com/azurecurve/azrcrv-rss-suffix/releases/tag/v1.2.0)
* Fix plugin action link to use admin_url() function.
* Rewrite option handling so defaults not stored in database on plugin initialisation.
* Add plugin icon and banner.
* Update azurecurve plugin menu.

### [Version 1.1.4](https://github.com/azurecurve/azrcrv-rss-suffix/releases/tag/v1.1.4)
* Fix bug with setting of default options.
* Fix bug with plugin menu.
Expand Down Expand Up @@ -92,5 +98,5 @@ Some of the top plugins available from **azurecurve** are:
* [Breadcrumbs](https://development.azurecurve.co.uk/classicpress-plugins/breadcrumbs/)
* [Series Index](https://development.azurecurve.co.uk/classicpress-plugins/series-index/)
* [To Twitter](https://development.azurecurve.co.uk/classicpress-plugins/to-twitter/)
* [Theme Switches](https://development.azurecurve.co.uk/classicpress-plugins/theme-switcher/)
* [Theme Switcher](https://development.azurecurve.co.uk/classicpress-plugins/theme-switcher/)
* [Toggle Show/Hide](https://development.azurecurve.co.uk/classicpress-plugins/toggle-showhide/)

0 comments on commit 2cfbe1b

Please sign in to comment.