-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
991d7c7
commit 17c9e79
Showing
12 changed files
with
132 additions
and
236 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<?php | ||
/** | ||
* Customize API: Wrapper class. | ||
* | ||
* @package GeneratePress | ||
*/ | ||
|
||
/** | ||
* Customize Wrapper Control class. | ||
* | ||
* @see WP_Customize_Control | ||
*/ | ||
class GeneratePress_Customize_Wrapper_Control extends WP_Customize_Control { | ||
/** | ||
* Type. | ||
* | ||
* @access public | ||
* @since 1.0.0 | ||
* @var string | ||
*/ | ||
public $type = 'generate-wrapper-control'; | ||
|
||
/** | ||
* Refresh the parameters passed to the JavaScript via JSON. | ||
* | ||
* @since 3.4.0 | ||
* @uses WP_Customize_Control::to_json() | ||
*/ | ||
public function to_json() { | ||
parent::to_json(); | ||
$this->json['choices'] = $this->choices; | ||
} | ||
|
||
/** | ||
* Empty JS template. | ||
* | ||
* @access public | ||
* @since 1.0.0 | ||
* @return void | ||
*/ | ||
public function content_template() {} | ||
|
||
/** | ||
* Empty PHP template. | ||
* | ||
* @access public | ||
* @since 1.0.0 | ||
* @return void | ||
*/ | ||
public function render_content() { | ||
$html_attributes = array( | ||
'class' => 'generate-customize-control-wrapper', | ||
'id' => $this->id, | ||
'data-wrapper-type' => $this->choices['type'], | ||
); | ||
|
||
if ( ! empty( $this->choices['class'] ) ) { | ||
$html_attributes['class'] .= ' ' . $this->choices['class']; | ||
} | ||
|
||
$attributes_string = ''; | ||
|
||
foreach ( $html_attributes as $attribute => $value ) { | ||
$attributes_string .= $attribute . '="' . esc_attr( $value ) . '" '; | ||
} | ||
|
||
$this->toggleIdScript(); | ||
?> | ||
<div <?php echo $attributes_string; // phpcs:ignore -- Escaped above. ?>> | ||
<?php | ||
foreach ( $this->choices['items'] as $wrapper ) { | ||
?> | ||
<div id="<?php echo esc_attr( $wrapper . '--wrapper' ); ?>"></div> | ||
<?php | ||
} | ||
?> | ||
</div> | ||
<?php | ||
} | ||
|
||
/** | ||
* Add a script to toggle the wrapper. | ||
*/ | ||
public function toggleIdScript() { | ||
if ( ! empty( $this->choices['toggleId'] ) ) : | ||
?> | ||
<script> | ||
var liElement = document.getElementById( 'customize-control-<?php echo esc_js( $this->id ); ?>' ); | ||
|
||
if ( liElement ) { | ||
liElement.setAttribute('data-toggleId', '<?php echo esc_attr( $this->choices['toggleId'] ); ?>'); | ||
} | ||
</script> | ||
<?php | ||
endif; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.