PageRenderTime 43ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 1ms

/wp-content/plugins/premium-seo-pack/modules/Social_Stats/init.php

https://gitlab.com/iamgraeme/royalmile
PHP | 350 lines | 257 code | 48 blank | 45 comment | 34 complexity | 136fdd55b628e2de6d14d51c1fdc434b MD5 | raw file
  1. <?php
  2. /*
  3. * Define class pspSocialStats
  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('pspSocialStats') != true) {
  9. class pspSocialStats
  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. private $module_folder = '';
  20. private $module = '';
  21. static protected $_instance;
  22. /*
  23. * Required __construct() function that initalizes the AA-Team Framework
  24. */
  25. public function __construct()
  26. {
  27. global $psp;
  28. $this->the_plugin = $psp;
  29. $this->module_folder = $this->the_plugin->cfg['paths']['plugin_dir_url'] . 'modules/Social_Stats/';
  30. $this->module = $this->the_plugin->cfg['modules']['Social_Stats'];
  31. $this->plugin_settings = $this->the_plugin->get_theoption( $this->the_plugin->alias . '_social' );
  32. if (is_admin()) {
  33. add_action('admin_menu', array( &$this, 'adminMenu' ));
  34. }
  35. $this->init();
  36. // social sharing
  37. if ( $this->the_plugin->is_admin !== true )
  38. $this->init_social_sharing();
  39. }
  40. /**
  41. * Head Filters & Init!
  42. *
  43. */
  44. public function init() {
  45. }
  46. /**
  47. * Social Sharing
  48. *
  49. */
  50. public function init_social_sharing() {
  51. // social sharing module
  52. require_once( $this->the_plugin->cfg['paths']['plugin_dir_path'] . 'aa-framework/utils/social_sharing.php' );
  53. $ssh = new pspSocialSharing( $this->the_plugin );
  54. }
  55. /**
  56. * Hooks
  57. */
  58. static public function adminMenu()
  59. {
  60. self::getInstance()
  61. ->_registerAdminPages();
  62. }
  63. /**
  64. * Register plug-in module admin pages and menus
  65. */
  66. protected function _registerAdminPages()
  67. {
  68. if ( $this->the_plugin->capabilities_user_has_module('Social_Stats') ) {
  69. add_submenu_page(
  70. $this->the_plugin->alias,
  71. $this->the_plugin->alias . " " . __('Social Stats', 'psp'),
  72. __('Social Stats', 'psp'),
  73. 'read',
  74. $this->the_plugin->alias . "_Social_Stats",
  75. array($this, 'display_index_page')
  76. );
  77. }
  78. return $this;
  79. }
  80. public function socialstats_scripts( $socialServices=array() )
  81. {
  82. if( count($socialServices) > 220 ){
  83. foreach ($socialServices as $key => $value){
  84. if( $value == 'twitter' ){
  85. echo '<script type="text/javascript" src="http://platform.twitter.com/widgets.js?' . ( time() ) . '"></script>';
  86. }
  87. elseif( $value == 'google' ){
  88. echo '<script type="text/javascript" src="http://apis.google.com/js/plusone.js?' . ( time() ) . '"></script>';
  89. }
  90. elseif( $value == 'digg' ){
  91. ?>
  92. <script type="text/javascript">
  93. (function() {
  94. var s = document.createElement('SCRIPT'), s1 = document.getElementsByTagName('SCRIPT')[0];
  95. s.type = 'text/javascript';
  96. s.async = true;
  97. s.src = 'http://widgets.digg.com/buttons.js';
  98. s1.parentNode.insertBefore(s, s1);
  99. })();
  100. </script>
  101. <?php
  102. }
  103. elseif( $value == 'linkedin' ){
  104. echo '<script type="text/javascript" src="http://platform.linkedin.com/in.js?' . ( time() ) . '"></script>';
  105. }
  106. elseif( $value == 'stumbleupon' ){
  107. ?>
  108. <script type="text/javascript">
  109. (function() {
  110. var li = document.createElement('script'); li.type = 'text/javascript'; li.async = true;
  111. li.src = ('https:' == document.location.protocol ? 'https:' : 'http:') + '//platform.stumbleupon.com/1/widgets.js';
  112. var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(li, s);
  113. })();
  114. </script>
  115. <?php
  116. }
  117. }
  118. }
  119. ?>
  120. <?php
  121. }
  122. public function display_meta_box()
  123. {
  124. $this->printBoxInterface();
  125. }
  126. public function display_index_page()
  127. {
  128. $this->printBaseInterface();
  129. }
  130. /*
  131. * printBaseInterface, method
  132. * --------------------------
  133. *
  134. * this will add the base DOM code for you options interface
  135. */
  136. private function printBaseInterface()
  137. {
  138. $socialServices = $this->the_plugin->get_theoption( $this->the_plugin->alias . '_social', true );
  139. if( isset($socialServices['services']) ) {
  140. $socialServices = $socialServices['services'];
  141. }
  142. //if( count($socialServices) > 0 ) $this->socialstats_scripts($socialServices);
  143. ?>
  144. <script type="text/javascript" src="<?php echo $this->module_folder;?>app.class.js" ></script>
  145. <link rel='stylesheet' href='<?php echo $this->module_folder;?>app.css' type='text/css' media='all' />
  146. <div id="psp-wrapper" class="fluid wrapper-psp">
  147. <?php
  148. // show the top menu
  149. pspAdminMenu::getInstance()->make_active('off_page_optimization|Social_Stats')->show_menu();
  150. ?>
  151. <!-- Main loading box -->
  152. <div id="psp-main-loading">
  153. <div id="psp-loading-overlay"></div>
  154. <div id="psp-loading-box">
  155. <div class="psp-loading-text"><?php _e('Loading', 'psp');?></div>
  156. <div class="psp-meter psp-animate" style="width:86%; margin: 34px 0px 0px 7%;"><span style="width:100%"></span></div>
  157. </div>
  158. </div>
  159. <!-- Content -->
  160. <div id="psp-content">
  161. <h1 class="psp-section-headline">
  162. <?php echo $this->module['Social_Stats']['menu']['title'];?>
  163. <span class="psp-section-info"><?php echo $this->module['Social_Stats']['description'];?></span>
  164. <?php
  165. $has_help = isset($this->module['Social_Stats']['help']) ? true : false;
  166. if( $has_help === true ){
  167. $help_type = isset($this->module['Social_Stats']['help']['type']) && $this->module['Social_Stats']['help']['type'] ? 'remote' : 'local';
  168. if( $help_type == 'remote' ){
  169. echo '<a href="#load_docs" class="psp-show-docs" data-helptype="' . ( $help_type ) . '" data-url="' . ( $this->module['Social_Stats']['help']['url'] ) . '">HELP</a>';
  170. }
  171. }
  172. ?>
  173. </h1>
  174. <!-- Container -->
  175. <div class="psp-container clearfix">
  176. <!-- Main Content Wrapper -->
  177. <div id="psp-content-wrap" class="clearfix" style="padding-top: 20px;">
  178. <!-- Content Area -->
  179. <div id="psp-content-area">
  180. <div class="psp-grid_4">
  181. <div class="psp-panel">
  182. <div class="psp-panel-header">
  183. <span class="psp-panel-title">
  184. <?php _e('Social Stats of your pages', 'psp');?>
  185. </span>
  186. </div>
  187. <div class="psp-panel-content">
  188. <form class="psp-form" id="1" action="#save_with_ajax">
  189. <div class="psp-form-row psp-table-ajax-list" id="psp-table-ajax-response">
  190. <?php
  191. $columns = array(
  192. 'id' => array(
  193. 'th' => __('ID', 'psp'),
  194. 'td' => '%ID%',
  195. 'width' => '40'
  196. ),
  197. 'title' => array(
  198. 'th' => __('Title', 'psp'),
  199. 'td' => '%title%',
  200. 'align' => 'left'
  201. )
  202. );
  203. if( count($socialServices) > 0 ){
  204. foreach ($socialServices as $key => $value){
  205. if( $value == 'facebook' ){
  206. $columns['ss_facebook'] = array(
  207. 'th' => __('Facebook', 'psp'),
  208. 'td' => '%ss_facebook%',
  209. 'width' => '80'
  210. );
  211. }
  212. if( $value == 'twitter' ){
  213. $columns['ss_twitter'] = array(
  214. 'th' => __('Twitter', 'psp'),
  215. 'td' => '%ss_twitter%',
  216. 'width' => '80'
  217. );
  218. }
  219. if( $value == 'google' ){
  220. $columns['ss_google'] = array(
  221. 'th' => __('Google +1', 'psp'),
  222. 'td' => '%ss_google%',
  223. 'width' => '80'
  224. );
  225. }
  226. if( $value == 'pinterest' ){
  227. $columns['ss_pinterest'] = array(
  228. 'th' => __('Pinterest', 'psp'),
  229. 'td' => '%ss_pinterest%',
  230. 'width' => '80'
  231. );
  232. }
  233. if( $value == 'stumbleupon' ){
  234. $columns['ss_stumbleupon'] = array(
  235. 'th' => __('Stumbleupon', 'psp'),
  236. 'td' => '%ss_stumbleupon%',
  237. 'width' => '80'
  238. );
  239. }
  240. if( $value == 'digg' ){
  241. $columns['ss_digg'] = array(
  242. 'th' => __('Digg', 'psp'),
  243. 'td' => '%ss_digg%',
  244. 'width' => '80'
  245. );
  246. }
  247. if( $value == 'linkedin' ){
  248. $columns['ss_linkedin'] = array(
  249. 'th' => __('Linkedin', 'psp'),
  250. 'td' => '%ss_linkedin%',
  251. 'width' => '80'
  252. );
  253. }
  254. }
  255. }
  256. $columns['date'] = array(
  257. 'th' => __('Date', 'psp'),
  258. 'td' => '%date%',
  259. 'width' => '120'
  260. );
  261. pspAjaxListTable::getInstance( $this->the_plugin )
  262. ->setup(array(
  263. 'id' => 'pspSocialStats',
  264. 'show_header' => true,
  265. 'show_footer' => false,
  266. 'items_per_page' => '10',
  267. 'post_statuses' => 'all',
  268. 'columns' => $columns,
  269. 'mass_actions' => false
  270. ))
  271. ->print_html();
  272. ?>
  273. </div>
  274. </form>
  275. </div>
  276. </div>
  277. </div>
  278. <div class="clear"></div>
  279. </div>
  280. </div>
  281. </div>
  282. </div>
  283. </div>
  284. <?php
  285. }
  286. /**
  287. * Singleton pattern
  288. *
  289. * @return pspSocialStats Singleton instance
  290. */
  291. static public function getInstance()
  292. {
  293. if (!self::$_instance) {
  294. self::$_instance = new self;
  295. }
  296. return self::$_instance;
  297. }
  298. }
  299. }
  300. // Initialize the pspSocialStats class
  301. //$pspSocialStats = new pspSocialStats();
  302. $pspSocialStats = pspSocialStats::getInstance();