Wordpress theme customisations - php

I'm working on customising a Wordpress theme called BusinessFinder+. It seems like a really solid theme but I'm getting pressure from my client to make some difficult tweaks.
I'm sure there is a simple snippet for the functions.php file but my skills don't stretch that far.
I'm trying to change the placeholder text for the homepage seach form (just below the hero slider):
https://www.betauk.com/nebetasi/
The current text is "Search keywords", we need it to be "Search members".
Also, there's another search form layout here (on top of the hero image):
https://www.betauk.com/nebetasi/about-beta/
This has the same placeholder text problem, instead of "Search keywords", we need it to be "Search members".
I've tried a simple "str_replace" snippet but it doesn't touch what's in the search forms. I've tried a "str_replace" on other text sections of the homepage (for example) and it works.
Can anyone offer any tips?

If you are not able to find the way to change your placeholder then you can do this by using jquery.
Please check it:
$(document).ready(function(){
$('#searchinput-text').attr("placeholder","Search members");
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<input type="text" name="s" id="searchinput-text" placeholder="Search keyword" class="searchinput" value="">
with using this code, your both search text box placeholder text will be changed.
Thanks.

Why don't you just go into where the form is (either in widgets or possibly in appearance->editor and amongst the files there) and find the form widget and edit the forms placeholder attribute?
<input type="text" name="s" id="searchinput-text" placeholder="Search keyword" class="searchinput" value="">

Related

Transfer Data from A Widget Search To A SEO Tool I am using my Site

I have a WordPress site at www.itzfizz.com and have this custom SEO tool on this page https://itzfizz.com/seo-analyzer/ which basically tells the user the different ways to improve the content of a page/blog
I am trying to create a sidebar widget on my blog posts, where if a user types in their site, the query transfers from the search on the blog sidebar onto the SEO analyzer search bar.
I've used
<form method="get" action="https://itzfizz.com/seo-analyzer/?p=text">
<input type="text" name="keyword" />
</form>
<button type="submit">Analyze Website</button>
but the query isn't transferred to the SEO analyzer page (Search Box) as the URL is static, can someone recommend options I can follow.
Thanks a ton
Several things to fix:
The p parameter should be removed.
The url parameter which is the URL of the website to be analysed is missing in your form.
The submit button is outside the form, so it doesn't do anything
The output and ref parameters are missing. Since they are fixed they can just be hardcoded as hidden.
Here's the complete code for the form.
<form method="get" action="https://itzfizz.com/seo-analyzer/">
<input type="hidden" name="output" value="html"/>
<input type="hidden" name="ref" value="https://itzfizz.com/seo-analyzer/"/>
<input type="url" name="url" placeholder="https://www.yoursite.com" />
<button type="submit">Analyze Website</button>
</form>

Custom HTML for the search box used by the ListController behavior

I want to customize list searching behavior for backend panel.
I need to send keywords through ajax request, make a specific query and return/update this list.
At the moment search input works through Data attributes API.
<input placeholder="Search..." type="text" name="listToolbarSearch[term]" value="2" data-request="listToolbarSearch::onSubmit" data-track-input="" data-load-indicator="" data-load-indicator-opaque="" class="form-control icon search growable" autocomplete="off">
To be more exact I want to extend data-request="listToolbarSearch::onSubmit" function or make something like this and execute it through javascript ajax api on click event. I can't find this function in the framework(
This is fairly simple to do. Inside your List Controller configuration (config_list.yaml file), the toolbar search option will accept a partial name to use.
# Toolbar widget configuration
toolbar:
# Partial for toolbar buttons
buttons: list_toolbar
# Partial for toolbar search
search: my_search
Then inside your controller view directory you can use any search markup you like. For example, create a partial called _my_search.htm with these contents:
<div class="loading-indicator-container size-input-text">
<input
placeholder="Search for something"
type="text"
name="term"
value=""
data-request="onMyHandler"
data-track-input
data-load-indicator
data-load-indicator-opaque
class="form-control"
autocomplete="off" />
</div>

How to add placeholder to joomla contact form

I am designing a template, however, I want my contact form to have placeholders. I tried overriding the contact component form file components/com_contact/views/contact/tmpl/default_form.php but it seems to use joomla JForm or something that doesn't give me the ability to add placeholder directly.
$this->form->getInput('contact_name');
$this->form->getInput('contact_email');
...
How can I add placeholde to the contacts? I definitely don't want to replace those pieces of code with naive html code. Neither I want to add a javascript code to do that (I know it's hard but I want it to be done using Joomla core).
You can add hint="Placeholder name" in components/com_contact/models/forms/contact.xml
<field
name="contact_name"
type="text"
label="COM_CONTACT_CONTACT_EMAIL_NAME_LABEL"
description="COM_CONTACT_CONTACT_EMAIL_NAME_DESC"
id="contact-name"
size="30"
filter="string"
required="true"
hint="Placeholder name"
/>

custom wordpress comment form html

I would like to modify the actual HTML of the comment forms in WordPress. I know of the comment_form() function that WordPress provides, but it doesn't actually let me modify the html of the form. What I'm specifically trying to do is make a bootstrap responsive form, which is not possible with the options provided with the comment_form() function. I've tried looking all over the internet for a way, but to no avail. Can anyone point me in the right direction?
Let me clarify this:
I am looking to modify the actual FORM and containing DIV elements of the comment form, not just the fields.
The uncustomizable parts of the function comment_form() should (idealistically) be limited purely to code that is essential for security and proper form handling by the WordPress core. However, that is not the case. To explore the issue, I used filters (could have used arguments) to completely remove all the code that is customizable. I set all available variables to empty strings—that is, all the stuff mentioned on the codex page for comment_form().
Here is the left-over, non-customisable code from comment_form():
<div id="respond" class="comment-respond">
<h3 id="reply-title" class="comment-reply-title"> <small><a rel="nofollow" id="cancel-comment-reply-link" href="/1#respond" style="display:none;">Click here to cancel reply.</a></small></h3>
<form action="http://www.[yourdomain].com/wp-comments-post.php" method="post" id="" class="comment-form">
<p class="form-submit">
<input name="submit" type="submit" id="" value="" />
<input type='hidden' name='comment_post_ID' value='1' id='comment_post_ID' />
<input type='hidden' name='comment_parent' id='comment_parent' value='0' />
</p>
</form>
</div><!-- #respond -->
Where does all this come from? At the bottom of the codex page for comment_form() it says…
Source Code
comment_form() is located in wp-includes/comment-template.php.
comment-template.php is linked and you can view the full code in the browser. comment_form() starts on line 1960. In fact, it’s the last function in that file. There are no arguments or filters that let you modify the residual code above. These lines of code are all moreorless “hard-coded”.
The text Click here to cancel reply. is the only text that survived my filter genocide. Strangely, comment_form() has back-up text for cancel_reply_link hard-coded into the function, in case it is passed to the function as an empty string. None of the other filterable items have hard-coded back-ups.
It is easy to see which bits of code are essential and which bits are non-essential for a HTML form. A little more difficult to judge is which bits are essential for a WordPress form. Some of the bits above were dynamically output (note that this is the first comment on a development blog with no other replies, no parent/child comments).
From the comment_form() function in comment-template.php you can draw out the code needed to produce the dynamic parts of the WordPress form. Then, with default arguments taken from the codex page for comment_form(), you could piece together a barebones form, hard-coding the desired fields, labels and wrapping HTML. I’m doing that now and putting my custom form function in my theme’s comments.php template file, which I call using comments_template() only in single.php (for this particular theme).
The result would be a full and proper, lean and mean WordPress comment form. But… it would be a form that could not be customized anymore using comment_form() arguments or related filters unless you went ahead and included the filter code in your own comment form function. Since you’re customizing the heck out it already, that’s probably not a problem. Similarly, all the WordPress actions would also be unavailable to you or any other plugins unless you also triggered those action functions in your own comment form function. Again, probably not an issue for you at this point.
But most importantly, the resulting form might break your theme if future WordPress updates change the way the core handles forms.
If you’re aware of those risks, you can probably rebuild a hand-coded comment form just from copying code on the codex page for comment_form() and in wp-includes/comment-template.php. I don’t have the finished code, otherwise I’d post it. But I will post when/if I succeed.
Right, that’s all from me for now. Bear in mind (all readers) that despite appearances, I am an amateur WordPress theme developer and my proficiency with PHP and WordPress is very rudimentary. Just writing up this post I learned a lot.
I’m also worried that a full and proper solution is already out there somewhere but I haven’t found it in my searches.
Just Create a New PHP file with the name of comment_form.php then paste all of your code. And your comment form is ready.
you shouldn't edit the wp-includes/comment-template.php file.
Keep this for your ref for more styling your existing comment form
http://codex.wordpress.org/Template_Tags/comment_form
Or this one
http://wordpress.org/support/topic/where-to-find-the-comment_form-function-in-wp3
Form code and action
<div class="comment-form">
<h2 class="comments-wrapper-heading"> Leave a comment </h2>
<form id="commentform" action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
<div class="commentform-element">
<label class="hide" for="author">Full Name</label>
<input class="input-fields" id="author" name="author" type="text" placeholder="Full Name" value=""/>
</div>
<div class="commentform-element">
<label class="hide" for="author">Email</label>
<input class="input-fields" id="email" name="email" type="text" placeholder="Email" value=""/>
</div>
<div class="commentform-element">
<label class="hide" for="comment">Message</label>
<textarea id="comment" class="input-fields" placeholder="Message" name="comment" cols="40" rows="200"></textarea>
</div>
<input name="submit" class="form-submit-button" type="submit" id="submit-comment" value="Post comment">
<input type="hidden" name="comment_post_ID" value="22" id="comment_post_ID">
<input type="hidden" name="comment_parent" id="comment_parent" value="0">
</form>
</div>
WP does not offer a way to create and use a comment form template. i.e.: as of 4.1.1, there's still no way to control all of the HTML markup that makes up the form. There are only ways to edit parts of it and that's by supplying arguments to comment_form().
So, if you would like to edit the whole layout (e.g.: place some of the content side to side instead of on top of one another; replace some of the <p>with <div>), you're out of luck.
What can we do?
An option would be to borrow the whole comment_form() function from the WordPress codebase (like this guy did): make a copy of the function in your theme, rename it, customize it and then call it in place of the vanilla function. That will work but there's a chance it might break on a future WordPress update if some of the inner workings of WP change.
Did you look for the comment_form() function in Wordpress code to see if you can edit it ?
You'll also find some informations here :
http://wordpress.org/support/topic/editing-the-comment-form
This function uses the default form. You need to make a comment-template.php file in your theme and in that file you can make your form.
Now when you will call comments_template() you will get your made form instead of default form.
I don't think you can change the containing div (<div id="respond" class="comment-respond">). Have a look at the comment-template.php
The only thing you can change is the form ID. 'id_form' => 'commentform'
You can make a responsive form without changing these elements.
I've recently answered something similiar on WPSE. You can go and check it out here

Javascript: Loading data into an hidden form element

I'm working on a school assignment, which consists of creating a social network (Basically: Facebook :P). This is in groups, and one of us wrote an auto-complete search engine, which works like this:
http://img585.imageshack.us/img585/333/194d61cbc3fe4cc98005ea1.png
You enter a name, it used some js and php to query the DB to find profiles matching the part of the string you entered. Now, I want to use this functionality to implement the tagging of photos. Now the problem is this: This .js script returns an unordered list of elements, consisting of links (hrefs), and if one is selected:
select: function( event, ui ) {
if (ui.item) {
window.location.href = ui.item.href;
}
}
gets called to navigate to the appropriate profile. Now what I'd like to do is: Enter a string, get the list of query results, and when I click one, i want to load it inside the box. Now I have almost 0 experience with PHP and JavaScript (I had to learn it from scratch basically, I can handle most of it now, but still... :P), and I can't get it to work
Basically that text box is "defined" in the html like this:
<div class="widget" id="search">
<form id="search" method="POST" enctype="multipart/form-data">
<input type="hidden" name="search" value="3559d7accf00360971961ca18989adc0614089c0" />
<div class="field text term "><label for="term">Zoeken</label>
<input type="text" name="term" id="term" class="text" value="" />
</div>
</form>
</div>
How do I access that actual textbox, and put data in it? Any takers? :) I can't seem to get it to work, despite trying almost every name, id or class that I see there. I just need to get the clicked name into the box, so I can just submit it & enter it into the database, as having to enter the entire exact name manually isn't really... Fancy enough
document.getElementById('term').value = newValue;
or, using jQuery (as you specified in the tags):
$('#term').val(newValue);

Categories