I have the plugin CKEditor for Wordpress installed and want to show a CKEditor on a custom admin page I made. I use the wordpress function wp_editor() to show it.
wp_editor("initial content", "uniqueid");
The problem is it shows a completely white editor instead of the CKEditor (so: a large white rectangle with a HTML and Visual above). It produces the following html on my page (I left out the "HTML" and "Add Media" button):
<div id="wp-uniqueid-wrap" class="wp-editor-wrap tmce-active"><link rel="stylesheet" id="editor-buttons-css" href="/wp-includes/css/editor.min.css?ver=4.1.1" type="text/css" media="all">
<div id="wp-uniqueid-editor-tools" class="wp-editor-tools">
<a id="uniqueid-tmce" class="hide-if-no-js wp-switch-editor switch-tmce" onclick="switchEditors.switchto(this);">Visual</a>
</div>
<div id="wp-uniqueid-editor-container" class="wp-editor-container">
<textarea class="wp-editor-area theEditor" rows="10" cols="40" name="uniqueid" id="uniqueid"><p>initial content</p></textarea>
</div>
</div>
Only when I click the "Visual" tab I get the CKEditor. Only then does it look exactly like the one in my regular admin pages (Posts and Pages).
So, my question is what should I add to my custom admin page or to my custom functions to have the CKEditor appear on a custom admin page like it appears on the "edit post" and "edit page" pages, without the user having to click the Visual tab to show the editor and its content?
Or, the other way around, which code is added to the regular "edit post" and "edit page" pages in order for the CKEditor to show up normally?
EDIT:
I managed to get it work partly. There is still something bugging me.
I added the following after the wp_editor() call:
<script>
window.onload = function(){
CKEDITOR.replace( "uniqueid" );
};
</script>
Now I see the editor.
I had the same issue with wp_editor() not displaying multiple TinyMCE editors on custom fields in Wordpress, as they all had the same class - so I added both 'wp_create_nonce($name)' and 'wp_create_nonce($this->id)'
<?php wp_editor($value, 'editor-'. wp_create_nonce($name) . wp_create_nonce($this->id) .'', $settings = array('textarea_name' => $name)); ?>
The nonce is generated based on the current time, the $action argument, and the current user ID.
Related
i want to remove the "home" or "shop" title from the google tab of my WordPress website as show in the picture.
how can i remove that "home" or any other page name from there in WordPress and just display my site name or maybe site title
You can do it by hooks, put this on function.php
add_filter('wp_title','hairmone_title',10,1);
function hairmone_title($title){
$title='Your new title'; //define your title here
return $title;
}
Easier is using Yoast Plugin
For all pages,
For single pages,
You should provide code here then we can help accurately.
But anyway, In header.php there is some code like <title><?php //Some Code Here ?></title>. You can remove everything between <title></title> and write your own text there.
For example <title> This is my website </title>
I am unable to display cforms II in lightbox in sidebar. Is there any way to display cforms II in lightbox?
I found this code to display in pages but it is not working in widget area.
[formlightbox text="some text"]
<!--cforms name="Call Me Back"-->
[/formlightbox]
even i used this code in page. popup displaying but cforms not displaying
<?php echo do_shortcode('[formlightbox text="some text"]<!--cforms name="Call Me Back"--> [/formlightbox]'); ?>
me too trying to get t done with the form lightbox plugin, first, the shortcode you are using doesn't support any more so visit plugin author website for updated shortcode that works with new version 1.1.2, i m using this shortcode
[formlightbox_call title="FORM NAME" class="1362370254262"]FORM NAME[/formlightbox_call]
[formlightbox_obj id="1362370254262" style="" onload="false"][/formlightbox_obj]
but the result is nothing show in lightbox....any idea guys?????
I am new to wordpress and i want to transfer data from one page to another in wordpress. I used php to post my form data to a wordpress page. My code is:
<form method='post' action='http://www.example.com/www/create_website/'>
.....
<input type ='submit' value = 'OK'/>
</form>
But every time i clicked the submit button i got error page not found. Why it is so because link is loading the page in browser but not working for form post. How can i solve the issue???
Having spent about a day figuring out how to do this, I thought it might be helpful to others in the stackoverflow community.
GOAL: To take the results from a form field and use it on another page.
In this example, my client wanted users to be able to fill in any amount in a text field to make a Paypal payment. I'm using S2Member plugin to create buttons and hook up the Paypal payments, but they did not offer this functionality --only buttons with hard wired amounts.
You can see this in action here:
http://virginiabloom.com/?page_id=250 . But it is LIVE. If you start a paypal payment, it WILL deduct money from your account. Which will make Virginia very happy.
HOW I SOLVED IT:
First, I created a form just for this field.
Enter Other Payment Amount $
Next, I found a very simple plugin on stackoverflow and adapted it to my needs:
<?php
/*
Plugin name: redirect on post
Desciption:
http://stackoverflow.com/questions/13686245/how-to-create-a-custom-url-based-on-dropdown-in-wordpress-form-submission
I-changed-dropdown-to-field-input
*/
function redirect_on_submit() {
// check if the post is set
if (isset($_POST['amount']) && ! empty ($_POST['amount']))
{
header( "Location: yourUrl.com/?
page_id=542&amount=" . $_POST['amount'] );
}
}
add_action('init', redirect_on_submit);
NOTE: Change the page URL and ID information in the header to point to the Wordpress page you want to send the information to.
If you don't know how to manually install a plugin, its very simple.
Save the snippet as a .php file. Open up your hosting account and find the plugins folder (its in the wp-content folder) Copy the file into the folder.
Go back to Wordpress and look at your plugins. You should see it there. If its not activated, the activate it.
I installed another plugin:
Allow PHP in Posts and Pages (Version 3.0.4)
After installing it, the plugin will appear on the Wordpress menu.
Open it and you can use their snippet maker that will put php into your post inside a short code.
Configuration:
Show the snippet not found message: yes (for debugging)
Use the old (pre.2.2 code: no
Use the advanced filter method: yes
Remove all plugin data on install: no
You should see the code snippet box appear at the bottom of the page.
My snippet was simple. I just wanted to echo the "amount" parameter from the page url. So it looked like this:
echo $_GET['amount']?>
Note that you have to put the ending php tag, but not the beginning tag.
Now, you just use the shortcode [php function=1] on the page wherever you want to get this parameter.
Here's what it looks like on MY results page.
<h2>Payment of $ [php function=1]</h2>
<strong><em>Click Paypal button to start payment or cancel.</em></strong>
[s2Member-PayPal-Button sp="1" ids="xxx" exp="24" desc="Payment" ps="paypal" lc="" cc="USD" dg="0" ns="1" custom="yoururl.com"
ra="[php function=1]" image="default" output="button" /]
To make sure that users can only enter in decimal numbers, I used jQuery validation on the form. There are other ways to do it, but this was very simple. Just put this code on the page with the form which I've included below.
<form id="myform" action="http://virginiabloom.com/?page_id=542" method="post"><span style="font-size:1.5em;">Enter Other Payment Amount $</span><input id="amount" class="left" name="amount" type="text" /><input type="submit" value="Submit" /></form>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://jquery.bassistance.de/validate/jquery.validate.js"></script>
<script src="http://jquery.bassistance.de/validate/additional-methods.js"></script>
<script>
$( "#myform" ).validate({
rules: {
amount: {
required: false,
number: true
}
}
});
</script>
That's it! I hope this helps somebody.
If you need to go to one of your WordPress page, please don't put the direct link in action.
Instead of that put the below php code.
<form method='post' action='<?php bloginfo('url'); ?>/your-page-name/' >
If you wants to go to a particular file inside your template directory put the below code
<form method='post' action='<?php bloginfo('template_url'); ?>/your-page.php' >
Check this WordPress codex page for more about bloginfo.
<?php bloginfo('url'); ?>
will generate the base site url.
I have created a plugin with short code now when I access the plugin through short code it works fine issue is that when I put some text above the short code that text goes below the plugin when i view the page.
Here is code that I put into wordpress editor:
<p>Unlock your device safely in 3 steps</p>
[CUSTOMSLIDER]
you can see the plugin shortcode is on second row but static text is on first row but when I will view the page the text goes below the plugin. here you can see its view. you can see the slider is at top and the text is below slider though these were opposite in original source.
in your custom plugin, instead of:
echo "content";
change that to:
$variable .= "content";
return $variable
from:
http://wordpress.org/support/topic/shortcode-moving-to-top-of-entry-content
I have modified the buddypress admin bar by creating the following plugin which adds a simple text link to the bar:
function bp_adminbar_currentsite_menu() {
global $bp;
?>
<li>
<!-- Insert your link url or relative url, and your link text below -->
EXAMPLE LINK TEXT
</li>
<?php
}
// Call The Function Above
add_action('bp_adminbar_menus', 'bp_adminbar_currentsite_menu', 999);
However, I do NOT want the above link to be shown when logged into the wordpress admin backend (so for example when an admin is editing a post). I thought about just doing a php_self check to see if it contained "/wp-admin/" but figured that there has to be a more elegant wordpress/buddypress hook here.
How can I get the above code to only show when you are viewing a normal blog page, NOT in the admin area?
Thanks
using is_admin() is the answer. It is a wordpress function that checks to see if you are looking at admin pages or not.