WP init
This commit is contained in:
+43
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace ElementsKit_Lite\Modules\Widget_Builder\Controls;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
class Control_Type_Animation extends CT_Base {
|
||||
|
||||
public function start_writing_conf( $file_handler, $conf ) {
|
||||
|
||||
$ret = '';
|
||||
|
||||
if ( ! empty( $conf->description ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'description\' => esc_html( \'' . esc_html( $conf->description ) . '\' ),' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->default ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'default\' => \'' . esc_html( $conf->default ) . '\',' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->separator ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'separator\' => \'' . esc_html( $conf->separator ) . '\',' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->classes ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'classes\' => \'' . esc_html( $conf->classes ) . '\',' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( isset( $conf->show_label ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'show_label\' => ' . ( $conf->show_label == 1 ? 'true' : 'false' ) . ',' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( isset( $conf->label_block ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'label_block\' => ' . ( $conf->label_block == 1 ? 'true' : 'false' ) . ',' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->prefix_class ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'prefix_class\' => \'' . esc_html( $conf->prefix_class ) . '\',' . PHP_EOL;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace ElementsKit_Lite\Modules\Widget_Builder\Controls;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
class Control_Type_Background extends CT_Base {
|
||||
|
||||
public function start_writing_conf( $file_handler, $conf ) {
|
||||
|
||||
$ret = '';
|
||||
|
||||
$ret .= "\t\t\t\t'fields_options' => [";
|
||||
$ret .= "\n\t\t\t\t\t'background' => [";
|
||||
$ret .= "\n\t\t\t\t\t\t'label' => '" . esc_html( $conf->label ) . "',";
|
||||
|
||||
if ( ! empty( $conf->description ) ) {
|
||||
$ret .= "\n\t\t\t\t\t\t'description' => '" . esc_html( $conf->description ) . "',";
|
||||
}
|
||||
|
||||
if ( isset( $conf->show_label ) ) {
|
||||
$ret .= "\n\t\t\t\t\t\t'show_label' => " . ( $conf->show_label == 1 ? 'true' : 'false' ) . ',';
|
||||
}
|
||||
|
||||
if ( isset( $conf->label_block ) ) {
|
||||
$ret .= "\n\t\t\t\t\t\t'label_block' => " . ( $conf->label_block == 1 ? 'true' : 'false' ) . ',';
|
||||
}
|
||||
|
||||
$ret .= "\n\t\t\t\t\t],";
|
||||
$ret .= "\n\t\t\t\t],\n";
|
||||
|
||||
if ( ! empty( $conf->separator ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'separator\' => \'' . esc_html( $conf->separator ) . '\',' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->selector ) ) {
|
||||
$selectorProperty = str_replace( ',', ', {{WRAPPER}} ', esc_html( $conf->selector ) );
|
||||
$ret .= "\t\t\t\t" . '\'selector\' => \'{{WRAPPER}} ' . $selectorProperty . '\',' . PHP_EOL;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace ElementsKit_Lite\Modules\Widget_Builder\Controls;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
class Control_Type_Border extends CT_Base {
|
||||
|
||||
public function start_writing_conf( $file_handler, $conf ) {
|
||||
|
||||
$ret = '';
|
||||
|
||||
$ret .= "\t\t\t\t'fields_options' => [";
|
||||
$ret .= "\n\t\t\t\t\t'border' => [";
|
||||
$ret .= "\n\t\t\t\t\t\t'label' => '" . esc_html( $conf->label ) . "',";
|
||||
|
||||
if ( ! empty( $conf->description ) ) {
|
||||
$ret .= "\n\t\t\t\t\t\t'description' => '" . esc_html( $conf->description ) . "',";
|
||||
}
|
||||
|
||||
if ( isset( $conf->show_label ) ) {
|
||||
$ret .= "\n\t\t\t\t\t\t'show_label' => " . ( $conf->show_label == 1 ? 'true' : 'false' ) . ',';
|
||||
}
|
||||
|
||||
if ( isset( $conf->label_block ) ) {
|
||||
$ret .= "\n\t\t\t\t\t\t'label_block' => " . ( $conf->label_block == 1 ? 'true' : 'false' ) . ',';
|
||||
}
|
||||
|
||||
$ret .= "\n\t\t\t\t\t],";
|
||||
$ret .= "\n\t\t\t\t],\n";
|
||||
|
||||
if ( ! empty( $conf->separator ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'separator\' => \'' . esc_html( $conf->separator ) . '\' ,' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->selector ) ) {
|
||||
$selectorProperty = str_replace( ',', ', {{WRAPPER}} ', esc_html( $conf->selector ) );
|
||||
$ret .= "\t\t\t\t" . '\'selector\' => \'{{WRAPPER}} ' . $selectorProperty . '\' ,' . PHP_EOL;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace ElementsKit_Lite\Modules\Widget_Builder\Controls;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
class Control_Type_Box_Shadow extends CT_Base {
|
||||
|
||||
public function start_writing_conf( $file_handler, $conf ) {
|
||||
|
||||
$ret = '';
|
||||
|
||||
if ( ! empty( $conf->label ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'label\' => esc_html( \'' . esc_html( $conf->label ) . '\', \'elementskit\' ),' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->selector ) ) {
|
||||
$selectorProperty = str_replace( ',', ', {{WRAPPER}} ', esc_html( $conf->selector ) );
|
||||
$ret .= "\t\t\t\t" . '\'selector\' => \'{{WRAPPER}} ' . $selectorProperty . '\',' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( isset( $conf->show_label ) || isset( $conf->label_block ) || ! empty( $conf->separator ) || ! empty( $conf->classes ) ) :
|
||||
$ret .= "\t\t\t\t'fields_options' => [";
|
||||
$ret .= "\n\t\t\t\t\t'box_shadow_type' => [";
|
||||
|
||||
if ( isset( $conf->show_label ) ) {
|
||||
$ret .= "\n\t\t\t\t\t\t'show_label' => " . ( $conf->show_label == 1 ? 'true' : 'false' ) . ',';
|
||||
}
|
||||
|
||||
if ( isset( $conf->label_block ) ) {
|
||||
$ret .= "\n\t\t\t\t\t\t'label_block' => " . ( $conf->label_block == 1 ? 'true' : 'false' ) . ',';
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->separator ) ) {
|
||||
$ret .= "\n\t\t\t\t\t\t'separator' => '" . esc_html( $conf->separator ) . "',";
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->classes ) ) {
|
||||
$ret .= "\n\t\t\t\t\t\t'classes' => '" . esc_html( $conf->classes ) . "',";
|
||||
}
|
||||
|
||||
$ret .= "\n\t\t\t\t\t],";
|
||||
$ret .= "\n\t\t\t\t],\n";
|
||||
endif;
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace ElementsKit_Lite\Modules\Widget_Builder\Controls;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
class Control_Type_Choose extends CT_Base {
|
||||
|
||||
public function start_writing_conf( $file_handler, $conf ) {
|
||||
|
||||
$ret = '';
|
||||
|
||||
if ( ! empty( $conf->description ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'description\' => esc_html( \'' . esc_html( $conf->description ) . '\' ),' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->default ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'default\' => esc_html( \'' . esc_html( $conf->default ) . '\' ),' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->separator ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'separator\' => \'' . esc_html( $conf->separator ) . '\' ,' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->classes ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'classes\' => \'' . esc_html( $conf->classes ) . '\' ,' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( isset( $conf->show_label ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'show_label\' => ' . ( $conf->show_label == 1 ? 'true' : 'false' ) . ' ,' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( isset( $conf->label_block ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'label_block\' => ' . ( $conf->label_block == 1 ? 'true' : 'false' ) . ' ,' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( isset( $conf->toggle ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'toggle\' => ' . ( $conf->toggle == 1 ? 'true' : 'false' ) . ' ,' . PHP_EOL;
|
||||
}
|
||||
|
||||
$ret .= "\t\t\t\t" . '\'options\' => array(' . PHP_EOL;
|
||||
|
||||
if ( ! empty( $conf->options ) ) {
|
||||
|
||||
$realArray = (array) $conf->options;
|
||||
|
||||
foreach ( $realArray as $val => $label ) {
|
||||
|
||||
$ret .= "\t\t\t\t\t" . '\'' . $val . '\' => array(' . PHP_EOL;
|
||||
|
||||
$ret .= "\t\t\t\t\t\t" . '\'title\' => esc_html( \'' . esc_html( $label->title ) . '\' ),' . PHP_EOL;
|
||||
$ret .= "\t\t\t\t\t\t" . '\'icon\' => \'' . esc_html( $label->icon ) . '\',' . PHP_EOL;
|
||||
|
||||
$ret .= "\t\t\t\t\t" . '),' . PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
$ret .= "\t\t\t\t" . ')' . PHP_EOL;
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace ElementsKit_Lite\Modules\Widget_Builder\Controls;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
class Control_Type_Code extends CT_Base {
|
||||
|
||||
public function start_writing_conf( $file_handler, $conf ) {
|
||||
|
||||
$ret = '';
|
||||
|
||||
if ( ! empty( $conf->placeholder ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'placeholder\' => esc_html( \'' . esc_html( $conf->placeholder ) . '\' ),' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->description ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'description\' => esc_html( \'' . esc_html( $conf->description ) . '\' ),' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->default ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'default\' => \'' . esc_html( $conf->default ) . '\',' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->separator ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'separator\' => \'' . esc_html( $conf->separator ) . '\',' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->classes ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'classes\' => \'' . esc_html( $conf->classes ) . '\',' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( isset( $conf->show_label ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'show_label\' => ' . ( $conf->show_label == 1 ? 'true' : 'false' ) . ',' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( isset( $conf->label_block ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'label_block\' => ' . ( $conf->label_block == 1 ? 'true' : 'false' ) . ',' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( isset( $conf->rows ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'rows\' => ' . intval( $conf->rows ) . ',' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( isset( $conf->language ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'language\' => \'' . esc_html( $conf->language ) . '\',' . PHP_EOL;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace ElementsKit_Lite\Modules\Widget_Builder\Controls;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
class Control_Type_Color extends CT_Base {
|
||||
|
||||
public function start_writing_conf( $file_handler, $conf ) {
|
||||
|
||||
$ret = '';
|
||||
|
||||
if ( ! empty( $conf->default ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'default\' => esc_html( \'' . esc_html( $conf->default ) . '\' ),' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->separator ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'separator\' => \'' . esc_html( $conf->separator ) . '\',' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->classes ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'classes\' => \'' . esc_html( $conf->classes ) . '\',' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->selectors ) ) {
|
||||
|
||||
$selectors = (array) $conf->selectors;
|
||||
$ret .= "\t\t\t\t" . '\'selectors\' => array(' . PHP_EOL;
|
||||
|
||||
foreach ( $selectors as $selectorName => $selectorValue ) {
|
||||
$selectorProperty = str_replace( ',', ', {{WRAPPER}} ', $selectorName );
|
||||
$ret .= "\t\t\t\t\t" . '\'{{WRAPPER}} ' . $selectorProperty . '\' => \'' . esc_html( $selectorValue ) . '\',' . PHP_EOL;
|
||||
}
|
||||
|
||||
$ret .= "\t\t\t\t" . '),' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( isset( $conf->show_label ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'show_label\' => ' . ( $conf->show_label == 1 ? 'true' : 'false' ) . ',' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( isset( $conf->label_block ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'label_block\' => ' . ( $conf->label_block == 1 ? 'true' : 'false' ) . ',' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( isset( $conf->alpha ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'alpha\' => ' . ( $conf->alpha == 1 ? 'true' : 'false' ) . ',' . PHP_EOL;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace ElementsKit_Lite\Modules\Widget_Builder\Controls;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
class Control_Type_Date_Time extends CT_Base {
|
||||
|
||||
public function start_writing_conf( $file_handler, $conf ) {
|
||||
|
||||
$ret = '';
|
||||
|
||||
if ( ! empty( $conf->description ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'description\' => esc_html( \'' . esc_html( $conf->description ) . '\' ),' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->default ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'default\' => esc_html( \'' . esc_html( $conf->default ) . '\' ),' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->separator ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'separator\' => \'' . esc_html( $conf->separator ) . '\' ,' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->classes ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'classes\' => \'' . esc_html( $conf->classes ) . '\' ,' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( isset( $conf->show_label ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'show_label\' => ' . ( $conf->show_label == 1 ? 'true' : 'false' ) . ' ,' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( isset( $conf->label_block ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'label_block\' => ' . ( $conf->label_block == 1 ? 'true' : 'false' ) . ' ,' . PHP_EOL;
|
||||
}
|
||||
|
||||
$ret .= "\t\t\t\t" . '\'picker_options\' => array(' . PHP_EOL;
|
||||
|
||||
if ( ! empty( $conf->picker_options ) ) {
|
||||
|
||||
foreach ( $conf->picker_options as $idx => $v_option ) {
|
||||
|
||||
$exp = explode( ':', $v_option );
|
||||
|
||||
// Check if $exp[1] is a boolean
|
||||
if (filter_var($exp[1], FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE) !== null) {
|
||||
// If it's boolean, return the actual boolean value (true/false)
|
||||
$ret .= "\t\t\t\t\t" . '\'' . esc_html($exp[0]) . '\' => ' . (filter_var($exp[1], FILTER_VALIDATE_BOOLEAN) ? 'true' : 'false') . ',' . PHP_EOL;
|
||||
} else {
|
||||
// Otherwise, return it as a string
|
||||
$ret .= "\t\t\t\t\t" . '\'' . esc_html($exp[0]) . '\' => \'' . esc_html($exp[1]) . '\',' . PHP_EOL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$ret .= "\t\t\t\t" . ')' . PHP_EOL;
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace ElementsKit_Lite\Modules\Widget_Builder\Controls;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
class Control_Type_Dimensions extends CT_Base {
|
||||
|
||||
public function start_writing_conf( $file_handler, $conf ) {
|
||||
$ret = '';
|
||||
|
||||
if ( ! empty( $conf->description ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'description\' => esc_html( \'' . esc_html( $conf->description ) . '\' ),' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->placeholder ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'placeholder\' => esc_html( \'' . esc_html( $conf->placeholder ) . '\' ),' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->allowed_dimensions ) ) {
|
||||
$allowed_dimensions = (array) $conf->allowed_dimensions;
|
||||
$ret .= "\t\t\t\t" . '\'allowed_dimensions\' => array(' . PHP_EOL;
|
||||
|
||||
foreach ( $allowed_dimensions as $key => $value ) {
|
||||
$ret .= "\t\t\t\t\t" . '\'' . esc_html( $value ) . '\',' . PHP_EOL;
|
||||
}
|
||||
|
||||
$ret .= "\t\t\t\t" . '),' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( isset( $conf->show_label ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'show_label\' => ' . ( $conf->show_label == 1 ? 'true' : 'false' ) . ',' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( isset( $conf->label_block ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'label_block\' => ' . ( $conf->label_block == 1 ? 'true' : 'false' ) . ',' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->separator ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'separator\' => \'' . esc_html( $conf->separator ) . '\',' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->selectors ) ) {
|
||||
|
||||
$selectors = (array) $conf->selectors;
|
||||
$ret .= "\t\t\t\t" . '\'selectors\' => array(' . PHP_EOL;
|
||||
|
||||
foreach ( $selectors as $selectorName => $selectorValue ) {
|
||||
$selectorProperty = str_replace( ',', ', {{WRAPPER}} ', $selectorName );
|
||||
$ret .= "\t\t\t\t\t" . '\'{{WRAPPER}} ' . $selectorProperty . '\' => \'' . esc_html( $selectorValue ) . '\',' . PHP_EOL;
|
||||
}
|
||||
|
||||
$ret .= "\t\t\t\t" . '),' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->classes ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'classes\' => \'' . esc_html( $conf->classes ) . '\',' . PHP_EOL;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace ElementsKit_Lite\Modules\Widget_Builder\Controls;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
class Control_Type_Font extends CT_Base {
|
||||
|
||||
public function start_writing_conf( $file_handler, $conf ) {
|
||||
|
||||
$ret = '';
|
||||
|
||||
if ( ! empty( $conf->description ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'description\' => esc_html( \'' . esc_html( $conf->description ) . '\' ),' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->default ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'default\' => esc_html( \'' . esc_html( $conf->default ) . '\' ),' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->separator ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'separator\' => \'' . esc_html( $conf->separator ) . '\' ,' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->classes ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'classes\' => \'' . esc_html( $conf->classes ) . '\' ,' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( isset( $conf->show_label ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'show_label\' => ' . ( $conf->show_label == 1 ? 'true' : 'false' ) . ' ,' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( isset( $conf->label_block ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'label_block\' => ' . ( $conf->label_block == 1 ? 'true' : 'false' ) . ' ,' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->options ) ) {
|
||||
|
||||
$ret .= "\t\t\t\t" . '\'options\' => array(' . PHP_EOL;
|
||||
|
||||
$realArray = (array) $conf->options;
|
||||
|
||||
foreach ( $realArray as $val => $label ) {
|
||||
|
||||
$ret .= "\t\t\t\t\t" . '\'' . esc_html( $label ) . '\' => \'' . esc_html( $val ) . '\',' . PHP_EOL;
|
||||
}
|
||||
|
||||
$ret .= "\t\t\t\t" . '),' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->groups ) ) {
|
||||
|
||||
$ret .= "\t\t\t\t" . '\'groups\' => array(' . PHP_EOL;
|
||||
|
||||
$realArray = (array) $conf->groups;
|
||||
|
||||
foreach ( $realArray as $val => $label ) {
|
||||
|
||||
$ret .= "\t\t\t\t\t" . '\'' . esc_html( $val ) . '\' => \'' . esc_html( $label ) . '\',' . PHP_EOL;
|
||||
}
|
||||
|
||||
$ret .= "\t\t\t\t" . '),' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->selectors ) ) {
|
||||
$selectors = (array) $conf->selectors;
|
||||
$ret .= "\t\t\t\t" . '\'selectors\' => array(' . PHP_EOL;
|
||||
|
||||
foreach ( $selectors as $selectorName => $selectorValue ) {
|
||||
$selectorProperty = str_replace( ',', ', {{WRAPPER}} ', $selectorName );
|
||||
$ret .= "\t\t\t\t\t" . '\'{{WRAPPER}} ' . $selectorProperty . '\' => \'' . esc_html( $selectorValue ) . '\',' . PHP_EOL;
|
||||
}
|
||||
|
||||
$ret .= "\t\t\t\t" . ')' . PHP_EOL;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace ElementsKit_Lite\Modules\Widget_Builder\Controls;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
class Control_Type_Gallery extends CT_Base {
|
||||
|
||||
public function start_writing_conf( $file_handler, $conf ) {
|
||||
|
||||
$ret = '';
|
||||
|
||||
if ( ! empty( $conf->description ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'description\' => esc_html( \'' . esc_html( $conf->description ) . '\' ),' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->default ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'default\' => esc_html( \'' . esc_html( $conf->default ) . '\' ),' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->separator ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'separator\' => \'' . esc_html( $conf->separator ) . '\' ,' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->classes ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'classes\' => \'' . esc_html( $conf->classes ) . '\' ,' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( isset( $conf->show_label ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'show_label\' => ' . ( $conf->show_label == 1 ? 'true' : 'false' ) . ' ,' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( isset( $conf->label_block ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'label_block\' => ' . ( $conf->label_block == 1 ? 'true' : 'false' ) . ' ,' . PHP_EOL;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace ElementsKit_Lite\Modules\Widget_Builder\Controls;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
class Control_Type_Hover extends CT_Base {
|
||||
|
||||
public function start_writing_conf( $file_handler, $conf ) {
|
||||
|
||||
$ret = '';
|
||||
|
||||
if ( ! empty( $conf->description ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'description\' => esc_html( \'' . esc_html( $conf->description ) . '\' ),' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->default ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'default\' => esc_html( \'' . esc_html( $conf->default ) . '\' ),' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->separator ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'separator\' => \'' . esc_html( $conf->separator ) . '\' ,' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->classes ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'classes\' => \'' . esc_html( $conf->classes ) . '\' ,' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( isset( $conf->show_label ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'show_label\' => ' . ( $conf->show_label == 1 ? 'true' : 'false' ) . ' ,' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( isset( $conf->label_block ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'label_block\' => ' . ( $conf->label_block == 1 ? 'true' : 'false' ) . ' ,' . PHP_EOL;
|
||||
}
|
||||
|
||||
$ret .= "\t\t\t\t" . '\'prefix_class\' => \'\' ,' . PHP_EOL;
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace ElementsKit_Lite\Modules\Widget_Builder\Controls;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
class Control_Type_Icons extends CT_Base {
|
||||
|
||||
public function start_writing_conf( $file_handler, $conf ) {
|
||||
|
||||
$ret = '';
|
||||
|
||||
if ( ! empty( $conf->description ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'description\' => esc_html( \'' . esc_html( $conf->description ) . '\' ),' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->separator ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'separator\' => \'' . esc_html( $conf->separator ) . '\' ,' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->classes ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'classes\' => \'' . esc_html( $conf->classes ) . '\' ,' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( isset( $conf->show_label ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'show_label\' => ' . ( $conf->show_label == 1 ? 'true' : 'false' ) . ' ,' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( isset( $conf->label_block ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'label_block\' => ' . ( $conf->label_block == 1 ? 'true' : 'false' ) . ' ,' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->skin ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'skin\' => \'' . esc_html( $conf->skin ) . '\' ,' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->fa4compatibility ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'fa4compatibility\' => \'' . esc_html( $conf->fa4compatibility ) . '\' ,' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->default ) ) {
|
||||
|
||||
$ret .= "\t\t\t\t" . '\'default\' => array(' . PHP_EOL;
|
||||
$ret .= "\t\t\t\t\t" . '\'value\' => \'' . esc_html( $conf->default->value ) . '\',' . PHP_EOL;
|
||||
$ret .= "\t\t\t\t\t" . '\'library\' => \'' . esc_html( $conf->default->library ) . '\',' . PHP_EOL;
|
||||
$ret .= "\t\t\t\t" . ')' . PHP_EOL;
|
||||
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace ElementsKit_Lite\Modules\Widget_Builder\Controls;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
class Control_Type_Image_Dimensions extends CT_Base {
|
||||
|
||||
public function start_writing_conf( $file_handler, $conf ) {
|
||||
$ret = '';
|
||||
|
||||
if ( ! empty( $conf->description ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'description\' => esc_html( \'' . esc_html( $conf->description ) . '\' ),' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->default ) && ( ! empty( $conf->default->width ) || ! empty( $conf->default->height ) ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'default\' => array(' . PHP_EOL;
|
||||
if ( ! empty( $conf->default->width ) ) {
|
||||
$ret .= "\t\t\t\t\t" . '\'width\' => ' . esc_html( $conf->default->width ) . ',' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->default->height ) ) {
|
||||
$ret .= "\t\t\t\t\t" . '\'height\' => ' . esc_html( $conf->default->height ) . ',' . PHP_EOL;
|
||||
}
|
||||
$ret .= "\t\t\t\t" . '),' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( isset( $conf->show_label ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'show_label\' => ' . ( $conf->show_label == 1 ? 'true' : 'false' ) . ',' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( isset( $conf->label_block ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'label_block\' => ' . ( $conf->label_block == 1 ? 'true' : 'false' ) . ',' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->separator ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'separator\' => \'' . esc_html( $conf->separator ) . '\',' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->selectors ) ) {
|
||||
|
||||
$selectors = (array) $conf->selectors;
|
||||
$ret .= "\t\t\t\t" . '\'selectors\' => array(' . PHP_EOL;
|
||||
|
||||
foreach ( $selectors as $selectorName => $selectorValue ) {
|
||||
$selectorProperty = str_replace( ',', ', {{WRAPPER}} ', $selectorName );
|
||||
$ret .= "\t\t\t\t\t" . '\'{{WRAPPER}} ' . $selectorProperty . '\' => \'' . esc_html( $selectorValue ) . '\',' . PHP_EOL;
|
||||
}
|
||||
|
||||
$ret .= "\t\t\t\t" . '),' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->classes ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'classes\' => \'' . esc_html( $conf->classes ) . '\',' . PHP_EOL;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace ElementsKit_Lite\Modules\Widget_Builder\Controls;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
class Control_Type_Image_Size extends CT_Base {
|
||||
|
||||
|
||||
public function start_writing_conf( $file_handler, $conf ) {
|
||||
|
||||
$ret = '';
|
||||
|
||||
if ( ! empty( $conf->label ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'label\' => esc_html( \'' . esc_html( $conf->label ) . '\', \'elementskit\' ),' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->description ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'description\' => esc_html( \'' . esc_html( $conf->description ) . '\' ),' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->exclude ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'exclude\' => [';
|
||||
foreach ( $conf->exclude as $value ) {
|
||||
$ret .= '\'' . $value . '\',';
|
||||
}
|
||||
$ret .= '],' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->default ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'default\' => esc_html( \'' . esc_html( $conf->default ) . '\' ),' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( isset( $conf->show_label ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'show_label\' => ' . ( $conf->show_label == 1 ? 'true' : 'false' ) . ' ,' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( isset( $conf->label_block ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'label_block\' => ' . ( $conf->label_block == 1 ? 'true' : 'false' ) . ' ,' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->separator ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'separator\' => \'' . esc_html( $conf->separator ) . '\' ,' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->classes ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'classes\' => \'' . esc_html( $conf->classes ) . '\' ,' . PHP_EOL;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace ElementsKit_Lite\Modules\Widget_Builder\Controls;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Control_Type_Input for \Elementor\Controls_Manager::TEXT
|
||||
* check below link for argument list
|
||||
*
|
||||
*
|
||||
* @see https://developers.elementor.com/elementor-controls/text-control/
|
||||
*
|
||||
* @package Elementor
|
||||
*/
|
||||
class Control_Type_Input extends CT_Base {
|
||||
|
||||
public function start_writing_conf( $file_handler, $conf ) {
|
||||
|
||||
$ret = '';
|
||||
|
||||
if ( ! empty( $conf->placeholder ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'placeholder\' => esc_html( \'' . esc_html( $conf->placeholder ) . '\' ),' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->description ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'description\' => esc_html( \'' . esc_html( $conf->description ) . '\' ),' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->default ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'default\' => esc_html( \'' . esc_html( $conf->default ) . '\' ),' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->separator ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'separator\' => \'' . esc_html( $conf->separator ) . '\',' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->classes ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'classes\' => \'' . esc_html( $conf->classes ) . '\',' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( isset( $conf->show_label ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'show_label\' => ' . ( $conf->show_label == 1 ? 'true' : 'false' ) . ',' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( isset( $conf->label_block ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'label_block\' => ' . ( $conf->label_block == 1 ? 'true' : 'false' ) . ',' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->input_type ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'input_type\' => \'' . esc_html( $conf->input_type ) . '\',' . PHP_EOL;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace ElementsKit_Lite\Modules\Widget_Builder\Controls;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
class Control_Type_Media extends CT_Base {
|
||||
|
||||
public function start_writing_conf( $file_handler, $conf ) {
|
||||
|
||||
$ret = '';
|
||||
|
||||
if ( ! empty( $conf->description ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'description\' => esc_html( \'' . esc_html( $conf->description ) . '\' ),' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->default ) ) {
|
||||
|
||||
$ret .= "\t\t\t\t" . '\'default\' => array(' . PHP_EOL;
|
||||
$ret .= "\t\t\t\t\t" . '\'url\' => \'' . esc_url( $conf->default->url ) . '\',' . PHP_EOL;
|
||||
$ret .= "\t\t\t\t" . '),' . PHP_EOL;
|
||||
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->separator ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'separator\' => \'' . esc_html( $conf->separator ) . '\',' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->classes ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'classes\' => \'' . esc_html( $conf->classes ) . '\',' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( isset( $conf->show_label ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'show_label\' => ' . ( $conf->show_label == 1 ? 'true' : 'false' ) . ',' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( isset( $conf->label_block ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'label_block\' => ' . ( $conf->label_block == 1 ? 'true' : 'false' ) . ',' . PHP_EOL;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace ElementsKit_Lite\Modules\Widget_Builder\Controls;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
class Control_Type_Number extends CT_Base {
|
||||
|
||||
public function start_writing_conf( $file_handler, $conf ) {
|
||||
|
||||
$ret = '';
|
||||
|
||||
if ( ! empty( $conf->placeholder ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'placeholder\' => esc_html( \'' . esc_html( $conf->placeholder ) . '\' ),' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->description ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'description\' => esc_html( \'' . esc_html( $conf->description ) . '\' ),' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->default ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'default\' => esc_html( \'' . esc_html( $conf->default ) . '\' ),' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->separator ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'separator\' => \'' . esc_html( $conf->separator ) . '\',' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->classes ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'classes\' => \'' . esc_html( $conf->classes ) . '\',' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->min ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'min\' => \'' . floatval( $conf->min ) . '\',' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->max ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'max\' => \'' . floatval( $conf->max ) . '\',' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->step ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'step\' => \'' . esc_html( $conf->step ) . '\',' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( isset( $conf->show_label ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'show_label\' => ' . ( $conf->show_label == 1 ? 'true' : 'false' ) . ',' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( isset( $conf->label_block ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'label_block\' => ' . ( $conf->label_block == 1 ? 'true' : 'false' ) . ',' . PHP_EOL;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace ElementsKit_Lite\Modules\Widget_Builder\Controls;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
class Control_Type_Select extends CT_Base {
|
||||
|
||||
public function start_writing_conf( $file_handler, $conf ) {
|
||||
|
||||
$ret = '';
|
||||
|
||||
if ( ! empty( $conf->description ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'description\' => esc_html( \'' . esc_html( $conf->description ) . '\' ),' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->default ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'default\' => esc_html( \'' . esc_html( $conf->default ) . '\' ),' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->separator ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'separator\' => \'' . esc_html( $conf->separator ) . '\' ,' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( isset( $conf->show_label ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'show_label\' => ' . ( $conf->show_label == 1 ? 'true' : 'false' ) . ' ,' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( isset( $conf->label_block ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'label_block\' => ' . ( $conf->label_block == 1 ? 'true' : 'false' ) . ' ,' . PHP_EOL;
|
||||
}
|
||||
|
||||
$ret .= "\t\t\t\t" . '\'options\' => array(' . PHP_EOL;
|
||||
|
||||
if ( ! empty( $conf->options ) ) {
|
||||
|
||||
$realArray = (array) $conf->options;
|
||||
|
||||
foreach ( $realArray as $val => $label ) {
|
||||
|
||||
$ret .= "\t\t\t\t\t" . '\'' . esc_html( $val ) . '\' => esc_html( \'' . esc_html( $label ) . '\' ),' . PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
$ret .= "\t\t\t\t" . '),' . PHP_EOL;
|
||||
|
||||
if ( ! empty( $conf->classes ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'classes\' => \'' . esc_html( $conf->classes ) . '\',' . PHP_EOL;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace ElementsKit_Lite\Modules\Widget_Builder\Controls;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
class Control_Type_Select2 extends CT_Base {
|
||||
|
||||
|
||||
public function start_writing_conf( $file_handler, $conf ) {
|
||||
|
||||
$ret = '';
|
||||
|
||||
if ( ! empty( $conf->description ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'description\' => esc_html( \'' . esc_html( $conf->description ) . '\' ),' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->default ) ) {
|
||||
|
||||
if ( gettype( $conf->default ) == 'string' ) {
|
||||
$ret .= "\t\t\t\t" . '\'default\' => esc_html( \'' . esc_html( $conf->default ) . '\' ),' . PHP_EOL;
|
||||
} else {
|
||||
$ret .= "\t\t\t\t" . '\'default\' => array(' . PHP_EOL;
|
||||
$defaults = (array) $conf->default;
|
||||
foreach ( $defaults as $key ) {
|
||||
$ret .= "\t\t\t\t\t" . '\'' . esc_html( $key ) . '\',' . PHP_EOL;
|
||||
}
|
||||
$ret .= "\t\t\t\t" . '),' . PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->separator ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'separator\' => \'' . esc_html( $conf->separator ) . '\' ,' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( isset( $conf->multiple ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'multiple\' => ' . ( $conf->multiple == 1 ? 'true' : 'false' ) . ' ,' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( isset( $conf->show_label ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'show_label\' => ' . ( $conf->show_label == 1 ? 'true' : 'false' ) . ' ,' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( isset( $conf->label_block ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'label_block\' => ' . ( $conf->label_block == 1 ? 'true' : 'false' ) . ' ,' . PHP_EOL;
|
||||
}
|
||||
|
||||
$ret .= "\t\t\t\t" . '\'options\' => array(' . PHP_EOL;
|
||||
|
||||
if ( ! empty( $conf->options ) ) {
|
||||
|
||||
$realArray = (array) $conf->options;
|
||||
|
||||
foreach ( $realArray as $val => $label ) {
|
||||
|
||||
$ret .= "\t\t\t\t\t" . '\'' . esc_html( $val ) . '\' => esc_html( \'' . esc_html( $label ) . '\' ),' . PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
$ret .= "\t\t\t\t" . '),' . PHP_EOL;
|
||||
|
||||
if ( ! empty( $conf->selectors ) ) {
|
||||
|
||||
$selectors = (array) $conf->selectors;
|
||||
$ret .= "\t\t\t\t" . '\'selectors\' => array(' . PHP_EOL;
|
||||
|
||||
foreach ( $selectors as $selectorName => $selectorValue ) {
|
||||
$selectorProperty = str_replace( ',', ', {{WRAPPER}} ', $selectorName );
|
||||
$ret .= "\t\t\t\t\t" . '\'{{WRAPPER}} ' . $selectorProperty . '\' => \'' . esc_html( $selectorValue ) . '\',' . PHP_EOL;
|
||||
}
|
||||
|
||||
$ret .= "\t\t\t\t" . '),' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->classes ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'classes\' => \'' . esc_html( $conf->classes ) . '\',' . PHP_EOL;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace ElementsKit_Lite\Modules\Widget_Builder\Controls;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Class Control_Type_Slider
|
||||
*
|
||||
* @see https://developers.elementor.com/elementor-controls/slider-control/
|
||||
*
|
||||
* @package ElementsKit_Lite\Modules\Widget_Builder\Controls
|
||||
*/
|
||||
class Control_Type_Slider extends CT_Base {
|
||||
|
||||
public function start_writing_conf( $file_handler, $conf ) {
|
||||
|
||||
$ret = '';
|
||||
|
||||
if ( ! empty( $conf->description ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'description\' => esc_html( \'' . esc_html( $conf->description ) . '\' ),' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->separator ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'separator\' => \'' . esc_html( $conf->separator ) . '\',' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->classes ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'classes\' => \'' . esc_html( $conf->classes ) . '\',' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( isset( $conf->show_label ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'show_label\' => ' . ( $conf->show_label == 1 ? 'true' : 'false' ) . ',' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( isset( $conf->label_block ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'label_block\' => ' . ( $conf->label_block == 1 ? 'true' : 'false' ) . ',' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->default ) ) {
|
||||
|
||||
$ret .= "\t\t\t\t" . '\'default\' => array(' . PHP_EOL;
|
||||
$ret .= "\t\t\t\t\t" . '\'unit\' => \'' . esc_html( $conf->default->unit ) . '\',' . PHP_EOL;
|
||||
$ret .= "\t\t\t\t\t" . '\'size\' => \'' . esc_html( $conf->default->size ) . '\',' . PHP_EOL;
|
||||
$ret .= "\t\t\t\t" . '),' . PHP_EOL;
|
||||
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->size_units ) ) {
|
||||
|
||||
$ret .= "\t\t\t\t" . '\'size_units\' => array(' . PHP_EOL;
|
||||
|
||||
foreach ( $conf->size_units as $size ) {
|
||||
|
||||
$ret .= "\t\t\t\t\t" . '\'' . esc_html( $size ) . '\',' . PHP_EOL;
|
||||
}
|
||||
|
||||
$ret .= "\t\t\t\t" . '),' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->range ) ) {
|
||||
|
||||
$ret .= "\t\t\t\t" . '\'range\' => array(' . PHP_EOL;
|
||||
|
||||
$realArray = (array) $conf->range;
|
||||
|
||||
foreach ( $realArray as $val => $label ) {
|
||||
|
||||
$ret .= "\t\t\t\t\t" . '\'' . $val . '\' => array(' . PHP_EOL;
|
||||
$ret .= "\t\t\t\t\t\t" . '\'min\' => \'' . floatval( $label->min ) . '\',' . PHP_EOL;
|
||||
$ret .= "\t\t\t\t\t\t" . '\'max\' => \'' . floatval( $label->max ) . '\',' . PHP_EOL;
|
||||
$ret .= "\t\t\t\t\t\t" . '\'step\' => \'' . esc_html( $label->step ) . '\',' . PHP_EOL;
|
||||
$ret .= "\t\t\t\t\t" . '),' . PHP_EOL;
|
||||
}
|
||||
|
||||
$ret .= "\t\t\t\t" . ')' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->selectors ) ) {
|
||||
|
||||
$selectors = (array) $conf->selectors;
|
||||
$ret .= "\t\t\t\t" . '\'selectors\' => array(' . PHP_EOL;
|
||||
|
||||
foreach ( $selectors as $selectorName => $selectorValue ) {
|
||||
$selectorProperty = str_replace( ',', ', {{WRAPPER}} ', $selectorName );
|
||||
$ret .= "\t\t\t\t\t" . '\'{{WRAPPER}} ' . $selectorProperty . '\' => \'' . esc_html( $selectorValue ) . '\',' . PHP_EOL;
|
||||
}
|
||||
|
||||
$ret .= "\t\t\t\t" . '),' . PHP_EOL;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace ElementsKit_Lite\Modules\Widget_Builder\Controls;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
class Control_Type_Switch extends CT_Base {
|
||||
|
||||
public function start_writing_conf( $file_handler, $conf ) {
|
||||
|
||||
$ret = '';
|
||||
|
||||
if ( ! empty( $conf->description ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'description\' => esc_html( \'' . esc_html( $conf->description ) . '\' ),' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->default ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'default\' => esc_html( \'' . esc_html( $conf->default ) . '\' ),' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->separator ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'separator\' => \'' . esc_html( $conf->separator ) . '\' ,' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->classes ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'classes\' => \'' . esc_html( $conf->classes ) . '\' ,' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( isset( $conf->show_label ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'show_label\' => ' . ( $conf->show_label == 1 ? 'true' : 'false' ) . ' ,' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( isset( $conf->label_block ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'label_block\' => ' . ( $conf->label_block == 1 ? 'true' : 'false' ) . ' ,' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->label_on ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'label_on\' => \'' . esc_html( $conf->label_on ) . '\' ,' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->label_off ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'label_off\' => \'' . esc_html( $conf->label_off ) . '\' ,' . PHP_EOL;
|
||||
}
|
||||
|
||||
$ret .= "\t\t\t\t" . '\'return_value\' => \'' . esc_html( $conf->return_value ) . '\' ,' . PHP_EOL;
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace ElementsKit_Lite\Modules\Widget_Builder\Controls;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
class Control_Type_Text_Area extends CT_Base {
|
||||
|
||||
public function start_writing_conf( $file_handler, $conf ) {
|
||||
|
||||
$ret = '';
|
||||
|
||||
if ( ! empty( $conf->placeholder ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'placeholder\' => esc_html( \'' . esc_html( $conf->placeholder ) . '\' ),' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->description ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'description\' => esc_html( \'' . esc_html( $conf->description ) . '\' ),' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->default ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'default\' => esc_html( \'' . esc_html( $conf->default ) . '\' ),' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->separator ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'separator\' => \'' . esc_html( $conf->separator ) . '\',' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( isset( $conf->show_label ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'show_label\' => ' . ( $conf->show_label == 1 ? 'true' : 'false' ) . ',' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( isset( $conf->label_block ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'label_block\' => ' . ( $conf->label_block == 1 ? 'true' : 'false' ) . ',' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( isset( $conf->rows ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'rows\' => ' . intval( $conf->rows ) . ',' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->classes ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'classes\' => \'' . esc_html( $conf->classes ) . '\',' . PHP_EOL;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace ElementsKit_Lite\Modules\Widget_Builder\Controls;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
class Control_Type_Text_Shadow extends CT_Base {
|
||||
|
||||
public function start_writing_conf( $file_handler, $conf ) {
|
||||
|
||||
$ret = '';
|
||||
|
||||
if ( ! empty( $conf->label ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'label\' => esc_html( \'' . esc_html( $conf->label ) . '\', \'elementskit\' ),' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->selector ) ) {
|
||||
$selectorProperty = str_replace( ',', ', {{WRAPPER}} ', esc_html( $conf->selector ) );
|
||||
$ret .= "\t\t\t\t" . '\'selector\' => \'{{WRAPPER}} ' . $selectorProperty . '\',' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( isset( $conf->show_label ) || isset( $conf->label_block ) || ! empty( $conf->separator ) || ! empty( $conf->classes ) ) :
|
||||
$ret .= "\t\t\t\t'fields_options' => [";
|
||||
$ret .= "\n\t\t\t\t\t'text_shadow_type' => [";
|
||||
|
||||
if ( isset( $conf->show_label ) ) {
|
||||
$ret .= "\n\t\t\t\t\t\t'show_label' => " . ( $conf->show_label == 1 ? 'true' : 'false' ) . ',';
|
||||
}
|
||||
|
||||
if ( isset( $conf->label_block ) ) {
|
||||
$ret .= "\n\t\t\t\t\t\t'label_block' => " . ( $conf->label_block == 1 ? 'true' : 'false' ) . ',';
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->separator ) ) {
|
||||
$ret .= "\n\t\t\t\t\t\t'separator' => '" . esc_html( $conf->separator ) . "',";
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->classes ) ) {
|
||||
$ret .= "\n\t\t\t\t\t\t'classes' => '" . esc_html( $conf->classes ) . "',";
|
||||
}
|
||||
|
||||
$ret .= "\n\t\t\t\t\t],";
|
||||
$ret .= "\n\t\t\t\t],\n";
|
||||
endif;
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace ElementsKit_Lite\Modules\Widget_Builder\Controls;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
class Control_Type_Typography extends CT_Base {
|
||||
|
||||
|
||||
public function start_writing_conf( $file_handler, $conf ) {
|
||||
|
||||
$ret = '';
|
||||
|
||||
if ( ! empty( $conf->label ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'label\' => esc_html( \'' . esc_html( $conf->label ) . '\', \'elementskit\' ),' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->selector ) ) {
|
||||
$selectorProperty = str_replace( ',', ', {{WRAPPER}} ', esc_html( $conf->selector ) );
|
||||
$ret .= "\t\t\t\t" . '\'selector\' => \'{{WRAPPER}} ' . $selectorProperty . '\',' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( isset( $conf->show_label ) || isset( $conf->label_block ) || ! empty( $conf->separator ) || ! empty( $conf->classes ) ) :
|
||||
$ret .= "\t\t\t\t'fields_options' => [";
|
||||
$ret .= "\n\t\t\t\t\t'typography' => [";
|
||||
|
||||
if ( isset( $conf->show_label ) ) {
|
||||
$ret .= "\n\t\t\t\t\t\t'show_label' => " . ( $conf->show_label == 1 ? 'true' : 'false' ) . ',';
|
||||
}
|
||||
|
||||
if ( isset( $conf->label_block ) ) {
|
||||
$ret .= "\n\t\t\t\t\t\t'label_block' => " . ( $conf->label_block == 1 ? 'true' : 'false' ) . ',';
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->separator ) ) {
|
||||
$ret .= "\n\t\t\t\t\t\t'separator' => '" . esc_html( $conf->separator ) . "',";
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->classes ) ) {
|
||||
$ret .= "\n\t\t\t\t\t\t'classes' => '" . esc_html( $conf->classes ) . "',";
|
||||
}
|
||||
|
||||
$ret .= "\n\t\t\t\t\t],";
|
||||
$ret .= "\n\t\t\t\t],\n";
|
||||
endif;
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace ElementsKit_Lite\Modules\Widget_Builder\Controls;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
class Control_Type_URL extends CT_Base {
|
||||
|
||||
public function start_writing_conf( $file_handler, $conf ) {
|
||||
|
||||
$ret = '';
|
||||
|
||||
if ( ! empty( $conf->placeholder ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'placeholder\' => esc_html( \'' . esc_html( $conf->placeholder ) . '\' ),' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->description ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'description\' => esc_html( \'' . esc_html( $conf->description ) . '\' ),' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->separator ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'separator\' => \'' . esc_html( $conf->separator ) . '\' ,' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( isset( $conf->show_label ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'show_label\' => ' . ( $conf->show_label == 1 ? 'true' : 'false' ) . ' ,' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( isset( $conf->label_block ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'label_block\' => ' . ( $conf->label_block == 1 ? 'true' : 'false' ) . ' ,' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( isset( $conf->show_external ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'show_external\' => ' . ( $conf->show_external == 1 ? 'true' : 'false' ) . ' ,' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->default ) ) {
|
||||
|
||||
$ret .= "\t\t\t\t" . '\'default\' => array(' . PHP_EOL;
|
||||
$ret .= "\t\t\t\t\t" . '\'url\' => \'' . esc_url( $conf->default->url ) . '\',' . PHP_EOL;
|
||||
$ret .= "\t\t\t\t\t" . '\'is_external\' => ' . ( $conf->default->is_external == 1 ? 'true' : 'false' ) . ',' . PHP_EOL;
|
||||
$ret .= "\t\t\t\t\t" . '\'nofollow\' => ' . ( $conf->default->nofollow == 1 ? 'true' : 'false' ) . ',' . PHP_EOL;
|
||||
$ret .= "\t\t\t\t" . '),' . PHP_EOL;
|
||||
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->classes ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'classes\' => \'' . esc_html( $conf->classes ) . '\',' . PHP_EOL;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace ElementsKit_Lite\Modules\Widget_Builder\Controls;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Class Control_Type_Wys
|
||||
*
|
||||
* @see https://developers.elementor.com/elementor-controls/wysiwyg-control/
|
||||
*
|
||||
* @package ElementsKit_Lite\Modules\Widget_Builder\Controls
|
||||
*/
|
||||
class Control_Type_Wys extends CT_Base {
|
||||
|
||||
public function start_writing_conf( $file_handler, $conf ) {
|
||||
|
||||
$ret = '';
|
||||
|
||||
if ( ! empty( $conf->placeholder ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'placeholder\' => esc_html( \'' . esc_html( $conf->placeholder ) . '\' ),' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->description ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'description\' => esc_html( \'' . esc_html( $conf->description ) . '\' ),' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->default ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'default\' => esc_html( \'' . esc_html( $conf->default ) . '\' ),' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->separator ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'separator\' => \'' . esc_html( $conf->separator ) . '\' ,' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->classes ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'classes\' => \'' . esc_html( $conf->classes ) . '\' ,' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( isset( $conf->show_label ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'show_label\' => ' . ( $conf->show_label == 1 ? 'true' : 'false' ) . ' ,' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( isset( $conf->label_block ) ) {
|
||||
$ret .= "\t\t\t\t" . '\'label_block\' => ' . ( $conf->label_block == 1 ? 'true' : 'false' ) . ' ,' . PHP_EOL;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace ElementsKit_Lite\Modules\Widget_Builder\Controls;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
abstract class CT_Base implements CT_Contract {
|
||||
|
||||
protected $text_domain;
|
||||
|
||||
public function __construct( $txt_domain ) {
|
||||
|
||||
$this->text_domain = $txt_domain;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace ElementsKit_Lite\Modules\Widget_Builder\Controls;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
interface CT_Contract {
|
||||
|
||||
public function start_writing_conf( $file_handler, $conf);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
|
||||
namespace ElementsKit_Lite\Modules\Widget_Builder\Controls;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
class CT_Factory {
|
||||
|
||||
public function make( $type, $domain, $group = 'single' ) {
|
||||
|
||||
if ( $group == 'single' ) {
|
||||
|
||||
switch ( $type ) {
|
||||
|
||||
case 'TextControl':
|
||||
return new Control_Type_Input( $domain );
|
||||
|
||||
case 'NumberControl':
|
||||
return new Control_Type_Number( $domain );
|
||||
|
||||
case 'UrlControl':
|
||||
return new Control_Type_URL( $domain );
|
||||
|
||||
case 'TextareaControl':
|
||||
return new Control_Type_Text_Area( $domain );
|
||||
|
||||
case 'SelectControl':
|
||||
return new Control_Type_Select( $domain );
|
||||
|
||||
case 'Select2Control':
|
||||
return new Control_Type_Select2( $domain );
|
||||
|
||||
case 'CodeControl':
|
||||
return new Control_Type_Code( $domain );
|
||||
|
||||
case 'SwitcherControl':
|
||||
return new Control_Type_Switch( $domain );
|
||||
|
||||
case 'ChooseControl':
|
||||
return new Control_Type_Choose( $domain );
|
||||
|
||||
case 'ColorControl':
|
||||
return new Control_Type_Color( $domain );
|
||||
|
||||
case 'EntranceAnimationControl':
|
||||
return new Control_Type_Animation( $domain );
|
||||
|
||||
case 'HoverAnimationControl':
|
||||
return new Control_Type_Animation( $domain );
|
||||
|
||||
case 'DateTimeControl':
|
||||
return new Control_Type_Date_Time( $domain );
|
||||
|
||||
case 'FontControl':
|
||||
return new Control_Type_Font( $domain );
|
||||
|
||||
case 'GalleryControl':
|
||||
return new Control_Type_Gallery( $domain );
|
||||
|
||||
case 'SliderControl':
|
||||
return new Control_Type_Slider( $domain );
|
||||
|
||||
case 'IconsControl':
|
||||
return new Control_Type_Icons( $domain );
|
||||
|
||||
case 'MediaControl':
|
||||
return new Control_Type_Media( $domain );
|
||||
|
||||
case 'WysiwygControl':
|
||||
return new Control_Type_Wys( $domain );
|
||||
|
||||
case 'DimensionsControl':
|
||||
return new Control_Type_Dimensions( $domain );
|
||||
|
||||
case 'ImageDimensionsControl':
|
||||
return new Control_Type_Image_Dimensions( $domain );
|
||||
|
||||
default:
|
||||
return new Control_Type_Input( $domain );
|
||||
}
|
||||
} elseif ( $group == 'group' ) {
|
||||
|
||||
switch ( $type ) {
|
||||
|
||||
case 'BackgroundControl':
|
||||
return new Control_Type_Background( $domain );
|
||||
|
||||
case 'BorderControl':
|
||||
return new Control_Type_Border( $domain );
|
||||
|
||||
case 'TextShadowControl':
|
||||
return new Control_Type_Text_Shadow( $domain );
|
||||
|
||||
case 'BoxShadowControl':
|
||||
return new Control_Type_Box_Shadow( $domain );
|
||||
|
||||
case 'TypographyControl':
|
||||
return new Control_Type_Typography( $domain );
|
||||
|
||||
case 'ImageSizeControl':
|
||||
return new Control_Type_Image_Size( $domain );
|
||||
|
||||
default:
|
||||
return new Control_Type_Border( $domain );
|
||||
}
|
||||
} elseif ( $group == 'responsive' ) {
|
||||
|
||||
}
|
||||
|
||||
return new Control_Type_Input( $domain );
|
||||
}
|
||||
}
|
||||
+537
@@ -0,0 +1,537 @@
|
||||
<?php
|
||||
|
||||
namespace ElementsKit_Lite\Modules\Widget_Builder\Controls;
|
||||
|
||||
use ElementsKit_Lite\Modules\Widget_Builder\Widget_File;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
class Widget_Writer {
|
||||
|
||||
private $widget_name;
|
||||
private $widget_id;
|
||||
private $file_handler = '';
|
||||
private $file_name;
|
||||
private $enqueue_handler_prefix;
|
||||
private $widget_class_name;
|
||||
private $folder_name;
|
||||
private $control_prefix;
|
||||
private $name_prefix = 'ekit_wb_';
|
||||
private $class_name_prefix = 'Ekit_Wb_';
|
||||
private $widget_obj;
|
||||
private $prepared_content = '';
|
||||
public $text_domain = 'elementskit-lite';
|
||||
|
||||
const TAB_CONTENT = 'Controls_Manager::TAB_CONTENT';
|
||||
const TAB_STYLE = 'Controls_Manager::TAB_STYLE';
|
||||
const TAB_ADVANCE = 'Controls_Manager::TAB_ADVANCED';
|
||||
|
||||
const CONTROL_GROUP_TYPE_SINGLE = 'single';
|
||||
const CONTROL_GROUP_TYPE_RESPONSIVE = 'responsive';
|
||||
const CONTROL_GROUP_TYPE_GROUPED = 'group';
|
||||
|
||||
|
||||
public function __construct( $widget, $widget_id, $txt_domain = 'elementskit-lite' ) {
|
||||
|
||||
$this->widget_obj = $widget;
|
||||
$this->file_name = '';
|
||||
$this->text_domain = $txt_domain;
|
||||
$this->widget_id = $widget_id;
|
||||
|
||||
$this->folder_name = $this->name_prefix . $this->widget_id;
|
||||
$this->widget_name = $this->name_prefix . $this->widget_id;
|
||||
$this->widget_class_name = $this->class_name_prefix . $this->widget_id;
|
||||
$this->control_prefix = $this->folder_name . '_';
|
||||
|
||||
$this->enqueue_handler_prefix = 'ekit-wb-' . $this->widget_id;
|
||||
}
|
||||
|
||||
|
||||
public function start_backing( $wp_filesystem ) {
|
||||
|
||||
$css_enqueue = $this->prepare_css_file( $this->widget_obj->css, $wp_filesystem );
|
||||
$js_enqueue = $this->prepare_js_file( $this->widget_obj->js, $wp_filesystem );
|
||||
$include_js = ! empty( $this->widget_obj->js_includes ) || ! empty( $this->widget_obj->css_includes );
|
||||
|
||||
$content = $this->prepare_php_file();
|
||||
|
||||
if ( $css_enqueue === true || $js_enqueue === true || $include_js === true ) {
|
||||
|
||||
$content .= $this->write_construct_method( $css_enqueue, $js_enqueue );
|
||||
}
|
||||
|
||||
$content .= $this->write_name_method();
|
||||
$content .= $this->write_title_method( $this->widget_obj->title );
|
||||
$content .= $this->write_categories_method( $this->widget_obj->categories );
|
||||
$content .= $this->write_icon_method( $this->widget_obj->icon );
|
||||
$content .= $this->write_register_control_method( $this->widget_obj->tabs );
|
||||
$content .= $this->write_render_method( $this->widget_obj->markup );
|
||||
$content .= $this->close_widget_class();
|
||||
|
||||
$this->prepared_content = $content;
|
||||
}
|
||||
|
||||
|
||||
private function get_url_path() {
|
||||
|
||||
$upload = wp_upload_dir();
|
||||
|
||||
return $upload['baseurl'] . '/elementskit/custom_widgets/' . $this->folder_name;
|
||||
}
|
||||
|
||||
|
||||
private function get_file_path() {
|
||||
|
||||
$upload = wp_upload_dir();
|
||||
$upload_dir = $upload['basedir'];
|
||||
$upload_dir = $upload_dir . '/elementskit/custom_widgets/' . $this->folder_name;
|
||||
|
||||
if ( ! is_dir( $upload_dir ) ) {
|
||||
wp_mkdir_p( $upload_dir );
|
||||
}
|
||||
|
||||
return $upload_dir;
|
||||
}
|
||||
|
||||
|
||||
public static function delete_widget( $widget_id ) {
|
||||
|
||||
$fl_sys = Widget_File::get_wp_filesystem_pointer();
|
||||
|
||||
$wb = new self( array(), $widget_id );
|
||||
|
||||
$dir = $wb->get_file_path();
|
||||
|
||||
if ( file_exists( $dir ) ) {
|
||||
|
||||
$fl_sys->delete( $dir, true );
|
||||
}
|
||||
|
||||
return true; // :P
|
||||
}
|
||||
|
||||
|
||||
private function prepare_css_file( $content, $file_system ) {
|
||||
|
||||
if ( empty( $content ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$trimmed = trim( $content );
|
||||
|
||||
if ( empty( $trimmed ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$path = $this->get_file_path();
|
||||
|
||||
return $file_system->put_contents( $path . '/style.css', $trimmed );
|
||||
}
|
||||
|
||||
|
||||
private function prepare_js_file( $content, $file_system ) {
|
||||
|
||||
if ( empty( $content ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$trimmed = trim( $content );
|
||||
|
||||
if ( empty( $trimmed ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$path = $this->get_file_path();
|
||||
|
||||
return $file_system->put_contents( $path . '/script.js', $trimmed );
|
||||
}
|
||||
|
||||
|
||||
public function finish_backing( $file_system ) {
|
||||
|
||||
$path = $this->get_file_path();
|
||||
|
||||
return $file_system->put_contents( $path . '/widget.php', $this->prepared_content );
|
||||
}
|
||||
|
||||
|
||||
private function prepare_php_file() {
|
||||
|
||||
$ret = '<?php' . PHP_EOL . PHP_EOL;
|
||||
$ret .= 'namespace Elementor;' . PHP_EOL . PHP_EOL;
|
||||
$ret .= 'defined(\'ABSPATH\') || exit;' . PHP_EOL . PHP_EOL;
|
||||
$ret .= 'class ' . $this->widget_class_name . ' extends Widget_Base {' . PHP_EOL . PHP_EOL;
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
private function write_construct_method( $css = false, $js = false ) {
|
||||
|
||||
$nm = $this->enqueue_handler_prefix;
|
||||
$url_path = $this->get_url_path();
|
||||
|
||||
$ret = "\t" . 'public function __construct($data = [], $args = null) {' . PHP_EOL;
|
||||
$ret .= "\t\t" . 'parent::__construct($data, $args);' . PHP_EOL . PHP_EOL;
|
||||
|
||||
if ( $css === true ) {
|
||||
$ret .= "\t\t" . 'wp_register_style( \'' . $nm . '-style-handle\', \'' . $url_path . '/style.css\');' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( $js === true ) {
|
||||
$ret .= "\t\t" . 'wp_register_script( \'' . $nm . '-script-handle\', \'' . $url_path . '/script.js\', [ \'elementor-frontend\' ], \'1.0.0\', true );' . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( ! empty( $this->widget_obj->css_includes ) ) {
|
||||
|
||||
$ret .= PHP_EOL;
|
||||
|
||||
foreach ( $this->widget_obj->css_includes as $idx => $cssInclude ) {
|
||||
|
||||
$ret .= "\t\t" . 'wp_enqueue_style( \'' . $nm . '-' . $idx . '-style-handle\', \'' . $cssInclude . '\');' . PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! empty( $this->widget_obj->js_includes ) ) {
|
||||
|
||||
$ret .= PHP_EOL;
|
||||
|
||||
foreach ( $this->widget_obj->js_includes as $idx => $jsInclude ) {
|
||||
|
||||
$ret .= "\t\t" . 'wp_enqueue_script( \'' . $nm . '-' . $idx . '-script-handle\', \'' . $jsInclude . '\', [ \'elementor-frontend\' ], \'1.0.0\', true );' . PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
$ret .= "\t" . '}' . PHP_EOL . PHP_EOL;
|
||||
|
||||
if ( $css === true ) {
|
||||
$ret .= "\n\t" . 'public function get_style_depends() {' . PHP_EOL;
|
||||
$ret .= "\t\t" . 'return [ \'' . $nm . '-style-handle\' ];' . PHP_EOL;
|
||||
$ret .= "\t" . '}' . PHP_EOL . PHP_EOL;
|
||||
}
|
||||
|
||||
if ( $js === true ) {
|
||||
$ret .= "\n\t" . 'public function get_script_depends() {' . PHP_EOL;
|
||||
$ret .= "\t\t" . 'return [ \'' . $nm . '-script-handle\' ];' . PHP_EOL;
|
||||
$ret .= "\t" . '}' . PHP_EOL . PHP_EOL;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
private function write_name_method() {
|
||||
|
||||
$ret = "\t" . 'public function get_name() {' . PHP_EOL;
|
||||
$ret .= "\t\t" . 'return \'' . $this->widget_name . '\';' . PHP_EOL;
|
||||
$ret .= "\t" . '}' . PHP_EOL . PHP_EOL;
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
private function write_title_method( $title = 'empty_title' ) {
|
||||
|
||||
$ret = "\n\t" . 'public function get_title() {' . PHP_EOL;
|
||||
$ret .= "\t\t" . 'return esc_html__( \'' . esc_html($title) . '\', \'' . $this->text_domain . '\' );' . PHP_EOL;
|
||||
$ret .= "\t" . '}' . PHP_EOL . PHP_EOL;
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
private function write_categories_method( $cat = array( 'basic' ) ) {
|
||||
|
||||
$cat = empty( $cat ) ? array( 'basic' ) : $cat;
|
||||
|
||||
$joined = '\'';
|
||||
$joined .= implode( '\', \'', $cat );
|
||||
$joined .= '\'';
|
||||
|
||||
$ret = "\n\t" . 'public function get_categories() {' . PHP_EOL;
|
||||
$ret .= "\t\t" . 'return [' . $joined . '];' . PHP_EOL;
|
||||
$ret .= "\t" . '}' . PHP_EOL . PHP_EOL;
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
private function write_icon_method( $icon = 'eicon-cog' ) {
|
||||
|
||||
$ret = "\n\t" . 'public function get_icon() {' . PHP_EOL;
|
||||
$ret .= "\t\t" . 'return \'' . $icon . '\';' . PHP_EOL;
|
||||
$ret .= "\t" . '}' . PHP_EOL . PHP_EOL;
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
private function write_register_control_method( $conf = array() ) {
|
||||
|
||||
$ret = "\n\t" . 'protected function register_controls() {' . PHP_EOL;
|
||||
|
||||
if ( ! empty( $conf->content ) ) {
|
||||
|
||||
foreach ( $conf->content as $indx => $section ) {
|
||||
|
||||
$ret .= $this->write_section( $section->title, self::TAB_CONTENT, 'content', $indx );
|
||||
|
||||
if ( ! empty( $section->controls ) ) {
|
||||
|
||||
$ret .= $this->write_add_control( $section->controls );
|
||||
}
|
||||
|
||||
$ret .= $this->close_section();
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->style ) ) {
|
||||
|
||||
foreach ( $conf->style as $indx => $section ) {
|
||||
|
||||
$ret .= $this->write_section( $section->title, self::TAB_STYLE, 'style', $indx );
|
||||
|
||||
if ( ! empty( $section->controls ) ) {
|
||||
|
||||
$ret .= $this->write_add_control( $section->controls );
|
||||
}
|
||||
|
||||
$ret .= $this->close_section();
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! empty( $conf->advanced ) ) {
|
||||
|
||||
foreach ( $conf->advanced as $indx => $section ) {
|
||||
|
||||
$ret .= $this->write_section( $section->title, self::TAB_ADVANCE, 'advance', $indx );
|
||||
|
||||
if ( ! empty( $section->controls ) ) {
|
||||
|
||||
$ret .= $this->write_add_control( $section->controls );
|
||||
}
|
||||
|
||||
$ret .= $this->close_section();
|
||||
}
|
||||
}
|
||||
|
||||
$ret .= "\t" . '}' . PHP_EOL . PHP_EOL;
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
private function write_section( $label, $tab = 'Controls_Manager::TAB_CONTENT', $tab_name = 'content', $indx = '' ) {
|
||||
|
||||
$key = $tab_name . '_section_' . $this->widget_id . '_' . $indx;
|
||||
|
||||
$ret = "\n\t\t" . '$this->start_controls_section(' . PHP_EOL;
|
||||
$ret .= "\t\t\t" . '\'' . $key . '\',' . PHP_EOL;
|
||||
$ret .= "\t\t\t" . 'array(' . PHP_EOL;
|
||||
|
||||
$ret .= "\t\t\t\t" . '\'label\' => esc_html__( \'' . esc_html($label) . '\', \'' . $this->text_domain . '\' ),' . PHP_EOL;
|
||||
$ret .= "\t\t\t\t" . '\'tab\' => ' . $tab . ',' . PHP_EOL;
|
||||
|
||||
$ret .= "\t\t\t" . ')' . PHP_EOL;
|
||||
$ret .= "\t\t" . ');' . PHP_EOL;
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
private function write_add_control( $controls = array() ) {
|
||||
|
||||
$ret = '';
|
||||
|
||||
foreach ( $controls as $controlObj ) {
|
||||
|
||||
if ( $controlObj->control_group === self::CONTROL_GROUP_TYPE_SINGLE ) {
|
||||
|
||||
$ret .= $this->prepare_add_control( $controlObj );
|
||||
|
||||
} elseif ( $controlObj->control_group === self::CONTROL_GROUP_TYPE_RESPONSIVE ) {
|
||||
|
||||
$ret .= $this->prepare_responsive_control( $controlObj );
|
||||
|
||||
} elseif ( $controlObj->control_group === self::CONTROL_GROUP_TYPE_GROUPED ) {
|
||||
|
||||
$ret .= $this->prepare_group_control( $controlObj );
|
||||
}
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
private function prepare_add_control( $controlObj ) {
|
||||
|
||||
$factory = new CT_Factory();
|
||||
$cnt_obj = $factory->make( $controlObj->controlType, $this->text_domain );
|
||||
|
||||
$ret = "\n\t\t" . '$this->add_control(' . PHP_EOL;
|
||||
$ret .= "\t\t\t" . '\'' . $this->control_prefix . $controlObj->key . '\',' . PHP_EOL;
|
||||
$ret .= "\t\t\t" . 'array(' . PHP_EOL;
|
||||
|
||||
$ret .= "\t\t\t\t" . '\'label\' => esc_html__( \'' . esc_html($controlObj->label) . '\', \'' . $this->text_domain . '\' ),' . PHP_EOL;
|
||||
$ret .= "\t\t\t\t" . '\'type\' => ' . $controlObj->control_type . ',' . PHP_EOL;
|
||||
|
||||
$ret .= $cnt_obj->start_writing_conf( $this->file_handler, $controlObj );
|
||||
|
||||
$ret .= "\t\t\t" . ')' . PHP_EOL;
|
||||
$ret .= "\t\t" . ');' . PHP_EOL;
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
private function prepare_responsive_control( $controlObj ) {
|
||||
|
||||
$factory = new CT_Factory();
|
||||
$cnt_obj = $factory->make( $controlObj->controlType, $this->text_domain, 'responsive' );
|
||||
|
||||
$ret = "\n\t\t" . '$this->add_responsive_control(' . PHP_EOL;
|
||||
$ret .= "\t\t\t" . '\'' . $this->control_prefix . $controlObj->key . '\',' . PHP_EOL;
|
||||
$ret .= "\t\t\t" . 'array(' . PHP_EOL;
|
||||
|
||||
$ret .= "\t\t\t\t" . '\'label\' => esc_html__( \'' . esc_html($controlObj->label) . '\', \'' . $this->text_domain . '\' ),' . PHP_EOL;
|
||||
$ret .= "\t\t\t\t" . '\'type\' => ' . $controlObj->control_type . ',' . PHP_EOL;
|
||||
|
||||
//$cnt_obj->start_writing_conf($this->file_handler, $controlObj);
|
||||
|
||||
$ret .= "\t\t\t" . ')' . PHP_EOL;
|
||||
$ret .= "\t\t" . ');' . PHP_EOL;
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
private function prepare_group_control( $controlObj ) {
|
||||
|
||||
$factory = new CT_Factory();
|
||||
$cnt_obj = $factory->make( $controlObj->controlType, $this->text_domain, 'group' );
|
||||
|
||||
$ret = "\n\t\t" . '$this->add_group_control(' . PHP_EOL;
|
||||
$ret .= "\t\t\t" . '' . $controlObj->control_type . ',' . PHP_EOL;
|
||||
$ret .= "\t\t\t" . 'array(' . PHP_EOL;
|
||||
|
||||
$ret .= "\t\t\t\t" . '\'name\' => \'' . $this->control_prefix . $controlObj->key . '\',' . PHP_EOL;
|
||||
|
||||
$ret .= $cnt_obj->start_writing_conf( $this->file_handler, $controlObj );
|
||||
|
||||
$ret .= "\t\t\t" . ')' . PHP_EOL;
|
||||
$ret .= "\t\t" . ');' . PHP_EOL;
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
private function close_section() {
|
||||
|
||||
return "\n\t\t" . '$this->end_controls_section();' . PHP_EOL . PHP_EOL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply proper security escaping to widget markup
|
||||
*
|
||||
* @param string $markup The widget markup template
|
||||
* @return string The processed markup with proper escaping
|
||||
*/
|
||||
private function apply_escaping($markup) {
|
||||
// Array of regex patterns and their replacements
|
||||
$patterns = [
|
||||
// Pattern 1: URL attributes in href, src, action with array access ["url"]
|
||||
'/(href|src|action)=["\']\s*<\?php\s+echo\s+isset\s*\(\s*\$settings\s*\[\s*["\']([^"\']+)["\']\s*\]\s*\[\s*["\']url["\']\s*\]\s*\)\s*\?\s*\$settings\s*\[\s*["\']([^"\']+)["\']\s*\]\s*\[\s*["\']url["\']\s*\]\s*:\s*["\'][^"\']*["\']\s*;\s*\?>/i'
|
||||
=> '$1="<?php echo isset($settings["$2"]["url"]) ? esc_url($settings["$3"]["url"]) : ""; ?>"',
|
||||
|
||||
// Pattern 2: URL attributes in href, src, action (standard, not arrays)
|
||||
'/(href|src|action)=["\']\s*<\?php\s+echo\s+isset\s*\(\s*\$settings\s*\[\s*["\']([^"\']+)["\']\s*\]\s*\)\s*\?\s*\$settings\s*\[\s*["\']([^"\']+)["\']\s*\]\s*:\s*["\'][^"\']*["\']\s*;\s*\?>/i'
|
||||
=> '$1="<?php echo isset($settings["$2"]) ? esc_url($settings["$3"]) : ""; ?>"',
|
||||
|
||||
// Pattern 3: Non-URL attributes (class, data-*, etc.) with array access
|
||||
'/(?<!href|src|action)=["\']\s*<\?php\s+echo\s+isset\s*\(\s*\$settings\s*\[\s*["\']([^"\']+)["\']\s*\]\s*\[\s*["\'](?!url)([^"\']+)["\']\s*\]\s*\)\s*\?\s*\$settings\s*\[\s*["\']([^"\']+)["\']\s*\]\s*\[\s*["\']([^"\']+)["\']\s*\]\s*:\s*["\'][^"\']*["\']\s*;\s*\?>/i'
|
||||
=> '="<?php echo isset($settings["$1"]["$2"]) ? esc_attr($settings["$3"]["$4"]) : ""; ?>"',
|
||||
|
||||
// Pattern 4: Non-URL attributes (class, data-*, etc.) standard access
|
||||
'/(?<!href|src|action)=["\']\s*<\?php\s+echo\s+isset\s*\(\s*\$settings\s*\[\s*["\']([^"\']+)["\']\s*\]\s*\)\s*\?\s*\$settings\s*\[\s*["\']([^"\']+)["\']\s*\]\s*:\s*["\'][^"\']*["\']\s*;\s*\?>/i'
|
||||
=> '="<?php echo isset($settings["$1"]) ? esc_attr($settings["$2"]) : ""; ?>"',
|
||||
|
||||
// Pattern 5: Text content (not in attributes) - use wp_kses_post()
|
||||
'/>\s*<\?php\s+echo\s+isset\s*\(\s*\$settings\s*\[\s*["\']([^"\']+)["\']\s*\]\s*\)\s*\?\s*\$settings\s*\[\s*["\']([^"\']+)["\']\s*\]\s*:\s*["\'][^"\']*["\']\s*;\s*\?>\s*</i'
|
||||
=> '><?php echo isset($settings["$1"]) ? wp_kses_post($settings["$2"]) : ""; ?><',
|
||||
];
|
||||
|
||||
// Apply patterns in order
|
||||
foreach ($patterns as $pattern => $replacement) {
|
||||
$markup = preg_replace($pattern, $replacement, $markup);
|
||||
}
|
||||
|
||||
// Additional safety check for any remaining URL array references
|
||||
$markup = preg_replace_callback(
|
||||
'/<\?php.*?\$settings\s*\[\s*["\']([^"\']+)["\']\s*\]\s*\[\s*["\']url["\']\s*\].*?\?>/i',
|
||||
function($matches) {
|
||||
$fullMatch = $matches[0];
|
||||
|
||||
// Only modify if it doesn't already have proper array checking
|
||||
if (strpos($fullMatch, 'isset') === false || strpos($fullMatch, 'esc_url') === false) {
|
||||
// Extract setting key
|
||||
preg_match('/\$settings\s*\[\s*["\']([^"\']+)["\']\s*\]/', $fullMatch, $keyMatches);
|
||||
$key = isset($keyMatches[1]) ? $keyMatches[1] : '';
|
||||
|
||||
if (!empty($key)) {
|
||||
return '<?php echo isset($settings["' . $key . '"]["url"]) ? esc_url($settings["' . $key . '"]["url"]) : ""; ?>';
|
||||
}
|
||||
}
|
||||
|
||||
return $fullMatch;
|
||||
},
|
||||
$markup
|
||||
);
|
||||
|
||||
return $markup;
|
||||
}
|
||||
|
||||
private function write_render_method( $markup = '' ) {
|
||||
|
||||
$markup = \ElementsKit_Lite\Libs\Template\Loader::instance()->replace_tags( $markup, $this->control_prefix );
|
||||
|
||||
// Apply security escaping
|
||||
$markup = $this->apply_escaping($markup);
|
||||
|
||||
$ret = "\n\t" . 'protected function render() {' . PHP_EOL;
|
||||
|
||||
if ( ! empty( $markup ) ) {
|
||||
|
||||
$ret .= "\t\t" . '$settings = $this->get_settings_for_display();' . PHP_EOL . PHP_EOL;
|
||||
|
||||
$ret .= "\t\t" . '?>' . PHP_EOL;
|
||||
$ret .= $markup . PHP_EOL;
|
||||
$ret .= "\t\t" . '<?php' . PHP_EOL;
|
||||
}
|
||||
|
||||
$ret .= "\t" . '}' . PHP_EOL . PHP_EOL;
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
private function close_widget_class() {
|
||||
|
||||
return PHP_EOL . '}' . PHP_EOL;
|
||||
}
|
||||
|
||||
|
||||
private function close_php_writer() {
|
||||
|
||||
fclose( $this->file_handler ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_fclose
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function get_widget_class_name() {
|
||||
return $this->widget_class_name;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user