permalinks - Disable plugin If slug contains specific word

admin2025-06-04  3

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.

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.

Share Improve this question edited Jan 16, 2019 at 5:51 fuxia 107k39 gold badges255 silver badges461 bronze badges asked Jan 14, 2019 at 8:10 Cavid MuradovCavid Muradov 215 bronze badges 3
  • What are you activating/de-activating the plugin in order to accomplish - and how and where are you initiating the function? – CK MacLeod Commented Jan 14, 2019 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 – Cavid Muradov Commented Jan 14, 2019 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 Commented Jan 14, 2019 at 9:23
Add a comment  | 

1 Answer 1

Reset to default 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' );
}
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1749006835a315562.html

最新回复(0)