本文整理汇总了PHP中CS函数的典型用法代码示例。如果您正苦于以下问题:PHP CS函数的具体用法?PHP CS怎么用?PHP CS使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CS函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addMediaButton
public function addMediaButton($editor_id)
{
$this->enqueue();
$title = sprintf(__('Insert Shortcodes', csl18n()));
$contents = (include CS()->path('includes/builder/svg/nav-elements-solid.php'));
echo "<button href=\"#\" title=\"{$title}\" id=\"cs-insert-shortcode-button\" class=\"button cs-insert-btn\">{$contents}</button>";
}
示例2: preInit
public static function preInit()
{
global $wp_version;
if (version_compare($wp_version, '4.1', '<')) {
require_once CS()->path('includes/utility/wp-json.php');
}
}
示例3: ajax_handler
public function ajax_handler($data)
{
CS_Shortcode_Preserver::init();
if ($this->sandbox_the_content) {
CS_Shortcode_Preserver::sandbox('cs_render_the_content');
}
add_filter('cs_preserve_shortcodes_no_wrap', '__return_true');
$this->orchestrator = $this->plugin->component('Element_Orchestrator');
$this->orchestrator->load_elements();
$this->mk1 = new Cornerstone_Legacy_Renderer($this->plugin->component('Legacy_Elements'));
global $post;
if (!isset($data['post_id']) || !($post = get_post((int) $data['post_id']))) {
wp_send_json_error(array('message' => 'post_id not set'));
}
setup_postdata($post);
$this->enqueue_extractor = $this->plugin->loadComponent('Enqueue_Extractor');
$this->enqueue_extractor->start();
if (isset($data['raw_markup'])) {
$this->raw_markup = (bool) $data['raw_markup'];
}
if (!isset($data['batch'])) {
wp_send_json_error(array('message' => 'No element data recieved'));
}
$jobs = $this->batch($data['batch']);
$scripts = $this->enqueue_extractor->get_scripts();
if (is_wp_error($jobs)) {
wp_send_json_error(array('message' => $jobs->get_error_message()));
}
$result = array('jobs' => $jobs, 'scripts' => $scripts);
//Suppress PHP error output unless debugging
if (CS()->common()->isDebug()) {
return wp_send_json_success($result);
}
return @wp_send_json_success($result);
}
示例4: inlineStyles
/**
* Load generated CSS output and place style tag in wp_head
*/
public function inlineStyles()
{
ob_start();
echo '<style id="cornerstone-generated-preview-css" type="text/css">';
$settings = CS()->settings();
$options = CS()->customizer()->optionData();
extract($settings);
extract($options);
include CS()->path() . 'includes/builder/styles.php';
do_action('cornerstone_generated_preview_css');
echo '</style>';
$css = ob_get_contents();
ob_end_clean();
//
// 1. Remove comments.
// 2. Remove whitespace.
// 3. Remove starting whitespace.
//
$output = preg_replace('#/\\*.*?\\*/#s', '', $css);
// 1
$output = preg_replace('/\\s*([{}|:;,])\\s+/', '$1', $output);
// 2
$output = preg_replace('/\\s\\s+(.*)/', '$1', $output);
// 3
echo $output;
}
示例5: __construct
public function __construct()
{
/* Get all saved data and put them in self::$settings for later use */
self::$settings = CS()->settings();
/* Handles post data */
if (isset($_POST['cornerstone_options_submitted']) && isset($_POST['cornerstone-fields'])) {
if (strip_tags($_POST['cornerstone_options_submitted']) == 'submitted' && current_user_can('manage_options')) {
$fields = $_POST['cornerstone-fields'];
// Empty checkboxes
if (isset($_POST['cornerstone-checkboxes'])) {
foreach ($_POST['cornerstone-checkboxes'] as $name) {
if (!in_array($name, $fields)) {
self::$settings[$name] = array();
}
}
}
// Convert checkbox to boolean
if (isset($_POST['cornerstone-checkbox'])) {
foreach ($_POST['cornerstone-checkbox'] as $name) {
self::$settings[$name] = in_array($name, $fields);
}
}
foreach ($fields as $name => $value) {
// remove html tags
self::$settings[$name] = is_array($value) ? array_map('strip_tags', $value) : strip_tags($value);
}
update_option('cornerstone_settings', self::$settings);
}
}
}
示例6: addMediaButton
public function addMediaButton($editor_id)
{
$this->enqueue();
$title = sprintf(__('Insert Shortcodes', csl18n()));
$contents = CS()->view('svg/nav-elements-solid', false);
echo "<button href=\"#\" title=\"{$title}\" id=\"cs-insert-shortcode-button\" class=\"button cs-insert-btn\">{$contents}</button>";
}
示例7: controls
public function controls()
{
global $post;
$url = add_query_arg(array('url' => CS()->common()->getEditURL(get_the_id())), admin_url('customize.php'));
$link = '<a href="' . $url . '">' . __('Customizer', csl18n()) . '</a>';
$html = '<ul class="cs-controls"><li class="cs-control cs-control-info-box"><h4>' . __('Looking for global styling?', csl18n()) . '</h4><p>' . sprintf(__('Sitewide styles outside of the content area are managed via the %s.', csl18n()), $link) . '</p></li></ul>';
return array('customizer_message' => array('type' => 'custom-markup', 'ui' => array(), 'options' => array('html' => $html)));
}
示例8: getAllowedPostTypes
/**
* Get an array of post types allowed for Cornerstone.
* This is based on both user role, and enabled post types
* @return array
*/
public function getAllowedPostTypes()
{
$settings = CS()->settings();
$user = wp_get_current_user();
if (!empty($user) && (user_can($user, 'manage_options') || count(array_intersect($settings['permitted_roles'], (array) $user->roles)) > 0)) {
return apply_filters('cornerstone_allowed_post_types', $settings['allowed_post_types']);
}
return array();
}
示例9: preInit
public static function preInit()
{
// Disable NextGEN Resource Manager
add_filter('run_ngg_resource_manager', '__return_false');
global $wp_version;
if (version_compare($wp_version, '4.1', '<')) {
require_once CS()->path('includes/utility/wp-json.php');
}
}
示例10: setup
public function setup()
{
// Disable revision through filter
if (apply_filters('cornerstone_disable_revisions', false) || !CS()->common()->uses_cornerstone()) {
return;
}
// Save cornerstone revision
add_action('save_post', array($this, 'saveRevision'), 10, 2);
// Restore cornerstone revision
add_action('wp_restore_post_revision', array($this, 'restoreRevision'), 10, 2);
}
示例11: handler
public function handler($data)
{
global $post;
$settings = get_post_meta($post->ID, '_cornerstone_settings', true);
$settings['responsive_text'] = isset($data['elements']) ? $data['elements'] : array();
update_post_meta($post->ID, '_cornerstone_settings', $settings);
$save_handler = CS()->component('Save_Handler');
foreach ($settings['responsive_text'] as $element) {
$save_handler->append_element($element);
}
}
示例12: setup
/**
* Instantiate
*/
public function setup()
{
$this->fontIcons = $this->plugin->config('common/font-icons');
add_action('init', array($this, 'init'));
$version = CS()->version();
if (false !== strpos($version, '-alpha')) {
$this->plugin->loadComponent('Alpha');
}
if (false !== strpos($version, '-')) {
$this->plugin->loadComponent('Prerelease');
}
}
示例13: __construct
public function __construct($data, $parent = null)
{
$this->parent = $parent;
$this->data = $data;
$type = isset($this->data['_type']) ? $this->data['_type'] : 'undefined';
$this->definition = CS()->component('Element_Orchestrator')->get($type);
if (isset($data['elements'])) {
unset($this->data['elements']);
foreach ($data['elements'] as $element) {
$this->elements[] = new self($element, $this);
}
}
}
示例14: ajaxResponseDelete
public function ajaxResponseDelete()
{
if (!isset($_POST['slug'])) {
return wp_send_json_error('Invalid request.');
}
$query = new WP_Query(array('post_type' => 'cs_user_templates', 'meta_key' => 'cs_template_slug', 'meta_value' => $_POST['slug']));
if ($query->post && wp_delete_post($query->post->ID, true)) {
if (CS()->common()->isDebug()) {
return wp_send_json_success();
}
return @wp_send_json_success();
}
return wp_send_json_error('Unable to delete template.');
}
示例15: x_pairing_notice
function x_pairing_notice()
{
if (x_plugin_cornerstone_exists() && class_exists('CS')) {
if (!defined('X_CURRENT') || version_compare(CS()->version(), X_CORNERSTONE_CURRENT, '<')) {
?>
<div class="updated x-notice warning">
<p><strong>IMPORTANT: Please update Cornerstone</strong>. You are using a newer version of X that may not be compatible. After updating, please ensure that you have cleared out your browser cache and any caching plugins you may be using. This message will self destruct upon updating Cornerstone.</p>
</div>
<?php
}
}
}