Skip to content

Commit

Permalink
Classic Theme Helper: Copy Testimonials Custom Post Type code to Clas…
Browse files Browse the repository at this point in the history
…sic Theme Helper package (#40295)

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/12034410054

Upstream-Ref: Automattic/jetpack@63a223a
  • Loading branch information
coder-karen authored and matticbot committed Nov 26, 2024
1 parent d0fdc5c commit a82b7a3
Show file tree
Hide file tree
Showing 11 changed files with 1,050 additions and 89 deletions.
60 changes: 30 additions & 30 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions vendor/automattic/jetpack-classic-theme-helper/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.7.2-alpha] - unreleased

This is an alpha version! The changes listed here are not final.

### Added
- Classic Theme Helper: Adding Testimonial custom post type content

## [0.7.1] - 2024-11-25
### Changed
- Updated dependencies. [#40286]
Expand Down Expand Up @@ -155,6 +162,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Add wordpress folder on gitignore. [#37177]

[0.7.2-alpha]: https://github.com/Automattic/jetpack-classic-theme-helper/compare/v0.7.1...v0.7.2-alpha
[0.7.1]: https://github.com/Automattic/jetpack-classic-theme-helper/compare/v0.7.0...v0.7.1
[0.7.0]: https://github.com/Automattic/jetpack-classic-theme-helper/compare/v0.6.7...v0.7.0
[0.6.7]: https://github.com/Automattic/jetpack-classic-theme-helper/compare/v0.6.6...v0.6.7
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
class Main {

const PACKAGE_VERSION = '0.7.1';
const PACKAGE_VERSION = '0.7.2-alpha';

/**
* Modules to include.
Expand Down
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;
}
}
}
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;
}
}
}
Loading

0 comments on commit a82b7a3

Please sign in to comment.