i create a new plugin .When the plugin is installed then a new link namely exam description setting will be come under the settings bar of wordpress dashboard. It have a text field for exam name & text area for exam description. When i give the corresponding data then it will be saved in new db created by my plugin. Db structure is e_id(int),e_name(varchar),e_des(text).So now my need is to use wp-editor *instead of* using text area .Is there any method to implement it.?
The function wp_editor is your answer (https://codex.wordpress.org/Function_Reference/wp_editor).
<?php
wp_editor($e_des, 'editor_' . $e_id, array(
'textarea_name' => 'editor_' . $e_id
));
?>
Related
I am new to WordPress but learning very fast. I started my first plugin that creates a custom admin menu. One of the submenus is named Business Profile. Here is what I want to do:
1). Add custom fields to the Business Profile to collection business info (ex: Business Name)
2). Each custom field needs a related shortcode
3). All shortcodes can be placed within content on Posts and Pages and replaced with the custom field value.
I'm looking for a tutorial or some direction on how to do the above without the use of a plugin. Can anyone point me in the right direction?
I believe that you want to store and retrieve only one business information.
function sample_register_my_custom_menu_page(){
add_menu_page(
__( 'Business Profile', 'business-profile' ),
'Business Profile',
'manage_options',
'business-profile-settings',
'business_profile_settings_page',
80
);
}
add_action( 'admin_menu', 'sample_register_my_custom_menu_page' );
function business_profile_settings_page(){
if ($_POST) {
// Form Submission Processing
$business_profile = array();
$business_profile['business_name'] = sanitize_text_field($_POST['business_name']);
update_option('business_profile_details', $business_profile);
}
// Form View
// Add your html form here
$business_profile = get_option( 'business_profile_details' );
// Get your saved data and pre fill your form.
}
You can further use add_shortcode to get the data from the options and display it the post.
Note: Use wp_options to store this data only if this is a single data set. If you want to save data of multiple business you may need to use a custom post for it.
I am new to moodle and i am using 2.9. I have a separate design for Signup page (HTML5 & CSS). How to integrate this page ?
I know the process of changing the default Login page like this
In config.php of my theme
'login' => array(
'file' => 'login.php',
'regions' => array(),
'options' => array('langmenu'=>true),
),
Where my Custom login page is login.php which is placed in my layout folder. So in this way i can takeover Login page design with my new design.
But i don't see any signup array in config page for Registration. So anyone can tell me how to do this change ?
Edit - I have checked this file moodle2\login\index_form.html I can see the signup design. But my issue is that file index_form.html has Moodle core CSS if i add my CSS there it will conflict also i dont know how to load the CSS from my theme folder to index_form.html.
Can anyone guide me ?
I already checked Moodle.org forum but not able to find the process.
Thanks In Advance
Lorry
Further to what #davosmith mentioned, you can actually use the existing auth/email plugin as a base for your plugin, So:
Copy auth/email and rename it to whatever you want, for example auth/foo. And rename all other instances of "email" to "foo".
Copy the login/signup_form.php to your plugin directory
in your auth/foo/auth.php file, add a function:
function signup_form() {
global $CFG;
require_once($CFG->dirroot.'/auth/foo/signup_form.php');
return new login_signup_form(null, null, 'post', '',
array('autocomplete'=>'on'));
}
Modify the auth/foo/signup_form.php to whatever you want
Hiii,
I'm one of the Moodler who working with Moodle.
to edit the signup page go at the following location and open the signup.php file.
./moodle/login/signup.php
in that file you can see at bottom of the page three lines.
...
echo $OUTPUT->header();
$mform_signup->display();
echo $OUTPUT->footer();
in which $mform signup->display(); create a form yu can comment and write HTML for your sign up form.
But make sure about the Action URL and the validations.
$mform is the object that create form and its class file is signup_form.php.
Hope it helpful for you ... Good Luck ['}
If you are wanting to avoid making changes to the core code in Moodle (which should almost always be what you want), then you can create a new signup form from scratch by first creating a new authentication plugin (in auth/NAMEOFPLUGIN).
When you create the authentication plugin, you should make sure that the 'can_signup' function returns true, that the 'user_signup' function does whatever processing is needed to create the new user account and that the 'signup_form' function returns a custom Moodle form that contains the fields you want.
It is possible to further customise this form by outputting custom HTML elements (using $mform->addElement('html', 'The HTML to output'); ). I would not advise completely abandoning the Moodle form (i.e. to replace it with hand-coded custom elements), as that will not be compatible with the signup code in login/signup.php (as well as losing the validation rules that are supported by the forms library).
i am newbie to wordpress theme development...
i know to create theme options in wordpress themes but now i want to use WYSIWYG Editor of wordpress, the wp_editor(), i have read some tuts on this but i can't make it...
here is my code:
add_settings_field('tinytxt', 'WYSIWYG: ', array($this, 'tinytxt'), 'oditer_theme_options', 'jd_theme_options_main_section');
public function tinytxt() {
wp_editor("{$this->options['tinytxt']}", 'tinytxtboom');
}
And how to retrieve the saved content from the database, i know to use get_option()...
thanks in advance...
You need to give your WordPress editor a name for the input, so that it can save the value.
wp_editor( $this->options['tinytxt'], 'tinytxtboom', array(
'textarea_name' => 'jd_theme_options[tinytxt]'
) );
This will give the hidden textarea wp_editor uses a name for the form submission. jd_theme_options matches the second argument to register_setting, and tinytxt is the option key you want to save the value under.
I think that's all you need. Comment if you have trouble. I'll be back tomorrow to check.
You could also try getting it to work with just a simple textarea, then try to get the wp_editor working.
How can i filter the link given in "link to existing content".
As in the above image. I just want WSP BANNER TO BE SHOWN.
where WSP BANNER & CALENDAR are custom post_type
Any help will be appreciable.
Currently there are no ready filters available for this purpose. A ticket has been posted for the request.Lets hope we get one soon.
Till then you can create your own filter.
Open includes/class-wp-editor.php and make folowing changes at line no 712
$pt_names = apply_filters('custom_insert_link_suggestion_filter',array_keys( $pts ));
we just added a new filter instead of getting all the public post types
Then in your theme add following code to filter the internal link custom post type
function my_filter_function($allowed_post_types)
{
if( condition chek)
{
return array('page','your custom post types');
}
}
add_filter('custom_insert_link_suggestion_filter','my_filter_function',10,1);
There is a plugin that could be helpful for you: B09 Link to Existing Content
It has a filter called "link_to_existing_content_post_types", that enables you to control which post types should be searched.
You can also use it together with this plugin, if you also want to have complete control over the search results: Search Everything.
Consider an example where my site is configured on wp.abc.com and I point my root domain www.abc.com to the new site. I need to update the URL's in General Setting. So when I update the URL, it is reflected in menu items etc. Will it be reflected in the content area links aslo?
I've built a view using the views module in Drupal to display a grid of thumbnail images (field_image) that are linked to a full size image for use with Lightbox.
I've got that part working but I also display caption text beneath the thumbnail image. I want to append this caption text to the A tag like: ...
I looked at overriding the views-view-field.tpl.php template but this is no HTML in this template it just prints $output;
I'm assuming that some PHP function somewhere in the views module is generating the actual HTML code for the link but I don't know where and how to override it in my theme.
Any help would be appreciated.
The $output for views-view-field.tpl.php is generated by default in the views field handler itself. You can set aside the $output variable, and use the template variables mentioned in the comments at the start of the file to build your own output.
I install the devel module, then using dpm($row) (etc) to see what values are available. All fields your View is pulling are available in the template. This includes fields for which you check on the "Exclude" option.
In building your link, I suggest you use the Drupal API functions, that way the link will be properly modified by other Drupal functions.
l(t('Link Title'), url/path, array(
'attributes' => array(
'title' => t('My Image Caption'),
),
));