Using the WordPress TinyMCE in an HTML iframe for plugin - wordpress

I have a WordPress plugin with settings page. On this settings page, the form to be submitted is loaded in an iframe. I wish to utilize the WordPress TinyMCE for a textarea in this form.
How do I achieve this? I can't really do it the way it is stated here (http://keighl.com/post/tinymce-in-wordpress-plugins/) since the form is present in an HTML file.

WORDPRESS 3.5 UPDATE BELOW
If you're using Wordpress version<3.0, you can use the post you referenced to, it's great.
If your wordpress version is above 3.0 (aka newer versions) you can't use the wp_tiny_mce function for the tiny_mce, because it's deprecated. You need the newer function, wp_editor, which you can read all about it in here:
http://codex.wordpress.org/Function_Reference/wp_editor
For you to use of the wp_editor function and other WP elements your iframe (the for now containing only html and not linked into wp), you need to make your the iframe html file a php file, and add a require function of wp-load.php file.
For example, if your iframe file is in your server's root folder with your wordpress install, all you need to do is to place the following in the top of your file:
<?php
require('./wp-load.php');
?>
//iframe html/php code here
After you do that you can use any wordpress function in your iframe, including the tiny_mce.
---- UPDATE ----
If you are using wordpress 3.5 or higher, the implement method has slightly changed. more information is right in this short tutorial

Related

How to find out where a script-tag has been defined in the wordpress-header?

I have to work in a wordpress project of a former colleague. But I cannot figure out how he added an link-address to a script into the header of each page. After a global search, the link-address was found inside the sql dump of the wordpress project. I could not find any plugin he might have used. I would like to change the link-address. Any idea, how he added it?
<script src="http://custom-link/page.js" type="text/javascript" defer=""></script>
It was added by the wordpress plugin divi builder.
Divi Theme Options
To add a code to every page navigate to Divi Theme Options > Integration tab.
Make sure the “Enable header code” option is checked, and paste your code below.

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.

How do I create and link Pages in Wordpress? (not the Pages that can be created inside the Wordpress Admin)

I would like to create a fully functional page within my WordPress application (which will have jQuery and other stuff). The problem is that when I create a file within my theme/starkers (I'm using the Starkers Theme) directory let say about.php the following links (in my index.php) don't work:
<li>About</li> <-- Fatal error: Call to undefined function get_header()
<li>About</li> <-- site not found
What's the best way of doing this becasue I think I can't add PHP and jQuery and other complex stuff inside the Pages that can be created in Wordpress Admin.
Any suggestions?
What's the best way of doing this becasue I think I can't add PHP and jQuery and other complex stuff inside the Pages that can be created in Wordpress Admin.
Why not? Just make a custom page template inside your theme, create a new page on your wp-admin, and assign that custom page template for your page. You should be able to customize that as much as you want.
Try a scan here : Wordpress Template Hierarchy : Pages
Try loading
require( '/path/to/your/wordpress/wp-load.php' );

Can I use a wordpress theme in new php pages?

I'm putting together a web site that needed to include some signup and blogging capability. Wordpress seems to be a perfect fit for that portion of the app, so I've started experimenting with it. I see plenty of tutorials on creating custom themes so I don't expect that to be a problem.
What I'm not able to figure out is what to do with the rest of my site. I will have other non-blogging related php pages that will access a database, etc. I see that wordpress has a capability for generic pages of static content, but these would need to be coded PHP pages. I just can't find a way of having the wordpress theme apply to other php pages outside of wordpress. I was hoping of just doing something like
wp_header();
blah blah
wp_sidebar();
blah blah
wp_footer();
but I'm not really seeing any examples or documentation on how this might be done. Am I missing a key piece of documentation?
EDIT: The answer is to essentially copy and paste a file from the theme, with one crucial addition:
require( dirname(__FILE__) . 'path_to_wp_root/wp-load.php');
That sets up the wordpress environment and allows me to call get_header(), get_sidebar(), get_footer(), etc.
Generally, "yes".
A well-designed WordPress theme uses mostly CSS/Stylesheets for display, and you are correct in your assumptions: Look through the "Codex" about Theme Design / Template Design (http://codex.wordpress.org/Stepping_Into_Templates).
Essentially you could base your design on some of the current theme files, but leave out "the loop".
I think what you really want to do is include wp-load.php at the top of your php file. This will give you access to all the wordpress functions (wp-header(), wp-footer(), etc).
wordpress has pages in it. each page can have its own content and its own template and still be part of the whole wordpress site. i mean it will share the header and the footer if you want and will share the css and javascript that you include in both.
for more information on pages and pages templates
What you should do is develop your other non-blogging related php pages as a wordpress plugin. There are plenty of references online on how to do this, for example:
http://www.tutorialized.com/view/tutorial/Creating-a-Custom-Wordpress-Plugin-from-Scratch/41834
Another option is to use Wordpress as the CMS for all content on your site. This is increasingly becoming popular, as Wordpress is quite good at non-blog-things these days.
define('STYLESHEETPATH', '');
define('TEMPLATEPATH', '');
$base = substr(__DIR__, 0,strrpos(__DIR__, '/[name of the dir where u store the php files]'));
require_once($base."/wp-load.php");
require_once($base."/wp-includes/pluggable.php");
easy to use wordpress function outside

Resources