I wrote a plugin and used it inside nop.web project. Now I want to control that, if plugin has been installed or not.
Please give me solution.
var pluginFinder = Nop.Core.Infrastructure.EngineContext.Current.Resolve<IPluginFinder>();
// check plugin is installed
var pluginDescriptor = pluginFinder.GetPluginDescriptorBySystemName("Misc.pluginname");
if (pluginDescriptor != null)
{
//Your code
}
You need to compile it and deploy it to your server. Then activate it under the plugins section from the administrator section.
Related
I have a responsive WP blog that I converted into an application with cordova.
(and added some extra features).
My idea would be to prompt an user that uses mobile to install the application if he run the site in his mobile browser instead in his application.
Something like:
if (isMobile() && !isApplication()) {
var download = prompt('Would you like to install the application instead ?');
....
}
Maybe such a plugin does already exist in WP ?
I use cordova-plugin-device to archive this for WP:
if(device.platform.toUpperCase().match(/WIN32NT|WINCE|WINDOWS/)) {
var download = prompt('Would you like to install the application instead ?');
....
}
The plugin I'm unit testing with phpunit has a dependency on another plugin, using is_plugin_active().
When testing the dependency in my unit test that function always returns false/inactive, when the it is definitely active, because it's working properly in the plugin itself. It seems to be accessible, so there must be some logic error when it comes to this wordpress core function.
This is my code:
function test_requirementsMet_true() {
$this->assertTrue(is_plugin_active('pluginFolder/plugin.php'));
}
Does anyone know of a work-around?
Assuming you scaffolded your tests with WP-CLI, you should know the plugin is loaded as an mu-plugin rather than a vanilla plugin, which means:
Only plugins installed in the plugins/ folder can be active.
Plugins in the mu-plugins/ folder can’t be "activated," so this
function will return false for those plugins.
My Meteor project has two part:
Home page: can be visited by anyone.
Admin Console: provide some management tools to administrator only
When I running this project in production mode:
$ meteor --production
Meteor will combine all the client side code into one big file, that make "Admin Console" code also delivered to normal visitors.
Is there any way to "minify" javascript/css files into two files?
one for normal visitor, one for admin?
I also pack this project into Android package, "Admin Console" code also exists in apk file, how can I exclude them ?
Thanks.
You can use meteor dynamic imports to only download code to the client based on the view the client is using. I have not tried this yet, but it should be possible to not load files dynamically based on the user's role.
Something like:
//must be called inside a meteor method or publish function
async function adminOnlyApi() {
if(Roles.userIsInRole(Meteor.userId, ['admin']) {
return await import('path/to/lib');
}
return {};
}
Assuming the lib exports a default object with a key 'foo' and value 'bar', calling adminOnlyApi.foo when logged in as admin should return 'bar', and return undefined when logged in with any other user...
I have added ckeditor to offer a nice WYSIWYG editor to my user. To allow them to upload pictures directly into this editor, I've installed kcfinder. I've put the following lines in my ckeditor's config :
config.filebrowserBrowseUrl = 'ckeditor/plugins/kcfinder/browse.php?type=files';
config.filebrowserImageBrowseUrl = 'ckeditor/plugins/kcfinder/browse.php?type=images';
config.filebrowserFlashBrowseUrl = 'ckeditor/plugins/kcfinder/browse.php?type=flash';
config.filebrowserUploadUrl = 'ckeditor/plugins/kcfinder/upload.php?type=files';
config.filebrowserImageUploadUrl = 'ckeditor/plugins/kcfinder/upload.php?type=images';
config.filebrowserFlashUploadUrl = 'ckeditor/plugins/kcfinder/upload.php?type=flash';
My problem : when I try to browse files on the server with kcfinder, Symfony tells me that there is no routes for "GET /admin/news_post_admin/ckeditor/plugins/kcfinder/browse.php". It looks like it tries to reach browse.php from my controller, which is not correct.
Any ideas how I could make Symfony find the correct path of browse.php ?
I was working on the integration between Symfony2 and KCFinder and recently finished a simple bundle. Main purpose of the bundle was the possibility to control access to the KCFinder (for logged in users only).
You can find instructions and download the bundle from here (page created on the fly):
http://avaer.net/stuff/KCFinderBundle/
Hope you find this helpful.
I've just moved a Drupal to my localserver and I forgot to disable Secure Pages.
Now I cannot access admin pages, because the site switches to HTTPS.
How can I disable it?
In your settings.php file:
$conf['securepages_enable'] = FALSE;
This will override the database setting.
In your sites/example.com/settings.php, leave this line out, and then it will use whatever value is in the database.
If you are using drush, you can keep the Secure Pages module enabled and just turn off the checkbox in the module's own config like:
drush vset securepages_enable 0
This will stop the redirect.
you can also change the URLs if you want, as follows, but the above is usually enough.
drush vset securepages_basepath http://nominet.dev
drush vset securepages_basepath_ssl http://nominet.dev
I'm running Drupal 7 btw, so YMMV, but seems to be a simple drush based solution following on from the above answer.
The way I've done it without disabling the module is to use SQL to change the variable setting. First backup your database (in case you put a semicolon in the wrong place; scratch that, always back up your database before making changes on the command line) and then run the following SQL on your database:
UPDATE variable SET value = 's:1:"0";' WHERE name = 'securepages_enable';
Then:
DELETE FROM cache;
DELETE FROM cache_page;
You need those two lines in order to clear the cache, otherwise the variable might stick around for a while.
If you have Drush installed:
drush dis -y securepages
I know this question is old and has been answered a few times, but there's another option that hasn't been suggested yet.
You could disable it completely:
// Disable SecurePages completely.
$conf['securepages_enable'] = FALSE;
and alter settings.php to enforce HTTPS depending on some context, e.g.:
if (isset($_SERVER['environment'] && $_SERVER['environment'] == 'staging')) {
$conf['securepages_basepath'] = 'http://staging.example.com';
$conf['securepages_basepath_ssl'] = 'https://staging.example.com';
} else if (isset($_SERVER['environment'] && $_SERVER['environment'] == 'production')) {
$conf['securepages_basepath'] = 'http://www.example.com';
$conf['securepages_basepath_ssl'] = 'https://www.example.com';
} else {
// We're on dev or some other server instance where SSL isn't needed.
$conf['securepages_enable'] = FALSE;
}
This is just an example, but it's been a helpful way for us to manage sites that exist on a dev server, a QA server, and a production server, where we want to track settings.php changes in version control without having to change things in each environment.
You can disable the module directly via the database. Just go into the system table, look for your module under the name column, and set the status field to zero.