Created
July 22, 2022 04:27
-
-
Save iworks/e25b644744191dea22923afbff8484af to your computer and use it in GitHub Desktop.
iWorks Default Gallery Link
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: iWorks Default Gallery Link | |
Plugin URI: http://iworks.pl/ | |
Description: Set "file" as default gallery link. | |
Version: 1.0.0 | |
Author: Marcin Pietrzak | |
Author URI: http://iworks.pl/ | |
License: GPLv2 or later | |
License URI: http://www.gnu.org/licenses/gpl-2.0.html | |
*/ | |
class iWorks_Default_Gallery_Link { | |
public function __construct() { | |
add_filter( 'the_content', array( $this, 'the_content' ), 1 ); | |
} | |
public function the_content( $content ) { | |
return preg_replace( '/(\[gallery[^\]]*)\]/', '$1 link="file"]', $content ); | |
} | |
} | |
new iWorks_Default_Gallery_Link(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment