Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions includes/Ajax/Frontend_Form_Ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
public function submit_post() {
check_ajax_referer( 'wpuf_form_add' );
add_filter( 'wpuf_form_fields', [ $this, 'add_field_settings' ] );

Check failure on line 38 in includes/Ajax/Frontend_Form_Ajax.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Whitespace found at end of line
@header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) );

Check warning on line 39 in includes/Ajax/Frontend_Form_Ajax.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Silencing errors is strongly discouraged. Use proper error checking instead. Found: @Header( 'Content-Type: application/json; charset=' ...

$form_id = isset( $_POST['form_id'] ) ? intval( wp_unslash( $_POST['form_id'] ) ) : 0;
$form = new Form( $form_id );
Expand Down Expand Up @@ -123,9 +124,9 @@
foreach ( $protected_shortcodes as $shortcode ) {
$search_for = '[' . $shortcode;
if ( strpos( $current_data, $search_for ) !== false ) {
wpuf()->ajax->send_error( sprintf(

Check failure on line 127 in includes/Ajax/Frontend_Form_Ajax.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Opening parenthesis of a multi-line function call must be the last content on the line
// translators: %s is shortcode
__( 'Using %s as shortcode is restricted', 'wp-user-frontend' ), $shortcode ) );

Check failure on line 129 in includes/Ajax/Frontend_Form_Ajax.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Closing parenthesis of a multi-line function call must be on a line by itself

Check failure on line 129 in includes/Ajax/Frontend_Form_Ajax.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Closing parenthesis of a multi-line function call must be on a line by itself

Check failure on line 129 in includes/Ajax/Frontend_Form_Ajax.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Multi-line function call not indented correctly; expected 20 spaces but found 24

Check failure on line 129 in includes/Ajax/Frontend_Form_Ajax.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Multi-line function call not indented correctly; expected 20 spaces but found 24
}
}
}
Expand Down Expand Up @@ -193,9 +194,9 @@
$this->on_edit_no_check_recaptcha( $post_vars );
}

$is_update = false;

Check warning on line 197 in includes/Ajax/Frontend_Form_Ajax.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Equals sign not aligned correctly; expected 1 space but found 11 spaces
// $default_post_author = wpuf_get_option( 'default_post_owner', 'wpuf_frontend_posting', 1 );

Check warning on line 198 in includes/Ajax/Frontend_Form_Ajax.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

This comment is 60% valid code; is this commented out code?
$post_author = $this->wpuf_get_post_user();

Check warning on line 199 in includes/Ajax/Frontend_Form_Ajax.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Equals sign not aligned correctly; expected 1 space but found 9 spaces

$allowed_tags = wp_kses_allowed_html( 'post' );
$postarr = [
Expand All @@ -207,7 +208,7 @@
'post_excerpt' => isset( $_POST['post_excerpt'] ) ? strip_shortcodes( wp_kses( wp_unslash( $_POST['post_excerpt'] ), $allowed_tags ) ) : '',
];

// $charging_enabled = wpuf_get_option( 'charge_posting', 'wpuf_payment' );

Check warning on line 211 in includes/Ajax/Frontend_Form_Ajax.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

This comment is 58% valid code; is this commented out code?
$charging_enabled = '';
$form = new Form( $form_id );
$payment_options = $form->is_charging_enabled();
Expand All @@ -228,7 +229,7 @@
//if date is set and assigned as publish date
if ( isset( $_POST['wpuf_is_publish_time'] ) ) {
if ( ! empty( $_POST[ $_POST['wpuf_is_publish_time'] ] ) ) {
// $postarr['post_date'] = date( 'Y-m-d H:i:s', strtotime( str_replace( array( ':', '/' ), '-', $_POST[$_POST['wpuf_is_publish_time']] ) ) );

Check warning on line 232 in includes/Ajax/Frontend_Form_Ajax.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

This comment is 64% valid code; is this commented out code?
$date_time = explode( ' ', sanitize_text_field( wp_unslash( ( $_POST[ $_POST['wpuf_is_publish_time'] ] ) ) ) );

if ( ! empty( $date_time[0] ) ) {
Expand Down Expand Up @@ -303,7 +304,7 @@
if ( 'pending' === get_post_meta( $post_id, '_wpuf_payment_status', true ) ) {
$postarr['post_status'] = 'pending';
}
} else {

Check failure on line 307 in includes/Ajax/Frontend_Form_Ajax.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

If control structure block found as the only statement within an "else" block. Use elseif instead.
if ( isset( $this->form_settings['comment_status'] ) ) {
$postarr['comment_status'] = $this->form_settings['comment_status'];
}
Expand Down Expand Up @@ -396,7 +397,7 @@
// find our if any images in post content and associate them
if ( ! empty( $postarr['post_content'] ) ) {
$dom = new DOMDocument();
@$dom->loadHTML( $postarr['post_content'] );

Check warning on line 400 in includes/Ajax/Frontend_Form_Ajax.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Silencing errors is strongly discouraged. Use proper error checking instead. Found: @$dom->loadHTML( ...
$images = $dom->getElementsByTagName( 'img' );

if ( $images->length ) {
Expand Down Expand Up @@ -452,7 +453,7 @@
} else {
$redirect_to = get_permalink( $post_id );
}
} else {

Check failure on line 456 in includes/Ajax/Frontend_Form_Ajax.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

If control structure block found as the only statement within an "else" block. Use elseif instead.
if ( $this->form_settings['redirect_to'] === 'page' ) {
$redirect_to = get_permalink( $this->form_settings['page_id'] );
} elseif ( $this->form_settings['redirect_to'] === 'url' ) {
Expand All @@ -465,8 +466,8 @@
}

if ( $charging_enabled === 'yes' && isset( $this->form_settings['payment_options'] )
&& 'enable_pay_per_post' === $this->form_settings['payment_options']

Check warning on line 469 in includes/Ajax/Frontend_Form_Ajax.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Found precision alignment of 1 spaces.
&& ! $is_update

Check warning on line 470 in includes/Ajax/Frontend_Form_Ajax.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Found precision alignment of 1 spaces.
) {
$redirect_to = add_query_arg(
[
Expand Down Expand Up @@ -528,7 +529,7 @@
$to = implode(
',',
array_filter(
array_map( static function ( $addr ) {

Check failure on line 532 in includes/Ajax/Frontend_Form_Ajax.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Opening parenthesis of a multi-line function call must be the last content on the line
$addr = trim( $addr );
return is_email( $addr ) ? $addr : null;
}, explode( ',', $to_raw ) )
Expand Down Expand Up @@ -583,6 +584,7 @@
// now perform some post related actions. it should be done after other action. either count related problem emerge
do_action( 'wpuf_add_post_after_insert', $post_id, $form_id, $this->form_settings, $meta_vars ); // plugin API to extend the functionality


return $response;
}

Expand Down Expand Up @@ -678,7 +680,7 @@

// 3) Very old separate fields (only for edit notifications)
if ( ! $enabled && 'edit' === $type && ! empty( $this->form_settings['notification_' . $type ] )
&& wpuf_is_checkbox_or_toggle_on( $this->form_settings['notification_' . $type ] ) ) {

Check warning on line 683 in includes/Ajax/Frontend_Form_Ajax.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Found precision alignment of 1 spaces.
$enabled = true;
$body = isset( $this->form_settings['notification_' . $type . '_body' ] ) ? $this->form_settings['notification_' . $type . '_body' ] : '';
$to = isset( $this->form_settings['notification_' . $type . '_to' ] ) ? $this->form_settings['notification_' . $type . '_to' ] : '';
Expand Down
5 changes: 5 additions & 0 deletions includes/Frontend/Frontend_Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
add_action( 'wpuf_guest_post_email_verified', [ $this, 'send_mail_to_admin_after_guest_mail_verified' ] );

$this->set_wp_post_types();

Check failure on line 23 in includes/Frontend/Frontend_Form.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Whitespace found at end of line
// Initialize WooCommerce hooks for proper attribute display
if ( method_exists( $this, 'init_woocommerce_hooks' ) ) {
$this->init_woocommerce_hooks();
}

// Enable post edit link for post authors in frontend
if ( ! is_admin() ) {
Expand Down
Loading
Loading