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

/code/cake/app/webroot/cp/wp-content/plugins/commentpress-core/commentpress-core/class_commentpress_display.php

https://github.com/DigitalPaulScholtenProject/DPSP-Platform
PHP | 2978 lines | 1327 code | 941 blank | 710 comment | 121 complexity | 3f961c856fd86a3366da1ee811d9374f MD5 | raw file
Possible License(s): GPL-3.0, GPL-2.0, AGPL-1.0, LGPL-2.1

Large files files are truncated, but you can click here to view the full file

  1. <?php /*
  2. ================================================================================
  3. Class CommentpressCoreDisplay
  4. ================================================================================
  5. AUTHOR: Christian Wach <needle@haystack.co.uk>
  6. --------------------------------------------------------------------------------
  7. NOTES
  8. =====
  9. --------------------------------------------------------------------------------
  10. */
  11. /*
  12. ================================================================================
  13. Class Name
  14. ================================================================================
  15. */
  16. class CommentpressCoreDisplay {
  17. /*
  18. ============================================================================
  19. Properties
  20. ============================================================================
  21. */
  22. // parent object reference
  23. var $parent_obj;
  24. // database object
  25. var $db;
  26. /**
  27. * @description: initialises this object
  28. * @param object $parent_obj a reference to the parent object
  29. * @return object
  30. * @todo:
  31. *
  32. */
  33. function __construct( $parent_obj ) {
  34. // store reference to parent
  35. $this->parent_obj = $parent_obj;
  36. // store reference to database wrapper (child of calling obj)
  37. $this->db = $this->parent_obj->db;
  38. // init
  39. $this->_init();
  40. // --<
  41. return $this;
  42. }
  43. /**
  44. * @description: PHP 4 constructor
  45. */
  46. function CommentpressCoreDisplay( $parent_obj ) {
  47. // is this php5?
  48. if ( version_compare( PHP_VERSION, "5.0.0", "<" ) ) {
  49. // call php5 constructor
  50. $this->__construct( $parent_obj );
  51. }
  52. // --<
  53. return $this;
  54. }
  55. /**
  56. * @description: if needed, sets up this object
  57. * @todo: work out how to upgrade.
  58. *
  59. */
  60. function activate() {
  61. // force WordPress to regenerate theme directories
  62. search_theme_directories( true );
  63. // get groupblog-set theme, if we have one
  64. $theme = $this->parent_obj->get_groupblog_theme();
  65. // did we get a CommentPress Core one?
  66. if ( $theme !== false ) {
  67. // we're in a groupblog context: BP Groupblog will already have set
  68. // the theme because we're adding our wpmu_new_blog action after it
  69. // --<
  70. return;
  71. }
  72. // test for WP3.4...
  73. if ( function_exists( 'wp_get_themes' ) ) {
  74. // get CommentPress Core theme by default, but allow overrides
  75. $target_theme = apply_filters(
  76. 'cp_forced_theme_slug',
  77. 'commentpress-theme'
  78. );
  79. // get the theme we want
  80. $theme = wp_get_theme(
  81. $target_theme
  82. );
  83. // if we get it...
  84. if ( $theme->exists() ) {
  85. // ignore if not allowed
  86. //if ( is_multisite() AND !$theme->is_allowed() ) { return; }
  87. // activate it
  88. switch_theme(
  89. $theme->get_template(),
  90. $theme->get_stylesheet()
  91. );
  92. }
  93. } else {
  94. // use pre-3.4 logic
  95. $themes = get_themes();
  96. //print_r( $themes ); die();
  97. // get CommentPress Core theme by default, but allow overrides
  98. // NB, the key prior to WP 3.4 is the theme's *name*
  99. $target_theme = apply_filters(
  100. 'cp_forced_theme_name',
  101. 'CommentPress Default Theme'
  102. );
  103. // the key is the theme name
  104. if ( isset( $themes[ $target_theme ] ) ) {
  105. // activate it
  106. switch_theme(
  107. $themes[ $target_theme ]['Template'],
  108. $themes[ $target_theme ]['Stylesheet']
  109. );
  110. }
  111. }
  112. }
  113. /**
  114. * @description: if needed, destroys this object
  115. * @todo:
  116. *
  117. */
  118. function deactivate() {
  119. // test for WP3.4...
  120. if ( function_exists( 'wp_get_theme' ) ) {
  121. // get CommentPress Core theme by default, but allow overrides
  122. $target_theme = apply_filters(
  123. 'cp_restore_theme_slug',
  124. WP_DEFAULT_THEME
  125. );
  126. // get the theme we want
  127. $theme = wp_get_theme(
  128. $target_theme
  129. );
  130. // if we get it...
  131. if ( $theme->exists() ) {
  132. // ignore if not allowed
  133. //if ( is_multisite() AND !$theme->is_allowed() ) { return; }
  134. // activate it
  135. switch_theme(
  136. $theme->get_template(),
  137. $theme->get_stylesheet()
  138. );
  139. }
  140. } else {
  141. // use pre-3.4 logic
  142. $themes = get_themes();
  143. //print_r( $themes ); die();
  144. // get default theme by default, but allow overrides
  145. // NB, the key prior to WP 3.4 is the theme's *name*
  146. $target_theme = apply_filters(
  147. 'cp_restore_theme_name',
  148. WP_DEFAULT_THEME
  149. );
  150. // the key is the theme name
  151. if ( isset( $themes[ $target_theme ] ) ) {
  152. // activate it
  153. switch_theme(
  154. $themes[ $target_theme ]['Template'],
  155. $themes[ $target_theme ]['Stylesheet']
  156. );
  157. }
  158. }
  159. }
  160. //##############################################################################
  161. /*
  162. ============================================================================
  163. PUBLIC METHODS
  164. ============================================================================
  165. */
  166. /**
  167. * @description: enqueue jQuery, jQuery UI and plugins
  168. * @todo:
  169. *
  170. */
  171. function get_jquery() {
  172. // default to minified scripts
  173. $debug_state = '';
  174. // target different scripts when debugging
  175. if ( defined( 'SCRIPT_DEBUG' ) AND SCRIPT_DEBUG === true ) {
  176. // use uncompressed scripts
  177. $debug_state = '.dev';
  178. }
  179. // add our javascript plugin and dependencies
  180. wp_enqueue_script(
  181. 'jquery_commentpress',
  182. plugins_url( 'commentpress-core/assets/js/jquery.commentpress'.$debug_state.'.js', COMMENTPRESS_PLUGIN_FILE ),
  183. array( 'jquery', 'jquery-form', 'jquery-ui-core', 'jquery-ui-resizable' ),
  184. COMMENTPRESS_VERSION // version
  185. );
  186. // add jQuery Scroll-To plugin
  187. wp_enqueue_script(
  188. 'jquery_scrollto',
  189. plugins_url( 'commentpress-core/assets/js/jquery.scrollTo.js', COMMENTPRESS_PLUGIN_FILE ),
  190. array( 'jquery_commentpress' ),
  191. COMMENTPRESS_VERSION // version
  192. );
  193. // add jQuery Cookie plugin (renamed to jquery.biscuit.js because some hosts don't like 'cookie' in the filename)
  194. wp_enqueue_script(
  195. 'jquery_cookie',
  196. plugins_url( 'commentpress-core/assets/js/jquery.biscuit.js', COMMENTPRESS_PLUGIN_FILE ),
  197. array( 'jquery_commentpress' ),
  198. COMMENTPRESS_VERSION // version
  199. );
  200. /*
  201. Prior to WP3.2 (IIRC), jQuery UI has to be added separately, as the built in one was not
  202. sufficiently up-to-date. This is no longer the case, so the independent jQuery UI package
  203. has been removed from CommentPress Core in favour of the built-in one.
  204. */
  205. }
  206. /**
  207. * @description: enqueue our quicktags script
  208. * @todo:
  209. *
  210. */
  211. function get_custom_quicktags() {
  212. // don't bother if the current user lacks permissions
  213. if ( ! current_user_can('edit_posts') AND ! current_user_can('edit_pages') ) {
  214. return;
  215. }
  216. // need access to WP version
  217. global $wp_version;
  218. // there's a new quicktags script in 3.3
  219. if ( version_compare( $wp_version, '3.2.99999', '>=' ) ) {
  220. // add our javascript script and dependencies
  221. wp_enqueue_script(
  222. 'commentpress_custom_quicktags',
  223. plugin_dir_url( COMMENTPRESS_PLUGIN_FILE ) . 'commentpress-core/assets/js/cp_quicktags_3.3.js',
  224. array( 'quicktags' ),
  225. COMMENTPRESS_VERSION, // version
  226. true // in footer
  227. );
  228. } else {
  229. // add our javascript script and dependencies
  230. wp_enqueue_script(
  231. 'commentpress_custom_quicktags',
  232. plugin_dir_url( COMMENTPRESS_PLUGIN_FILE ) . 'commentpress-core/assets/js/cp_quicktags.js',
  233. array( 'quicktags' ),
  234. COMMENTPRESS_VERSION, // version
  235. false // not in footer (but may need to be in WP 3.3)
  236. );
  237. }
  238. }
  239. /**
  240. * @description: get plugin stylesheets
  241. * @return string $styles
  242. * @todo:
  243. *
  244. */
  245. function get_frontend_styles() {
  246. // add jQuery UI stylesheet -> needed for resizable columns
  247. wp_enqueue_style(
  248. 'cp_jquery_ui_base',
  249. plugins_url( 'commentpress-core/assets/css/jquery.ui.css', COMMENTPRESS_PLUGIN_FILE ),
  250. false,
  251. COMMENTPRESS_VERSION, // version
  252. 'all' // media
  253. );
  254. }
  255. /**
  256. * @description: test if TinyMCE is allowed
  257. * @return boolean $allowed
  258. * @todo:
  259. *
  260. */
  261. function is_tinymce_allowed() {
  262. // check option
  263. if (
  264. $this->db->option_exists( 'cp_comment_editor' ) AND
  265. $this->db->option_get( 'cp_comment_editor' ) != '1'
  266. ) {
  267. // --<
  268. return false;
  269. }
  270. // don't return TinyMCE for touchscreens, mobile phones or tablets
  271. if ( $this->db->is_mobile_touch OR $this->db->is_mobile OR $this->db->is_tablet ) {
  272. // --<
  273. return false;
  274. }
  275. // --<
  276. return true;
  277. }
  278. /**
  279. * @description: get built-in TinyMCE scripts from Wordpress Includes directory
  280. * @return string $scripts
  281. * @todo:
  282. *
  283. */
  284. function get_tinymce() {
  285. // check if we can
  286. if ( !$this->is_tinymce_allowed() ) {
  287. // --<
  288. return;
  289. }
  290. // test for wp_editor()
  291. if ( function_exists( 'wp_editor' ) ) {
  292. // don't include anything - this will be done in the comment form template
  293. return;
  294. } else {
  295. // test for WordPress version
  296. global $wp_version;
  297. // for WP 3.2+
  298. if ( version_compare( $wp_version, '3.2', '>=' ) ) {
  299. // don't need settings
  300. $this->_get_tinymce();
  301. } else {
  302. // get site HTTP root
  303. $site_http_root = trailingslashit( get_bloginfo('wpurl') );
  304. // all TinyMCE scripts
  305. $scripts .= '<!-- TinyMCE -->
  306. <script type="text/javascript" src="'.$site_http_root.'wp-includes/js/tinymce/tiny_mce.js"></script>
  307. <script type="text/javascript" src="'.$site_http_root.'wp-includes/js/tinymce/langs/wp-langs-en.js?ver=20081129"></script>
  308. '."\n";
  309. // add our init
  310. $scripts .= $this->_get_tinymce_init();
  311. // out to browser
  312. echo $scripts;
  313. }
  314. }
  315. }
  316. /**
  317. * @description: get help text
  318. * @return HTML $help
  319. * @todo: translation
  320. *
  321. */
  322. function get_help() {
  323. $help = <<<HELPTEXT
  324. <p>For further information about using CommentPress, please refer to the <a href="http://www.futureofthebook.org/commentpress/support/">CommentPress support pages</a> or use one of the links below:</p>
  325. <ul>
  326. <li><a href="http://www.futureofthebook.org/commentpress/support/structuring-your-document/">Structuring your Document</a></li>
  327. <li><a href="http://www.futureofthebook.org/commentpress/support/formatting-your-document/">Formatting Your Document</a></li>
  328. <li><a href="http://www.futureofthebook.org/commentpress/support/using-commentpress/">How to read a CommentPress document</a></li>
  329. </ul>
  330. HELPTEXT;
  331. // --<
  332. return $help;
  333. }
  334. /**
  335. * @description: show the posts and their comment count in a list format
  336. * @todo:
  337. *
  338. */
  339. function list_posts( $params = 'numberposts=-1&order=DESC' ) {
  340. // get all posts
  341. $posts = get_posts( $params );
  342. // have we set the option?
  343. $list_style = $this->db->option_get( 'cp_show_extended_toc' );
  344. //print_r( $list_style ); die();
  345. // if not set or set to 'off'
  346. if ( $list_style === false OR $list_style == '0' ) {
  347. // --------------------------
  348. // old-style undecorated list
  349. // --------------------------
  350. // run through them...
  351. foreach( $posts AS $item ) {
  352. // get comment count for that post
  353. $count = count( $this->db->get_approved_comments( $item->ID ) );
  354. // write list item
  355. echo '<li class="title"><a href="'.get_permalink( $item->ID ).'">'.get_the_title( $item->ID ).' ('.$count.')</a></li>'."\n";
  356. }
  357. } else {
  358. // ------------------------
  359. // new-style decorated list
  360. // ------------------------
  361. // run through them...
  362. foreach( $posts AS $item ) {
  363. // init output
  364. $_html = '';
  365. //print_r( $item ); die();
  366. //setup_postdata( $item );
  367. // get comment count for that post
  368. $count = count( $this->db->get_approved_comments( $item->ID ) );
  369. // compat with Co-Authors Plus
  370. if ( function_exists( 'get_coauthors' ) ) {
  371. // get multiple authors
  372. $authors = get_coauthors( $item->ID );
  373. //print_r( $authors ); die();
  374. // if we get some
  375. if ( !empty( $authors ) ) {
  376. // use the Co-Authors format of "name, name, name & name"
  377. $author_html = '';
  378. // init counter
  379. $n = 1;
  380. // find out how many author we have
  381. $author_count = count( $authors );
  382. // loop
  383. foreach( $authors AS $author ) {
  384. // default to comma
  385. $sep = ', ';
  386. // if we're on the penultimate
  387. if ( $n == ($author_count - 1) ) {
  388. // use ampersand
  389. $sep = __( ' &amp; ', 'commentpress-core' );
  390. }
  391. // if we're on the last, don't add
  392. if ( $n == $author_count ) { $sep = ''; }
  393. // get name
  394. $author_html .= $this->echo_post_author( $author->ID, false );
  395. // and separator
  396. $author_html .= $sep;
  397. // increment
  398. $n++;
  399. // are we showing avatars?
  400. if ( get_option( 'show_avatars' ) ) {
  401. // get avatar
  402. $_html .= get_avatar( $author->ID, $size='32' );
  403. }
  404. }
  405. // add citation
  406. $_html .= '<cite class="fn">'.$author_html.'</cite>'."\n";
  407. // add permalink
  408. $_html .= '<p class="post_activity_date">'.get_the_time('l, F jS, Y', $item->ID).'</p>'."\n";
  409. }
  410. } else {
  411. // get avatar
  412. $author_id = $item->post_author;
  413. // are we showing avatars?
  414. if ( get_option( 'show_avatars' ) ) {
  415. $_html .= get_avatar( $author_id, $size='32' );
  416. }
  417. // add citation
  418. $_html .= '<cite class="fn">'.$this->echo_post_author( $author_id, false ).'</cite>';
  419. // add permalink
  420. $_html .= '<p class="post_activity_date">'.get_the_time('l, F jS, Y', $item->ID).'</p>';
  421. }
  422. // write list item
  423. echo '<li class="title">
  424. <div class="post-identifier">
  425. '.$_html.'
  426. </div>
  427. <a href="'.get_permalink( $item->ID ).'" class="post_activity_link">'.get_the_title( $item->ID ).' ('.$count.')</a>
  428. </li>'."\n";
  429. }
  430. }
  431. }
  432. /**
  433. * @description: show username (with link)
  434. * @todo: remove from theme functions.php?
  435. *
  436. */
  437. function echo_post_author( $author_id, $echo = true ) {
  438. // get author details
  439. $user = get_userdata( $author_id );
  440. // kick out if we don't have a user with that ID
  441. if ( !is_object( $user ) ) { return; }
  442. // access plugin
  443. global $commentpress_core, $post;
  444. // if we have the plugin enabled and it's BP
  445. if ( is_object( $post ) AND is_object( $commentpress_core ) AND $commentpress_core->is_buddypress() ) {
  446. // construct user link
  447. $author = bp_core_get_userlink( $user->ID );
  448. } else {
  449. // link to theme's author page
  450. $link = sprintf(
  451. '%1$s',
  452. esc_html( $user->display_name )
  453. );
  454. $author = apply_filters( 'the_author_posts_link', $link );
  455. }
  456. // if we're echoing
  457. if ( $echo ) {
  458. echo $author;
  459. } else {
  460. return $author;
  461. }
  462. }
  463. /**
  464. * @description: print the posts and their comment count in a list format
  465. * @todo:
  466. *
  467. */
  468. function list_pages() {
  469. /*
  470. Question: do we want to use WP menus? And if so, how?
  471. Currently, we're using wp_list_pages(), so let's try wp_page_menu() first
  472. // If we set the theme to use wp_nav_menu(), we need to register it
  473. register_nav_menu( 'primary', __( 'Primary Menu', 'commentpress-core' ) );
  474. Our navigation menu. If one isn't filled out, wp_nav_menu falls back to
  475. wp_page_menu. The menu assiged to the primary position is the one used. If
  476. none is assigned, the menu with the lowest ID is used.
  477. //wp_nav_menu( array( 'theme_location' => 'primary' ) );
  478. // set list pages defaults
  479. $args = array(
  480. 'sort_column' => 'menu_order, post_title',
  481. 'menu_class' => 'menu',
  482. 'include' => '',
  483. 'exclude' => '',
  484. 'echo' => true,
  485. 'show_home' => false,
  486. 'link_before' => '',
  487. 'link_after' => ''
  488. );
  489. */
  490. // test for custom menu
  491. if ( has_nav_menu( 'toc' ) ) {
  492. // try and use it
  493. wp_nav_menu( array(
  494. 'theme_location' => 'toc',
  495. 'echo' => true,
  496. 'container' => '',
  497. 'items_wrap' => '%3$s',
  498. ) );
  499. return;
  500. }
  501. // get welcome page ID
  502. $welcome_id = $this->db->option_get( 'cp_welcome_page' );
  503. // get front page
  504. $page_on_front = $this->db->option_wp_get( 'page_on_front' );
  505. // print link to title page, if we have one and it's the front page
  506. if ( $welcome_id !== false AND $page_on_front == $welcome_id ) {
  507. // define title page
  508. $title_page_title = get_the_title( $welcome_id );
  509. // allow overrides
  510. $title_page_title = apply_filters( 'cp_title_page_title', $title_page_title );
  511. // echo list item
  512. echo '<li class="page_item page-item-'.$welcome_id.'"><a href="'.get_permalink( $welcome_id ).'">'.$title_page_title.'</a></li>';
  513. }
  514. // get page display option
  515. //$depth = $this->db->option_get( 'cp_show_subpages' );
  516. // ALWAYS write subpages into page, even if they aren't displayed
  517. $depth = 0;
  518. // get pages to exclude
  519. $exclude = $this->db->option_get( 'cp_special_pages' );
  520. // do we have any?
  521. if ( !$exclude ) { $exclude = array(); }
  522. // exclude title page, if we have one
  523. if ( $welcome_id !== false ) { $exclude[] = $welcome_id; }
  524. // set list pages defaults
  525. $defaults = array(
  526. 'depth' => $depth,
  527. 'show_date' => '',
  528. 'date_format' => $this->db->option_get( 'date_format' ),
  529. 'child_of' => 0,
  530. 'exclude' => implode( ',', $exclude ),
  531. 'title_li' => '',
  532. 'echo' => 1,
  533. 'authors' => '',
  534. 'sort_column' => 'menu_order, post_title',
  535. 'link_before' => '',
  536. 'link_after' => '',
  537. 'exclude_tree' => ''
  538. );
  539. // use Wordpress function to echo
  540. wp_list_pages( $defaults );
  541. /*
  542. // The following code manually lists pages, but adds the comment count to the name
  543. // init params
  544. $params = 'sort_column=menu_order';
  545. // exclude the special pages
  546. $params .= '&exclude='.implode( ',', $special );
  547. //echo $params; exit();
  548. // get all pages
  549. $_pages = get_pages( $params );
  550. // run through them...
  551. foreach( $_pages AS $_page ) {
  552. // get comment count for that page
  553. $count = count( $this->db->get_approved_comments( $_page->ID ) );
  554. // write list item
  555. echo '<li class="title"><a href="'.get_page_link( $_page->ID ).'">'.$_page->post_title.' ('.$count.')</a></li>'."\n";
  556. }
  557. */
  558. }
  559. /**
  560. * @description: get the block comment icon
  561. * @param integer $comment_count number of comments
  562. * @param string $text_signature comment text signature
  563. * @param string $block_type either 'auto', 'line' or 'block'
  564. * @param integer $para_num sequnetial commentable block number
  565. * @return string $comment_icon
  566. * @todo:
  567. *
  568. */
  569. function get_comment_icon(
  570. $comment_count,
  571. $text_signature,
  572. $block_type = 'auto',
  573. $para_num = 1
  574. ) { // -->
  575. // reset icon
  576. $icon = null;
  577. // if we have no comments...
  578. if( $comment_count == 0 ) {
  579. // show add comment icon
  580. $icon = 'comment_add.png';
  581. $class = ' no_comments';
  582. } elseif( $comment_count > 0 ) {
  583. // show comments present icon
  584. $icon = 'comment.png';
  585. $class = ' has_comments';
  586. }
  587. // define block title by block type
  588. switch ( $block_type ) {
  589. // ----------------------------
  590. // auto-formatted
  591. // ----------------------------
  592. case 'auto':
  593. default:
  594. // define title text
  595. $title_text = sprintf( _n(
  596. // singular
  597. 'There is %d comment written for this paragraph',
  598. // plural
  599. 'There are %d comments written for this paragraph',
  600. // number
  601. $comment_count,
  602. // domain
  603. 'commentpress-core'
  604. // substitution
  605. ), $comment_count );
  606. // define add comment text
  607. $add_text = sprintf( _n(
  608. // singular
  609. 'Leave a comment on paragraph %d',
  610. // plural
  611. 'Leave a comment on paragraph %d',
  612. // number
  613. $para_num,
  614. // domain
  615. 'commentpress-core'
  616. // substitution
  617. ), $para_num );
  618. break;
  619. // ----------------------------
  620. // line-by-line, eg poetry
  621. // ----------------------------
  622. case 'line':
  623. // define title text
  624. $title_text = sprintf( _n(
  625. // singular
  626. 'There is %d comment written for this line',
  627. // plural
  628. 'There are %d comments written for this line',
  629. // number
  630. $comment_count,
  631. // domain
  632. 'commentpress-core'
  633. // substitution
  634. ), $comment_count );
  635. // define add comment text
  636. $add_text = sprintf( _n(
  637. // singular
  638. 'Leave a comment on line %d',
  639. // plural
  640. 'Leave a comment on line %d',
  641. // number
  642. $para_num,
  643. // domain
  644. 'commentpress-core'
  645. // substitution
  646. ), $para_num );
  647. break;
  648. // ----------------------------
  649. // comment-blocks
  650. // ----------------------------
  651. case 'block':
  652. // define title text
  653. $title_text = sprintf( _n(
  654. // singular
  655. 'There is %d comment written for this block',
  656. // plural
  657. 'There are %d comments written for this block',
  658. // number
  659. $comment_count,
  660. // domain
  661. 'commentpress-core'
  662. // substitution
  663. ), $comment_count );
  664. // define add comment text
  665. $add_text = sprintf( _n(
  666. // singular
  667. 'Leave a comment on block %d',
  668. // plural
  669. 'Leave a comment on block %d',
  670. // number
  671. $para_num,
  672. // domain
  673. 'commentpress-core'
  674. // substitution
  675. ), $para_num );
  676. break;
  677. }
  678. // define small
  679. $small = '<small class="comment_count" title="'.$title_text.'">'.(string) $comment_count.'</small>';
  680. // define HTML for comment icon
  681. $comment_icon = '<span class="commenticonbox"><a class="para_permalink'.$class.'" href="#'.$text_signature.'" title="'.$add_text.'">'.$add_text.'</a> '.$small.'</span>'."\n";
  682. // --<
  683. return $comment_icon;
  684. }
  685. /**
  686. * @description: get the block paragraph icon
  687. * @param integer $comment_count number of comments
  688. * @param string $text_signature comment text signature
  689. * @param string $block_type either 'auto', 'line' or 'block'
  690. * @param integer $para_num sequnetial commentable block number
  691. * @return string $comment_icon
  692. * @todo:
  693. *
  694. */
  695. function get_paragraph_icon(
  696. $comment_count,
  697. $text_signature,
  698. $block_type = 'auto',
  699. $para_num = 1
  700. ) { // -->
  701. // define block title by block type
  702. switch ( $block_type ) {
  703. // ----------------------------
  704. // auto-formatted
  705. // ----------------------------
  706. case 'auto':
  707. default:
  708. // define permalink text
  709. $permalink_text = sprintf( _n(
  710. // singular
  711. 'Permalink for paragraph %d',
  712. // plural
  713. 'Permalink for paragraph %d',
  714. // number
  715. $para_num,
  716. // domain
  717. 'commentpress-core'
  718. // substitution
  719. ), $para_num );
  720. // define paragraph marker
  721. //$para_marker = '<span class="para_marker"><a id="'.$text_signature.'" href="#'.$text_signature.'" title="'.$permalink_text.'">&para; <span>'.(string) $para_num.'</span></a></span>';
  722. $para_marker = '<span class="para_marker"><a id="'.$text_signature.'" href="#'.$text_signature.'" title="'.$permalink_text.'"><span>'.(string) $para_num.'</span></a></span>';//JVDP
  723. break;
  724. // ----------------------------
  725. // line-by-line, eg poetry
  726. // ----------------------------
  727. case 'line':
  728. // define permalink text
  729. $permalink_text = sprintf( _n(
  730. // singular
  731. 'Permalink for line %d',
  732. // plural
  733. 'Permalink for line %d',
  734. // number
  735. $para_num,
  736. // domain
  737. 'commentpress-core'
  738. // substitution
  739. ), $para_num );
  740. // define paragraph marker
  741. $para_marker = '<span class="para_marker"><a id="'.$text_signature.'" href="#'.$text_signature.'" title="'.$permalink_text.'">&para; <span>'.(string) $para_num.'</span></a></span>';
  742. break;
  743. // ----------------------------
  744. // comment-blocks
  745. // ----------------------------
  746. case 'block':
  747. // define permalink text
  748. $permalink_text = sprintf( _n(
  749. // singular
  750. 'Permalink for block %d',
  751. // plural
  752. 'Permalink for block %d',
  753. // number
  754. $para_num,
  755. // domain
  756. 'commentpress-core'
  757. // substitution
  758. ), $para_num );
  759. // define paragraph marker
  760. $para_marker = '<span class="para_marker"><a id="'.$text_signature.'" href="#'.$text_signature.'" title="'.$permalink_text.'">&para; <span>'.(string) $para_num.'</span></a></span>';
  761. break;
  762. }
  763. // define HTML for paragraph icon
  764. $paragraph_icon = $para_marker."\n";
  765. // --<
  766. return $paragraph_icon;
  767. }
  768. /**
  769. * @description: get the content comment icon tag
  770. * @param string $text_signature comment text signature
  771. * @return string $para_tag
  772. * @todo:
  773. *
  774. */
  775. function get_para_tag( $text_signature, $commenticon, $tag = 'p' ) {
  776. // return different stuff for different tags
  777. switch( $tag ) {
  778. case 'ul':
  779. // define list tag
  780. $para_tag = '<'.$tag.' class="textblock" id="textblock-'.$text_signature.'">'.
  781. '<li class="list_commenticon">'.$commenticon.'</li>';
  782. break;
  783. case 'ol':
  784. // define list tag
  785. $para_tag = '<'.$tag.' class="textblock" id="textblock-'.$text_signature.'" start="0">'.
  786. '<li class="list_commenticon">'.$commenticon.'</li>';
  787. break;
  788. // compat with WP Footnotes
  789. case 'ol class="footnotes"':
  790. // define list tag
  791. $para_tag = '<ol class="footnotes textblock" id="textblock-'.$text_signature.'" start="0">'.
  792. '<li class="list_commenticon">'.$commenticon.'</li>';
  793. break;
  794. case 'p':
  795. case 'p style="text-align:left"':
  796. case 'p style="text-align:left;"':
  797. case 'p style="text-align: left"':
  798. case 'p style="text-align: left;"':
  799. // define para tag
  800. $para_tag = '<'.$tag.' class="textblock" id="textblock-'.$text_signature.'">'.$commenticon;
  801. break;
  802. case 'p style="text-align:right"':
  803. case 'p style="text-align:right;"':
  804. case 'p style="text-align: right"':
  805. case 'p style="text-align: right;"':
  806. // define para tag
  807. $para_tag = '<'.$tag.' class="textblock textblock-right" id="textblock-'.$text_signature.'">'.$commenticon;
  808. break;
  809. case 'p style="text-align:center"':
  810. case 'p style="text-align:center;"':
  811. case 'p style="text-align: center"':
  812. case 'p style="text-align: center;"':
  813. // define para tag
  814. $para_tag = '<'.$tag.' class="textblock textblock-center" id="textblock-'.$text_signature.'">'.$commenticon;
  815. break;
  816. case 'p style="text-align:justify"':
  817. case 'p style="text-align:justify;"':
  818. case 'p style="text-align: justify"':
  819. case 'p style="text-align: justify;"':
  820. // define para tag
  821. $para_tag = '<'.$tag.' class="textblock textblock-justify" id="textblock-'.$text_signature.'">'.$commenticon;
  822. break;
  823. case 'p class="notes"':
  824. // define para tag
  825. $para_tag = '<p class="notes textblock" id="textblock-'.$text_signature.'">'.$commenticon;
  826. break;
  827. case 'div':
  828. // define opening tag (we'll close it later)
  829. $para_tag = '<div class="textblock" id="textblock-'.$text_signature.'">'.$commenticon;
  830. break;
  831. case 'span':
  832. // define opening tag (we'll close it later)
  833. $para_tag = '<span class="textblock" id="textblock-'.$text_signature.'">'.$commenticon;
  834. break;
  835. }
  836. /*
  837. print_r( array(
  838. 't' => $text_signature,
  839. 'p' => $para_tag
  840. ) );
  841. */
  842. // --<
  843. return $para_tag;
  844. }
  845. /**
  846. * @description: get the text signature input for the comment form
  847. * @param string $text_sig comment text signature
  848. * @return string $input
  849. * @todo:
  850. *
  851. */
  852. function get_signature_input( $text_sig = '' ) {
  853. // define input tag
  854. $input = '<input type="hidden" name="text_signature" value="'.$text_sig.'" id="text_signature" />';
  855. // --<
  856. return $input;
  857. }
  858. /**
  859. * @description: get the minimise all button
  860. * @param: string $sidebar type of sidebar (comments, toc, activity)
  861. * @return string $tag
  862. * @todo:
  863. *
  864. */
  865. function get_minimise_all_button( $sidebar = 'comments' ) {
  866. switch( $sidebar ) {
  867. case 'comments':
  868. // define minimise button
  869. $tag = '<span id="cp_minimise_all_comments" title="'.__( 'Minimise all Comment Sections', 'commentpress-core' ).'"></span>';
  870. break;
  871. case 'activity':
  872. // define minimise button
  873. $tag = '<span id="cp_minimise_all_activity" title="'.__( 'Minimise all Activity Sections', 'commentpress-core' ).'"></span>';
  874. break;
  875. case 'toc':
  876. // define minimise button
  877. $tag = '<span id="cp_minimise_all_contents" title="'.__( 'Minimise all Contents Sections', 'commentpress-core' ).'"></span>';
  878. break;
  879. }
  880. // --<
  881. return $tag;
  882. }
  883. /**
  884. * @description: get the header minimise button
  885. * @return string $tag
  886. * @todo:
  887. *
  888. */
  889. function get_header_min_link() {
  890. // define minimise button
  891. $link = '<li><a href="#" id="btn_header_min" class="css_btn" title="'.__( 'Minimise Header', 'commentpress-core' ).'">'.__( 'Minimise Header', 'commentpress-core' ).'</a></li>'."\n";
  892. // --<
  893. return $link;
  894. }
  895. /**
  896. * @description: get an image wrapped in a link
  897. * @param: string $src location of image file
  898. * @param: string $url link target
  899. * @return string $tag
  900. * @todo:
  901. *
  902. */
  903. function get_linked_image( $src = '', $url = '' ) {
  904. // init html
  905. $html = '';
  906. // do we have an image?
  907. if ( $src != '' ) {
  908. // construct link
  909. $html .= '<img src="'.$src.'" />';
  910. }
  911. // do we have one?
  912. if ( $url != '' ) {
  913. // construct link around image
  914. $html .= '<a href="'.$url.'">'.$html.'</a>';
  915. }
  916. // --<
  917. return $html;
  918. }
  919. /**
  920. * @description: got the Wordpress admin page
  921. * @return string $admin_page
  922. * @todo:
  923. *
  924. */
  925. function get_admin_page() {
  926. // init
  927. $admin_page = '';
  928. // open div
  929. $admin_page .= '<div class="wrap" id="commentpress_admin_wrapper">'."\n\n";
  930. // get our form
  931. $admin_page .= $this->_get_admin_form();
  932. // close div
  933. $admin_page .= '</div>'."\n\n";
  934. // --<
  935. return $admin_page;
  936. }
  937. //##############################################################################
  938. /*
  939. ============================================================================
  940. PRIVATE METHODS
  941. ============================================================================
  942. */
  943. /*
  944. ----------------------------------------------------------------------------
  945. Object Initialisation
  946. ----------------------------------------------------------------------------
  947. */
  948. /**
  949. * @description: object initialisation
  950. * @todo:
  951. *
  952. */
  953. function _init() {
  954. // moved mobile checks to class_commentpress_db.php so it only loads as needed
  955. // and so that it loads *after* the old Commentpress loads it
  956. }
  957. /**
  958. * @description: returns the admin form HTML
  959. * @return string $admin_page
  960. * @todo: translation
  961. *
  962. */
  963. function _get_admin_form() {
  964. // sanitise admin page url
  965. $url = $_SERVER['REQUEST_URI'];
  966. $url_array = explode( '&', $url );
  967. if ( $url_array ) { $url = $url_array[0]; }
  968. // if we need to upgrade...
  969. if ( $this->db->check_upgrade() ) {
  970. // get upgrade options
  971. $upgrade = $this->_get_upgrade();
  972. // init text
  973. $options_text = '';
  974. // if there are options
  975. if ( $upgrade != '' ) {
  976. $options_text = __( ' The following options have become available in the new version.', 'commentpress-core' );
  977. }
  978. // define admin page
  979. $admin_page = '
  980. <div class="icon32" id="icon-options-general"><br/></div>
  981. <h2>'.__( 'CommentPress Core Upgrade', 'commentpress-core' ).'</h2>
  982. <form method="post" action="'.htmlentities($url.'&updated=true').'">
  983. '.wp_nonce_field( 'commentpress_admin_action', 'commentpress_nonce', true, false ).'
  984. '.wp_referer_field( false ).'
  985. <input id="cp_upgrade" name="cp_upgrade" value="1" type="hidden" />
  986. <h3>'.__( 'Please upgrade CommentPress Core', 'commentpress-core' ).'</h3>
  987. <p>'.__( 'It looks like you are running an older version of CommentPress Core.', 'commentpress-core' ).$options_text.'</p>
  988. <table class="form-table">
  989. '.$upgrade.'
  990. </table>
  991. '.
  992. '<input type="hidden" name="action" value="update" />
  993. <p class="submit">
  994. <input type="submit" name="commentpress_submit" value="'.__( 'Upgrade', 'commentpress-core' ).'" class="button-primary" />
  995. </p>
  996. </form>'."\n\n\n\n";
  997. } else {
  998. // define admin page
  999. $admin_page = '
  1000. <div class="icon32" id="icon-options-general"><br/></div>
  1001. <h2>'.__( 'CommentPress Core Settings', 'commentpress-core' ).'</h2>
  1002. <form method="post" action="'.htmlentities($url.'&updated=true').'">
  1003. '.wp_nonce_field( 'commentpress_admin_action', 'commentpress_nonce', true, false ).'
  1004. '.wp_referer_field( false ).'
  1005. '.
  1006. $this->_get_options().
  1007. '<input type="hidden" name="action" value="update" />
  1008. '.$this->_get_submit().'
  1009. </form>'."\n\n\n\n";
  1010. }
  1011. // --<
  1012. return $admin_page;
  1013. }
  1014. /**
  1015. * @description: returns the CommentPress Core options for the admin form
  1016. * @return string $options
  1017. * @todo:
  1018. *
  1019. */
  1020. function _get_options() {
  1021. // define CommentPress Core theme options
  1022. $options = '
  1023. <h3>'.__( 'Options for CommentPress Core', 'commentpress-core' ).'</h3>
  1024. <p>'.__( 'When the CommentPress Default Theme (or a valid CommentPress Child Theme) is active, the following options modify its behaviour.', 'commentpress-core' ).'</p>
  1025. <h4>'.__( 'Global Options', 'commentpress-core' ).'</h4>
  1026. <table class="form-table">
  1027. '.$this->_get_deactivate().'
  1028. '.$this->_get_reset().'
  1029. '.$this->_get_optional_options().'
  1030. </table>
  1031. <h4>'.__( 'Table of Contents', 'commentpress-core' ).'</h4>
  1032. <p>'.__( 'Choose how you want your Table of Contents to appear and function.<br />
  1033. <strong style="color: red;">NOTE!</strong> When Chapters are Pages, the TOC will always show Sub-Pages, since collapsing the TOC makes no sense in that situation.', 'commentpress-core' ).'</p>
  1034. <table class="form-table">
  1035. '.$this->_get_toc().'
  1036. </table>
  1037. <h4>'.__( 'Page Display Options', 'commentpress-core' ).'</h4>
  1038. <table class="form-table">
  1039. <tr valign="top">
  1040. <th scope="row"><label for="cp_title_visibility">'.__( 'Default page title visibility (can be overridden on individual pages)', 'commentpress-core' ).'</label></th>
  1041. <td><select id="cp_title_visibility" name="cp_title_visibility">
  1042. <option value="show" '.(($this->db->option_get('cp_title_visibility') == 'show') ? ' selected="selected"' : '').'>'.__( 'Show page titles', 'commentpress-core' ).'</option>
  1043. <option value="hide" '.(($this->db->option_get('cp_title_visibility') == 'hide') ? ' selected="selected"' : '').'>'.__( 'Hide page titles', 'commentpress-core' ).'</option>
  1044. </select>
  1045. </td>
  1046. </tr>
  1047. <tr valign="top">
  1048. <th scope="row"><label for="cp_page_meta_visibility">'.__( 'Default page meta visibility (can be overridden on individual pages)', 'commentpress-core' ).'</label></th>
  1049. <td><select id="cp_page_meta_visibility" name="cp_page_meta_visibility">
  1050. <option value="show" '.(($this->db->option_get('cp_page_meta_visibility') == 'show') ? ' selected="selected"' : '').'>'.__( 'Show page meta', 'commentpress-core' ).'</option>
  1051. <option value="hide" '.(($this->db->option_get('cp_page_meta_visibility') == 'hide') ? ' selected="selected"' : '').'>'.__( 'Hide page meta', 'commentpress-core' ).'</option>
  1052. </select>
  1053. </td>
  1054. </tr>
  1055. <tr valign="top">
  1056. <th scope="row"><label for="cp_excerpt_length">'.__( 'Blog excerpt length', 'commentpress-core' ).'</label></th>
  1057. <td><input type="text" id="cp_excerpt_length" name="cp_excerpt_length" value="'.$this->db->option_get('cp_excerpt_length').'" class="small-text" /> '.__( 'words', 'commentpress-core' ).'</td>
  1058. </tr>
  1059. </table>
  1060. <h4>'.__( 'Commenting Options', 'commentpress-core' ).'</h4>
  1061. <table class="form-table">
  1062. '.$this->_get_editor().'
  1063. '.$this->_get_override().'
  1064. </table>
  1065. <h4>'.__( 'Theme Customisation', 'commentpress-core' ).'</h4>
  1066. <p>'.__( 'You can set a custom background colour in <em>Appearance &#8594; Background</em>.<br />
  1067. You can also set a custom header image and header text colour in <em>Appearance &#8594; Header</em>.<br />
  1068. Below are extra options for changing how the theme looks.', 'commentpress-core' ).'</p>
  1069. <table class="form-table">
  1070. <tr valign="top" id="cp_header_bg_colour-row">
  1071. <th scope="row"><label for="cp_header_bg_colour">'.__( 'Header Background Colour', 'commentpress-core' ).'</label></th>
  1072. <td><input type="text" name="cp_header_bg_colour" id="cp_header_bg_colour" value="'.$this->db->option_get('cp_header_bg_colour').'" /><span class="description hide-if-js">'.__( 'If you want to hide header text, add <strong>#blank</strong> as text colour.', 'commentpress-core' ).'</span><input type="button" class="button hide-if-no-js" value="'.__( 'Select a Colour', 'commentpress-core' ).'" id="pickcolor" /><div id="color-picker" style="z-index: 100; background:#eee; border:1px solid #ccc; position:absolute; display:none;"></div></td>
  1073. </tr>
  1074. <tr valign="top">
  1075. <th scope="row"><label for="cp_js_scroll_speed">'.__( 'Scroll speed', 'commentpress-core' ).'</label></th>
  1076. <td><input type="text" id="cp_js_scroll_speed" name="cp_js_scroll_speed" value="'.$this->db->option_get('cp_js_scroll_speed').'" class="small-text" /> '.__( 'milliseconds', 'commentpress-core' ).'</td>
  1077. </tr>
  1078. <tr valign="top">
  1079. <th scope="row"><label for="cp_min_page_width">'.__( 'Minimum page width', 'commentpress-core' ).'</label></th>
  1080. <td><input type="text" id="cp_min_page_width" name="cp_min_page_width" value="'.$this->db->option_get('cp_min_page_width').'" class="small-text" /> '.__( 'pixels', 'commentpress-core' ).'</td>
  1081. </tr>
  1082. '.$this->_get_sidebar().'
  1083. </table>
  1084. ';
  1085. // --<
  1086. return $options;
  1087. }
  1088. /**
  1089. * @description: returns optional options, if defined
  1090. * @return string $html
  1091. * @todo:
  1092. *
  1093. */
  1094. function _get_optional_options() {
  1095. // init
  1096. $html = '';
  1097. // do we have the option to choose blog type (new in 3.3.1)?
  1098. if ( $this->db->option_exists( 'cp_blog_type' ) ) {
  1099. // define no types
  1100. $types = array();
  1101. // allow overrides
  1102. $types = apply_filters( 'cp_blog_type_options', $types );
  1103. // if we get some from a plugin, say...
  1104. if ( !empty( $types ) ) {
  1105. // define title
  1106. $type_title = __( 'Default Text Format', 'commentpress-core' );
  1107. // allow overrides
  1108. $type_title = apply_filters( 'cp_blog_type_label', $type_title );
  1109. // add extra message
  1110. $type_title .= __( ' (can be overridden on individual pages)', 'commentpress-core' );
  1111. // construct options
  1112. $type_option_list = array();
  1113. $n = 0;
  1114. // get existing
  1115. $blog_type = $this->db->option_get( 'cp_blog_type' );
  1116. foreach( $types AS $type ) {
  1117. if ( $n == $blog_type ) {
  1118. $type_option_list[] = '<option value="'.$n.'" selected="selected">'.$type.'</option>';
  1119. } else {
  1120. $type_option_list[] = '<option value="'.$n.'">'.$type.'</option>';
  1121. }
  1122. $n++;
  1123. }
  1124. $type_options = implode( "\n", $type_option_list );
  1125. // define upgrade
  1126. $html .= '
  1127. <tr valign="top">
  1128. <th scope="row"><label for="cp_blog_type">'.$type_title.'</label></th>
  1129. <td><select id="cp_blog_type" name="cp_blog_type">
  1130. '.$type_options.'
  1131. </select>
  1132. </td>
  1133. </tr>
  1134. ';
  1135. }
  1136. }
  1137. // do we have the option to choose blog workflow (new in 3.3.1)?
  1138. if ( $this->db->option_exists( 'cp_blog_workflow' ) ) {
  1139. // off by default
  1140. $has_workflow = false;
  1141. // allow overrides
  1142. $has_workflow = apply_filters( 'cp_blog_workflow_exists', $has_workflow );
  1143. // if we have workflow enabled, by a plugin, say...
  1144. if ( $has_workflow !== false ) {
  1145. // define label
  1146. $workflow_label = __( 'Enable Custom Workflow', 'commentpress-core' );
  1147. // define label
  1148. $workflow_label = apply_filters( 'cp_blog_workflow_label', $workflow_label );
  1149. // add extra message
  1150. $workflow_label .= ' (Not recommended because it is still very experimental)';
  1151. // define upgrade
  1152. $html .= '
  1153. <tr valign="top">
  1154. <th scope="row"><label for="cp_blog_workflow">'.$workflow_label.'</label></th>
  1155. <td><input id="cp_blog_workflow" name="cp_blog_workflow" value="1" type="checkbox" '.( $this->db->option_get('cp_blog_workflow') ? ' checked="checked"' : '' ).' /></td>
  1156. </tr>
  1157. ';
  1158. }
  1159. }
  1160. // --<
  1161. return $html;
  1162. }
  1163. /**
  1164. * @description: returns the upgrade details for the admin form
  1165. * @return string $upgrade
  1166. * @todo:
  1167. *
  1168. */
  1169. function _get_upgrade() {
  1170. // init
  1171. $upgrade = '';
  1172. // do we have the option to choose the default sidebar (new in 3.3.3)?
  1173. if ( !$this->db->option_exists( 'cp_sidebar_default' ) ) {
  1174. // define labels
  1175. $label = __( 'Which sidebar do you want to be active by default? (can be overridden on individual pages)', 'commentpress-core' );
  1176. $contents_label = __( 'Contents', 'commentpress-core' );
  1177. $activity_label = __( 'Activity', 'commentpress-core' );
  1178. $comments_label = __( 'Comments', 'commentpress-core' );
  1179. // define upgrade
  1180. $upgrade .= '
  1181. <tr valign="top">
  1182. <th scope="row"><label for="cp_sidebar_default">'.$label.'</label></th>
  1183. <td><select id="cp_sidebar_default" name="cp_sidebar_default">
  1184. <option value="toc">'.$contents_label.'</option>
  1185. <option value="activity">'.$activity_label.'</option>
  1186. <option value="comments" selected="selected">'.$comments_label.'</option>
  1187. </select>
  1188. </td>
  1189. </tr>
  1190. ';
  1191. }
  1192. // do we have the option to show or hide page meta (new in 3.3.2)?
  1193. if ( !$this->db->option_exists( 'cp_page_meta_visibility' ) ) {
  1194. $meta_label = __( 'Show or hide page meta by default', 'commentpress-core' );
  1195. $meta_show_label = __( 'Show page meta', 'commentpress-core' );
  1196. $meta_hide_label = __( 'Hide page meta', 'commentpress-core' );
  1197. // define upgrade
  1198. $upgrade .= '
  1199. <tr valign="top">
  1200. <th scope="row"><label for="cp_page_meta_visibility">'.$meta_label.'</label></th>
  1201. <td><select id="cp_page_meta_visibility" name="cp_page_meta_visibility">
  1202. <option value="show">'.$meta_show_label.'</option>
  1203. <option value="hide" selected="selected">'.$meta_hide_label.'</option>
  1204. </select>
  1205. </td>
  1206. </tr>
  1207. ';
  1208. }
  1209. // do we have the option to choose blog type (new in 3.3.1)?
  1210. if ( !$this->db->option_exists( 'cp_blog_type' ) ) {
  1211. // define no types
  1212. $types = array();
  1213. // allow overrides
  1214. $types = apply_filters( 'cp_blog_type_options', $types );
  1215. // if we get some from a plugin, say...
  1216. if ( !empty( $types ) ) {
  1217. // define title
  1218. $type_title = __( 'Blog Type', 'commentpress-core' );
  1219. // allow overrides
  1220. $type_title = apply_filters( 'cp_blog_type_label', $type_title );
  1221. // construct options
  1222. $type_option_list = array();
  1223. $n = 0;
  1224. foreach( $types AS $type ) {
  1225. $type_option_list[] = '<option value="'.$n.'">'.$type.'</option>';
  1226. $n++;
  1227. }
  1228. $type_options = implode( "\n", $type_option_list );
  1229. // define upgrade
  1230. $upgrade .= '
  1231. <tr valign="top">
  1232. <th scope="row"><label for="cp_blog_type">'.$type_title.'</label></th>
  1233. <td><select id="cp_blog_type" name="cp_blog_type">
  1234. '.$type_options.'
  1235. </select>
  1236. </td>
  1237. </tr>
  1238. ';
  1239. }
  1240. }
  1241. // do we have the option to choose blog workflow (new in 3.3.1)?
  1242. if ( !$this->db->option_exists( 'cp_blog_workflow' ) ) {
  1243. // off by default
  1244. $has_workflow = false;
  1245. // allow overrides
  1246. $has_workflow = apply_filters( 'cp_blog_workflow_exists', $has_workflow );
  1247. // if we have workflow enabled, by a plugin, say...
  1248. if ( $has_workflow !== false ) {
  1249. // define label
  1250. $workflow_label = __( 'Enable Custom Workflow', 'commentpress-core' );
  1251. // define label
  1252. $workflow_label = apply_filters( 'cp_blog_workflow_label', $workflow_label );
  1253. // define upgrade
  1254. $upgrade .= '
  1255. <tr valign="top">
  1256. <th scope="row"><label for="cp_blog_workflow">'.$workflow_label.'</label></th>
  1257. <td><input id="cp_reset" name="cp_blog_workflow" value="1" type="checkbox" /></td>
  1258. </tr>
  1259. ';
  1260. }
  1261. }
  1262. // do we have the option to choose the TOC layout (new in 3.3)?
  1263. if ( !$this->db->option_exists( 'cp_show_extended_toc' ) ) {
  1264. $extended_label = __( 'Appearance of TOC for posts', 'commentpress-core' );
  1265. $extended_info_label = __( 'Extended information', 'commentpress-core' );
  1266. $extended_title_label = __( 'Just the title', 'commentpress-core' );
  1267. // define upgrade
  1268. $upgrade .= '
  1269. <tr valign="top">
  1270. <th scope="row"><label for="cp_show_extended_toc">'.$extended_label.'</label></th>
  1271. <td><select id="cp_show_extended_toc" name="cp_show_extended_toc">
  1272. <option value="1">'.$extended_info_label.'</option>
  1273. <option value="0" selected="selected">'.$extended_title_label.'</option>
  1274. </select>
  1275. </td>
  1276. </tr>
  1277. ';
  1278. }
  1279. // do we have the option to set the comment editor?
  1280. if ( !$this->db->option_exists( 'cp_comment_editor' ) ) {
  1281. $editor_label = __( 'Comment form editor', 'commentpress-core' );
  1282. $rich_label = __( 'Rich-text Editor', 'commentpress-core' );
  1283. $plain_label = __( 'Plain-text Editor', 'commentpress-core' );
  1284. // define upgrade
  1285. $upgrade .= '
  1286. <tr valign="top">
  1287. <th scope="row"><label for="cp_comment_editor">'.$editor_label.'</label></th>
  1288. <td><select id="cp_comment_editor" name="cp_comment_editor">
  1289. <option value="1" selected="selected">'.$rich_label.'</option>
  1290. <option value="0">'.$plain_label.'</option>
  1291. </select>
  1292. </td>
  1293. </tr>
  1294. ';
  1295. }
  1296. // do we have the option to set the default behaviour?
  1297. if ( !$this->db->option_exists( 'cp_promote_reading' ) ) {
  1298. $behaviour_label = __( 'Default comment form behaviour', 'commentpress-core' );
  1299. $reading_label = __( 'Promote reading', 'commentpress-core' );
  1300. $commenting_label = __( 'Promote commenting', 'commentpress-core' );
  1301. // define upgrade
  1302. $upgrade .= '
  1303. <tr valign="top">
  1304. <th scope="row"><label for="cp_promote_reading">'.$behaviour_label.'</label></th>
  1305. <td><select id="cp_promote_reading" name="cp_promote_reading">
  1306. <option value="1">'.$reading_label.'</option>
  1307. <option value="0" selected="selected">'.$commenting_label.'</option>
  1308. </select>
  1309. </td>
  1310. </tr>
  1311. ';
  1312. }
  1313. // do we have the option to show or hide titles?
  1314. if ( !$this->db->option_exists( 'cp_title_visibility' ) ) {
  1315. // define labels
  1316. $titles_label = __( 'Show or hide page titles by default', 'commentpress-core' );
  1317. $titles_select_show = __( 'Show page titles', 'commentpress-core' );
  1318. $titles_select_hide = __( 'Hide page titles', 'commentpress-core' );
  1319. // define upgrade
  1320. $upgrade .= '
  1321. <tr valign="top">
  1322. <th scope="row"><label for="cp_title_visibility">'.$titles_label.'</label></th>
  1323. <td><select id="cp_title_visibility" name="cp_title_visibility">
  1324. <option value="show" selected="selected">'.$titles_select_show.'</option>
  1325. <option value="hide">'.$titles_select_hide.'</option>
  1326. </select>
  1327. </td>
  1328. </tr>
  1329. ';
  1330. }
  1331. // do we have the option to set the header bg colour?
  1332. if ( !$this->db->option_exists( 'cp_header_bg_colour' ) ) {
  1333. // define labels
  1334. $colour_label = __( 'Header Background Colour', 'commentpress-core' );
  1335. $colour_select_text = __( 'If you want to hide header text, add <strong>#blank</strong> as text colour.', 'commentpress-core' );
  1336. $colour_select_label = __( 'Select a Colour', 'commentpress-core' );
  1337. // define upgrade
  1338. $upgrade .= '
  1339. <tr valign="top" id="cp_header_bg_colour-row">
  1340. <th scope="row"><label for="cp_header_bg_colour">'.$colour_label.'</label></th>
  1341. <td><input type="text" name="cp_header_bg_colour" id="cp_header_bg_colour" value="'.$this->db->header_bg_colour.'" /><span class="description hide-if-js">'.$colour_select_text.'</span><input type="button" class="button hide-if-no-js" value="'.$colour_select_label.'" id="pickcolor" /><div id="color-picker" style="z-index: 100; background:#eee; border:1px solid #ccc; position:absolute; display:none;"></div></td>
  1342. </tr>
  1343. ';
  1344. }
  1345. // do we have the option to set the scroll speed?
  1346. if ( !$this->db->option_exists( 'cp_js_scroll_speed' ) ) {
  1347. // define labels
  1348. $scroll_label = __( 'Scroll speed', 'commentpress-core' );
  1349. $scroll_ms_label = __( 'milliseconds', 'commentpress-core' );
  1350. // define upgrade
  1351. $upgrade .= '
  1352. <tr valign="top">
  1353. <th scope="row"><label for="cp_js_scroll_speed">'.$scroll_label.'</label></th>
  1354. <td><input type="text" id="cp_js_scroll_speed" name="cp_js_scroll_speed" value="'.$this->db->js_scroll_speed.'" class="small-text" /> '.$scroll_ms_label.'</td>
  1355. </tr>
  1356. ';
  1357. }
  1358. // do we have the option to set the minimum page width?
  1359. if ( !$this->db->option_exists( 'cp_min_page_width' ) ) {
  1360. // define labels
  1361. $min_label = __( 'Minimum page width', 'commentpress-core' );
  1362. $min_pix_label = __( 'pixels', 'commentpress-core' );
  1363. // define upgrade
  1364. $upgrade .= '
  1365. <tr valign="top">
  1366. <th scope="row"><label for="cp_min_page_width"></label></th>
  1367. <td><input type="text" id="cp_min_page_width" name="cp_min_page_width" value="'.$this->db->min_page_width.'" class="small-text" /> '.$min_pix_label.'</td>
  1368. </tr>
  1369. ';
  1370. }
  1371. // --<
  1372. return $upgrade;
  1373. }
  1374. /**
  1375. * @description: returns the multisite deactivate button for the admin form
  1376. * @return string $html
  1377. * @todo:
  1378. *
  1379. */
  1380. function _get_deacti

Large files files are truncated, but you can click here to view the full file