本文整理汇总了PHP中Get::state_shortcode方法的典型用法代码示例。如果您正苦于以下问题:PHP Get::state_shortcode方法的具体用法?PHP Get::state_shortcode怎么用?PHP Get::state_shortcode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Get
的用法示例。
在下文中一共展示了Get::state_shortcode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: do_shortcode
/**
* Handle Shortcode(s) in Content
* ------------------------------
*/
function do_shortcode($content)
{
if (strpos($content, '{{') === false) {
return $content;
}
foreach (Get::state_shortcode() as $key => $value) {
$key = preg_quote($key, '#');
// %[a,b,c]: option(s) ... accept `a`, `b`, or `c`
if (strpos($key, '%\\[') !== false) {
$key = preg_replace_callback('#%\\\\\\[(.*?)\\\\\\]#', function ($matches) {
return '(' . str_replace(array(',', '&\\#44;'), array('|', ','), $matches[1]) . ')';
}, $key);
}
// %s: accept any value(s) without line break(s)
// %m: accept any value(s) with/without line break(s)
// %i: accept integer number(s)
// %f: accept float number(s)
// %b: accept boolean value(s)
$key = str_replace(array('%s', '%m', '%i', '%f', '%b'), array('(.+?)', '([\\s\\S]+?)', '(\\d+?)', '((?:\\d*\\.)?\\d+?)', '\\b(TRUE|FALSE|YES|NO|Y|N|ON|OFF|true|false|yes|no|y|n|on|off|1|0|\\+|\\-)\\b'), $key);
$content = preg_replace('#(?<!`)' . $key . '|' . $key . '(?!`)#', Converter::DW($value), $content);
}
return $content;
}
示例2: function
<?php
/**
* Shortcode Manager
* -----------------
*/
Route::accept($config->manager->slug . '/shortcode', function () use($config, $speak) {
if (!Guardian::happy(1)) {
Shield::abort();
}
$shortcodes = Get::state_shortcode(null, array(), false);
$G = array('data' => $shortcodes);
Config::set(array('page_title' => $speak->shortcodes . $config->title_separator . $config->manager->title, 'cargo' => 'cargo.shortcode.php'));
if ($request = Request::post()) {
$request = Filter::apply('request:__shortcode', $request);
Guardian::checkToken($request['token']);
$data = array();
for ($i = 0, $keys = $request['key'], $count = count($keys); $i < $count; ++$i) {
if (trim($keys[$i]) !== "") {
$data[$keys[$i]] = $request['value'][$i];
}
}
$P = array('data' => $data);
File::serialize($data)->saveTo(STATE . DS . 'shortcode.txt', 0600);
Notify::success(Config::speak('notify_success_updated', $speak->shortcode));
Weapon::fire('on_shortcode_update', array($G, $P));
Guardian::kick($config->url_current);
}
Shield::lot(array('segment' => 'shortcode', 'files' => Mecha::O($shortcodes)))->attach('manager');
});
示例3: function
/**
* Include User Defined Function(s)
* --------------------------------
*/
if ($function = File::exist(SHIELD . DS . $config->shield . DS . 'functions.php')) {
include $function;
}
/**
* Handle Shortcode(s) in Content
* ------------------------------
*/
Filter::add('shortcode', function ($content) use($config, $speak) {
if (strpos($content, '{{') === false) {
return $content;
}
foreach (Get::state_shortcode() as $key => $value) {
$key = preg_quote($key, '#');
// %[a,b,c]: options ... accept `a`, `b`, or `c`
if (strpos($key, '%\\[') !== false) {
$key = preg_replace_callback('#%\\\\\\[(.*?)\\\\\\]#', function ($matches) {
return '(' . str_replace(',', '|', $matches[1]) . ')';
}, $key);
}
// %s: accept any values without line breaks
// %S: accept any values with/without line breaks
// %i: accept integer numbers
// %f: accept float numbers
// %b: accept boolean values
$key = str_replace(array('%s', '%S', '%i', '%f', '%b'), array('(.+?)', '([\\s\\S]+?)', '(\\d+?)', '((?:\\d*\\.)?\\d+?)', '\\b(TRUE|FALSE|YES|NO|ON|OFF|true|false|yes|no|on|off|1|0)\\b'), $key);
$value = str_replace(array('\\n', '\\r', '\\t'), array("\n", "\r", "\t"), $value);
$content = preg_replace('#(?<!`)' . $key . '(?!`)#', $value, $content);