Skip to content

Commit

Permalink
Merge pull request #1327 from visual-framework/php-8-updates
Browse files Browse the repository at this point in the history
php warnings fixes
  • Loading branch information
kasprzyk-sz authored Apr 8, 2024
2 parents 25ddf0c + ee3aa8c commit 283bc62
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 35 deletions.
46 changes: 24 additions & 22 deletions wp-content/plugins/vf-wp/vf-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,49 +224,51 @@ class_exists($config['class'])
* Ensure plugin post is published with correct content
*/
static public function register_update($config, $plugin = null) {
if ( ! $plugin) {
$plugin = get_page_by_path(
$config['post_name'],
OBJECT,
$config['post_type']
);
if (!$plugin && isset($config['post_name'], $config['post_type'])) {
$plugin = get_page_by_path(
$config['post_name'],
OBJECT,
$config['post_type']
);
}
if ( ! $plugin instanceof WP_Post) {
return;
if (!$plugin instanceof WP_Post) {
return;
}

$post_content = '';

// Add generic plugin preview block to post content
if ($plugin->post_type === VF_Blocks::post_type()) {
$post_content = '<!-- wp:vf/plugin {"ver":"2.0.0","ref":"'
. VF_Blocks::name_post_to_block($plugin->post_name)
. '"} /-->';
$post_content = '<!-- wp:vf/plugin {"ver":"2.0.0","ref":"'
. VF_Blocks::name_post_to_block($plugin->post_name)
. '"} /-->';
}

// Add generic plugin preview block to post content
if ($plugin->post_type === VF_Containers::post_type()) {
$post_content = '<!-- wp:vf/plugin {"ver":"2.0.0","ref":"'
. VF_Containers::name_post_to_block($plugin->post_name)
. '"} /-->';
$post_content = '<!-- wp:vf/plugin {"ver":"2.0.0","ref":"'
. VF_Containers::name_post_to_block($plugin->post_name)
. '"} /-->';
}

$data = array(
'ID' => $plugin->ID,
'post_content' => $post_content,
'post_status' => 'publish'
'ID' => $plugin->ID,
'post_content' => $post_content,
'post_status' => 'publish'
);

if (isset($config['post_title'])) {
$data['post_title'] = $config['post_title'];
$data['post_title'] = $config['post_title'];
}

if (isset($config['dates'])) {
$time = current_time('mysql');
$data['post_date'] = $time;
$data['post_date_gmt'] = get_gmt_from_date($time);
$time = current_time('mysql');
$data['post_date'] = $time;
$data['post_date_gmt'] = get_gmt_from_date($time);
}

wp_update_post($data);
}
}

/**
* Save plugin data to a global option key/value array
Expand Down
33 changes: 20 additions & 13 deletions wp-content/plugins/vf-wp/vf-type.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,21 +232,28 @@ public function after_setup_theme_migrations() {
}

// Iterate over registered block plugins
foreach ($vf_plugins as $key => $config) {
// Skip unknown or deprecated plugins
$plugin = VF_Plugin::get_plugin($key);
if ( ! $plugin || $plugin->is_deprecated()) {
continue;
}
$date = strtotime($plugin->post()->post_date_gmt);
foreach ($vf_plugins as $key => $config) {
// Skip unknown or deprecated plugins
$plugin = VF_Plugin::get_plugin($key);
if (!$plugin || $plugin->is_deprecated()) {
continue;
}

// Ensure that $plugin->post() returns a valid WP_Post object
$post = $plugin->post();
if (!$post instanceof WP_Post) {
continue;
}

// Force a migration (11/11/2020 @ 11:11am UTC)
if ($date < 1605093071) {
VF_Plugin::register_update(array(
$date = strtotime($post->post_date_gmt);

// Force a migration (11/11/2020 @ 11:11am UTC)
if ($date < 1605093071) {
VF_Plugin::register_update(array(
'dates' => true
), $plugin->post());
}
}
), $post);
}
}
}

/**
Expand Down
2 changes: 2 additions & 0 deletions wp-content/themes/vf-wp/blocks/vfwp-profile/template.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<?php
$image_url = get_field('image_url');
$image = get_field('image');
if (is_array($image) && isset($image['ID'])) {
$image = wp_get_attachment_image($image['ID'], 'medium', false, array(
'class' => 'vf-profile__image',
'loading' => 'lazy',
'itemprop' => 'image',
));
}

$name = get_field('full_name');
$link = get_field('profile_link');
Expand Down

0 comments on commit 283bc62

Please sign in to comment.