| 1 |
<?php |
| 2 |
|
| 3 |
class PostXOxygenElement extends OxyEl { |
| 4 |
|
| 5 |
function init() { |
| 6 |
// Do some initial things here. |
| 7 |
} |
| 8 |
|
| 9 |
function afterInit() { |
| 10 |
$this->removeApplyParamsButton(); |
| 11 |
} |
| 12 |
|
| 13 |
function name() { |
| 14 |
return __( 'PostX Templates', 'ultimate-post' ); |
| 15 |
} |
| 16 |
|
| 17 |
function slug() { |
| 18 |
return 'postx-templates'; |
| 19 |
} |
| 20 |
|
| 21 |
function icon() { |
| 22 |
return ULTP_URL . 'addons/oxygen/icon.svg'; |
| 23 |
} |
| 24 |
|
| 25 |
function button_place() { |
| 26 |
// return "interactive"; |
| 27 |
} |
| 28 |
|
| 29 |
function button_priority() { |
| 30 |
return 9; |
| 31 |
} |
| 32 |
|
| 33 |
|
| 34 |
function render( $options, $defaults, $content ) { |
| 35 |
$templates = $options['templates']; |
| 36 |
|
| 37 |
if ( $templates ) { |
| 38 |
if ( isset( $_GET['action'] ) && strpos( sanitize_key( $_GET['action'] ), 'oxy_render_oxy' ) !== false ) { |
| 39 |
echo ultimate_post()->build_css_for_inline_print( $templates, true ); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 40 |
} |
| 41 |
|
| 42 |
$args = array( |
| 43 |
'p' => $templates, |
| 44 |
'post_type' => 'ultp_templates', |
| 45 |
); |
| 46 |
$the_query = new \WP_Query( $args ); |
| 47 |
if ( $the_query->have_posts() ) { |
| 48 |
while ( $the_query->have_posts() ) { |
| 49 |
$the_query->the_post(); |
| 50 |
the_content(); |
| 51 |
} |
| 52 |
wp_reset_postdata(); |
| 53 |
} |
| 54 |
} elseif ( isset( $_GET['action'] ) && strpos( sanitize_key( $_GET['action'] ), 'oxy_render_oxy' ) !== false ) { |
| 55 |
// @codingStandardsIgnoreLine |
| 56 |
echo '<p style="text-align:center;">' . sprintf( esc_html__( 'Pick a Template from your saved ones. Or create a template from: %s.', 'ultimate-post' ) . ' ', '<strong><i>' . esc_html__( 'Dashboard > PostX > Saved Templates', 'ultimate-post' ) . '</i></strong>' ) . '</p>'; |
| 57 |
} |
| 58 |
} |
| 59 |
|
| 60 |
function controls() { |
| 61 |
$this->addOptionControl( |
| 62 |
array( |
| 63 |
'type' => 'dropdown', |
| 64 |
'name' => esc_html__( 'Select Your Template', 'ultimate-post' ), |
| 65 |
'slug' => 'templates', |
| 66 |
'default' => '', |
| 67 |
) |
| 68 |
)->setValue( ultimate_post()->get_all_lists( 'ultp_templates' ) )->rebuildElementOnChange(); |
| 69 |
} |
| 70 |
|
| 71 |
function defaultCSS() { |
| 72 |
ultimate_post()->register_scripts_common(); |
| 73 |
} |
| 74 |
} |
| 75 |
|
| 76 |
new PostXOxygenElement(); |
| 77 |
|