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

Add check for image #105

Open
wants to merge 3 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
11 changes: 7 additions & 4 deletions classes/class-sailthru-content.php
Original file line number Diff line number Diff line change
Expand Up @@ -428,10 +428,13 @@ function generate_meta_tags() {
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' );
$thumb = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'concierge-thumb' );

$post_image = $image[0];
$horizon_tags['sailthru.image.full'] = esc_attr( $post_image );
$post_thumbnail = $thumb[0];
$horizon_tags['sailthru.image.thumb'] = $post_thumbnail;
if ( ! empty( $image ) ) {
$horizon_tags['sailthru.image.full'] = esc_attr( $image[0] );
}

if ( ! empty( $thumb ) ) {
$horizon_tags['sailthru.image.thumb'] = $thumb[0];
}
}

// expiration date
Expand Down
19 changes: 11 additions & 8 deletions classes/class-sailthru-meta-box.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,20 @@ public function add_metabox() {

public function render_metabox( $post ) {

// Retrieves the global content options.
// Retrieves the global content options.
$options = get_option( 'sailthru_content_settings' );

$tags_checked = false;
$cat_checked = false;

if ( isset( $options['sailthru_interest_tag_options'] ) && !empty( $options['sailthru_interest_tag_options'] ) ) {
$tags_checked = in_array( 'wordpress_tags', $options['sailthru_interest_tag_options'], true ) ? true : false;
$cat_checked = in_array( 'wordpress_categories', $options['sailthru_interest_tag_options'], true ) ? true : false;
}
}

// Do we send this content type? Warn the user if not.
// Do we send this content type? Warn the user if not.
if ( isset( $options['sailthru_content_post_types'] ) && !empty( $options['sailthru_content_post_types'] ) ) {

if ( ! in_array($post->post_type, $options['sailthru_content_post_types'] ) ) {
echo '<p>This content type is not enabled for Sailthru recommendations.</p><p><a href=" ' . esc_url( admin_url( 'admin.php?page=sailthru_content_settings') ) .' ">Enable this content type</a>.</p>';
return;
Expand All @@ -58,7 +61,7 @@ public function render_metabox( $post ) {
if( empty( $sailthru_meta_tags ) ) $sailthru_meta_tags = '';
if( empty( $sailthru_post_expiration ) ) $sailthru_post_expiration = '';

/* tags */
/* tags */
echo '<table class="form-table">';

echo '<tr>';
Expand All @@ -67,15 +70,15 @@ public function render_metabox( $post ) {
echo '<input type="text" id="sailthru_meta_tags" name="sailthru_meta_tags" class="sailthru_meta_tags_field widefat" placeholder="' . esc_attr__( '', 'text_domain' ) . '" value="' . esc_attr( $sailthru_meta_tags ) . '">';
echo '<p class="description">' . esc_attr__( 'Comma separated list of tags', 'text_domain' ) . '</p>';
echo '</td>';
echo '</tr>';
echo '</tr>';

if ($tags_checked || $cat_checked) {
echo '<tr>';
echo '<td>';
echo '<small>' . esc_attr__( 'Your settings include', 'text_domain' ) . '';

if ($cat_checked) {

if (true === $cat_checked) {
echo esc_attr__( 'WordPress categories', 'text_domain' ) ;
}
Expand All @@ -94,7 +97,7 @@ public function render_metabox( $post ) {
echo '</tr>';
}

/* post expiration */
/* post expiration */
echo '<tr class="line">';
echo '<td>';
echo '<label for="sailthru_post_expiration" class="sailthru_post_expiration_label" style="padding-bottom:8px; display:block; font-weight:bold">' . esc_attr__( 'Content Expires', 'text_domain' ) . '</label>';
Expand Down
6 changes: 6 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "sailthru/sailthru-wordpress-plugin",
"description": "Add the power of Sailthru to your WordPress set up.",
"type": "wordpress-plugin",
"license": "GPL-2.0-or-later"
}