newcity/newcity-wp-shortcodes
Composer 安装命令:
composer require newcity/newcity-wp-shortcodes
包简介
README 文档
README
This plugin adds shortcodes and an interface for inserting and editing their contents. The editing interface depends on the Shortcake (Shortcode UI) plugin
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.
The following shortcodes are included:
- 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.
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'); }
Locking down the local scripts path
function lock_shortcodes_settings() { $current_options = get_option('newcity_shortcodes_options', false); $locked_options = array_merge($current_options, array('permanent' => array('script_path'))); update_option('newcity_shortcodes_options', $locked_options, 'yes'); }
Setting initial state for 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', ) ); 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>:
<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.
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.
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
[local_script script="sample02" path="custom-path"]
Inline Media Shortcode
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.
<div class="media { ALIGNMENT_CLASS }"> <figure> <div class="media__wrapper"> <img src="{ IMAGE_SOURCE }" alt="{ IMAGE_ALT_TAG }" /> </div> <figcaption>{ IMAGE CAPTION }</figcaption> </figure> </div>
newcity/newcity-wp-shortcodes 适用场景与选型建议
newcity/newcity-wp-shortcodes 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.84k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2017 年 12 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 newcity/newcity-wp-shortcodes 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 newcity/newcity-wp-shortcodes 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 1.84k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2017-12-19