container->get_permission( 'edit_ctas' ), 'popup-maker-call-to-actions', [ $this, 'render_page' ] ); } /** * Render settings page title & container. * * @return void */ public function render_page() { ?> [ 'ctaId' => [ 'type' => 'string' ], 'instanceId' => [ 'type' => 'string' ], ], 'render_callback' => [ $this, 'render_cta_block' ], ]); } /** * Render CTA block. * * @param array{ctaId: int, instanceId: string} $attributes * @return string */ public function render_cta_block( $attributes ) { $cta_id = $attributes['ctaId'] ?? null; $instance_id = $attributes['instanceId'] ?? uniqid( 'cta_instance_' ); if ( ! $cta_id ) { return ''; } $cta_post = get_post( $cta_id ); $label = get_post_meta( $cta_id, 'cta_label', true ); // Basic rendering with tracking return sprintf( '', esc_attr( $cta_id ), esc_attr( $instance_id ), esc_html( $label ) ); } /** * Render CTA shortcode. * * @param array{id: int} $atts Shortcode attributes. * @return string */ public function cta_shortcode( $atts = [] ) { $atts = shortcode_atts([ 'id' => null, ], $atts); if ( ! $atts['id'] ) { return ''; } $instance_id = uniqid( 'cta_shortcode_' ); // Reuse block rendering logic return $this->render_cta_block([ 'ctaId' => $atts['id'], 'instanceId' => $instance_id, ]); } }