This plugin adds shortcodes and an interface for inserting and editing their contents.
The editing interface depends on the Shortcake (Shortcode UI) plugin, (*1)
By default, no shortcodes are added or enabled. To enable individual shortcodes, go to Settings -> NewCity Shortcodes and check the codes you wish to enable., (*2)
The following shortcodes are included:, (*3)
custom_blockquote
local_script
inline_media
Setting default enabled plugins for a theme
This plugin sets a Wordpress option called newcity_shortcodes_options. It contains
a single array called enabled_shortcodes[]. By setting this value with PHP, most likely
in your theme's functions.php file, you can either lock the values down permanently or
set up an initial state for the theme., (*4)
Locking down the enabled plugins
// Check for existence of newcity-wp-shortcodes plugin
if ( class_exists('NewCityShortcodes')) {
// Set value for `newcity_shortcodes_options` only if it does not exist yet
function set_nc_shortcode_options() {
$options = array(
'enabled_shortcodes' => array(
'custom_blockquote',
'local_script',
'inline_media',
)
);
update_option('newcity_shortcodes_options', $options, '', 'yes');
}
// Disabled checkboxes in settings window by setting `"permanent"` to `true`
// in the plugin's options
function lock_shortcodes_settings() {
$current_options = get_option('newcity_shortcodes_options', false);
$locked_options = array_merge($current_options, array('permanent' => array('enabled_plugins')));
update_option('newcity_shortcodes_options', $locked_options, 'yes');
}
// Check if you need to set the enabled shortcodes each time a page loads
add_action('init', 'set_nc_shortcode_option');
add_action('init', 'lock_shortcodes_settings');
}
// Check for existence of newcity-wp-shortcodes plugin
if ( class_exists('NewCityShortcodes')) {
// Set value for `newcity_shortcodes_options` only if it does not exist yet
function set_nc_shortcode_options() {
$options = array(
'enabled_shortcodes' => array(
'custom_blockquote',
'local_script',
'inline_media',
)
);
if ( ! get_option('newcity_shortcodes_options', false) ) {
add_option('newcity_shortcodes_options', $options, '', 'yes');
}
}
// Check if you need to set the enabled shortcodes each time a page loads
add_action('init', 'set_nc_shortcode_option');
}
Shortcode Descriptions
Custom Blockquote Shortcode
Creates a blockquote that supports a citation field and wraps the quote body in a <p>:, (*5)
<blockquote>
<p>Quote body goes here</p>
<cite>Citation goes here</cite>
</blockquote>
Local Script Shortcode
Allows the enqueuing of javascript files that are stored in the theme folder's local-scripts folder.
This is a more secure alternative to allowing script code to be pasted directly into the content field., (*6)
By default, this shortcode will look for the script named in the source attribute in the folder set
as the default on the plugin settings page. This folder can be overridden using the path attribute,
but all script paths must be located inside the current theme's folder., (*7)
Enqueuing {theme-folder}/js/sample.js when js is the default path
[local_script script="sample" /]
Enqueuing {theme-folder}/custom-path/sample02.js when js is the default path
A replacement for the default media placement WYSIWYG tools. Inserts an image with optional caption,
wrapped in sufficient containers to allow for lots of customization., (*8)