When using featherlight as a wordpress plugin, how can I change default options without breaking theme, etc.?
I see that the only js loaded on my page is
/wp-content/plugins/wp-featherlight/js/wpFeatherlight.pkgd.min.js?ver=1.3.0
Currently I need to add all these attributes to every link:
data-featherlight="iframe"
data-featherlight-iframe-frameborder="0"
data-featherlight-iframe-allow="autoplay; encrypted-media"
data-featherlight-iframe-allowfullscreen="true"
data-featherlight-iframe-style="position:fixed;background:#000;border:none;top:0;right:0;bottom:0;left:0;width:100%;height:100%;"
...which is a lot of repeated overhead. How can I set these as defaults for all my iframe lightboxes?
You can set defaults globally like this:
$.extend($.featherlight.defaults, {
type: "iframe",
iframeFrameborder: "0",
iframeAllow: "autoplay; encrypted-media",
iframeAllowfullscreen: "true",
iframeStyle: "position:fixed;background:#000;border:none;top:0;right:0;bottom:0;left:0;width:100%;height:100%;",
});
Related
A Plugin i use in Wordpress has a css stylesheet which I only need in the frontend but not in the wordpress backend. (There it causes a small bug)
How can I prevent the stylesheet from loading in the backend?
Or the other way around, how can I make a stylsheet load only in the frontend?
Thanks for your help!
With Simple Custom CSS and JS plugin by SilkyPress.com the CSS can be set to appear In Frontend, In Admin or On Login Page separately.
Check slug of imported style and use this solution
// this will remove the stylesheet when init fires
add_action('admin_init','your_remove_default_stylesheets');
// this is your function to deregister the default admin stylesheet
function your_remove_default_stylesheets() {
wp_deregister_style('wp-admin');
}
Change wp-admin to your slug
https://developer.wordpress.org/reference/functions/wp_deregister_style/
I’m inside the New Post page on WP-Admin, where you can create a new post.
At the right column, there’s the category selector, in which you select the category for that new post.
I have something like 15 categories, and therefore the category box is showing with a scrolling bar. Since I need to automate some post creation, I need all the categories to be visible right away, without having to scroll.
So I found the css file that manages the height of the category box (it’s inside /wp-admin/css/edit.css and //wp-admin/css/edit-rtl.css) and there I changed the CSS files to allow a bigger height by default on that box.
However when I open the new post page, it still shows the small box in categories, and when I see the CSS rule, the change I made is not visible. It’s like the CSS is cached or something. I already made sure that my browser is not caching it.
The problem I think it’s because the CSS rules are not pulled directly from CSS files, but from this file:
http://www.website.com/wp-admin/load-styles.php?c=0&dir=ltr&load%5B%5D=dashicons,admin-bar,buttons,media-views,common,forms,admin-menu,dashboard,list-tables,edit,revisions,media,themes,about,nav-menu&load%5B%5D=s,widgets,site-icon,l10n,wp-auth-check&ver=4.7
That file seems to go and gather the CSS information from some place (which I assumed was the CSS files in the wp-admin/css/ folder, in which I could find the exact same CSS rules that were applied to the category box) but for some reason, it’s not retreiving the updated CSS file. Or something else is happening (Server side caching the PHP response and therefore retreiving all the time the old response?)
I wouldn't recommend tampering with core admin files, as any changes you make could be lost from a WordPress update.
The proper way to do it is through a custom function added to your theme or child-theme functions.php file:
add_action('admin_head', 'custom_admin_css');
function custom_admin_css() {
echo '<style>
/* remove scrollbar from categories panel */
.categorydiv div.tabs-panel { max-height: none !important; }
</style>';
}
Another options that will allow you to have CSS for individual pages is to use this OH header/footer plugin. Once you install the plugin you can then add your CSS in the header textarea of the pages admin. Just make sure you enclose your CSS within a <style></style> tag.
I use this plugin to dynamically change the CSS in a user friendly way within the WordPress backend:
http://wordpress.org/extend/plugins/option-tree/
I set it up, and appended it to the theme (not a plugin anymore) - this works.
What I don't get is that those inputs get actually changed. So I set up a input field where the user can add a hexadecimalcode(colorpicker) to change the background, or even the font color.
How do I get this information to change in my CSS? I tried:
body {
{{custom_background_css}}
background-color: {{custom_background_css|background-color}};
}
where custom_background_css the id of this input field is. but nothing changes. I also read the documentation but I don't get it...
To adjust theme options for CSS, you'll have to include the CSS in your header, or write a .php file that generates the CSS you want, and link to that. But maybe the easiest way is to hook wp_head from functions.php, and write the code directly there. See below for a schematic example to add to your functions.php
// this is the hooked function
function add_css() {
echo "dynamically generated CSS here";
}
// Add your wp_head hooks
add_action('wp_head', 'add_css', 5);
I'm creating a Wordpress App. It consists on using custom fields on custom type, for managing personal projects.
My issue: I want to add the admin editor (tinyMCE) on frontend. Considering that I can have many textareas that will begin TinyMCE editors. So, I used this code:
PHP (on theme functions.php):
// TINY-MCE EDITOR ON FRONTEND
add_filter('wp_head','add_tinymce_editor');
function add_tinymce_editor(){
wp_admin_css('thickbox');
wp_enqueue_script('wp-tinymce');
wp_enqueue_script('tinymce');
wp_enqueue_script('editor');
add_thickbox();
}
JS (on theme single-projects.php):
jQuery(document).ready(function(){
// EDITORS
tinyMCE.init({
mode : "specific_textareas",
theme : "simple",
editor_selector :"tinymce_enabled"
});
});
On JS I set the "editor_selector" with a Class for all textareas that will begin tinyMCE editors. I cannot assign a single ID for each textareas because these can be 4 or 5 or 6, or more!!!
HTML: (on theme single-projects.php):
<textarea name="new-task-description" id="new-task-description"
class="tinymce_enabled required"></textarea>
Each textarea is present on Jquery UI Accordions.
Now, my problem is, on Firebug (or browser console) I get this error:
tinyMCE is not defined
What's wrong?
thanks in advance!!!
With Wordpress 3.3 you can use wp_editor() which is a lot easier.
http://codex.wordpress.org/Function_Reference/wp_editor
The right way to include scripts is add_action('wp_enqueue_scripts', 'tinymce_editor');
If tinymce is not defined the file tiny_mce.js has not been loaded on the page. Make sure the file gets loaded eigther directly or with the means wordpress offers.
A site I'm creating for a customer in D6 has various images overlaying parts of the main content area. It looks very pretty and they have to be there for the general effect.
The problem is, if you use this theme in the administration pages, the images get in the way of everything.
My solution was to create a custom admin theme, based on the default one, which has these image areas disabled in the output template files - page.tpl.php
The problem is that when you try and edit the blocks page, it uses the default theme and half the blocks admin settings are unclickable behind the images. I KNOW this is by design in Drupal, but it's annoying the hell out of me and is edging towards "bug" rather than "feature" in my mind. It also appears that there is no way of getting around it.
You can edit /modules/blocks/block.admin.inc to force Drupal to show the blocks page in the chosen admin theme. BUT whichever changes you then make will not be transferred to the default theme, as Drupal treats each theme separately and each theme can have different block layouts. :x
function block_admin_display($theme = NULL) {
global $custom_theme;
// If non-default theme configuration has been selected, set the custom theme.
// $custom_theme = isset($theme) ? $theme : variable_get('theme_default', 'garland');
// Display admin theme
$custom_theme = variable_get('admin_theme', '0');
// Fetch and sort blocks
$blocks = _block_rehash();
usort($blocks, '_block_compare');
return drupal_get_form('block_admin_display_form', $blocks, $theme);
}
Can anyone help? the only thing I can think of is to push the $content area well below the areas where the image appear and use blocks only for content display.
Thanks!
in template.php you can put
function YOURTHEME_preprocess_page(&$vars) {
if (implode('/', arg()) == 'admin/build/block'){
$vars['body_classes'] = $vars['body_classes'].' administer_block';
}
}
and you'll have a nice body class which you can use to hide those images using CSS.
If anyone's still having a problem with this, a bit similar to barraponto's solution above, if you are using the admin menu module, it adds a class (.admin-menu) to the body, which you can use to hide any overlaying divs etc that are getting in the way.
you can apply admin theme wherever you want using hook_init() in your custom module:
function yourmodule_init()
{
if ( some condition here like arg(0) == 'foobar'
or node_load(arg(1))->type == 'something' )
{
$GLOBALS['custom_theme'] = variable_get('admin_theme', '0');
drupal_add_css(drupal_get_path('module', 'system') .'/admin.css', 'module');
drupal_add_js(drupal_get_path('theme', 'myadmintheme').'/jscripts/adminjs.js');
}
}
EDIT: then (probably) you have to use form_alter against the block editing form to restore the target theme. in this way you don't have to hack the core.
Thanks for bringing up this topic! I was having the same problem, and it's annoying. Here's how to remedy it without a single line of code:
1) Switch the main theme to your administration theme.
2) Configure Blocks. This always affects the currently selected main theme.
3) Switch the main theme back to what it's supposed to be. Your admin theme will still reflect your changes.
could just use the block-admin..... tpl file from block module and theme it in your custom theme. I have done this way as admin theme module never overrides block admin even when you use custom path bit.
If you don't need your new theme while performing administration tasks, you can use a different theme while doing so.
Goto "Site Configuration" -> "Administration Theme". Here you can pick the theme to be used while doing admin. So your new theme is only used while users are viewing your site. And you can do admin tasks without the interference of all your images.