Noptin_Post_Types::display_form_columns( string $column, int $post_id )
Displays a column.
Parameters Parameters
- $column
(string) (Required) The column being displayed.
- $post_id
(int) (Required) The post being displayed.
Return Return
(void)
Source Source
File: includes/class-noptin-post-types.php
public function display_form_columns( $column, $post_id ) { switch ( $column ) { case 'subscriptions': $views = (int) get_post_meta( $post_id, '_noptin_subscribers_count', true ); if ( empty( $views ) ) { // Ensure that there is always a subscriber count for sorting to count. update_post_meta( $post_id, '_noptin_subscribers_count', 0 ); } else { // Link to the list of subscribers who signed up using this specific form. $url = get_noptin_subscribers_overview_url(); $url = esc_url( add_query_arg( '_subscriber_via', $post_id, $url ) ); $title = esc_attr__( 'View the list of subscribers who signed up using this form.', 'newsletter-optin-box' ); $views = "<a href='$url' title='$title'>$views</a>"; } echo $views; break; case 'type': $types = array( 'sidebar' => _x( 'Widget', 'Subscription forms that are meant to appear in a widget area', 'newsletter-optin-box' ), 'inpost' => _x( 'Shortcode', 'Subscription forms that are embedded in posts using shortcodes', 'newsletter-optin-box' ), 'popup' => _x( 'Popup', 'Subscription forms that appear in a popup', 'newsletter-optin-box' ), 'slide_in' => _x( 'Sliding', 'Subscription forms that slide into view', 'newsletter-optin-box' ), ); $type = get_post_meta( $post_id, '_noptin_optin_type', true ); if ( empty( $types[ $type ] ) ) { echo '<strong>' . noptin_clean( $type ) . '</strong>'; } else { echo '<strong>' . esc_html( $types[ $type ] ) . '</strong>'; } if ( 'inpost' === $type ) { $title = esc_attr__( 'Use this shortcode to display the form on your website', 'newsletter-optin-box' ); echo "<br><input title='$title' style='color: #607D8B;' onClick='this.select();' type='text' value='[noptin-form id=$post_id]' disabled />"; } break; case 'impressions': $impressions = (int) get_post_meta( $post_id, '_noptin_form_views', true ); if ( empty( $impressions ) ) { update_post_meta( $post_id, '_noptin_form_views', 0 ); } echo $impressions; break; case 'conversion': $subscriptions = (int) get_post_meta( $post_id, '_noptin_subscribers_count', true ); $impressions = (int) get_post_meta( $post_id, '_noptin_form_views', true ); $conversion = ( $subscriptions && $impressions ) ? ( $subscriptions * 100 / $impressions ) : 0; $conversion = empty( $conversion ) ? 0 : round( $conversion, 2 ) . '%'; echo $conversion; break; case 'shortcode': $form_type = get_post_meta( $post_id, '_noptin_optin_type', true ); if ( 'inpost' === $form_type ) { echo "[noptin-form id=$post_id]"; } else { echo '__'; } break; } }
Expand full source code Collapse full source code View on GitHub