0

I want that If Slug contains "revslider" word, deactivate some plugins and If slug doesnt contain this word, again activate plugin automatically.

I searched in Google and wrote this code (I am not a developer).

$url = $_SERVER["REQUEST_URI"];

$isItSlide = strpos($url, 'revslider');

if ($isItSlide!==false) {
    deactivate_plugins( '/resize-image-after-upload/resize-image-after-upload.php' );
} else {
    activate_plugins( '/resize-image-after-upload/resize-image-after-upload.php' );
}

If I use this code, it works in first step, Plugin can disable, but it doesnt activate again in other pages.

3
  • What are you activating/de-activating the plugin in order to accomplish - and how and where are you initiating the function?
    – CK MacLeod
    Jan 14 '19 at 8:37
  • 1
    I add this code to function.php. I want If I am in Slider Revolution page, disable Resize Image plugin. If I write code without else part, it works. If I am in Slider Revolution page, Resize image plugin is disable. But I want if I leave this page, plugin must activate again Jan 14 '19 at 8:45
  • I'm still not sure what specifically you're trying to accomplish (e.g., load or show images with "natural" dimensions, prevent the media library from producing a set of images), but those two functions aren't written for what I think you;'re attempting. You may need to focus on disabling a particular function or set of functions or effects rather than trying to act upon a plugin's status as activated to deactivated. Depending upon how the plugin is written, it may be more or less easily manipulable on that basis. Without much more detail, it will be impossible to provide a solution.
    – CK MacLeod
    Jan 14 '19 at 9:23
1

I found this alternative:

$url = $_SERVER["REQUEST_URI"];

$isItSlide = strpos($url, 'revslider');
$isItBlog = strpos($url, 'post.php');

if ($isItSlide!==false) {
    deactivate_plugins( '/resize-image-after-upload/resize-image-after-upload.php' );
}

if ($isItBlog!==false) {
    activate_plugins( '/resize-image-after-upload/resize-image-after-upload.php' );
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.