PageRenderTime 51ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

/pi.pitch_no_code.php

https://github.com/EpicVoyage/pitch-no-code
PHP | 66 lines | 28 code | 12 blank | 26 comment | 2 complexity | 65278a51d8cd122b7c6536da8c37fe3b MD5 | raw file
  1. <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  2. /**
  3. * ExpressionEngine - by EllisLab
  4. *
  5. * @package ExpressionEngine
  6. * @author ExpressionEngine Dev Team
  7. * @copyright Copyright (c) 2003 - 2011, EllisLab, Inc.
  8. * @license http://expressionengine.com/user_guide/license.html
  9. * @link http://expressionengine.com
  10. * @since Version 2.0
  11. */
  12. /**
  13. * Pitch No Code Plugin
  14. *
  15. * @package ExpressionEngine
  16. * @subpackage Addons
  17. * @category Plugin
  18. * @author Pitch w/ Changes from EpicVoyage
  19. * @link http://pitch.net.nz
  20. * @link https://www.epicvoyage.org
  21. */
  22. $plugin_info = array(
  23. 'pi_name' => 'Pitch No Code',
  24. 'pi_version' => '1.1.0',
  25. 'pi_author' => 'Pitch w/ Changes from EpicVoyage',
  26. 'pi_author_url' => 'http://pitch.net.nz',
  27. 'pi_description' => 'A plugin to strip code such as html and js.',
  28. 'pi_usage' => Pitch_no_code::usage()
  29. );
  30. class Pitch_no_code
  31. {
  32. function pitch_no_code()
  33. {
  34. // Give us access to EE functions please.
  35. $this->EE =&get_instance();
  36. // Grab everything inside our tag pair and put into content var.
  37. $content = $this->EE->TMPL->tagdata;
  38. // Strip out all content which matches our regex.
  39. $content = preg_replace('@<(script|style)[^>]*?>.*?</\1>@si', '', $content);
  40. // Now for extra safety run this content through the native PHP strip_tags() function before we return.
  41. $this->return_data = strip_tags($content);
  42. }
  43. function usage()
  44. {
  45. ob_start();
  46. ?>
  47. This simple plugin is designed to strip out any html, css, js and php code from the content inside the tag pair. This is helpful when you want clean text with no mark up from a field which is a WYSIWYG for example.
  48. {exp:pitch_no_code}{your-field-goes-here}{/exp:pitch_no_code}
  49. <?php
  50. return ob_get_clean();
  51. }
  52. }
  53. /* End of file pi.pitch_no_code.php */
  54. /* Location: /system/expressionengine/third_party/pitch_no_code/pi.pitch_no_code.php */