Açıklama Yok

divi-builder.php 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  1. <?php
  2. function berocket_apl_et_builder_ready() {
  3. if( class_exists('ET_Builder_Module') ) {
  4. class ET_Builder_Module_brands_by_name extends ET_Builder_Module {
  5. function init() {
  6. $this->name = __( 'Brands by Name', 'brands-for-woocommerce' );
  7. $this->slug = 'et_pb_brands_by_name';
  8. $this->whitelisted_fields = array(
  9. 'image',
  10. 'imgh',
  11. 'imgw',
  12. 'text',
  13. 'column',
  14. 'position',
  15. 'style',
  16. );
  17. $this->fields_defaults = array(
  18. 'image' => array('off'),
  19. 'imgh' => array( '64px', 'add_default_setting' ),
  20. 'text' => array('on', 'add_default_setting'),
  21. 'column' => array( 2, 'add_default_setting' ),
  22. 'position' => array( '1' ),
  23. 'style' => array( 'vertical' ),
  24. );
  25. }
  26. function get_fields() {
  27. $fields = array(
  28. 'image' => array(
  29. "label" => esc_html__( 'Display image', 'brands-for-woocommerce' ),
  30. 'type' => 'yes_no_button',
  31. 'options' => array(
  32. 'off' => esc_html__( "No", 'et_builder' ),
  33. 'on' => esc_html__( 'Yes', 'et_builder' ),
  34. ),
  35. ),
  36. 'imgh' => array(
  37. "label" => esc_html__( 'Maximum image height', 'brands-for-woocommerce' ),
  38. 'type' => 'text',
  39. ),
  40. 'imgw' => array(
  41. "label" => esc_html__( 'Maximum image width', 'brands-for-woocommerce' ),
  42. 'type' => 'text',
  43. ),
  44. 'text' => array(
  45. "label" => esc_html__( 'Display name', 'brands-for-woocommerce' ),
  46. 'type' => 'yes_no_button',
  47. 'options' => array(
  48. 'off' => esc_html__( "No", 'et_builder' ),
  49. 'on' => esc_html__( 'Yes', 'et_builder' ),
  50. ),
  51. ),
  52. 'column' => array(
  53. "label" => esc_html__( 'Columns', 'brands-for-woocommerce' ),
  54. 'type' => 'number',
  55. ),
  56. 'position' => array(
  57. "label" => esc_html__( 'Position', 'brands-for-woocommerce' ),
  58. 'type' => 'select',
  59. 'options' => array(
  60. '1' => esc_html__( 'Name after image', 'brands-for-woocommerce' ),
  61. '2' => esc_html__( 'Name before image', 'brands-for-woocommerce' ),
  62. '3' => esc_html__( 'Name under image', 'brands-for-woocommerce' ),
  63. '4' => esc_html__( 'Show only on letter click', 'brands-for-woocommerce' ),
  64. ),
  65. ),
  66. 'style' => array(
  67. "label" => esc_html__( 'Style', 'brands-for-woocommerce' ),
  68. 'type' => 'select',
  69. 'options' => array(
  70. 'vertical' => esc_html__( 'Vertical', 'brands-for-woocommerce' ),
  71. 'horizontal' => esc_html__( 'Horizontal', 'brands-for-woocommerce' ),
  72. ),
  73. ),
  74. 'color' => array(
  75. "label" => esc_html__( 'Color', 'brands-for-woocommerce' ),
  76. 'type' => 'color',
  77. 'options' => array(
  78. 'vertical' => esc_html__( 'Vertical', 'brands-for-woocommerce' ),
  79. 'horizontal' => esc_html__( 'Horizontal', 'brands-for-woocommerce' ),
  80. ),
  81. ),
  82. );
  83. return $fields;
  84. }
  85. function shortcode_callback( $atts, $content = null, $function_name = '' ) {
  86. $atts['image'] = ! empty($atts['image']) && $atts['image'] == 'on';
  87. $atts['text'] = empty($atts['text']) || $atts['text'] == 'on';
  88. $BeRocket_product_brand = BeRocket_product_brand::getInstance();
  89. return $BeRocket_product_brand->brands_catalog_shortcode($atts);
  90. }
  91. protected function _add_additional_border_fields() {
  92. parent::_add_additional_border_fields();
  93. $this->advanced_options["border"]['css'] = array(
  94. 'main' => array(
  95. 'border_radii' => "%%order_class%% .et_pb_image_wrap",
  96. 'border_styles' => "%%order_class%% .et_pb_image_wrap",
  97. )
  98. );
  99. }
  100. }
  101. new ET_Builder_Module_brands_by_name;
  102. class ET_Builder_Module_brands_list extends ET_Builder_Module {
  103. function init() {
  104. $this->name = __( 'Brands List', 'brands-for-woocommerce' );
  105. $this->slug = 'et_pb_brands_list';
  106. $this->whitelisted_fields = array(
  107. 'use_image',
  108. 'imgh',
  109. 'text',
  110. 'hide_empty',
  111. 'slider',
  112. 'per_row',
  113. 'count',
  114. 'orderby',
  115. 'padding',
  116. 'border_color',
  117. 'border_width',
  118. );
  119. $this->fields_defaults = array(
  120. 'use_image' => array('on', 'add_default_setting'),
  121. 'imgh' => array( '64px', 'add_default_setting' ),
  122. 'text' => array('off', 'add_default_setting'),
  123. 'hide_empty' => array('on', 'add_default_setting'),
  124. 'slider' => array('off', 'add_default_setting'),
  125. 'per_row' => array('3', 'add_default_setting'),
  126. 'count' => array('', 'add_default_setting'),
  127. 'orderby' => array('name', 'add_default_setting'),
  128. 'padding' => array('3px', 'add_default_setting'),
  129. 'border_color' => array('', 'add_default_setting'),
  130. 'border_width' => array('', 'add_default_setting'),
  131. );
  132. }
  133. function get_fields() {
  134. $fields = array(
  135. 'title' => array(
  136. "label" => esc_html__( 'Title', 'brands-for-woocommerce' ),
  137. 'type' => 'text',
  138. ),
  139. 'use_image' => array(
  140. "label" => esc_html__( 'Display image', 'brands-for-woocommerce' ),
  141. 'type' => 'yes_no_button',
  142. 'options' => array(
  143. 'off' => esc_html__( "No", 'et_builder' ),
  144. 'on' => esc_html__( 'Yes', 'et_builder' ),
  145. ),
  146. ),
  147. 'imgh' => array(
  148. "label" => esc_html__( 'Image height', 'brands-for-woocommerce' ),
  149. 'type' => 'text',
  150. ),
  151. 'use_name' => array(
  152. "label" => esc_html__( 'Display name', 'brands-for-woocommerce' ),
  153. 'type' => 'yes_no_button',
  154. 'options' => array(
  155. 'off' => esc_html__( "No", 'et_builder' ),
  156. 'on' => esc_html__( 'Yes', 'et_builder' ),
  157. ),
  158. ),
  159. 'hide_empty' => array(
  160. "label" => esc_html__( 'Hide brands without products', 'brands-for-woocommerce' ),
  161. 'type' => 'yes_no_button',
  162. 'options' => array(
  163. 'off' => esc_html__( "No", 'et_builder' ),
  164. 'on' => esc_html__( 'Yes', 'et_builder' ),
  165. ),
  166. ),
  167. 'slider' => array(
  168. "label" => esc_html__( 'Display as slider', 'brands-for-woocommerce' ),
  169. 'type' => 'yes_no_button',
  170. 'options' => array(
  171. 'off' => esc_html__( "No", 'et_builder' ),
  172. 'on' => esc_html__( 'Yes', 'et_builder' ),
  173. ),
  174. ),
  175. 'per_row' => array(
  176. "label" => esc_html__( 'Brands per row', 'brands-for-woocommerce' ),
  177. 'type' => 'number',
  178. ),
  179. 'count' => array(
  180. "label" => esc_html__( 'Number of brands', 'brands-for-woocommerce' ),
  181. 'type' => 'number',
  182. ),
  183. 'orderby' => array(
  184. "label" => esc_html__( 'Order By', 'brands-for-woocommerce' ),
  185. 'type' => 'select',
  186. 'options' => array(
  187. 'name' => esc_html__( 'Brand name', 'brands-for-woocommerce' ),
  188. 'count' => esc_html__( 'Count of products', 'brands-for-woocommerce' ),
  189. ),
  190. ),
  191. 'padding' => array(
  192. "label" => esc_html__( 'Padding around brands', 'brands-for-woocommerce' ),
  193. 'type' => 'text',
  194. ),
  195. 'border_color' => array(
  196. "label" => esc_html__( 'Border color', 'brands-for-woocommerce' ),
  197. 'type' => 'color',
  198. ),
  199. 'border_width' => array(
  200. "label" => esc_html__( 'Border width', 'brands-for-woocommerce' ),
  201. 'type' => 'text',
  202. ),
  203. );
  204. return $fields;
  205. }
  206. function shortcode_callback( $atts, $content = null, $function_name = '' ) {
  207. $atts['use_image'] = empty($atts['use_image']) || $atts['use_image'] == 'on';
  208. $atts['use_name'] = ! empty($atts['use_name']) && $atts['use_name'] == 'on';
  209. $atts['hide_empty'] = empty($atts['hide_empty']) || $atts['hide_empty'] == 'on';
  210. $atts['slider'] = ! empty($atts['slider']) && $atts['slider'] == 'on';
  211. $BeRocket_product_brand = BeRocket_product_brand::getInstance();
  212. return $BeRocket_product_brand->brands_list_shortcode($atts);
  213. }
  214. protected function _add_additional_border_fields() {
  215. }
  216. }
  217. new ET_Builder_Module_brands_list;
  218. class ET_Builder_Module_brands_products extends ET_Builder_Module {
  219. function init() {
  220. $this->name = __( 'Brands Products', 'brands-for-woocommerce' );
  221. $this->slug = 'et_pb_brands_products';
  222. $this->whitelisted_fields = array(
  223. 'brand_id',
  224. 'brand_slug',
  225. 'columns',
  226. 'orderby',
  227. 'order',
  228. );
  229. $this->fields_defaults = array(
  230. 'brand_id' => array('', 'add_default_setting'),
  231. 'brand_slug' => array('', 'add_default_setting'),
  232. 'columns' => array( '4', 'add_default_setting' ),
  233. 'orderby' => array('title', 'add_default_setting'),
  234. 'order' => array('desc', 'add_default_setting'),
  235. );
  236. }
  237. function get_fields() {
  238. $fields = array(
  239. 'brand_id' => array(
  240. "label" => esc_html__( 'brand ID(s)', 'brands-for-woocommerce' ),
  241. 'type' => 'text',
  242. ),
  243. 'brand_slug' => array(
  244. "label" => esc_html__( 'brand slug(s)', 'brands-for-woocommerce' ),
  245. 'type' => 'text',
  246. ),
  247. 'columns' => array(
  248. "label" => esc_html__( 'count of columns for product list', 'brands-for-woocommerce' ),
  249. 'type' => 'number',
  250. ),
  251. 'orderby' => array(
  252. "label" => esc_html__( 'Order By', 'brands-for-woocommerce' ),
  253. 'type' => 'select',
  254. 'options' => array(
  255. 'title' => esc_html__( 'Order by title', 'brands-for-woocommerce' ),
  256. 'name' => esc_html__( 'Order by post name (post slug)', 'brands-for-woocommerce' ),
  257. 'date' => esc_html__( 'Order by date', 'brands-for-woocommerce' ),
  258. 'modified' => esc_html__( 'Order by last modified date', 'brands-for-woocommerce' ),
  259. 'rand' => esc_html__( 'Random order', 'brands-for-woocommerce' ),
  260. ),
  261. ),
  262. 'order' => array(
  263. "label" => esc_html__( 'Order Type', 'brands-for-woocommerce' ),
  264. 'type' => 'select',
  265. 'options' => array(
  266. 'asc' => esc_html__( 'ascending', 'brands-for-woocommerce' ),
  267. 'desc' => esc_html__( 'descending', 'brands-for-woocommerce' ),
  268. ),
  269. ),
  270. );
  271. return $fields;
  272. }
  273. function shortcode_callback( $atts, $content = null, $function_name = '' ) {
  274. $BeRocket_product_brand = BeRocket_product_brand::getInstance();
  275. return $BeRocket_product_brand->products_shortcode($atts);
  276. }
  277. protected function _add_additional_border_fields() {
  278. }
  279. }
  280. new ET_Builder_Module_brands_products;
  281. class ET_Builder_Module_product_brands_info extends ET_Builder_Module {
  282. function init() {
  283. $this->name = __( 'Brand info for product page', 'brands-for-woocommerce' );
  284. $this->slug = 'et_pb_product_brands_info';
  285. $this->whitelisted_fields = array(
  286. 'type',
  287. 'product_id',
  288. );
  289. $this->fields_defaults = array(
  290. 'type' => array('name,image,description', 'add_default_setting'),
  291. 'product_id' => array('', 'add_default_setting'),
  292. );
  293. }
  294. function get_fields() {
  295. $fields = array(
  296. 'type' => array(
  297. "label" => esc_html__( 'Data type', 'brands-for-woocommerce' ),
  298. 'type' => 'text',
  299. ),
  300. 'product_id' => array(
  301. "label" => esc_html__( 'Product ID', 'brands-for-woocommerce' ),
  302. 'type' => 'number',
  303. ),
  304. );
  305. return $fields;
  306. }
  307. function shortcode_callback( $atts, $content = null, $function_name = '' ) {
  308. $BeRocket_product_brand = BeRocket_product_brand::getInstance();
  309. return $BeRocket_product_brand->shortcode_product_brands_info($atts);
  310. }
  311. protected function _add_additional_border_fields() {
  312. }
  313. }
  314. new ET_Builder_Module_product_brands_info;
  315. class ET_Builder_Module_brands_info extends ET_Builder_Module {
  316. function init() {
  317. $this->name = __( 'Brand info', 'brands-for-woocommerce' );
  318. $this->slug = 'et_pb_brands_info';
  319. $this->whitelisted_fields = array(
  320. 'type',
  321. 'id',
  322. );
  323. $this->fields_defaults = array(
  324. 'type' => array('name,image,description', 'add_default_setting'),
  325. 'id' => array('', 'add_default_setting'),
  326. );
  327. }
  328. function get_fields() {
  329. $fields = array(
  330. 'type' => array(
  331. "label" => esc_html__( 'Data type', 'brands-for-woocommerce' ),
  332. 'type' => 'text',
  333. ),
  334. 'id' => array(
  335. "label" => esc_html__( 'Brand ID', 'brands-for-woocommerce' ),
  336. 'type' => 'number',
  337. ),
  338. );
  339. return $fields;
  340. }
  341. function shortcode_callback( $atts, $content = null, $function_name = '' ) {
  342. $BeRocket_product_brand = BeRocket_product_brand::getInstance();
  343. return $BeRocket_product_brand->shortcode_brands_info($atts);
  344. }
  345. protected function _add_additional_border_fields() {
  346. }
  347. }
  348. new ET_Builder_Module_brands_info;
  349. class ET_Builder_Module_brands_product_thumbnail extends ET_Builder_Module {
  350. function init() {
  351. $this->name = __( 'Brand thumbnail', 'brands-for-woocommerce' );
  352. $this->slug = 'et_pb_brands_product_thumbnail';
  353. $this->fb_support = true;
  354. $this->whitelisted_fields = array(
  355. 'post_id',
  356. 'width',
  357. 'height',
  358. 'position',
  359. );
  360. $this->fields_defaults = array(
  361. 'post_id' => array('', 'add_default_setting'),
  362. 'width' => array('35%', 'add_default_setting'),
  363. 'height' => array('', 'add_default_setting'),
  364. 'position' => array('right', 'add_default_setting'),
  365. );
  366. }
  367. function get_fields() {
  368. $fields = array(
  369. 'post_id' => array(
  370. "label" => esc_html__( 'Product ID', 'brands-for-woocommerce' ),
  371. 'type' => 'number',
  372. ),
  373. 'width' => array(
  374. "label" => esc_html__( 'Data type', 'brands-for-woocommerce' ),
  375. 'type' => 'text',
  376. ),
  377. 'height' => array(
  378. "label" => esc_html__( 'Data type', 'brands-for-woocommerce' ),
  379. 'type' => 'text',
  380. ),
  381. 'position' => array(
  382. "label" => esc_html__( 'Position', 'brands-for-woocommerce' ),
  383. 'type' => 'select',
  384. 'options' => array(
  385. 'none' => esc_html__( 'none', 'brands-for-woocommerce' ),
  386. 'left' => esc_html__( 'left', 'brands-for-woocommerce' ),
  387. 'right' => esc_html__( 'right', 'brands-for-woocommerce' ),
  388. ),
  389. ),
  390. );
  391. return $fields;
  392. }
  393. function shortcode_callback( $atts, $content = null, $function_name = '' ) {
  394. $BeRocket_product_brand = BeRocket_product_brand::getInstance();
  395. return $BeRocket_product_brand->shortcode_brands_product_thumbnail($atts);
  396. }
  397. protected function _add_additional_border_fields() {
  398. }
  399. }
  400. new ET_Builder_Module_brands_product_thumbnail;
  401. }
  402. }
  403. add_action('et_builder_modules_loaded', 'berocket_apl_et_builder_ready');