Skip to content

Commit

Permalink
* Fix plugin action link to use admin_url() function.
Browse files Browse the repository at this point in the history
 * 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 e68d97d commit b641a0e
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 87 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
# azrcrv-shortcodes-in-comments
Shortcodes in Comments plugin for ClassicPress

Full plugin details available at [azurecurve Development](https://development.azurecurve.co.uk/classicpress-plugins/shortcodes-in-comments/)
[Shortcodes in Comments plugin for ClassicPress](https://development.azurecurve.co.uk/classicpress-plugins/shortcodes-in-comments/)
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.
113 changes: 32 additions & 81 deletions azrcrv-shortcodes-in-comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* ------------------------------------------------------------------------------
* Plugin Name: Shortcodes in Comments
* Description: Allows shortcodes to be used in comments
* 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/shortcodes-in-comments/
Expand Down Expand Up @@ -36,7 +36,6 @@
*
*/
// add actions
add_action('admin_init', 'azrcrv_sic_set_default_options');
add_action('admin_menu', 'azrcrv_sic_create_admin_menu');
add_action('admin_post_azrcrv_sic_save_options', 'azrcrv_sic_save_options');
add_action('network_admin_menu', 'azrcrv_sic_create_network_admin_menu');
Expand All @@ -46,9 +45,10 @@
// add filters
add_filter('plugin_action_links', 'azrcrv_sic_add_plugin_action_link', 10, 2);
add_filter('comments_template', 'azrcrv_sic_remove_unallowed_shortcodes');
//add_filter('comment_text', 'shortcode_unautop');
add_filter('comment_text', 'do_shortcode');
add_filter('dynamic_sidebar', 'azrcrv_sic_restore_all_shortcodes');
add_filter('codepotent_update_manager_image_path', 'azrcrv_sic_custom_image_path');
add_filter('codepotent_update_manager_image_url', 'azrcrv_sic_custom_image_url');

/**
* Load language files.
Expand All @@ -62,98 +62,49 @@ function azrcrv_sic_load_languages() {
}

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

$option_name = 'azrcrv-sic';

$new_options = array(
'allowed-shortcodes' => 'b,i,u,center,centre,strike,quote,color,size,img,url,link,ol,ul,li,code',
'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_sic_update_options($option_name, $new_options, false);
}

switch_to_blog($original_blog_id);
}else{
azrcrv_sic_update_options( $option_name, $new_options, false);
}
if (get_site_option($option_name) === false){
azrcrv_sic_update_options($option_name, $new_options, true);
}
}
//set defaults for single site
else{
azrcrv_sic_update_options($option_name, $new_options, false);
}
function azrcrv_sic_custom_image_path($path){
if (strpos($path, 'azrcrv-shortcodes-in-comments') !== 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_sic_update_options($option_name, $new_options, $is_network_site){
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_sic_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_sic_update_default_options($options, $new_options));
}
}
}
function azrcrv_sic_custom_image_url($url){
if (strpos($url, 'azrcrv-shortcodes-in-comments') !== 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_sic_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_sic_update_default_options($value, $updated_options[$key]);
} else {
$updated_options[$key] = $value;
}
}
return $updated_options;
function azrcrv_sic_get_option($option_name){

$defaults = array(
'allowed-shortcodes' => 'b,i,u,center,centre,strike,quote,color,size,img,url,link,ol,ul,li,code',
);

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

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

return $options;

}

/**
Expand All @@ -170,7 +121,7 @@ function azrcrv_sic_add_plugin_action_link($links, $file){
}

if ($file == $this_plugin){
$settings_link = '<a href="'.get_bloginfo('wpurl').'/wp-admin/admin.php?page=azrcrv-sic"><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' ,'shortcodes-in-comments').'</a>';
$settings_link = '<a href="'.admin_url('admin.php?page=azrcrv-sic').'"><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' ,'shortcodes-in-comments').'</a>';
array_unshift($links, $settings_link);
}

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_sic(){
'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_sic(){
'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_sic(){
'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_sic(){
'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 @@
=== Shortcodes in Comments ===

Description: Allows shortcodes to be used in comments.
Version: 1.1.4
Version: 1.2.0
Tags: shortcode, shortcodes, comment, comments
Author: azurecurve
Author URI: https://development.azurecurve.co.uk/
Plugin URI: https://development.azurecurve.co.uk/classicpress-plugins/shortcodes-in-comments/
Download link: https://github.com/azurecurve/azrcrv-shortcodes-in-comments/releases/download/v1.1.4/azrcrv-shortcodes-in-comments.zip
Download link: https://github.com/azurecurve/azrcrv-shortcodes-in-comments/releases/download/v1.2.0/azrcrv-shortcodes-in-comments.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-shortcodes-in-comments/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-shortcodes-in-comments/releases/tag/v1.1.4)
* Fix bug with setting of default options.
* Fix bug with plugin menu.
Expand Down Expand Up @@ -93,5 +99,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 b641a0e

Please sign in to comment.