http://www.frostjedi.com/terra/scripts/demo/jquery02.html
根据这个链接元素可以通过执行$('#container1').append($('#container2'))来移动.不幸的是,它似乎对我不起作用.有任何想法吗?
在插件激活时,我有4个在WordPress数据库中创建的表.
在卸载时我想删除表.
我已经能够写出来删除停用表.但是从我读过的内容来看,最好保留数据库表信息,直到管理员卸载而不是停用.
我一直在寻找答案,但我似乎能找到的只是停用它们.我也有我需要用它卸载的版本选项.
我正在尝试将可变产品添加到Wordpress插件Woocommerce的购物车中.
到目前为止,我已经能够添加单/简单产品:
$woocommerce->cart->add_to_cart( [product_id], [quantity] );
Run Code Online (Sandbox Code Playgroud)
但是,在函数签名中查看WC_Class:
function add_to_cart( $product_id, $quantity = 1, $variation_id = '', $variation = '', $cart_item_data = array() ) {
Run Code Online (Sandbox Code Playgroud)
我们可以清楚地看到函数允许变量_id的输入.
我已尝试过以下行的每个空值和整数组合:
$woocommerce->cart->add_to_cart( 24, 1, 28, null, null );
Run Code Online (Sandbox Code Playgroud)
等等无济于事.
我也试过自己的hacky方法试图重新创建由Woocommerce自己的产品页面发布的帖子事件,再次没有运气.
<a id="buy_v" href="#">Buy Variable Product !</a>
<script>
$('#buy_v').click(function(e) {
e.preventDefault();
addToCartV(24,26,'Red',1);
return false;
});
function addToCartV(p_id, v_id, c, q) {
$.ajax({
type: 'POST',
url: '/wp/?product=tee1&add-to-cart=variation&product_id='+p_id,
data: { 'attribute_colour': c,
'variation_id': v_id,
'quantity': q,
'product_id': p_id},
success: function(response, textStatus, jqXHR){
// log a message to the …Run Code Online (Sandbox Code Playgroud) 我已多次阅读WordPress codex,但如果涉及多个参数,仍然无法理解如何返回值.例如:
function bbp_get_topic_title( $topic_id = 0 ) {
$topic_id = bbp_get_topic_id( $topic_id );
$title = get_the_title( $topic_id );
return apply_filters( 'bbp_get_topic_title', $title, $topic_id );
}
Run Code Online (Sandbox Code Playgroud)
在上面的过滤器中,有2个参数.当我add_filter,我应该返回2值,还是只返回我需要的值?如果需要标题,以下示例是否正确?
add_filter( 'bbp_get_topic_title', 'my_topic_title', 10, 2 );
function my_topic_title( $title, $topic_id ){
$title = 'my_example_title';
return $title;
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试向基于 WordPress 的网站添加自定义 URL 结构。
例如:
example.com/machines //list all machines in a table
example.com/machines?some=params //list filtered machines in a table
example.com/machines/1 //show single machine
Run Code Online (Sandbox Code Playgroud)
数据将来自我已经开发的外部 API,通过 curl。
我无法将数据导入自定义帖子类型,因为它在许多表上进行了规范化,业务逻辑很复杂,而且 api 无论如何都被其他设备使用。
我查看了add_rewrite_rule的文档,但第二个参数让我感到困惑:
$redirect
(string) (required) The URL you would like to actually fetch
Run Code Online (Sandbox Code Playgroud)
好吧,我没有要获取的 url,我想运行一个函数,它将充当一个简单的路由器 - 获取 url 部分,调用外部 api 并返回一个包含正确数据的模板。
调用 API 很简单,但我如何实际将 url 路由到函数,以及如何加载模板(利用现有的 WordPress header.php 和 footer.php)让我感到困惑。
我在Woocommerce版本3+中创建了一个可变产品("父"产品).从Wordpress插件,我想以编程方式创建具有新属性值的产品变体("儿童"产品).
变体属性已在Woocommerce中设置.
因此,每次创建一个变体时,新属性的值也应该以编程方式创建,并在父变量产品中设置.
如何才能做到这一点?可能吗?
更新:我已经编写了更多我想要的代码行,并尝试了很多东西来解决它,使用woocommerce对象,并使用wordpress数据库在数据库中添加关于术语,termmeta,术语与post的关系的缺失数据对象 - 但没有什么能够让它发挥作用.我无法确定错误的地方 - 这就是为什么我无法提供更窄的问题 - 堆栈流更多的事情.
我想以编程方式创建一个带有两个新variante属性的变量产品("父"产品) - 所有这些都来自Wordpress插件(所以没有HTTP请求到API).
还应该动态创建这两个variante属性.
如何才能做到这一点 ?
(使用Woocommerce第3版)
更新:我已经写了更多代码,我希望,并尝试了很多东西来解决它,使用woocommerce对象,并使用wordpress数据库在数据库中添加关于术语,termmeta,术语与post的关系的缺失数据对象 - 但没有什么能够让它发挥作用.我无法确定错误的地方 - 这就是为什么我无法提供更窄的问题 - 堆栈流更多的事情.
忍受我,我正在学习. 我经常看到如下所示的片段:
<?p
$imageArray = get_field('image_field');
$imageAlt = $imageArray['alt'];
$imageURL = $imageArray['url'];
?>
Run Code Online (Sandbox Code Playgroud)
它具有教学意义,清晰有序.但是在查询数组之前是否有必要获取整个数组?我可以不在一行中定义变量吗?像下面的东西(这不起作用,我尝试过的其他变种都没有):
$imageAlt = get_field('image_field', ['alt']);
$imageURL = get_field('image_field', ['url']);
Run Code Online (Sandbox Code Playgroud) 我有一个带有本地通知的应用程序。问题是它显示了来自 Visual Studio 的“项目名称”(见截图)。我希望应用程序显示我可以指定的内容(应用程序名称)。
[![2]](https://i.stack.imgur.com/BoTGv.png)
构建您在上面看到的通知的代码是:
PendingIntent resultPendingIntent = stackBuilder.GetPendingIntent(0, (int)PendingIntentFlags.UpdateCurrent);
// Build the notification:
NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
.SetAutoCancel(true)
.SetContentIntent(resultPendingIntent)
.SetContentTitle("Button Clicked")
.SetNumber(count)
.SetSmallIcon(Resource.Drawable.ic_stat_button_click)
.SetContentText(String.Format("The button has been clicked {0} times.", count));
// Finally, publish the notification:
NotificationManager notificationManager = (NotificationManager)GetSystemServiceContext.NotificationService);
notificationManager.Notify(ButtonClickNotificationId, builder.Build());
Run Code Online (Sandbox Code Playgroud)
我正在使用 Android 7.0 进行测试,似乎本地通知文档没有显示有关这种“新”显示通知方式的任何信息。不过,我可以更改小图标。
我在 Xamarin 论坛或 Google 上找不到有关该问题的任何信息。我真的怀疑人们想在那里看到 Visual Studio 的项目名称。
我什至下载了本地通知示例项目,它显示了项目名称。
这是限制还是我错过了什么?在我看来,它太重要而不能成为限制。
wordpress ×6
php ×5
woocommerce ×2
add-filter ×1
apache ×1
arrays ×1
c# ×1
javascript ×1
jquery ×1
mysql ×1
product ×1
uninstall ×1
variations ×1
wamp ×1
windows-7 ×1
xamarin ×1