Skip to content
This repository has been archived by the owner on Oct 29, 2022. It is now read-only.

Commit

Permalink
Fixed typo/syntax error in gallery field
Browse files Browse the repository at this point in the history
  • Loading branch information
RostiMelk committed Mar 31, 2020
1 parent 3a49af5 commit 8114393
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions scripts/fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ function acf_field(appendCode, fieldName, typeOfField, returnType, seniority, pl
case "file":
switch (returnType) {
case "array":
var fieldCode = "<?php\n" + "$file = get_field('" + fieldName + "');\n" + "if ($file): ?>;\n" + "\t<a href=\"<? php echo $file['url']; ?>\"><?php echo $file['filename']; ?></a>\n" + "<?php endif; ?>";
var fieldCode = "<?php\n" + "$file = get_field('" + fieldName + "');\n" + "if ($file): ?>;\n" + "\t<a href=\"<?php echo $file['url']; ?>\"><?php echo $file['filename']; ?></a>\n" + "<?php endif; ?>";
break;
case "url":
var fieldCode = "<?php if( get_field('file') ): ?>\n" + "\t<a href=\"<?php the_field('" + fieldName + "'); ?>'>Download File</a>\n" + "<?php endif; ?>\n";
break;
case "id":
var fieldCode = "<?php\n" + "$file = get_field('" + fieldName + "');\n" + "if( $file ):\n" + "\t$url = wp_get_attachment_url( $file ); ?>\n" + "\t<a href=\"<? php echo esc_html($url); ?>\">Download File</a>\n" + "<?php endif; ?>";
var fieldCode = "<?php\n" + "$file = get_field('" + fieldName + "');\n" + "if( $file ):\n" + "\t$url = wp_get_attachment_url( $file ); ?>\n" + "\t<a href=\"<?php echo esc_html($url); ?>\">Download File</a>\n" + "<?php endif; ?>";
break;
default:
fieldError();
Expand All @@ -73,7 +73,7 @@ function acf_field(appendCode, fieldName, typeOfField, returnType, seniority, pl
case "gallery":
switch (returnType) {
case "array":
var fieldCode = "<?php\n" + "$images = get_field('" + fieldName + "');\n" + "if( $images ): ?>\n" + "\t<?php foreach( $images as $image ): ?>\n" + "\t\t<a href=\"<? php echo esc_url($image['url']); ?>\">\n" + "\t\t\t<img src=\"<? php echo esc_url($image['sizes']['thumbnail']); ?>\" alt=\"<? php echo esc_attr($image['alt']); ?>\"/>\n" + "\t\t</a>\n" + "\t<?php endforeach; ?>\n" + "<?php endif; ?>";
var fieldCode = "<?php\n" + "$images = get_field('" + fieldName + "');\n" + "if( $images ): ?>\n" + "\t<?php foreach( $images as $image ): ?>\n" + "\t\t<a href=\"<?php echo esc_url($image['url']); ?>\">\n" + "\t\t\t<img src=\"<?php echo esc_url($image['sizes']['thumbnail']); ?>\" alt=\"<?php echo esc_attr($image['alt']); ?>\"/>\n" + "\t\t</a>\n" + "\t<?php endforeach; ?>\n" + "<?php endif; ?>";
break;
case "url":
var fieldCode = "<?php the_field('" + fieldName + "'); ?>";
Expand Down Expand Up @@ -126,7 +126,7 @@ function acf_field(appendCode, fieldName, typeOfField, returnType, seniority, pl
break;

case "page_link":
var fieldCode = "<?php\n" + "$urls = get_field('" + fieldName + "');\n" + "if( $urls ): ?>\n" + "\t<?php foreach( $urls as $url ): ?>\n" + "\t\t<a href=\"<? php echo esc_url($url); ?>\" ><?php echo esc_html( $url ); ?></a>\n" + "\t<?php endforeach; ?>\n" + "<?php endif; ?>";
var fieldCode = "<?php\n" + "$urls = get_field('" + fieldName + "');\n" + "if( $urls ): ?>\n" + "\t<?php foreach( $urls as $url ): ?>\n" + "\t\t<a href=\"<?php echo esc_url($url); ?>\" ><?php echo esc_html( $url ); ?></a>\n" + "\t<?php endforeach; ?>\n" + "<?php endif; ?>";
break;

case "relationship":
Expand Down Expand Up @@ -232,4 +232,4 @@ function acf_field(appendCode, fieldName, typeOfField, returnType, seniority, pl
if(!appendCode) {
copyCodeToClipboard(fieldCode, subFields);
}
}
}
2 changes: 1 addition & 1 deletion scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,4 +197,4 @@ function copyFieldCode() {
// Clear session storage
sessionStorage.removeItem("fieldcode");
});
}
}

0 comments on commit 8114393

Please sign in to comment.