3v4l.org

run code in 500+ PHP versions simultaneously
<?php /* Plugin Name: WordPress Hashtags Description: WordPress Hashtags allows you to automatically fetch your blog content and detect hashtags and set them as links Author: Samuel Elh Version: 0.3.2 Author URI: http://samelh.com */ // Prevent direct access defined('ABSPATH') || exit; class WPHT { protected static $instance = null; public static function instance() { return null == self::$instance ? new self : self::$instance; } public $settings; public $notice; function __construct() { $this->settings = array(); $this->settings['filtered'] = strlen( get_option('wpht_filter') ) > 1 ? get_option('wpht_filter') : 'pc,pt,wc,wt,bbp,bp,ct'; $this->settings['filter'] = explode( ',', $this->settings['filtered'] ); $this->settings['def_path'] = 'https://twitter.com/hashtag/[hashtag]/'; $this->settings['path'] = strlen( get_option('wpht_path') ) > 1 ? get_option('wpht_path') : $this->settings['def_path']; $this->settings['ignored'] = get_option('wpht_ignored') ? explode(',', get_option('wpht_ignored')) : array(); $this->settings['link_settings'] = get_option('wpht_lsettings') ? get_option('wpht_lsettings') : "{'_blank': '', 'nofollow': '', 'title' : '[hashtag]', 'class': '', 'css': '' }"; $this->settings['link_settings'] = stripslashes( $this->settings['link_settings'] ); $this->settings['link_settings'] = str_replace( array( "'", addslashes("'") ), '"', $this->settings['link_settings'] ); $this->settings['link_settings'] = stripslashes( $this->settings['link_settings'] ); $this->settings['link_settings_json'] = json_decode( $this->settings['link_settings'], true ); $ob = (object) $this->settings['link_settings_json']; $ob->title = ! empty( $ob->title ) ? (string) $ob->title : '[hashtag]'; $ob->css = ! empty( $ob->css ) ? (string) $ob->css : ''; $ob->class = ! empty( $ob->class ) ? (string) $ob->class : ''; $ob->nofollow = ! empty( $ob->nofollow ) ? (string) $ob->nofollow : ''; $ob->_blank = ! empty( $ob->_blank ) ? (string) $ob->_blank : ''; $this->settings['link_settings_json'] = (array) $ob; $this->settings['link_settings_json']['title'] = str_replace( '{apos}', "'", $this->settings['link_settings_json']['title']); $this->settings['link_settings_json']['title'] = '' !== $this->settings['link_settings_json']['title'] ? $this->settings['link_settings_json']['title'] : '[hashtag]'; } public function init() { if( in_array( 'pc', $this->settings['filter'] ) ) add_filter('the_content', array( &$this, 'filter')); if( in_array( 'pt', $this->settings['filter'] ) ) add_filter('the_title', array( &$this, 'filter')); if( in_array( 'wc', $this->settings['filter'] ) ) add_filter('widget_text', array( &$this, 'filter')); if( in_array( 'wt', $this->settings['filter'] ) ) add_filter('widget_title', array( &$this, 'filter')); if( in_array( 'bbp', $this->settings['filter'] ) ) { add_filter('bbp_get_topic_content', array( &$this, 'filter')); add_filter('bbp_get_reply_content', array( &$this, 'filter')); } if( in_array( 'ct', $this->settings['filter'] ) ) add_filter('comment_text', array( &$this, 'filter')); if( in_array( 'bp', $this->settings['filter'] ) ) add_filter('bp_get_activity_content_body', array( &$this, 'filter')); add_action( 'admin_menu', array( &$this, 'wpht_add_options_page')); add_filter( "plugin_action_links_".plugin_basename(__FILE__), array( &$this, 'wpht_push_settings_link')); add_action('admin_enqueue_scripts', array( &$this, 'wpht_admin_enqueue_scripts')); add_shortcode('wp-hashtag', array( &$this, 'wpht_shortcode')); } public function wpht_add_options_page() { add_options_page( 'WordPress Hashtags', 'WP Hashtags', 'manage_options', 'wordpress-hashtags', array( &$this, 'wpht_settings' ) ); } public function wpht_push_settings_link($links) { array_push( $links, '<a href="options-general.php?page=wordpress-hashtags">' . __( 'Settings' ) . '</a>' ); return $links; } public function wpht_shortcode( $atts, $content = null ) { return do_shortcode( $this->filter( $content ) ); } public function wpht_admin_enqueue_scripts() { if( isset( $_GET['page'] ) && $_GET['page'] == 'wordpress-hashtags' ) { wp_enqueue_script('wpht-admin-js', plugin_dir_url(__FILE__) . 'assets/admin.js' ); wp_enqueue_style('wpht-admin-css', plugin_dir_url(__FILE__) . 'assets/admin.css' ); } } public function filter( $content ) { if( is_feed() ) return $content; $original_content = $content; $content = mb_convert_encoding( (string) $content, 'UTF-8', 'UTF-8'); $content = html_entity_decode($content, ENT_QUOTES); $content = apply_filters( 'wpht_pre_filter_content', $content, $original_content ); preg_match_all( apply_filters ("wpht_regex_pattern", '/#(\w{4,10})/u'), strip_tags($content), $hashtags ); $hashtags = array_unique( array_filter( $hashtags[1] ) ); if( !empty( $this->settings['ignored'] ) ) : foreach( $this->settings['ignored'] as $ignored ) :; foreach( $hashtags as $key => $hashtag ) if( $hashtag == $ignored ) unset( $hashtags[$key] ); endforeach; endif; $parsedHashtags = array(); $href = $this->settings['path']; $title = $this->settings['link_settings_json']['title']; $atts = ' title="' . $title . '"'; $class = $this->settings['link_settings_json']['class']; $atts .= $class !== '' ? ' class="'. $class .'"' : ''; $style = $this->settings['link_settings_json']['css']; $atts .= $style !== '' ? ' style="'. $style .'"' : ''; $blank = $this->settings['link_settings_json']['_blank']; $atts .= $blank == '1' ? ' target="_blank"' : ''; $nofollow = $this->settings['link_settings_json']['nofollow']; $atts .= $nofollow == '1' ? ' rel="nofollow"' : ''; $link = '<a href="' . $href . '"' . $atts . '>#[hashtag]</a>'; foreach( $hashtags as $hashtag ) :; $parsedHashtags[] = str_replace( '[hashtag]', $hashtag, $link ); endforeach; $tarHashtags = array(); foreach( $hashtags as $hashtag ) :; $tarHashtags[] = '#' . $hashtag; endforeach; $content = str_replace( $tarHashtags, $parsedHashtags, $content ); return apply_filters( 'wpht_filter_content', $content, $original_content ); } function wpht_settings() { if( isset( $_POST['submit'] ) ) { $filtered = isset( $_POST['wpht_filtered'] ) ? $_POST['wpht_filtered'] : $this->settings['filtered']; $filtered = array_filter( array_unique( explode( ',', $filtered ) ) ); $filtered = empty( $filtered ) ? array('none') : $filtered; $filtered = implode( ',', $filtered ); $ignored = isset( $_POST['wpht_ignored'] ) ? $_POST['wpht_ignored'] : false; $ignored = array_filter( array_unique( explode( ',', $ignored ) ) ); $ignored = empty( $ignored ) ? false : $ignored; $ignored = $ignored ? implode( ',', $ignored ) : false; update_option( 'wpht_filter', $filtered ); if( isset( $_POST['wpht_path'] ) && $_POST['wpht_path'] !== $this->settings['def_path'] ) update_option( 'wpht_path', $_POST['wpht_path'] ); else delete_option( 'wpht_path' ); if( $ignored ) update_option( 'wpht_ignored', $ignored ); else delete_option( 'wpht_ignored' ); if( isset( $_POST['wpht_lsettings'] ) ) update_option('wpht_lsettings', $_POST['wpht_lsettings'] ); // $_POST['wpht_lsettings'] for a hidden field of a JSON object constructed and validated with JS $this->notice = '<div id="updated" class="updated notice is-dismissible"><p>Changes saved successfully.</p></div>'; $this::__construct(); } ?> <div class="wrap"> <div class="wpht_left"> <?php echo isset( $this->notice ) ? $this->notice : ''; ?> <h2>WordPress Hashtags &raquo; Settings</h2> <form method="post" onchange="wpht_change()"> <table class="wpht"> <tr> <td valign="top"><h3>Filter</h3></td> <td> <label><input type="checkbox" class="wpht_filters" id="pc" <?php echo in_array( 'pc', $this->settings['filter'] ) ? 'checked="checked"' : ''; ?>/>Posts/pages content</label><br/> <label><input type="checkbox" class="wpht_filters" id="pt" <?php echo in_array( 'pt', $this->settings['filter'] ) ? 'checked="checked"' : ''; ?> />Posts/pages title</label><br/> <label><input type="checkbox" class="wpht_filters" id="ct" <?php echo in_array( 'ct', $this->settings['filter'] ) ? 'checked="checked"' : ''; ?> />Comments text</label><br/> <label><input type="checkbox" class="wpht_filters" id="wc" <?php echo in_array( 'wc', $this->settings['filter'] ) ? 'checked="checked"' : ''; ?> />Widgets content</label><br/> <label><input type="checkbox" class="wpht_filters" id="wt" <?php echo in_array( 'wt', $this->settings['filter'] ) ? 'checked="checked"' : ''; ?> />Widgets title</label><br/> <?php if( function_exists('bbpress') ) : ?> <label><input type="checkbox" class="wpht_filters" id="bbp" <?php echo in_array( 'bbp', $this->settings['filter'] ) ? 'checked="checked"' : ''; ?> />bbPress topic and replies</label><br/> <?php endif; ?> <?php if( function_exists('bbpress') ) : ?> <label><input type="checkbox" class="wpht_filters" id="bp" <?php echo in_array( 'bp', $this->settings['filter'] ) ? 'checked="checked"' : ''; ?> />BuddyPress activity</label> <?php endif; ?> </td> </tr> <tr> <td><h3>Hashtag URL</h3></td> <td> <input type="text" value="<?php echo $this->settings['path']; ?>" name="wpht_path" size="50" /> <i style="display:block">Use <code>[hashtag]</code> for the hashtag name</i> </td> </tr> <tr> <td><h3>Ignore hashtags</h3></td> <td> <div id="ignored-hashtags"></div> <span class="add-hashtag" onclick="wpht_addHT()" title="Add hashtag">+</span> <textarea id="ignore-hashtags" placeholder="add hashtags separated by commas" name="wpht_ignored"><?php echo implode(',', $this->settings['ignored']), !empty($this->settings['ignored']) ? ',' : ''; ?></textarea> </td> </tr> <tr> <td valign="top"><h3>Link settings</h3></td> <td> <label> <strong>Title:</strong><i> Use <code>[hashtag]</code> for the hashtag name</i><br/> <input type="text" id="_link-title" size="50" value="<?php echo $this->settings['link_settings_json']['title']; ?>" /> </label><br/> <label> <strong>CSS class(s):</strong><br/> <input type="text" size="50" id="_link-class" value="<?php echo $this->settings['link_settings_json']['class']; ?>" /> </label><br/> <label> <strong>Inline CSS style:</strong><br/> <input type="text" size="50" id="_link-css" value="<?php echo $this->settings['link_settings_json']['css']; ?>" /> </label><br/> <label><input type="checkbox" id="_new-tab" <?php echo $this->settings['link_settings_json']['_blank'] == '1' ? 'checked="checked"' : ''; ?>/>Open in new tab</label><br/> <label><input type="checkbox" id="_no-follow" <?php echo $this->settings['link_settings_json']['nofollow'] == '1' ? 'checked="checked"' : ''; ?>/>Enable <code>rel=nofollow</code></label><br/> </td> </tr> <tr> <td><h3>Preview</h3></td> <td><h2><?php echo do_shortcode('[wp-hashtag]#WordPress[/wp-hashtag]'); ?></h2></td> </tr> <tr> <td> <input type="hidden" value="<?php echo $this->settings['filtered']; ?>" id="wpht_filtered" name="wpht_filtered" /> <input type="hidden" value="<?php echo str_replace('"','\'',$this->settings['link_settings']); ?>" id="wpht_lsettings" name="wpht_lsettings" /> <?php submit_button(); ?> </td> </tr> </table> </form> <h3>Using shortcodes</h3> <p> If there is any place we can not fetch its content and parse hashtags, you can simply use the shortcode <code>[wp-hashtag]</code>: <li>Plain text: <code>[wp-hashtag]#hashtag[/wp-hashtag]</code></li> <li>PHP template, etc: <code>&lt;?php echo do_shortcode('[wp-hashtag]#hashtag[/wp-hashtag]'); ?&gt;</code></li> </p> </div> <div class="wpht_right"> <h3>Check out more of our premium plugins</h3> <?php if( function_exists('bbpress')) : ?> <li><a target="_blank" href="http://go.samelh.com/get/bbpress-ultimate/">bbPress Ultimate</a> adds more features to your forums and bbPress/BuddyPress profiles..</li> <li><a target="_blank" href="http://go.samelh.com/get/bbpress-thread-prefixes/">bbPress Thread Prefixes</a> enables thread prefixes in your blog, just like any other forum board!</li> <?php endif; ?> <li><a target="_blank" href="http://go.samelh.com/get/youtube-information/">YouTube Information</a>: easily embed YouTube video/channel info and stats, video cards, channel cards, widgets, shortcodes..</li> <li><a target="_blank" href="http://go.samelh.com/get/wpchats/">WpChats</a> bringing instant live chat &amp; private messaging feature to your site..</li> <p>View more of our <a target="_blank" href="https://profiles.wordpress.org/elhardoum#content-plugins">free</a> and <a target="_blank" href="http://codecanyon.net/user/samiel/portfolio?ref=samiel">premium</a> plugins.</p> <p><hr/></p> <h3>Subscribe, Join our mailing list</h3> <p><i>Join our mailing list today for more WordPress tips and tricks and awesome free and premium plugins</i><p> <form action="//samelh.us12.list-manage.com/subscribe/post?u=677d27f6f70087b832c7d6b67&amp;id=7b65601974" method="post" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate=""> <label><strong>Email:</strong><br/> <input type="email" value="<?php echo wp_get_current_user()->email; ?>" name="EMAIL" class="required email" id="mce-EMAIL" /> </label> <br/> <label><strong>Your name:</strong><br/> <input type="text" value="<?php echo wp_get_current_user()->user_nicename; ?>" name="FNAME" class="" id="mce-FNAME" /> </label> <br/> <input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button" /> </form> <p><hr/></p> <h3>Are you looking for help?</h3> <p>Don't worry, we got you covered:</p> <li><a href="http://wordpress.org/support/plugin/wp-hashtags">Go to plugin support forum on WordPress</a></li> <li><a href="http://support.samelh.com/">Try our Support forum</a></li> <li><a href="http://blog.samelh.com/">Browse our blog for tutorials</a></li> <p><hr/></p> <p> <li><a href="https://wordpress.org/support/view/plugin-reviews/wp-hashtags?rate=5#postform">Give us &#9733;&#9733;&#9733;&#9733;&#9733; rating</a></li> <li><a href="http://twitter.com/samuel_elh">Follow @Samuel_Elh on Twitter</a></li> </p> <p>Thank you! :)</p> </div> </div> <?php } } // Load it! WPHT::instance()->init();

Abusive script

This script was stopped while abusing our resources

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.3.130.0030.01316.80
8.3.120.0060.00319.23
8.3.110.0060.00318.31
8.3.100.0030.00616.87
8.3.90.0030.00626.77
8.3.80.0070.00318.68
8.3.70.0110.00418.27
8.3.60.0120.00318.18
8.3.50.0060.00816.63
8.3.40.0040.01118.79
8.3.30.0070.00718.83
8.3.20.0060.00320.34
8.3.10.0060.00323.65
8.3.00.0000.00822.18
8.2.250.0040.01516.89
8.2.240.0030.00716.76
8.2.230.0090.00020.94
8.2.220.0000.00824.06
8.2.210.0030.00526.77
8.2.200.0060.00616.75
8.2.190.0060.00916.75
8.2.180.0130.00616.63
8.2.170.0080.00822.96
8.2.160.0070.00722.08
8.2.150.0030.00524.18
8.2.140.0080.00024.66
8.2.130.0030.00619.83
8.2.120.0000.00826.35
8.2.110.0090.00920.93
8.2.100.0100.00317.97
8.2.90.0040.00417.88
8.2.80.0060.00318.90
8.2.70.0090.00018.03
8.2.60.0090.00018.28
8.2.50.0080.00018.10
8.2.40.0080.00019.45
8.2.30.0050.00319.44
8.2.20.0040.00418.18
8.2.10.0000.00819.44
8.2.00.0000.00818.14
8.1.300.0130.00318.36
8.1.290.0090.00030.84
8.1.280.0070.00725.92
8.1.270.0030.00620.45
8.1.260.0030.00526.35
8.1.250.0050.00328.09
8.1.240.0030.00723.83
8.1.230.0060.00619.01
8.1.220.0040.00417.74
8.1.210.0000.00818.77
8.1.200.0050.00517.60
8.1.190.0060.00317.61
8.1.180.0030.00519.04
8.1.170.0000.00818.69
8.1.160.0060.00619.19
8.1.150.0000.00818.94
8.1.140.0040.00420.42
8.1.130.0050.00220.50
8.1.120.0000.00717.56
8.1.110.0080.00017.51
8.1.100.0040.00417.49
8.1.90.0050.00517.59
8.1.80.0000.00917.46
8.1.70.0030.00317.60
8.1.60.0030.00517.75
8.1.50.0030.00617.57
8.1.40.0090.00017.66
8.1.30.0040.00417.67
8.1.20.0040.00417.79
8.1.10.0000.00817.68
8.1.00.0030.00617.60
8.0.300.0000.00918.77
8.0.290.0040.00417.00
8.0.280.0030.00318.50
8.0.270.0000.00817.01
8.0.260.0000.00820.38
8.0.250.0050.00217.17
8.0.240.0040.00417.06
8.0.230.0000.00717.08
8.0.220.0000.00816.95
8.0.210.0000.00716.98
8.0.200.0000.00817.12
8.0.190.0080.00017.16
8.0.180.0050.00317.04
8.0.170.0030.00617.12
8.0.160.0040.00416.98
8.0.150.0030.00617.06
8.0.140.0040.00417.09
8.0.130.0000.00613.50
8.0.120.0080.00016.96
8.0.110.0000.00717.04
8.0.100.0000.00716.97
8.0.90.0050.00317.08
8.0.80.0030.01217.02
8.0.70.0000.00816.96
8.0.60.0000.00816.89
8.0.50.0050.00316.96
8.0.30.0070.01017.01
8.0.20.0130.00817.21
8.0.10.0000.00717.22
8.0.00.0110.01016.92
7.4.330.0000.00515.55
7.4.320.0000.00716.64
7.4.300.0060.00316.70
7.4.290.0030.00316.73
7.4.280.0040.00416.57
7.4.270.0040.00316.74
7.4.260.0070.00016.66
7.4.250.0000.00716.59
7.4.240.0040.00416.61
7.4.230.0000.00716.80
7.4.220.0080.00016.47
7.4.210.0070.01016.71
7.4.200.0070.00016.83
7.4.160.0100.00816.59
7.4.140.0130.00517.86
7.4.130.0140.00516.65
7.4.120.0120.00616.77
7.4.110.0120.01316.89
7.4.100.0050.01316.86
7.4.90.0070.01016.49
7.4.80.0110.01119.39
7.4.70.0120.00416.67
7.4.60.0070.01016.69
7.4.50.0210.00016.25
7.4.40.0090.00816.70
7.4.00.0030.01015.21
7.3.330.0000.00513.42
7.3.320.0030.00313.37
7.3.310.0000.00816.47
7.3.300.0030.00316.38
7.3.290.0080.00016.48
7.3.280.0080.00816.38
7.3.260.0110.01116.44
7.3.240.0140.00716.46
7.3.230.0180.00416.68
7.3.210.0090.00916.57
7.3.200.0110.00616.40
7.3.190.0170.00616.70
7.3.180.0100.01016.62
7.3.170.0120.00916.50
7.3.160.0130.02816.50
7.3.30.0090.00514.82
7.3.20.0780.00714.65
7.3.10.0550.00314.89
7.3.00.0690.00314.86
7.2.330.0070.01116.84
7.2.320.0110.01116.72
7.2.310.0060.01216.75
7.2.300.0030.01416.55
7.2.290.0070.01516.63
7.2.160.0000.01214.90
7.2.150.0830.00014.71
7.2.140.1780.01015.16
7.2.130.0720.01015.04
7.2.120.0790.00015.03
7.2.110.0780.01015.14
7.2.100.0720.00715.35
7.2.90.0560.00314.83
7.2.80.0630.00715.19
7.2.70.0610.00715.32
7.2.60.0590.01015.18
7.2.50.0590.00714.89
7.2.40.0670.00015.09
7.2.30.0710.00614.82
7.2.20.0850.01015.21
7.2.10.0770.00015.13
7.2.00.0700.00315.22
7.1.270.0720.01014.04
7.1.260.0580.00313.78
7.1.250.0540.01013.94

preferences:
77.76 ms | 1187 KiB | 4 Q