-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
8 changed files
with
863 additions
and
6 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
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 |
---|---|---|
|
@@ -17,6 +17,7 @@ class Plugin { | |
*/ | ||
public function __construct() { | ||
new Assets(); | ||
new Term_UI( __DIR__ ); | ||
} | ||
|
||
} |
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,113 @@ | ||
<?php | ||
/** | ||
* Term_UI class. | ||
* | ||
* @package Schedule_Terms | ||
*/ | ||
|
||
namespace HAMWORKS\WP\Schedule_Terms; | ||
|
||
use JJJ\WP\Term\Meta\UI; | ||
|
||
/** | ||
* Term meta UI controller. | ||
*/ | ||
class Term_UI extends UI { | ||
|
||
/** | ||
* Plugin version. | ||
* | ||
* @var string | ||
*/ | ||
public $version = '2.0.0'; | ||
|
||
/** | ||
* Database version. | ||
* | ||
* @var string | ||
*/ | ||
public $db_version = 202204190000; | ||
|
||
/** | ||
* Metadata key. | ||
* | ||
* @var string | ||
*/ | ||
public $meta_key = 'use_schedule'; | ||
|
||
/** | ||
* Constrouctor. | ||
* | ||
* @param string $file Plugin file. | ||
*/ | ||
public function __construct( $file = '' ) { | ||
$this->labels = array( | ||
'singular' => esc_html__( 'Scheduled', 'schedule-posts' ), | ||
); | ||
|
||
parent::__construct( $file ); | ||
} | ||
|
||
/** | ||
* Enqueue scripts. | ||
*/ | ||
public function enqueue_scripts() { | ||
$asset_file = include plugin_dir_path( __DIR__ ) . 'build/admin.asset.php'; | ||
|
||
foreach ( $asset_file['dependencies'] as $style ) { | ||
wp_enqueue_style( $style ); | ||
} | ||
|
||
wp_enqueue_script( | ||
'schedule-terms-admin', | ||
plugins_url( 'build/admin.js', __DIR__ ), | ||
$asset_file['dependencies'], | ||
$asset_file['version'], | ||
true | ||
); | ||
} | ||
|
||
/** | ||
* Output. | ||
* | ||
* @param mixed $meta term meta. | ||
*/ | ||
protected function format_output( $meta = '' ) { | ||
if ( $meta ) { | ||
?> | ||
<span data-use-schedule><?php esc_html_e( 'Use Schedule', 'schedule-posts' ); ?></span> | ||
<?php | ||
} | ||
} | ||
|
||
/** | ||
* Output the form field | ||
* | ||
* @param \WP_Term|null $term term meta. | ||
*/ | ||
protected function form_field( $term = null ) { | ||
$value = isset( $term->term_id ) | ||
? $this->get_meta( $term->term_id ) | ||
: ''; | ||
|
||
?> | ||
<input | ||
type="checkbox" | ||
name="term-<?php echo esc_attr( $this->meta_key ); ?>" | ||
id="term-<?php echo esc_attr( $this->meta_key ); ?>" | ||
<?php checked( ! ! $value, true, true ); ?> | ||
/> | ||
<?php | ||
} | ||
|
||
/** | ||
* Output the form field | ||
*/ | ||
protected function quick_edit_form_field() { | ||
?> | ||
<input type="checkbox" name="term-<?php echo esc_attr( $this->meta_key ); ?>"> | ||
<?php | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.