$sjb_attach_resume = '<div class="col-md-3 col-xs-12">'
. '<label for="applicant_resume">' . apply_filters('sjb_resume_label', __('Attach Resume', 'simple-job-board')) . '<span class="sjb-required required">*</span></label>'
. '</div>'
. '<div class="col-md-9 col-xs-12">
<div class="form-group">'
. '<input type="file" name="applicant_resume" id="applicant-resume" class="sjb-attachment form-control "' . apply_filters('sjb_resume_required', 'required="required"') . '>'
. '<span class="sjb-invalid-attachment validity-note" id="file-error-message"></span>'
. '</div>'
. '</div>'
. '<div class="clearfix"></div>';
echo apply_filters('sjb_attach_resume', $sjb_attach_resume);
I assume you didn't write the code, since you're asking this. Honestly and respectfully you should learn the basics before playing around with file uploads etc. as it can be a major security risk if not handled properly.
As for your question, you can remove the required-attribute completely from the file input:
$sjb_attach_resume = '<div class="col-md-3 col-xs-12">'
. '<label for="applicant_resume">' . apply_filters('sjb_resume_label', __('Attach Resume', 'simple-job-board')) . '<span class="sjb-required required">*</span></label>'
. '</div>'
. '<div class="col-md-9 col-xs-12">
<div class="form-group">'
. '<input type="file" name="applicant_resume" id="applicant-resume" class="sjb-attachment form-control ">'
. '<span class="sjb-invalid-attachment validity-note" id="file-error-message"></span>'
. '</div>'
. '</div>'
. '<div class="clearfix"></div>';
echo apply_filters('sjb_attach_resume', $sjb_attach_resume);
...or remove it by modifying the filter applied, by adding a code snippet to your theme's functions.php file:
add_filter( 'sjb_resume_required', '__return_empty_string' );
Related
I have a website where users may upload images...
I need to add my logo (watermark) to the images every single time to uploaded.
How can I do so?
Anybody have a good tutorial, article or example for this? Or know of any function in php which I would need to find the position of the watermark?
<?php
if(houzez_edit_property()) {
$property_images = get_post_meta( $property_data->ID, 'fave_property_images', false );
$featured_image_id = get_post_thumbnail_id( $property_data->ID );
$property_images[] = $featured_image_id;
$property_images = array_unique($property_images);
if (!empty($property_images[0])) {
foreach ($property_images as $prop_image_id) {
$is_featured_image = ($featured_image_id == $prop_image_id);
$featured_icon = ($is_featured_image) ? 'text-success' : '';
$img_available = wp_get_attachment_image($prop_image_id, 'thumbnail');
if (!empty($img_available)) {
echo '<div class="col-md-3 col-sm-4 col-6 property-thumb">';
echo wp_get_attachment_image($prop_image_id, 'houzez-item-image-1', false, array('class' => 'img-fluid'));
echo '<div class="upload-gallery-thumb-buttons">';
echo '<button class="icon icon-fav icon-featured" data-property-id="' . intval($property_data->ID) . '" data-attachment-id="' . intval($prop_image_id) . '"><i class="houzez-icon icon-rating-star full-star '.esc_attr($featured_icon).'"></i></button>';
echo '<button class="icon icon-delete" data-property-id="' . intval($property_data->ID) . '" data-attachment-id="' . intval($prop_image_id) . '"><span class="btn-loader houzez-loader-js"></span><i class="houzez-icon icon-remove-circle"></i></button>';
echo '</div>';
echo '<input type="hidden" class="propperty-image-id" name="propperty_image_ids[]" value="' . intval($prop_image_id) . '"/>';
if ($is_featured_image) {
echo '<input type="hidden" class="featured_image_id" name="featured_image_id" value="' . intval($prop_image_id) . '">';
}
echo '</div>';
}
}
}
}
?>
Use PHP GD Library. You can open saved image file, write text or overlay watermark image and save image again.
I'm developing a News website in Wordpress, and I need to show in a bootstrap carousel the first three posts, my problem is that I need to add the "active" class only at the first of the three elements, but really don't know how to. Here's my code:
<?php
$args = array('numberposts' => '3');
$recent_posts = wp_get_recent_posts($args);
foreach ($recent_posts as $recent) {
echo '<div class="item active"><a href="' . get_permalink($recent["ID"]) . '" title=" ' . esc_attr($recent["post_title"]) . '" >' .$recent["post_date"] . ': <strong>' .$recent["post_title"] . '</strong></a></div>';
}
?>
I've already tried a answer found on this site (this one):
$isFirst = true;
foreach ($recent_posts as $recent) {
echo '<div class="item' . $isFirst ? ' active' : '' . '"><a href="' . get_permalink($recent["ID"]) . '" title=" ' . esc_attr($recent["post_title"]) . '" >' .$recent["post_date"] . ": <strong>" .$recent["post_title"] . '</strong></a></div>';
$isFirst = false;
?>
but it just printed me the "active" words.
Thanks for your help
You need to set $i so that you can count how many times you have gone through the loop and do some logic with it, like in my example below. Instead of having two lines of code that are nearly identical like I have done below though, you should be able to do the if conditional right around the class active. I didn't do that so you could clearly see the conditional and the count of the loops through the array.
<?php
$args = array('numberposts' => '3');
$recent_posts = wp_get_recent_posts($args);
$i = 0;
foreach ($recent_posts as $recent) {
if ($i == 0) {
echo '<div class="item active"><a href="' . get_permalink($recent["ID"]) . '" title=" ' . esc_attr($recent["post_title"]) . '" >' .$recent["post_date"] . ': <strong>' .$recent["post_title"] . '</strong></a></div>';
} else {
echo '<div class="item"><a href="' . get_permalink($recent["ID"]) . '" title=" ' . esc_attr($recent["post_title"]) . '" >' .$recent["post_date"] . ': <strong>' .$recent["post_title"] . '</strong></a></div>';
}
$i++;
}
?>
I was wondering whether you guys could help me figure out why this isn't generating the HTML correctly. The variable $wholeTeam is returned from $wpdb->get_results(...) and is confirmed to be of length 3 (because echo count($wholeTeam) is spitting that number out and I've directly looked in the MySQL db to make sure there are 3 rows). For some reason, only the last of the 3 is being generated; the first 2 aren't.
<h2>Current members <span class="title-count"> <?php echo count($wholeTeam) ?> </span></h2>
<div class="row">
<?php
$sandwichTop = '<div class="col-xs-12 col-sm-6 col-md-4 col-lg-3"><img src="/assets/';
$sandwichBottom = '/><button type="button" class="edit-mem-btn wp-core-ui button-primary">Edit</button></div>';
foreach ($wholeTeam as $thisMember)
$sandwichMiddle = $thisMember->picfn . '" id="memberid-' . $thisMember->id . '"';
echo $sandwichTop . $sandwichMiddle . $sandwichBottom;
?>
</div>
gets generated as
<div class="row">
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-3">
<img src="/assets/thepic.png" id="memberid-3"/>
<button type="button" class="edit-mem-btn wp-core-ui button-primary">Edit</button></div>
</div>
</div>
Code
foreach ($wholeTeam as $thisMember)
$sandwichMiddle = $thisMember->picfn . '" id="memberid-' . $thisMember->id . '"';
echo $sandwichTop . $sandwichMiddle . $sandwichBottom;
is equivalent to:
foreach ($wholeTeam as $thisMember) {
$sandwichMiddle = $thisMember->picfn . '" id="memberid-' . $thisMember->id . '"';
}
echo $sandwichTop . $sandwichMiddle . $sandwichBottom;
That's why you echo only once. If you want to echo every foreach iteration:
foreach ($wholeTeam as $thisMember) {
$sandwichMiddle = $thisMember->picfn . '" id="memberid-' . $thisMember->id . '"';
echo $sandwichTop . $sandwichMiddle . $sandwichBottom;
}
I have thoroughly confused myself.
I have a page with information that is dynamically generated with PHP. I am trying to use jQuery to hide and reveal the information. However, when I execute the code the function only works on the first instance.
Here's the html/php code:
<div id="container">
<?php
foreach ($datas as $name)
{
if ($name['state'] === 'PA')
{
echo
'<input type="hidden" name="id" value="' . $name['id'] . '" />' .
'<h1 id="name">' . htmlentities($name['name']) . '</h1>' .
'<p id="descriptionlist">' .
htmlentities($name['description']) . ' ' .
'<br />' .
'<ul id="link">' .
'<li class="l1">' .
'' . $name['sname'] . '' .
'</li>' .
'</ul>' .
'</p>' .
'<div id = "locBar' . $name['id'] . '">' . '<div id="locText' . $name['id'] . '">' .
'<h2 id="location">Location</h2>' .
'</div>' . '</div>' .
'<div id="locDiv' . $name['id'] . '">' .
Here's the jQuery script:
$(document).ready(function(){
$('#locBar').click(function(){
$('#locDiv').slideToggle('slow')
})
});
Obviously, jQuery doesn't understand that if I am clicking the div in the second iteration, that anything should happen. How do I fix this?
What does the generated html look like?
Im guessing as this is the beginning of a foreach loop, you are generating multiple divs with the same ID (locBar and locDiv). You should never have multiple items with the same ID.
Change it to use class instead
I have the following variable $prod_list_contents which is a mix of html and php METHODS to display the products from my database:
$prod_list_contents .= '<div style="width:100%;">';
$prod_list_contents .= '';
while ($listing = tep_db_fetch_array($listing_query)) {
$rows++;
$prod_list_contents .= '
<div class="cat_prod_box">
<div class="image">
<div class="cat_image_table">
<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES_CAT . $listing['products_image'], $listing['products_name'], 255, 340, 'class="cat_image_round"') . '
<div class="hidden_thing">Click to View</div>
</a>
</div>
</div>
<div class="cat_product_info" >';
$prod_list_contents .= '<div class="span_style_num">Style: '. $listing['products_model'] . '</div>';
$prod_list_contents .= '<div class="span_colors">Colors: red, blue</div>';
$prod_list_contents .= '<div class="span_product_name">' . $listing['products_name'] . '</div>';
$prod_list_contents .= '<div class="span_price">CAD ' .$currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) .'</div>' ;
$prod_list_contents .= '</div></div>';
}
$prod_list_contents .= ' </div>' .
' '
;
echo $prod_list_contents;
I am trying to incorporate a color table into the same div that is being displayed through this same variable. My color table is derived through the following bit of php:
<div >
<?php
$ctr = 0;
$clr=1;
foreach($products_options_array as $products_options_array2) {
$ctr++;
//if it is a color image, or a color hex
if($products_options_array2['color_image']!='')
{
$clr_sec = "style=\"background-image:url(images/pattern/".$products_options_array2['color_image'].") !important; height:28px; width:28px;\"" . "class=\"testy\"";
}
else {
$clr_sec = "style=\"background-color:".$products_options_array2['color_code']." !important; height:28px; width:28px;float:left;\"" . "class=\"testy\"";
}
?>
<div <?php echo $clr_sec;?>> </div>
<?php
$clr++;
} ?>
</div>
I have tried adding it into the prod_list_contents variable but I don't think I can because of the php here is not METHODS. and requires semi colons etc. Is there another way to go about this? Or am I able to add it in and I'm just being stupid?
If i understand your question correctly you wan to add $clr_sec to $prod_list_contents.
Just change
<div <?php echo $clr_sec;?>> </div>
to
$prod_list_contents.='<div '.$clr_sec.'</div>';