本文整理汇总了PHP中K::wrap方法的典型用法代码示例。如果您正苦于以下问题:PHP K::wrap方法的具体用法?PHP K::wrap怎么用?PHP K::wrap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类K
的用法示例。
在下文中一共展示了K::wrap方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: select
/**
* Prints or returns an dropdown select
*/
static function select($name)
{
// $params
if (func_num_args() > 1) {
$params = func_get_arg(1);
}
if (empty($params)) {
$params = array();
}
// Load defaults
$params += array('id' => '');
// Sanitize $params[multiple], and Add brackets if the former is true
if (!empty($params['multiple'])) {
$params['multiple'] = 'multiple';
$name .= '[]';
}
// Add name
$params['name'] = $name;
// $args
if (func_num_args() > 2) {
$args = func_get_arg(2);
}
if (empty($args)) {
$args = array();
}
$args += array('default' => '', 'options' => array(), 'html_before' => '', 'html_after' => '', 'selected' => '');
// Make 'selected' an array
if ($selected = $args['selected']) {
if (!is_array($selected)) {
$selected = array($selected);
}
}
// Use 'default' is 'selected' is empty
if (!$selected) {
$selected = array($args['default']);
}
// Build options
$options = '';
foreach ($args['options'] as $value => $label) {
$options .= K::wrap($label, array('value' => $value, 'selected' => in_array($value, $selected) ? 'selected' : null), array('in' => 'option', 'return' => true));
}
// Build the input field html
$select = sprintf('%s<select %s>%s</select>%s', $args['html_before'], K::params_str($params), $options, $args['html_after']);
// Format
if (!empty($args['format'])) {
$select = str_replace(array(':select', ':name', ':id'), array($select, $name, $params['id']), $args['format']);
}
// Print or return the input field HTML
if (!empty($args['return'])) {
return $select;
} else {
echo $select;
}
}
示例2: paf_page_cb
/**
* Callback function for pages
*/
function paf_page_cb()
{
global $paf;
global $paf_options, $paf_pages, $paf_sections, $paf_tabs;
global $paf_page_tabs, $paf_page_sections, $paf_page_options;
global $paf_page, $paf_tab;
// Get submit button text (looks in: tab > page > default )
if ($paf_tab && ($submit_button_text = K::get_var('submit_button', $paf_page_tabs[$paf_tab]))) {
} else {
if ($submit_button_text = K::get_var('submit_button', $paf_pages[$paf_page])) {
} else {
$submit_button_text = __('Save Changes');
}
}
// Get reset button text (looks in: tab > page )
if ($paf_tab && ($reset_button_text = K::get_var('reset_button', $paf_page_tabs[$paf_tab]))) {
} else {
if ($reset_button_text = K::get_var('reset_button', $paf_pages[$paf_page])) {
}
}
// Start output
echo '<div class="wrap">' . '<h2>' . K::get_var('title', $paf_pages[$paf_page], $paf_page) . '</h2>';
// Print tabs links
if ($paf_page_tabs) {
echo '<h2 class="nav-tab-wrapper">';
foreach ($paf_page_tabs as $slug => $page_tab) {
printf('<a href="?page=%s&tab=%s" class="nav-tab %s">%s</a>', $paf_page, $slug, $paf_tab === $slug ? 'nav-tab-active' : '', $page_tab['menu_title']);
}
echo '</h2>';
echo '<h2>' . $paf_page_tabs[$paf_tab]['title'] . '</h2>';
}
// Print the options
echo '<form id="paf-form" class="hidden" action="' . paf_url() . '" method="post">';
// Show options that don't have sections
reset($paf_page_options);
foreach ($paf_page_options as $id => $page_option) {
if (K::get_var('section', $page_option)) {
continue;
}
paf_print_option($id);
}
// Show options that have sections
reset($paf_page_options);
foreach ($paf_page_sections as $section_id => $page_section) {
K::wrap(K::get_var('title', $page_section, $section_id), array('class' => 'title'), array('in' => 'h3'));
foreach ($paf_page_options as $id => $page_option) {
if ($section_id === K::get_var('section', $page_option)) {
paf_print_option($id);
}
}
}
// Nonce
wp_nonce_field('paf_save', 'paf_nonce');
// Submit and Reset buttons
echo '<p>';
K::input('paf_submit', array('class' => 'button button-large button-primary', 'href' => '#', 'id' => 'paf-submit', 'type' => 'submit', 'value' => $submit_button_text), array('in' => 'input'));
if ($reset_button_text) {
echo ' ';
K::wrap('Reset', array('class' => 'button button-large paf-reset', 'href' => '#', 'id' => 'paf-reset'), array('in' => 'a'));
}
echo '</p>';
echo '</form>';
// Add JS and CSS
paf_asset_js('paf', TRUE);
paf_asset_css('paf', TRUE);
echo '</div>';
}
示例3: paf_option_return_dump
/**
* Generate formatted and syntax highlighted dump
*/
function paf_option_return_dump($option_id)
{
global $paf_options;
$option = $paf_options[$option_id];
ksort($option);
array_walk_recursive($option, 'paf_htmlspecialchars_recursive');
$dump = K::wrap("\$options[ '{$option_id}' ] = " . var_export($option, true) . ';', array('class' => 'php paf-code-block'), array('html_before' => '<pre>', 'html_after' => '</pre>', 'in' => 'code', 'return' => true));
// Remove white space before 'array ('
$dump = preg_replace('/=>\\s+array \\(/s', '=> array (', $dump);
// Replace 2 spaces with 4 spaces
$pattern = "/((?: )+)(\\d+|'|array|\\))/";
$dump = preg_replace($pattern, '\\1\\1\\2', $dump);
return $dump;
}
示例4: skelet_tinyMCE_php
function skelet_tinyMCE_php($tag)
{
global $paf_shortcodes;
$select2_enqueued = false;
$protocol = is_ssl() ? 'https' : 'http';
// Head
printf('<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title></title>');
// CSS
printf('<link rel="stylesheet" href="%s" />', admin_url('css/common' . (is_rtl() ? '-rtl' : '') . '.css'));
printf('<link rel="stylesheet" href="%s" />', admin_url('css/forms' . (is_rtl() ? '-rtl' : '') . '.css'));
printf('<link rel="stylesheet" href="%s" />', site_url('wp-includes/css/dashicons' . (is_rtl() ? '-rtl' : '') . '.min.css'));
printf('<link rel="stylesheet" href="%s" />', site_url('wp-includes/css/buttons' . (is_rtl() ? '-rtl' : '') . '.min.css'));
print '<style>body { height: auto; margin: 0; min-width: 0; padding: 1em; }</style>';
paf_asset_css('paf');
// JS
printf('<script src="%s"></script>', "{$protocol}://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.1/jquery.min.js");
printf('<script src="%s"></script>', "{$protocol}://cdnjs.cloudflare.com/ajax/libs/jquery.serializeJSON/1.2.0/jquery.serializeJSON.min.js");
paf_asset_js('paf');
ob_start();
?>
<script>
var paf;
var shortcode = '';
var wrap = <?php
echo K::get_var('wrap', $paf_shortcodes[$tag]) ? 'true' : 'false';
?>
;
jQuery( document ).ready( function ( $ ) {
/* Fill content field with selected text if any */
var content = parent.tinymce.activeEditor.selection.getContent( { format : 'text' } );
$( '#content' ).val( content );
// Update shortcode
$( 'input,select,textarea', 'form' ).on( 'change keyup', function() { $( 'form' ).change(); } );
// Autoselect shortcode
$( "#shortcode" ).mouseover( function() { $( this ).select(); } );
/**
* Bind to form events
*
* - On submit: Fill the WP editor
* - On change: update the shortcode value
*/
$( 'form' ).on( 'submit change', function( e ) {
e.preventDefault();
shortcode = '';
paf = $( this ).serializeJSON().paf;
content = $( '#content' ).val();
if( 'undefined' === typeof paf ) {
paf = {};
}
// Build the shortcode
Object.keys( paf ).map( function(v) {
if( 'undefined' !== paf[ v ] && paf[ v ] ) {
shortcode += ' '
+ v
+ '="'
+ paf[ v ].toString().split().join().replace( '"', '\\"', 'g' )
+ '"'
;
}
} );
if( wrap ) {
shortcode = "[<?php
echo $tag;
?>
" + shortcode + "]"
+ content
+ "[/<?php
echo $tag;
?>
]"
;
} else {
shortcode = "[<?php
echo $tag;
?>
" + shortcode + "]";
}
// Update the demo
$( "#shortcode" ).val( shortcode );
// Fill the editor and close
if ( 'submit' === e.type ) {
parent.tinymce.activeEditor.execCommand( "mceInsertContent", false, shortcode );
parent.tinymce.activeEditor.windowManager.close( window );
}
} ).change();
} );
</script>
<?php
//.........这里部分代码省略.........