-
Notifications
You must be signed in to change notification settings - Fork 798
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Classic Theme Helper: Copy Testimonials Custom Post Type code to Clas…
…sic Theme Helper package (#40295)
- Loading branch information
1 parent
9a5997a
commit 63a223a
Showing
7 changed files
with
1,722 additions
and
763 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
4 changes: 4 additions & 0 deletions
4
...kages/classic-theme-helper/changelog/add-testimonials-cpt-to-classic-theme-helper-package
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,4 @@ | ||
Significance: patch | ||
Type: added | ||
|
||
Classic Theme Helper: Adding Testimonial custom post type content |
48 changes: 48 additions & 0 deletions
48
...classic-theme-helper/src/custom-post-types/class-jetpack-testimonial-textarea-control.php
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,48 @@ | ||
<?php | ||
/** | ||
* Helper class for the Jetpack Testimonial Textarea Control. | ||
* | ||
* @package automattic/jetpack-classic-theme-helper | ||
*/ | ||
|
||
namespace Automattic\Jetpack\Classic_Theme_Helper; | ||
|
||
if ( ! class_exists( __NAMESPACE__ . '\Jetpack_Testimonial_Textarea_Control' ) ) { | ||
/** | ||
* Extends the WP_Customize_Control class to clean the textarea content. | ||
*/ | ||
class Jetpack_Testimonial_Textarea_Control extends \WP_Customize_Control { | ||
/** | ||
* Control type. | ||
* | ||
* @var string | ||
*/ | ||
public $type = 'textarea'; | ||
|
||
/** | ||
* Render the control's content. | ||
*/ | ||
public function render_content() { | ||
?> | ||
<label> | ||
<span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span> | ||
<textarea rows="5" style="width:100%;" <?php $this->link(); ?>><?php echo esc_textarea( $this->value() ); ?></textarea> | ||
</label> | ||
<?php | ||
} | ||
|
||
/** | ||
* Sanitize content passed to control. | ||
* | ||
* @param string $value Control value. | ||
* @return string Sanitized value. | ||
*/ | ||
public static function sanitize_content( $value ) { | ||
if ( ! empty( $value ) ) { | ||
$value = apply_filters( 'the_content', $value ); | ||
} | ||
$value = preg_replace( '@<div id="jp-post-flair"([^>]+)?>(.+)?</div>@is', '', $value ); | ||
return $value; | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...es/classic-theme-helper/src/custom-post-types/class-jetpack-testimonial-title-control.php
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,28 @@ | ||
<?php | ||
/** | ||
* Helper class for the Jetpack Testimonial Title Control. | ||
* | ||
* @package automattic/jetpack-classic-theme-helper | ||
*/ | ||
|
||
namespace Automattic\Jetpack\Classic_Theme_Helper; | ||
|
||
if ( ! class_exists( __NAMESPACE__ . '\Jetpack_Testimonial_Title_Control' ) ) { | ||
/** | ||
* Extends the WP_Customize_Control class to clean the title parameter. | ||
*/ | ||
class Jetpack_Testimonial_Title_Control extends \WP_Customize_Control { | ||
/** | ||
* Sanitize content passed to control. | ||
* | ||
* @param string $value Control value. | ||
* @return string Sanitized value. | ||
*/ | ||
public static function sanitize_content( $value ) { | ||
if ( '' != $value ) { // phpcs:ignore Universal.Operators.StrictComparisons.LooseNotEqual -- handle non-string inputs gracefully. | ||
$value = trim( convert_chars( wptexturize( $value ) ) ); | ||
} | ||
return $value; | ||
} | ||
} | ||
} |
Oops, something went wrong.