Skip to content

Commit

Permalink
chore: better seperation between free and pro
Browse files Browse the repository at this point in the history
  • Loading branch information
Soare-Robert-Daniel committed Jun 30, 2023
1 parent 73bf170 commit 3dac914
Showing 1 changed file with 49 additions and 45 deletions.
94 changes: 49 additions & 45 deletions inc/plugins/class-dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -291,70 +291,75 @@ public function form_submissions_widget() {
*/
public function form_submissions_widget_content() {

$is_active = Pro::is_pro_active();
$is_active = Pro::is_pro_active();
$entries = array();
$count = 0;
$posts_filter = 'all';

$posts_filter = isset( $_GET['otter_nonce'] ) && wp_verify_nonce( sanitize_key( $_GET['otter_nonce'] ), 'otter_widget_nonce' ) && isset( $_GET['otter_form_widget_filter'] ) ? sanitize_key( $_GET['otter_form_widget_filter'] ) : 'all';
if ( $is_active ) {
$posts_filter = isset( $_GET['otter_nonce'] ) && wp_verify_nonce( sanitize_key( $_GET['otter_nonce'] ), 'otter_widget_nonce' ) && isset( $_GET['otter_form_widget_filter'] ) ? sanitize_key( $_GET['otter_form_widget_filter'] ) : 'all';

$query_args = array(
'post_type' => 'otter_form_record',
'posts_per_page' => 5,
);
$query_args = array(
'post_type' => 'otter_form_record',
'posts_per_page' => 5,
);

if ( 'all' !== $posts_filter ) {
$query_args['post_status'] = $posts_filter;
}
if ( 'all' !== $posts_filter ) {
$query_args['post_status'] = $posts_filter;
}

$query = new \WP_Query( $query_args );
$entries = array();
$query = new \WP_Query( $query_args );

$records_count = wp_count_posts( 'otter_form_record' );

$count = $records_count->read + $records_count->unread;
$records_count = wp_count_posts( 'otter_form_record' );

if ( 'read' === $posts_filter ) {
$count = $records_count->read;
} elseif ( 'unread' === $posts_filter ) {
$count = $records_count->unread;
}
$count = $records_count->read + $records_count->unread;

if ( $query->have_posts() ) {
if ( 'read' === $posts_filter ) {
$count = $records_count->read;
} elseif ( 'unread' === $posts_filter ) {
$count = $records_count->unread;
}

while ( $query->have_posts() ) {
$query->the_post();
if ( $query->have_posts() ) {

$meta = get_post_meta( get_the_ID(), 'otter_form_record_meta', true );
while ( $query->have_posts() ) {
$query->the_post();

$title = null;
$date = null;
$meta = get_post_meta( get_the_ID(), 'otter_form_record_meta', true );

if ( isset( $meta['post_id']['value'] ) ) {
$date = get_the_date( 'F j, H:i', $meta['post_id']['value'] );
}
$title = null;
$date = null;

if ( isset( $meta['post_id']['value'] ) ) {
$date = get_the_date( 'F j, H:i', $meta['post_id']['value'] );
}

if ( isset( $meta['inputs'] ) && is_array( $meta['inputs'] ) ) {
// Find the first email field and use that as the title.
foreach ( $meta['inputs'] as $input ) {
if ( isset( $input['type'] ) && 'email' === $input['type'] && ! empty( $input['value'] ) ) {
$title = $input['value'];
break;
if ( isset( $meta['inputs'] ) && is_array( $meta['inputs'] ) ) {
// Find the first email field and use that as the title.
foreach ( $meta['inputs'] as $input ) {
if ( isset( $input['type'] ) && 'email' === $input['type'] && ! empty( $input['value'] ) ) {
$title = $input['value'];
break;
}
}
}
}


if ( ! $title ) {
if ( ! $title ) {

if ( isset( $meta['post_id']['value'] ) ) {
$title = __( 'Submission', 'otter-blocks' ) . ' #' . get_the_ID();
} else {
$title = __( 'No title', 'otter-blocks' );
if ( isset( $meta['post_id']['value'] ) ) {
$title = __( 'Submission', 'otter-blocks' ) . ' #' . get_the_ID();
} else {
$title = __( 'No title', 'otter-blocks' );
}
}
}

$entries[] = array(
'title' => $title,
'date' => $date,
);
$entries[] = array(
'title' => $title,
'date' => $date,
);
}
}
}

Expand Down Expand Up @@ -496,7 +501,6 @@ public function form_submissions_widget_content() {
if (select && entriesContainer) {
select.addEventListener('change', (e) => {
const value = e.target.value;
console.log(value);

// change the url param based on the value
const url = new URL(window.location.href);
Expand Down

0 comments on commit 3dac914

Please sign in to comment.