Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set event feature image which event has no image #162

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
13 changes: 9 additions & 4 deletions includes/class-import-facebook-events-aioec.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ public function import_event( $centralize_array, $event_args ) {
}

$is_exitsing_event = $ife_events->common->get_event_by_event_id( $this->event_posttype, $centralize_array['ID'] );
$options = ife_get_import_options( $centralize_array['origin'] );

if ( $is_exitsing_event ) {
// Update event or not?
$options = ife_get_import_options( $centralize_array['origin'] );
$update_events = isset( $options['update_events'] ) ? $options['update_events'] : 'no';
$skip_trash = isset( $options['skip_trash'] ) ? $options['skip_trash'] : 'no';
$post_status = get_post_status( $is_exitsing_event );
Expand Down Expand Up @@ -180,9 +180,14 @@ public function import_event( $centralize_array, $event_args ) {
$event_image = $centralize_array['image_url'];
if ( ! empty( $event_image ) ) {
$ife_events->common->setup_featured_image_to_event( $inserted_event_id, $event_image );
} else {
if ( $is_exitsing_event ) {
delete_post_thumbnail( $inserted_event_id );
}else{
$default_thumb = isset( $options['ife_event_default_thumbnail'] ) ? $options['ife_event_default_thumbnail'] : '';
if( !empty( $default_thumb ) ){
set_post_thumbnail( $inserted_event_id, $default_thumb );
}else{
if ( $is_exitsing_event ) {
delete_post_thumbnail( $inserted_event_id );
}
}
}

Expand Down
13 changes: 9 additions & 4 deletions includes/class-import-facebook-events-ee4.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ public function import_event( $centralize_array, $event_args ) {
}

$is_exitsing_event = $ife_events->common->get_event_by_event_id( $this->event_posttype, $centralize_array['ID'] );
$options = ife_get_import_options( $centralize_array['origin'] );

if ( $is_exitsing_event ) {
// Update event or not?
$options = ife_get_import_options( $centralize_array['origin'] );
$update_events = isset( $options['update_events'] ) ? $options['update_events'] : 'no';
$skip_trash = isset( $options['skip_trash'] ) ? $options['skip_trash'] : 'no';
$post_status = get_post_status( $is_exitsing_event );
Expand Down Expand Up @@ -175,9 +175,14 @@ public function import_event( $centralize_array, $event_args ) {
$event_image = $centralize_array['image_url'];
if ( ! empty( $event_image ) ) {
$ife_events->common->setup_featured_image_to_event( $inserted_event_id, $event_image );
} else {
if ( $is_exitsing_event ) {
delete_post_thumbnail( $inserted_event_id );
}else{
$default_thumb = isset( $options['ife_event_default_thumbnail'] ) ? $options['ife_event_default_thumbnail'] : '';
if( !empty( $default_thumb ) ){
set_post_thumbnail( $inserted_event_id, $default_thumb );
}else{
if ( $is_exitsing_event ) {
delete_post_thumbnail( $inserted_event_id );
}
}
}

Expand Down
13 changes: 9 additions & 4 deletions includes/class-import-facebook-events-em.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,10 @@ public function import_event( $centralize_array, $event_args ) {
}

$is_exitsing_event = $ife_events->common->get_event_by_event_id( $this->event_posttype, $centralize_array['ID'] );
$options = ife_get_import_options( $centralize_array['origin'] );

if ( $is_exitsing_event ) {
// Update event or not?
$options = ife_get_import_options( $centralize_array['origin'] );
$update_events = isset( $options['update_events'] ) ? $options['update_events'] : 'no';
$skip_trash = isset( $options['skip_trash'] ) ? $options['skip_trash'] : 'no';
$post_status = get_post_status( $is_exitsing_event );
Expand Down Expand Up @@ -225,9 +225,14 @@ public function import_event( $centralize_array, $event_args ) {
$event_image = $centralize_array['image_url'];
if ( ! empty( $event_image ) ) {
$ife_events->common->setup_featured_image_to_event( $inserted_event_id, $event_image );
} else {
if ( $is_exitsing_event ) {
delete_post_thumbnail( $inserted_event_id );
}else{
$default_thumb = isset( $options['ife_event_default_thumbnail'] ) ? $options['ife_event_default_thumbnail'] : '';
if( !empty( $default_thumb ) ){
set_post_thumbnail( $inserted_event_id, $default_thumb );
}else{
if ( $is_exitsing_event ) {
delete_post_thumbnail( $inserted_event_id );
}
}
}

Expand Down
13 changes: 9 additions & 4 deletions includes/class-import-facebook-events-event-organizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ public function import_event( $centralize_array, $event_args ) {
}

$is_exitsing_event = $ife_events->common->get_event_by_event_id( $this->event_posttype, $centralize_array['ID'] );
$options = ife_get_import_options( $centralize_array['origin'] );

if ( $is_exitsing_event ) {
// Update event or not?
$options = ife_get_import_options( $centralize_array['origin'] );
$update_events = isset( $options['update_events'] ) ? $options['update_events'] : 'no';
$skip_trash = isset( $options['skip_trash'] ) ? $options['skip_trash'] : 'no';
$post_status = get_post_status( $is_exitsing_event );
Expand Down Expand Up @@ -191,9 +191,14 @@ public function import_event( $centralize_array, $event_args ) {
$event_image = $centralize_array['image_url'];
if ( ! empty( $event_image ) ) {
$ife_events->common->setup_featured_image_to_event( $inserted_event_id, $event_image );
} else {
if ( $is_exitsing_event ) {
delete_post_thumbnail( $inserted_event_id );
}else{
$default_thumb = isset( $options['ife_event_default_thumbnail'] ) ? $options['ife_event_default_thumbnail'] : '';
if( !empty( $default_thumb ) ){
set_post_thumbnail( $inserted_event_id, $default_thumb );
}else{
if ( $is_exitsing_event ) {
delete_post_thumbnail( $inserted_event_id );
}
}
}

Expand Down
7 changes: 6 additions & 1 deletion includes/class-import-facebook-events-eventon.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ public function import_event( $centralize_array, $event_args ) {
}

$is_exitsing_event = $ife_events->common->get_event_by_event_id( $this->event_posttype, $centralize_array['ID'] );
$options = ife_get_import_options( $centralize_array['origin'] );

if ( $is_exitsing_event ) {
// Update event or not?
$options = ife_get_import_options( $centralize_array['origin'] );
$update_events = isset( $options['update_events'] ) ? $options['update_events'] : 'no';
$skip_trash = isset( $options['skip_trash'] ) ? $options['skip_trash'] : 'no';
$post_status = get_post_status( $is_exitsing_event );
Expand Down Expand Up @@ -189,6 +189,11 @@ public function import_event( $centralize_array, $event_args ) {
$event_image = $centralize_array['image_url'];
if ( ! empty( $event_image ) ) {
$ife_events->common->setup_featured_image_to_event( $inserted_event_id, $event_image );
}else{
$default_thumb = isset( $options['ife_event_default_thumbnail'] ) ? $options['ife_event_default_thumbnail'] : '';
if( !empty( $default_thumb ) ){
set_post_thumbnail( $inserted_event_id, $default_thumb );
}
}
$address = isset( $centralize_array['location']['address_1'] ) ? sanitize_text_field( $centralize_array['location']['address_1'] ) : '';
$full_address = isset( $centralize_array['location']['full_address'] ) ? sanitize_text_field( $centralize_array['location']['full_address'] ) : '';
Expand Down
13 changes: 9 additions & 4 deletions includes/class-import-facebook-events-ife.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ public function import_event( $centralize_array, $event_args ) {
}

$is_exitsing_event = $ife_events->common->get_event_by_event_id( $this->event_posttype, $centralize_array['ID'] );
$options = ife_get_import_options( $centralize_array['origin'] );

if ( $is_exitsing_event ) {
// Update event or not?
$options = ife_get_import_options( $centralize_array['origin'] );
$update_events = isset( $options['update_events'] ) ? $options['update_events'] : 'no';
$skip_trash = isset( $options['skip_trash'] ) ? $options['skip_trash'] : 'no';
$post_status = get_post_status( $is_exitsing_event );
Expand Down Expand Up @@ -188,9 +188,14 @@ public function import_event( $centralize_array, $event_args ) {
$event_image = $centralize_array['image_url'];
if ( ! empty( $event_image ) ) {
$ife_events->common->setup_featured_image_to_event( $inserted_event_id, $event_image );
} else {
if ( $is_exitsing_event && 'ical' !== $event_args['import_origin'] ) {
delete_post_thumbnail( $inserted_event_id );
}else{
$default_thumb = isset( $options['ife_event_default_thumbnail'] ) ? $options['ife_event_default_thumbnail'] : '';
if( !empty( $default_thumb ) ){
set_post_thumbnail( $inserted_event_id, $default_thumb );
}else{
if ( $is_exitsing_event ) {
delete_post_thumbnail( $inserted_event_id );
}
}
}

Expand Down
13 changes: 9 additions & 4 deletions includes/class-import-facebook-events-my-calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ public function import_event( $centralize_array, $event_args ) {
}

$is_exitsing_event = $ife_events->common->get_event_by_event_id( $this->event_posttype, $centralize_array['ID'] );
$options = ife_get_import_options( $centralize_array['origin'] );
if ( $is_exitsing_event ) {
// Update event or not?
$options = ife_get_import_options( $centralize_array['origin'] );
$update_events = isset( $options['update_events'] ) ? $options['update_events'] : 'no';
$skip_trash = isset( $options['skip_trash'] ) ? $options['skip_trash'] : 'no';
$post_status = get_post_status( $is_exitsing_event );
Expand Down Expand Up @@ -157,9 +157,14 @@ public function import_event( $centralize_array, $event_args ) {
$event_image = $centralize_array['image_url'];
if ( ! empty( $event_image ) ) {
$ife_events->common->setup_featured_image_to_event( $inserted_event_id, $event_image );
} else {
if ( $is_exitsing_event ) {
delete_post_thumbnail( $inserted_event_id );
}else{
$default_thumb = isset( $options['ife_event_default_thumbnail'] ) ? $options['ife_event_default_thumbnail'] : '';
if( !empty( $default_thumb ) ){
set_post_thumbnail( $inserted_event_id, $default_thumb );
}else{
if ( $is_exitsing_event ) {
delete_post_thumbnail( $inserted_event_id );
}
}
}
$timezone = isset( $centralize_array['timezone'] ) ? sanitize_text_field( $centralize_array['timezone'] ) : '';
Expand Down
16 changes: 13 additions & 3 deletions includes/class-import-facebook-events-tec.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ public function import_event( $centralize_array, $event_args ) {
global $ife_events;

$is_exitsing_event = $ife_events->common->get_event_by_event_id( $this->event_posttype, $centralize_array['ID'] );
$options = ife_get_import_options( $centralize_array['origin'] );

if ( $is_exitsing_event && is_numeric( $is_exitsing_event ) && $is_exitsing_event > 0 ) {

$options = ife_get_import_options( $centralize_array['origin'] );
$update_events = isset( $options['update_events'] ) ? $options['update_events'] : 'no';
$skip_trash = isset( $options['skip_trash'] ) ? $options['skip_trash'] : 'no';
$post_status = get_post_status( $is_exitsing_event );
Expand Down Expand Up @@ -267,6 +267,11 @@ public function create_event( $centralize_array = array(), $formated_args = arra
$event_featured_image = $centralize_array['image_url'];
if ( ! empty( $event_featured_image ) ) {
$ife_events->common->setup_featured_image_to_event( $new_event_id, $event_featured_image );
}else{
$default_thumb = isset( $options['ife_event_default_thumbnail'] ) ? $options['ife_event_default_thumbnail'] : '';
if( !empty( $default_thumb ) ){
set_post_thumbnail( $new_event_id, $default_thumb );
}
}

do_action( 'ife_after_create_tec_' . $centralize_array['origin'] . '_event', $new_event_id, $formated_args, $centralize_array );
Expand Down Expand Up @@ -353,8 +358,13 @@ public function update_event( $event_id, $centralize_array, $formated_args = arr
$event_featured_image = $centralize_array['image_url'];
if ( ! empty( $event_featured_image ) ) {
$ife_events->common->setup_featured_image_to_event( $update_event_id, $event_featured_image );
} else {
delete_post_thumbnail( $update_event_id );
}else{
$default_thumb = isset( $options['ife_event_default_thumbnail'] ) ? $options['ife_event_default_thumbnail'] : '';
if( !empty( $default_thumb ) ){
set_post_thumbnail( $update_event_id, $default_thumb );
}else{
delete_post_thumbnail( $update_event_id );
}
}

do_action( 'ife_after_update_tec_' . $centralize_array['origin'] . '_event', $update_event_id, $formated_args, $centralize_array );
Expand Down
8 changes: 4 additions & 4 deletions languages/import-facebook-events.pot
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2024 Xylus Themes
# Copyright (C) 2025 Xylus Themes
# This file is distributed under the GPL-2.0+.
msgid ""
msgstr ""
Expand All @@ -9,7 +9,7 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2024-11-30T07:00:03+00:00\n"
"POT-Creation-Date: 2025-01-16T13:02:14+00:00\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"X-Generator: WP-CLI 2.11.0\n"
"X-Domain: import-facebook-events\n"
Expand Down Expand Up @@ -963,8 +963,8 @@ msgstr ""
msgid "Import histories are deleted successfully."
msgstr ""

#: includes/class-import-facebook-events-tec.php:279
#: includes/class-import-facebook-events-tec.php:366
#: includes/class-import-facebook-events-tec.php:284
#: includes/class-import-facebook-events-tec.php:376
msgid "Something went wrong, please try again."
msgstr ""

Expand Down