【问题标题】:How can I add and then read attributes to a pre existing shortcode of WPBakery Page Builder如何向 WPBakery Page Builder 的预先存在的短代码添加然后读取属性
【发布时间】:2022-06-14 03:44:32
【问题描述】:

我有一个 php 代码列表,我在其中使用 vc_add_param() 函数在 vc_row 元素内的新选项卡中添加某些属性。

我使用particles.js 库来为vc_row 元素添加一些背景粒子。

vc_row元素背景添加粒子的过程是使用javascript完成的。​​

在我读取元素短代码中存在的类时,我需要一种方法来读取属性并存储它们,以便particle.js 库工作。

我的javascript:

"use strict";
jQuery(function(a) {
    a.fn.bakeryParticles= function() {
        // here I need a code to read the attributes
        }, a(".vc_row").each(function() {
        a(this).bakeryParticles()
    })
});

下面是我使用 php 存储在 row 元素中的属性示例:

vc_add_param("vc_row", array( "save_always" => true, "type" => "textarea",  "group" => "Particles", "class" => "", "heading" => "Particle size", "param_name" => "particles_size_value", "value" => "5", "description" => "Integer (0-500)" ));
vc_add_param("vc_row", array( "save_always" => true, "type" => "dropdown",  "group" => "Particles", "class" => "", "heading" => "Randomize particle size", "param_name" => "particles_size_random", "value" => array("Yes" => "true", "No" => "false")));
vc_add_param("vc_row", array( "save_always" => true, "type" => "dropdown",  "group" => "Particles", "class" => "", "heading" => "Animate particle size", "param_name" => "particles_size_anim_enable", "value" =>  array("No" => "false", "Yes" => "true") ));

问题

如何修改我的 javascript 代码,以便它可以读取新的 row 元素属性的值?

行元素如下所示:

【问题讨论】:

  • 你能展示一下这三个vc_add_param 调用实际产生的 HTML 吗?
  • @CBroe 我添加了元素的截图,注意我包含的 3 行代码只是为了让读者更容易使代码尽可能紧凑,因为 Particles 选项卡有100 多个属性选项

标签: javascript php particles.js


猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-08-01
  • 1970-01-01
  • 2018-10-11
  • 2019-04-10
  • 1970-01-01
  • 2020-06-30
相关资源
最近更新 更多