PageRenderTime 25ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/wp-content/plugins/premium-seo-pack/modules/rich_snippets/shortcodes/movie/init.php

https://gitlab.com/iamgraeme/royalmile
PHP | 121 lines | 67 code | 29 blank | 25 comment | 13 complexity | e9a2e2e7e46d049e714b458a5071efc8 MD5 | raw file
  1. <?php
  2. /*
  3. * Define class pspRichSnippets
  4. * Make sure you skip down to the end of this file, as there are a few
  5. * lines of code that are very important.
  6. */
  7. !defined('ABSPATH') and exit;
  8. if (class_exists('pspSnippet_movie') != true) {
  9. class pspSnippet_movie extends pspRichSnippets
  10. {
  11. /*
  12. * Some required plugin information
  13. */
  14. const VERSION = '1.0';
  15. /*
  16. * Store some helpers config
  17. */
  18. public $the_plugin = null;
  19. protected $module_folder = '';
  20. protected $module_folder_path = '';
  21. static protected $_instance;
  22. /*
  23. * Required __construct() function that initalizes the AA-Team Framework
  24. */
  25. public function __construct( $shortcode=null )
  26. {
  27. global $psp;
  28. // access parent class!
  29. $this->shortcode_cfg( $shortcode, array(
  30. 'type' => $shortcode,
  31. 'execute' => true
  32. ) );
  33. $this->the_plugin = $psp;
  34. $this->module_folder = $this->the_plugin->cfg['paths']['plugin_dir_url'] . 'modules/rich_snippets/shortcodes/'.$this->shortcode.'/';
  35. $this->module_folder_path = $this->the_plugin->cfg['paths']['plugin_dir_path'] . 'modules/rich_snippets/shortcodes/'.$this->shortcode.'/';
  36. $this->init();
  37. }
  38. public function init() {
  39. $shortcode = $this->the_plugin->alias . '_rs_' . $this->shortcode;
  40. add_shortcode( $shortcode, array( $this, 'gethtml') );
  41. }
  42. public function gethtml( $atts = array(), $content = null ) {
  43. $ret = array();
  44. // the attributes
  45. extract( $this->shortcode_atts($atts, $content) );
  46. // html MOVIE
  47. $type = ( !empty($eventtype) ? $eventtype : ucfirst( $this->shortcodeCfg['type'] ) );
  48. //$ret[] = '<div itemscope itemtype="http://schema.org/' . $type .'">';
  49. $ret[] = '<div itemscope itemtype="http://schema.org/Movie">';
  50. if ( !empty($image) ) {
  51. $imgalt = isset($name) ? $name : __($type.' Image', 'psp');
  52. $ret[] = '<img class="schema_image" itemprop="image" src="' . esc_url($image) . '" alt="' . $imgalt . '" />';
  53. }
  54. if ( !empty($name) && !empty($url) ) {
  55. $ret[] = '<a class="schema_url" target="_blank" itemprop="url" href="' . esc_url($url) . '">';
  56. $ret[] = '<div class="schema_name" itemprop="name">' . $name . '</div>';
  57. $ret[] = '</a>';
  58. } else if ( !empty($name) && empty($url) ) {
  59. $ret[] = '<div class="schema_name" itemprop="name">' . $name . '</div>';
  60. }
  61. if ( !empty($description) ) {
  62. $ret[] = '<div class="schema_description" itemprop="description">' . esc_attr($description) . '</div>';
  63. }
  64. if ( !empty($director) ) {
  65. $ret[] = '<div itemprop="director" itemscope itemtype="http://schema.org/Person">' . __('Directed by:', 'psp') . ' <span itemprop="name">' . $director . '</span></div>';
  66. }
  67. if ( !empty($producer) ) {
  68. $ret[] = '<div itemprop="producer" itemscope itemtype="http://schema.org/Person">' . __('Produced by:', 'psp') . ' <span itemprop="name">' . $producer . '</span></div>';
  69. }
  70. if ( !empty($actor) ) {
  71. $ret[] = '<div itemprop="director" itemscope itemtype="http://schema.org/Person">' . __('Starring:', 'psp') . ' <span itemprop="name">' . $actor . '</span></div>';
  72. }
  73. $ret[] = '</div>';
  74. // build Full html!
  75. return $this->shortcode_execute( $ret, $atts, $content );
  76. }
  77. /**
  78. * Singleton pattern
  79. *
  80. * @return pspSnippet_event Singleton instance
  81. */
  82. static public function getInstance()
  83. {
  84. if (!self::$_instance) {
  85. self::$_instance = new self;
  86. }
  87. return self::$_instance;
  88. }
  89. }
  90. }
  91. // Initialize the pspSnippet_movie class
  92. $pspSnippet_movie = new pspSnippet_movie('movie');