$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>permalinks - Disable plugin If slug contains specific word|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

permalinks - Disable plugin If slug contains specific word

matteradmin9PV0评论

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' );
}
Post a comment

comment list (0)

  1. No comments so far