Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

Commit

Permalink
Uploading version 1.3.2beta
Browse files Browse the repository at this point in the history
  • Loading branch information
nelio committed Jul 31, 2015
1 parent 273f6e5 commit 777e7e4
Show file tree
Hide file tree
Showing 13 changed files with 796 additions and 160 deletions.
Binary file added assets/1-1-nelioefi-placeholder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/16-9-nelioefi-placeholder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/3-4-nelioefi-placeholder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/4-3-nelioefi-placeholder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/9-16-nelioefi-placeholder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/default-placeholder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
152 changes: 152 additions & 0 deletions assets/default-placeholder.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/nelioefi-placeholder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
97 changes: 84 additions & 13 deletions includes/admin/edit-post.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,22 @@ function nelioefi_add_url_metabox() {

}


function nelioefi_url_metabox( $post ) {
$nelioefi_url = get_post_meta( $post->ID, _nelioefi_url(), true );
$nelioefi_alt = get_post_meta( $post->ID, '_nelioefi_alt', true );

$nelioefi_title = '';
$nelioefi_caption = '';
$nelioefi_aspect_ratio = '16:9';

$attachment_id = get_post_meta( $post->ID, '_thumbnail_id', true );
$attachment = get_post( $attachment_id );
if ( $attachment && 'nelioefi_hidden' == $attachment->post_status ) {
$nelioefi_title = $attachment->post_title;
$nelioefi_caption = $attachment->post_excerpt;
$nelioefi_aspect_ratio = get_post_meta( $post->ID, _nelioefi_aspect_ratio(), true );
}

$has_img = strlen( $nelioefi_url ) > 0;
if ( $has_img ) {
$hide_if_img = 'display:none;';
Expand All @@ -36,9 +49,24 @@ function nelioefi_url_metabox( $post ) {
$show_if_img = 'display:none;';
}
?>
<input type="text" placeholder="ALT attribute" style="width:100%;margin-top:10px;<?php echo $show_if_img; ?>"
id="nelioefi_alt" name="nelioefi_alt"
value="<?php echo esc_attr( $nelioefi_alt ); ?>" /><?php
<div id="nelioefi_meta_options" style="<?php echo $show_if_img; ?>">
<strong><?php _e( 'Title', 'nelioefi' )?></strong><br>
&nbsp;&nbsp;<input type="text" id="nelioefi_title" name="nelioefi_title"
value="<?php echo esc_attr( $nelioefi_title ); ?>" /><br><br>

<strong><?php _e( 'Caption', 'nelioefi' )?></strong><br>
&nbsp;&nbsp;<input type="text" id="nelioefi_caption" name="nelioefi_caption"
value="<?php echo esc_attr( $nelioefi_caption ); ?>" /><br><br>

<strong><?php _e( 'Aspect Ratio', 'nelioefi' )?></strong><br>
&nbsp;&nbsp;<select id="nelioefi_aspect_ratio" name="nelioefi_aspect_ratio">
<option <?php if ( '16:9' == $nelioefi_aspect_ratio ) echo 'selected="selected"'; ?> value="16:9"><?php _e( 'Super Panoramic', 'nelioefi' ); ?></option>
<option <?php if ( '4:3' == $nelioefi_aspect_ratio ) echo 'selected="selected"'; ?> value="4:3"><?php _e( 'Panoramic', 'nelioefi' ); ?></option>
<option <?php if ( '1:1' == $nelioefi_aspect_ratio ) echo 'selected="selected"'; ?> value="1:1"><?php _e( 'Squared', 'nelioefi' ); ?></option>
<option <?php if ( '3:4' == $nelioefi_aspect_ratio ) echo 'selected="selected"'; ?> value="3:4"><?php _e( 'Portrait', 'nelioefi' ); ?></option>
<option <?php if ( '9:16' == $nelioefi_aspect_ratio ) echo 'selected="selected"'; ?> value="9:16"><?php _e( 'Super Portrait', 'nelioefi' ); ?></option>
</select>
</div><?php
if ( $has_img ) { ?>
<div id="nelioefi_preview_block"><?php
} else { ?>
Expand All @@ -64,8 +92,9 @@ function nelioefiRemoveFeaturedImage() {
jQuery("#nelioefi_preview_block").hide();
jQuery("#nelioefi_image_wrapper").hide();
jQuery("#nelioefi_remove_button").hide();
jQuery("#nelioefi_alt").hide();
jQuery("#nelioefi_alt").val('');
jQuery("#nelioefi_meta_options").hide();
jQuery("#nelioefi_title").val('');
jQuery("#nelioefi_caption").val('');
jQuery("#nelioefi_url").val('');
jQuery("#nelioefi_url").show();
jQuery("#nelioefi_preview_button").parent().show();
Expand All @@ -75,10 +104,11 @@ function nelioefiPreview() {
jQuery("#nelioefi_image_wrapper").css('background-image', "url('" + jQuery("#nelioefi_url").val() + "')" );
jQuery("#nelioefi_image_wrapper").show();
jQuery("#nelioefi_remove_button").show();
jQuery("#nelioefi_alt").show();
jQuery("#nelioefi_meta_options").show();
jQuery("#nelioefi_url").hide();
jQuery("#nelioefi_preview_button").parent().hide();
}
<?php if ( $has_img ) { ?> jQuery("head").append("<style>#postimagediv{display:none}</style>"); <?php } ?>
</script>
</div>
<input type="text" placeholder="Image URL" style="width:100%;margin-top:10px;<?php echo $hide_if_img; ?>"
Expand All @@ -90,16 +120,57 @@ function nelioefiPreview() {
<?php
}

add_action( 'save_post', 'nelioefi_save_url' );
function nelioefi_save_url( $post_ID ) {
add_action( 'save_post', 'nelioefi_save_efi_information', 1, 99 );
function nelioefi_save_efi_information( $post_id ) {

// Sometimes, we save a revision (for previewing).
// We just need to make sure that we always edit the original attachment.
if ( $aux = wp_is_post_revision( $post_id ) ) {
$post_id = $aux;
}

if ( isset( $_POST['nelioefi_url'] ) ) {
$url = strip_tags( $_POST['nelioefi_url'] );
update_post_meta( $post_ID, _nelioefi_url(), $url );
} else {
$url = '';
}

if ( isset( $_POST['nelioefi_alt'] ) )
update_post_meta( $post_ID, '_nelioefi_alt', strip_tags( $_POST['nelioefi_alt'] ) );
}
if ( empty( $url ) ) {

// Remove
$feat_image_id = get_post_meta( $post_id, '_thumbnail_id', true );
if ( $feat_image_id ) {
$attachment = get_post( $feat_image_id );
if ( $attachment && 'nelioefi_hidden' === $attachment->post_status ) {
wp_delete_post( $feat_image_id );
delete_post_meta( $post_id, '_thumbnail_id' );
delete_post_meta( $post_id, _nelioefi_url() );
delete_post_meta( $post_id, _nelioefi_aspect_ratio() );
}
}

} else {

if ( isset( $_POST['nelioefi_aspect_ratio'] ) ) {
$aspect_ratio = $_POST['nelioefi_aspect_ratio'];
} else {
$aspect_ratio = '4:3';
}

if ( isset( $_POST['nelioefi_title'] ) ) {
$title = $_POST['nelioefi_title'];
} else {
$title = '';
}

if ( isset( $_POST['nelioefi_caption'] ) ) {
$caption = $_POST['nelioefi_caption'];
} else {
$caption = '';
}

nelioefi_set_external_featured_image( $post_id, $url, $aspect_ratio, $title, '', $caption );
}

}

Loading

0 comments on commit 777e7e4

Please sign in to comment.