how to set the default priority of a plugin programatically in elgg - elgg

How can I set the priority of a plugin by default, programatically, so that after installation and activation, it is shown at the bottom of the plugin list automatically.
I know that we can set the priority in the administration section but how can we set that in code, so that when this plugin is installed on another site, by default it is at the bottom of plugin list.
I have tried:
elgg_register_event_handler('init', 'system', 'myplugin_init', 999999);
but it doesn't seem to work, and I can't find anymore documentation on it.
I'm using elgg 1.8.16

Add a priority dependency to your plugin's manifest to keep it in proper order to overridden one.
There's no such feature like "always on bottom" since it would be problematic to handle multiple plugins that want to be on bottom of plugins list.

I have used this to set the priority last, but only setting the priority does not work until you clear the cache.
$plugin = elgg_get_plugin_from_id('myplugin');
$plugin->setPriority('last');
I have used the following function for setting the priority as it runs once per installation.
run_function_once($functionname, $timelastupdatedcheck = 0)
and have flushed the cache after that using elgg_reset_system_cache()

Related

Buddypress template hierarchy is not being used

I am updating an installation of buddypress (1.5) to the most recent version (2.1.1). I have updated the files and am now trying to update the theme to use the template hierarchy pattern.
For this I created the following directory structure within my theme:
my-theme/
buddypress/
groups/
index-directory.php
index-directory.php contains a single die('debug') statement for testing.
If I copy this buddypress directory into the twentyfourteen directory and activate that theme, I am seeing the debug message when I'm on the group listing page. However, when I use my custom theme, the message is not showing up.
This tells me that the template hierarchy is not being applied on my theme. Why could that be?
I suspect that somehow my theme is being treated as a legacy theme, I don't understand why though. I commented out the whole functions.php to make sure it's not because of aynthing in there. The header comment in the style.css does not contain anything special either.
Any help on this?
Thanks.
The problem was my own mistake. Our theme stylesheet had a Template: bp-default in it. I didn’t notice it at first because our theme is named similarly and my mind read it as the title of our theme. If I remove it, my templates are included.
For anyone stumbling on this problem in the future, here are the reasons why the template hierarchy could be deactivated by Buddypress:
Theme compat is disabled when a theme meets one of the following criteria:
1) It declares BP support with add_theme_support( 'buddypress' )
2) It is bp-default, or a child theme of bp-default
3) A legacy template is found at members/members-loop.php. This is a
fallback check for themes that were derived from bp-default, and have
not been updated for BP 1.7+; we make the assumption that any theme in
this category will have the members-loop.php template, and so use its
presence as an indicator that theme compatibility is not required
https://buddypress.org/support/topic/default-theme-is-still-showing/

Wordpress bug and errors

I have a site that is almost fixed, but I'm having some errors... So I tried to reinstall the theme but Wordpress remembers all the settings from before (header, etc)... The problem that caused this to happen is that the site has a white bar on the side that doesn't need to be there, and it shrinks the site in half... Both on my laptop, desktop and iphone. Also, the slider doesn't display my featured slides. I get this error at the top of the page when trying to add a new slider:
Notice: wp_deregister_script was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or init hooks. Please see Debugging in WordPress for more information. (This message was added in version 3.3.) in /home/setli/public_html/wp-includes/functions.php on line 2944
Here's the site in question.
I'll hire someone to help me get this fixed asap and pay you via Paypal.
There is a large image (1600px wide) in your navigation area at the top of the page. This image is causing the entire site to get pushed outward and offset the containing div.
You need to add this to your CSS to fix:
#logo {
width: 100%;
overflow: hidden;
}
As for the error you put in your question, I do not see that anywhere. I would suggest completely deleting your theme from the server, and then download/install it again. Have you updated the theme recently? When did these issues start occurring?
Also, it looks like two themes are being using. Are you using a framework and a child theme? Try changing/disabling the child theme.
Quote:
Notice: wp_deregister_script was called incorrectly. Scripts and
styles should not be registered or enqueued until the
wp_enqueue_scripts, admin_enqueue_scripts, or init hooks.
Are you calling the function containing wp_deregister_script directly? Those functions should be called by using actions. Instead of calling that function directly, you should use add_action('wp_enqueue_scripts', 'your_function_name'); to run that function.
You use admin_enqueue_scripts instead of wp_enqueue_script if the script is meant for the WordPress dashboard.
Read more:
admin_enqueue_scripts()
wp_enqueue_script()

using two domain same database with different wordpress theme

I want to use, same database, (content / users / comments / meta's / categories etc.) for another wordpress install in my sub directory.
I actually want to create mobile version of my site. But i dont want to use, any mobile detect script ory css3 media queries. Just want to create my new theme (for mobile version)
For example;
the main domain has also sub domain like ;
maindomain.com // root
mobile.maindomain.com // sub directory
How this could be possible ?
One of the nice things about WordPress is the great number of hooks in the code allowing you to extend or override core functionality.
One way to approach this problem would be to set an Apache environment variable in your vhost file for each site that could be used in the WordPress bootstrap process to over-ride the theme and base URL setup.
e.g. in Apache vhost add:
SetEnv WP_CONTEXT main
and
SetEnv WP_CONTEXT mobile
(or equivalent if you're using a different webserver).
In wp-config.php:
switch ($_SERVER['WP_CONTEXT']) {
case 'main':
define('WP_HOME','http://maindomain.com');
define('WP_SITEURL','http://maindomain.com');
break;
case 'mobile':
define('WP_HOME','http://mobile.maindomain.com');
define('WP_SITEURL','http://mobile.maindomain.com');
break;
}
This will set the base URLs based on the environment variable.
Then in plugin add the following filters:
add_filter('template', 'change_theme');
add_filter('option_template', 'change_theme');
add_filter('option_stylesheet', 'change_theme');
function change_theme()
{
switch ($_SERVER['WP_CONTEXT']) {
case 'main':
return 'main';
break;
case 'mobile':
return 'mobile';
break;
}
This needs to be in a plugin so that it's loaded before the normal theme loading process (functions.php is part of the theme and hence too late). These filters will intercept and over-ride the theme settings from the database.
You cant do that directly, as WP stores its url in database.
AFAIK there is a way to "link" tables in sql, so it might be the way - link everything beside wp_options for example, but still it is a tricky way.
i had the same probleme and it works at least for me:
add this code to the functions.php in the mobile theme:
remove_filter('template_redirect','redirect_canonical');
read more about this hook from Here
add these in the wp-config.php:
define('WP_HOME','http://mobile.maindomain.com');
define('WP_SITEURL','http://mobile.maindomain.com');
read more these hooks from Here
Apply these changes in the wordpress installation of the mobile version

WordPress: prevent caching of tinymce's custom buttons?

I'm following this tutorial on how to add a custom button to TinyMCE editor in WordPress. Trying to edit author's JS to include my functionality, yet it seems to have gotten cached. Article author has a hack for it (code snippet below), and it did work for the first time (the button is in the toolbar now), although it doesn't work for subsequent refreshes.
// "This will intercept the version check and increment the current version number by 3.
// It's the quick and dirty way to do it without messing with the settings directly..."
function my_refresh_mce($ver) {
$ver += 3;
return $ver;
}
add_filter( 'tiny_mce_version', 'my_refresh_mce');
What can I do to disable this caching?
Latest fresh WordPress localhost install, no plugins activated.
Turns out the 'no plugins activated' was not enough. Once I did a completely fresh install (without W3 Total Cache plugin), the issue disappeared.

Drupal administration theme doesn't apply to Blocks pages (admin/build/block)

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.

Resources