Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/469.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Wordpress快捷码弹出窗口包括wp函数_Javascript_Php_Wordpress_Popup_Shortcode - Fatal编程技术网

Javascript Wordpress快捷码弹出窗口包括wp函数

Javascript Wordpress快捷码弹出窗口包括wp函数,javascript,php,wordpress,popup,shortcode,Javascript,Php,Wordpress,Popup,Shortcode,我使用本教程在tinymce中添加了一个快捷键 这一切都很好 现在我想在弹出文件中包含一些wordpress函数,以便使用“colorpicker”、“mediainclude”等 这是行不通的。在我的弹出文件中,我尝试包含这些脚本以利用它,但它不起作用: $absolute_path = __FILE__; $path_to_file = explode( 'wp-content', $absolute_path ); $path_to_wp = $path_to_file[0]; // Ac

我使用本教程在tinymce中添加了一个快捷键 这一切都很好

现在我想在弹出文件中包含一些wordpress函数,以便使用“colorpicker”、“mediainclude”等

这是行不通的。在我的弹出文件中,我尝试包含这些脚本以利用它,但它不起作用:

$absolute_path = __FILE__;
$path_to_file = explode( 'wp-content', $absolute_path );
$path_to_wp = $path_to_file[0];
// Access WordPress
require_once( $path_to_wp . '/wp-load.php' );
wp_enqueue_script('media-upload');
wp_enqueue_style('thickbox');
wp_enqueue_style( 'wp-color-picker' );

我昨晚把它修好了。我想你忘了将颜色选择器等的样式排队。这就是我将脚本排队的方式

<?php 
if ( !current_user_can('publish_posts') ) exit();

wp_enqueue_script( 
    array( 
        'iris', 
        'json2', 
        'jquery', 
        'jquery-ui-core', 
        'jquery-ui-sortable',
        'jquery-ui-tabs',
        'jquery-ui-slider',
        'jquery-ui-datepicker',
        'jquery-ui-autocomplete',
        'tiny-mce-popup',
        'shortcodes',
        'media-upload', 
        'thickbox',
    )  
); 
    wp_enqueue_style( 'wp-color-picker', false, true );          
    wp_enqueue_script( 'wp-color-picker', false, true ); 
?>

不知道为什么,但最后两个只有在这样做时才起作用

下面是颜色选择器的脚本

<script>
jQuery(document).ready(function($){
var myOptions = {
    // you can declare a default color here,
    // or in the data-default-color attribute on the input
    defaultColor: false,
    // a callback to fire whenever the color changes to a valid color
    change: function(event, ui){},
    // a callback to fire when the input is emptied or an invalid color
    clear: function() {},
    // hide the color picker controls on load
    hide: true,
    // show a group of common colors beneath the square
    // or, supply an array of colors to customize further
    palettes: true
};

$('.my-color-field').wpColorPicker(myOptions);
});
</script>
<span class="wp-picker-input-wrap">
  <input type="text" class="my-color-field" style="display: none;">
</span>

jQuery(文档).ready(函数($){
变量myOptions={
//您可以在此处声明默认颜色,
//或者在输入的数据默认颜色属性中
defaultColor:false,
//每当颜色更改为有效颜色时激发的回调
更改:函数(事件,ui){},
//当输入为空或颜色无效时激发的回调
清除:函数(){},
//加载时隐藏颜色选择器控件
隐藏:是的,
//在正方形下方显示一组常用颜色
//或者,提供一系列颜色以进一步定制
调色板:正确
};
$('.my color field').wpColorPicker(myOptions);
});
和HTML来显示颜色选择器

<script>
jQuery(document).ready(function($){
var myOptions = {
    // you can declare a default color here,
    // or in the data-default-color attribute on the input
    defaultColor: false,
    // a callback to fire whenever the color changes to a valid color
    change: function(event, ui){},
    // a callback to fire when the input is emptied or an invalid color
    clear: function() {},
    // hide the color picker controls on load
    hide: true,
    // show a group of common colors beneath the square
    // or, supply an array of colors to customize further
    palettes: true
};

$('.my-color-field').wpColorPicker(myOptions);
});
</script>
<span class="wp-picker-input-wrap">
  <input type="text" class="my-color-field" style="display: none;">
</span>


如果对你有效,请告诉我。这些都在我的window.php文件中,该文件用于填充thickbox窗口中的内容等。

您是否找到了解决方案?我正在尝试在一个厚盒子里使用颜色选择器,但它没有开火。