WordPress comment form autocomplete off - wordpress

I need to disable autocomplete function for comment forms defined in comment-template.php file
2478 '<form autocomplete="off" action="%s" method="post" id="%s" class="%s"%s>'
This is my working version - but I need to be able to keep this working after update.
What is the clean way to patch WordPress core files when there is no do_action or other method for doing so.

you can create a child template, then override specific file into specific path.
after all you can be sure updating your template does not effect your modification
so you create a comment-template.php in your child template
for creating child template please visit following link
https://developer.wordpress.org/themes/advanced-topics/child-themes/

Related

Using Timber with the updated Calendar designs in The Events Calendar Plugin

I'm using the events calendar plugin for Wordpress with a Timber based theme. I'm currently using a previously documented method to integrate which is here:
https://theeventscalendar.com/support/forums/topic/events-pages-not-showing-up-in-timber-based-theme/
Since v5 of the plugin there is an option [set to default too] which uses the updated calendar and event designs that breaks my current integration method. I've tried to update my template PHP files but with little success.
The legacy functions which are relatively simple to call using the function() method in Timber are:
<?php tribe_events_before_html(); ?>
<?php tribe_get_view(); ?>
<?php tribe_events_after_html(); ?>
https://timber.github.io/docs/guides/functions/
However in the v2 templates added to The Events Calendar in v5 they are calling a class, e.g:
use Tribe\Events\Views\V2\Template_Bootstrap;
get_header();
echo tribe( Template_Bootstrap::class )->get_view_html();
get_footer();
The main problem I have is that I'm unsure how to expose this class to the Timber context. If anyone could give me a steer it would be much appreciated. What I have now works fine but the tribe_get_view function is deprecated and considered legacy so is not going to be around for ever so I need to come up with some sort of solution.
Thanks!
Right so the method I posted is no longer require at all and neither is a work around. Just make sure you have a page-plugin.twig template available. Hopefully this will help anyone else who ends up in a bit of a rabbit hole.....
To clarify, there is a workaround in timber/starter-theme, which involves multiple files, including a 'page-plugin.twig' template. Don't just add a 'page-plugin.twig' template and expect that to fix it.
Third party plugins that hijack the theme will call wp_head() to get
the header template. We use this to start our output buffer and render
into the view/page-plugin.twig template in footer.php
Go here https://github.com/timber/starter-theme.
Copy the header.php, footer.php, and page-plugin.twig into your theme and customize for your own site.
The method documented here: https://mcintosh.io/using-the-events-calendar-plugin-with-timber-and-twig/
Worked for me. You create a default template file and a matching twig template:
[your theme]/tribe/events/v2/default-template.php
[your theme]/[your twig template directory]/events.twig
The default-template.php file contains this line:
$context['tribe_markup'] = tribe( Template_Bootstrap::class )->get_view_html();
Which can be rendered like this in the events.twig template:
<div class="events-container">
{{tribe_markup}}
</div>
Note that you will need to have to select "Enable updated designs for all calendar views" in events > settings > display
I think the div.events-container may be needed for the default stylesheets, but haven't tested otherwise.

Changing the "standard template" name of the single.php post template

I have a Wordpress website, now i want to change the post template name how it displays in the Wordpress CMS. Now it's saying "Standard template", i want to rename this to "News", just for usability reasons.
I can't find a way to do this. I know you can create new post templates by creating new files, but it always takes the single.php as standard template. I'm also using a child-theme, so i dont want to delete the single.php file, just rename the text: "Standard template".
Thanks in advance.
I tried creating a new post template file with a custom title. This doesnt solve problem, as the single.php file will still be the standard one (i dont want the user to have to change the template).
You can use another single.php for another post type for example if you have news registered as a post type you could have a single-news.php and that file then would server all the single views of postype = news. But from what i understand you would like to create a template appearing to the user with a different name. For that the best practice is to create a directory inside your child theme and name it page-teplates. Inside this directory you can create as many different templates you want and wordpress will recognize them but adding the following code at the top of each template. For the sake of the example lets say i want to create a contact page template. I will create a contact.php file inside the directory page-templates and have these lines of code inside.
<?php
/**
* Template Name: Contact
**/
get_header();
/* My templates Code/Design Here */
get_footer();
The possibilities are endless.
The code in this post will generate a dropdown box similar to the one that you see in pages.
All it requires is a little editing of your child themes functions.php file .
In most cases, you just need to copy your single.php file to a new file name in your child theme and edit the functions.php file in your child theme. Name your templates as seen in the code Dimitrios posted.
consider using the premium elementor page builder to create custom post templates that you can apply at will.
Try a plugin like Post Custom Templates Lite

Wordpress static Form on any page - Plugin, Widget or Shortcode?

I am frankly new to wordpress but programm in PHP.
Task:
I have a form (don't wanna use a form plugin) and want to include this form on either 1. Sidebar or 2. within content of any Page except one (Contact-page).
I want to programm the Widget, Shortcode or Plugin bymyself. I don't need a tutorial how to programm this.
Question:
What do you advise me to use: a shortcode, plugin, widget or a "hack" in the template (f.e. if ($page!=="contact"){...}
The answer should consider
Ease and flexibility of use
Short time to develop
Speed of Rendering
Thanks for advise of experienced Wordpress Users/Developpers.
PS: the form is very simple maybe there is even another fast way you know how to do this.
Try This
1)first to fall you make a page templates of contact page.(make copy of page.php than only change the name of templates)
2)than that template in you make your custom form.
3)that page template you apply in your contact page.
Make a template-myForm.php file, and populate it with following:
<?php
/**
* Template for displaying search forms for My Web Site
*
*/
?>
<form role="search" method="get" class="search-form" action="<?php echo home_url( '/' ); ?>">
<!-- your form content-->
</form>
Add to site <?php get_template_part( 'template', 'myForm' ); ?> where you want a custom search form. I used it for search form, so it was easy to make it into widget also. I used separate template file for site search, and searcform.php for search widget. If you are aiming at different kind of form tag, you have to create that a Widget.
It is a class Your_Widget extends WP_Widget, which for you can find tutorials on your own, or just check out PHP code file: wp-includes/class-wp-widget.php in your Wordpress copy and extend it. Me personally use tutorials. I find it more simple.
So, to summ up, you would have two copies of your form - one to show as a template part, and an another one for sidebar or other registered widget area. If it is identicall in both versions, using this solution you would have to remember to keep changing it in two places (which is again simpler than hard-coding).
For me beeing not a native English speaker and just a part time Wordpress coder, this is what I offer. More integrated and PHP-programming-friendly solution, find in Wordpress forums, here on stackoverflow and Wordpress.org site.
I also am aware this is not exactly what you are looking for - not using shortcode. I hope this will kick you off into Wordpress world, and you will find how to offer a custom form to your users!
Good luck!

creating wordpress custom php page

I'm trying my make my first theme for wordpress.
Is there any possibility to create custom php page to display custom content?
Pretty much adding to WordPress another copy of the likes of single.php, post.php or 404.php.
All I want just a page to display the custom content on it.
Every tutorial I found so far uses just creating new page within WordPress.
I want to avoid it and for custom page to be enabled straight after theme activation.
The Idea is to have something like my_custom_page.php and to be able link to it after.
Is there any way of doing it?
Thanks
here is the solution to what I was looking for
http://kovshenin.com/2014/static-templates/
To achieve custom page functionality you can use page template concept of wordpress. Creating a page template is extremely easy. Create any new file in your theme and start the file with a comment block like so:
<?php
/*
Template Name: My Awesome Custom Page
*/
<h1>Hello There</h1>
You need paste php code inside this template file. When you submit for then redirection action will be page with custom template page.
Referance :
https://premium.wpmudev.org/blog/creating-custom-page-templates-in-wordpress/
Video :
https://youtu.be/1ZdHI8HuboA

admin template selection is missing on page creation in wordpress 3.2.x

I am using WordPress 3.2.1 ,
Page template selection drop down is missing on Pages (Add,Edit)
wp-admin > Pages >Add New > Page Attributes
I Edit the Template Page Default page as below code
/*
Template Name: New Template
*/
But still the template drop down no visible , my older version of WordPress it display by default.
Following is the screen shot for more idea
I solved this problem solved by adding the typical following code:
/*
Template Name: Custom
*/
Don't add any spaces after Name:
It'll work if you use template name: as well.
It might help someone: check if your index.php file is in place.
If it's not there, wordpress treats the template as corrupt and it doesn't display the template selection.
This should be simple to troubleshoot. The requirements for the page template to work are straight forward:
The template needs the page title in the top of the file like you've shown (the title needs to be wrapped in a PHP tag, you probably just didn't add it with your example bu I want to make sure you havne't overlooked it):
<?php
/*
Template Name: Custom
*/
?>
The second requirement is that the file is in the root of the theme folder.
With those two requirements in place, it should work. If it isn't working you nave a few possible issues. I list a few off the top of my head:
You might need to re-install WordPress in-case a file was corrupted
during your last update.
It's possible someone has altered the WP-Admin layout using users
roles.
That's all I can thing of at the moment, let me know how it turns out.
I had the same issue. It actually turned out to be a missing style.css file within the template directory in my case.
This happens because the get_post_templates() in class-wp-theme.php first checks for errors. If it finds any then it returns an empty array (no templates are displayed).
A side effect of this is that saving a page would clear the existing template and use the page.php instead.
So in short if the errors() method of your theme returns any errors then no templates dropdown.
hope that helps someone.
Same issued, I found out that in appearance panel in your WordPress dashboard the stylesheet is missing. You shouldn't rename the style.css in your theme folder.
Not sure if this will help anyone, but we solved the problem by disabling our theme and re-enabling it again. We had some other theme folders in the theme directory that we weren't using so we deleted those out as well. good luck, it's a really random problem to solve!
yeah!template dropdown not showing because you have no template So how to solve this::---
1 create template folder in theme
2 create a template in this folder
like:-
<?php /* Template Name: Home */ echo "template"; ?>
and check-in page dropdown will be there.

Resources