html.php 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078
  1. <?php
  2. /**
  3. * Template functions.
  4. *
  5. * @package Pen
  6. */
  7. if ( ! function_exists( 'pen_html_logo' ) ) {
  8. /**
  9. * Displays the custom logo.
  10. *
  11. * Does nothing if the custom logo is not available.
  12. *
  13. * @since Pen 1.0.0
  14. * @return string
  15. */
  16. function pen_html_logo() {
  17. if ( function_exists( 'get_custom_logo' ) && pen_option_get( 'header_logo_display' ) ) {
  18. $logo = trim( get_custom_logo() );
  19. if ( $logo ) {
  20. return sprintf(
  21. '<div class="pen_logo %1$s">%2$s</div>',
  22. pen_class_animation( 'header_logo', false ),
  23. $logo
  24. );
  25. }
  26. }
  27. return '';
  28. }
  29. }
  30. if ( ! function_exists( 'pen_html_connect' ) ) {
  31. /**
  32. * Generates markup for the social network links.
  33. *
  34. * @param string $location The location of the social network links (for now it can be header or footer).
  35. *
  36. * @since Pen 1.0.0
  37. * @return string
  38. */
  39. function pen_html_connect( $location ) {
  40. ob_start( 'pen_compress_html' );
  41. $rss_display = pen_option_get( 'rss_' . $location . '_display' );
  42. $rss_url = pen_option_get( 'rss' );
  43. if ( $rss_url && $rss_display ) {
  44. $rss_url = explode( '|', $rss_url );
  45. foreach ( $rss_url as $rss_url ) {
  46. ?>
  47. <li class="pen_rss" title="<?php esc_attr_e( 'Subscribe the RSS', 'pen' ); ?>">
  48. <a href="<?php echo esc_url( $rss_url ); ?>">
  49. <span class="screen-reader-text">
  50. <?php
  51. esc_html_e( 'RSS', 'pen' );
  52. ?>
  53. </span>
  54. </a>
  55. </li>
  56. <?php
  57. }
  58. }
  59. $email_display = pen_option_get( 'email_' . $location . '_display' );
  60. $email = pen_option_get( 'email' );
  61. if ( $email && $email_display ) {
  62. $email = explode( '|', $email );
  63. foreach ( $email as $email ) {
  64. if ( false !== strpos( $email, '@' ) ) {
  65. $email = 'mailto:' . antispambot( $email );
  66. }
  67. ?>
  68. <li class="pen_email" title="<?php esc_attr_e( 'E-mail', 'pen' ); ?>">
  69. <a href="<?php echo esc_url( $email ); ?>">
  70. <span class="screen-reader-text">
  71. <?php
  72. esc_html_e( 'E-mail', 'pen' );
  73. ?>
  74. </span>
  75. </a>
  76. </li>
  77. <?php
  78. }
  79. }
  80. $facebook_display = pen_option_get( 'facebook_' . $location . '_display' );
  81. $facebook_url = pen_option_get( 'facebook' );
  82. if ( $facebook_url && $facebook_display ) {
  83. $facebook_url = explode( '|', $facebook_url );
  84. foreach ( $facebook_url as $facebook_url ) {
  85. ?>
  86. <li class="pen_facebook" title="<?php esc_attr_e( 'Facebook', 'pen' ); ?>">
  87. <a href="<?php echo esc_url( $facebook_url ); ?>">
  88. <span class="screen-reader-text">
  89. <?php
  90. esc_html_e( 'Facebook', 'pen' );
  91. ?>
  92. </span>
  93. </a>
  94. </li>
  95. <?php
  96. }
  97. }
  98. $instagram_display = pen_option_get( 'instagram_' . $location . '_display' );
  99. $instagram_url = pen_option_get( 'instagram' );
  100. if ( $instagram_url && $instagram_display ) {
  101. $instagram_url = explode( '|', $instagram_url );
  102. foreach ( $instagram_url as $instagram_url ) {
  103. ?>
  104. <li class="pen_instagram" title="<?php esc_attr_e( 'Instagram', 'pen' ); ?>">
  105. <a href="<?php echo esc_url( $instagram_url ); ?>">
  106. <span class="screen-reader-text">
  107. <?php
  108. esc_html_e( 'Instagram', 'pen' );
  109. ?>
  110. </span>
  111. </a>
  112. </li>
  113. <?php
  114. }
  115. }
  116. $vk_display = pen_option_get( 'vk_' . $location . '_display' );
  117. $vk_url = pen_option_get( 'vk' );
  118. if ( $vk_url && $vk_display ) {
  119. $vk_url = explode( '|', $vk_url );
  120. foreach ( $vk_url as $vk_url ) {
  121. ?>
  122. <li class="pen_vk" title="<?php esc_attr_e( 'VK', 'pen' ); ?>">
  123. <a href="<?php echo esc_url( $vk_url ); ?>">
  124. <span class="screen-reader-text">
  125. <?php
  126. esc_html_e( 'VK', 'pen' );
  127. ?>
  128. </span>
  129. </a>
  130. </li>
  131. <?php
  132. }
  133. }
  134. $pinterest_display = pen_option_get( 'pinterest_' . $location . '_display' );
  135. $pinterest_url = pen_option_get( 'pinterest' );
  136. if ( $pinterest_url && $pinterest_display ) {
  137. $pinterest_url = explode( '|', $pinterest_url );
  138. foreach ( $pinterest_url as $pinterest_url ) {
  139. ?>
  140. <li class="pen_pinterest" title="<?php esc_attr_e( 'Pinterest', 'pen' ); ?>">
  141. <a href="<?php echo esc_url( $pinterest_url ); ?>">
  142. <span class="screen-reader-text">
  143. <?php
  144. esc_html_e( 'Pinterest', 'pen' );
  145. ?>
  146. </span>
  147. </a>
  148. </li>
  149. <?php
  150. }
  151. }
  152. $twitter_display = pen_option_get( 'twitter_' . $location . '_display' );
  153. $twitter_url = pen_option_get( 'twitter' );
  154. if ( $twitter_url && $twitter_display ) {
  155. $twitter_url = explode( '|', $twitter_url );
  156. foreach ( $twitter_url as $twitter_url ) {
  157. ?>
  158. <li class="pen_twitter" title="<?php esc_attr_e( 'Twitter', 'pen' ); ?>">
  159. <a href="<?php echo esc_url( $twitter_url ); ?>">
  160. <span class="screen-reader-text">
  161. <?php
  162. esc_html_e( 'Twitter', 'pen' );
  163. ?>
  164. </span>
  165. </a>
  166. </li>
  167. <?php
  168. }
  169. }
  170. $linkedin_display = pen_option_get( 'linkedin_' . $location . '_display' );
  171. $linkedin_url = pen_option_get( 'linkedin' );
  172. if ( $linkedin_url && $linkedin_display ) {
  173. $linkedin_url = explode( '|', $linkedin_url );
  174. foreach ( $linkedin_url as $linkedin_url ) {
  175. ?>
  176. <li class="pen_linkedin" title="<?php esc_attr_e( 'LinkedIn', 'pen' ); ?>">
  177. <a href="<?php echo esc_url( $linkedin_url ); ?>">
  178. <span class="screen-reader-text">
  179. <?php
  180. esc_html_e( 'LinkedIn', 'pen' );
  181. ?>
  182. </span>
  183. </a>
  184. </li>
  185. <?php
  186. }
  187. }
  188. $bitbucket_display = pen_option_get( 'bitbucket_' . $location . '_display' );
  189. $bitbucket_url = pen_option_get( 'bitbucket' );
  190. if ( $bitbucket_url && $bitbucket_display ) {
  191. $bitbucket_url = explode( '|', $bitbucket_url );
  192. foreach ( $bitbucket_url as $bitbucket_url ) {
  193. ?>
  194. <li class="pen_bitbucket" title="<?php esc_attr_e( 'BitBucket', 'pen' ); ?>">
  195. <a href="<?php echo esc_url( $bitbucket_url ); ?>">
  196. <span class="screen-reader-text">
  197. <?php
  198. esc_html_e( 'BitBucket', 'pen' );
  199. ?>
  200. </span>
  201. </a>
  202. </li>
  203. <?php
  204. }
  205. }
  206. $flickr_display = pen_option_get( 'flickr_' . $location . '_display' );
  207. $flickr_url = pen_option_get( 'flickr' );
  208. if ( $flickr_url && $flickr_display ) {
  209. $flickr_url = explode( '|', $flickr_url );
  210. foreach ( $flickr_url as $flickr_url ) {
  211. ?>
  212. <li class="pen_flickr" title="<?php esc_attr_e( 'Flickr', 'pen' ); ?>">
  213. <a href="<?php echo esc_url( $flickr_url ); ?>">
  214. <span class="screen-reader-text">
  215. <?php
  216. esc_html_e( 'Flickr', 'pen' );
  217. ?>
  218. </span>
  219. </a>
  220. </li>
  221. <?php
  222. }
  223. }
  224. $github_display = pen_option_get( 'github_' . $location . '_display' );
  225. $github_url = pen_option_get( 'github' );
  226. if ( $github_url && $github_display ) {
  227. $github_url = explode( '|', $github_url );
  228. foreach ( $github_url as $github_url ) {
  229. ?>
  230. <li class="pen_github" title="<?php esc_attr_e( 'Github', 'pen' ); ?>">
  231. <a href="<?php echo esc_url( $github_url ); ?>">
  232. <span class="screen-reader-text">
  233. <?php
  234. esc_html_e( 'Github', 'pen' );
  235. ?>
  236. </span>
  237. </a>
  238. </li>
  239. <?php
  240. }
  241. }
  242. $telegram_display = pen_option_get( 'telegram_' . $location . '_display' );
  243. $telegram_url = pen_option_get( 'telegram' );
  244. if ( $telegram_url && $telegram_display ) {
  245. $telegram_url = explode( '|', $telegram_url );
  246. foreach ( $telegram_url as $telegram_url ) {
  247. ?>
  248. <li class="pen_telegram" title="<?php esc_attr_e( 'Telegram', 'pen' ); ?>">
  249. <a href="<?php echo esc_url( $telegram_url ); ?>">
  250. <span class="screen-reader-text">
  251. <?php
  252. esc_html_e( 'Telegram', 'pen' );
  253. ?>
  254. </span>
  255. </a>
  256. </li>
  257. <?php
  258. }
  259. }
  260. $whatsapp_display = pen_option_get( 'whatsapp_' . $location . '_display' );
  261. $whatsapp_url = pen_option_get( 'whatsapp' );
  262. if ( $whatsapp_url && $whatsapp_display ) {
  263. $whatsapp_url = explode( '|', $whatsapp_url );
  264. foreach ( $whatsapp_url as $whatsapp_url ) {
  265. ?>
  266. <li class="pen_whatsapp" title="<?php esc_attr_e( 'WhatsApp', 'pen' ); ?>">
  267. <a href="<?php echo esc_attr( $whatsapp_url ); ?>">
  268. <span class="screen-reader-text">
  269. <?php
  270. esc_html_e( 'WhatsApp', 'pen' );
  271. ?>
  272. </span>
  273. </a>
  274. </li>
  275. <?php
  276. }
  277. }
  278. $skype_display = pen_option_get( 'skype_' . $location . '_display' );
  279. $skype_url = pen_option_get( 'skype' );
  280. if ( $skype_url && $skype_display ) {
  281. $skype_url = explode( '|', $skype_url );
  282. foreach ( $skype_url as $skype_url ) {
  283. ?>
  284. <li class="pen_skype" title="<?php esc_attr_e( 'Skype', 'pen' ); ?>">
  285. <a href="<?php echo esc_attr( $skype_url ); ?>">
  286. <span class="screen-reader-text">
  287. <?php
  288. esc_html_e( 'Skype', 'pen' );
  289. ?>
  290. </span>
  291. </a>
  292. </li>
  293. <?php
  294. }
  295. }
  296. $slack_display = pen_option_get( 'slack_' . $location . '_display' );
  297. $slack_url = pen_option_get( 'slack' );
  298. if ( $slack_url && $slack_display ) {
  299. $slack_url = explode( '|', $slack_url );
  300. foreach ( $slack_url as $slack_url ) {
  301. ?>
  302. <li class="pen_slack" title="<?php esc_attr_e( 'Slack', 'pen' ); ?>">
  303. <a href="<?php echo esc_url( $slack_url ); ?>">
  304. <span class="screen-reader-text">
  305. <?php
  306. esc_html_e( 'Slack', 'pen' );
  307. ?>
  308. </span>
  309. </a>
  310. </li>
  311. <?php
  312. }
  313. }
  314. $output = ob_get_clean();
  315. if ( $output ) {
  316. return '<div class="pen_social_networks pen_animate_on_scroll pen_custom_animation_fadeIn"><ul>' . $output . '</ul></div><!-- .pen_social_networks -->';
  317. }
  318. return false;
  319. }
  320. }
  321. if ( ! function_exists( 'pen_html_search_box' ) ) {
  322. /**
  323. * Generates markup for the search box.
  324. *
  325. * @since Pen 1.0.0
  326. * @return string
  327. */
  328. function pen_html_search_box() {
  329. $search_display = get_post_meta( get_the_ID(), 'pen_content_search_display_override', true );
  330. if ( ! $search_display || 'default' === $search_display ) {
  331. $search_display = pen_option_get( 'search_display' );
  332. }
  333. if ( $search_display && 'no' !== $search_display ) {
  334. return trim( get_search_form( false ) );
  335. }
  336. return false;
  337. }
  338. }
  339. if ( ! function_exists( 'pen_html_navigation_fallback' ) ) {
  340. /**
  341. * Fallback navigation menu.
  342. *
  343. * @since Pen 1.0.8
  344. * @return void
  345. */
  346. function pen_html_navigation_fallback() {
  347. if ( current_user_can( 'edit_theme_options' ) ) {
  348. ?>
  349. <nav id="pen_navigation" class="<?php echo esc_attr( pen_class_navigation() ); ?>" role="navigation" title="<?php esc_html_e( 'This is a shortcut link for users with theme customization permission, invisible for the rest.', 'pen' ); ?>" aria-label="<?php esc_attr_e( 'Header Menu', 'pen' ); ?>">
  350. <div class="pen_container <?php pen_class_animation( 'navigation' ); /* phpcs:ignore */ ?>">
  351. <ul id="primary-menu" class="menu">
  352. <li class="pen_menu_create">
  353. <?php
  354. if ( is_customize_preview() ) {
  355. $url = '#';
  356. $attributes = ' class="pen_customizer_shortcut" data-type="panel" data-target="nav_menus"';
  357. } else {
  358. $url = esc_url( self_admin_url( 'nav-menus.php' ) );
  359. $attributes = '';
  360. }
  361. printf(
  362. '<a href="%1$s"%2$s>%3$s</a>',
  363. esc_attr( $url ),
  364. $attributes, /* phpcs:ignore */
  365. esc_html__( 'Create a menu?', 'pen' )
  366. );
  367. ?>
  368. </li>
  369. </ul>
  370. </div>
  371. <?php
  372. pen_html_jump_menu( 'navigation' );
  373. ?>
  374. </nav>
  375. <?php
  376. }
  377. }
  378. }
  379. if ( ! function_exists( 'pen_html_footer_menu_fallback' ) ) {
  380. /**
  381. * Fallback footer menu.
  382. *
  383. * @since Pen 1.0.8
  384. * @return void
  385. */
  386. function pen_html_footer_menu_fallback() {
  387. if ( current_user_can( 'edit_theme_options' ) ) {
  388. ?>
  389. <nav id="pen_footer_menu" role="navigation" class="<?php pen_class_animation( 'footer_menu' ); /* phpcs:ignore */ ?>" title="<?php esc_html_e( 'This is a shortcut link for users with theme customization permission, invisible for the rest.', 'pen' ); ?>" aria-label="<?php esc_attr_e( 'Footer Menu', 'pen' ); ?>">
  390. <ul id="secondary-menu" class="menu">
  391. <li class="pen_menu_create">
  392. <?php
  393. if ( is_customize_preview() ) {
  394. $url = '#';
  395. $attributes = ' class="pen_customizer_shortcut" data-type="panel" data-target="nav_menus"';
  396. } else {
  397. $url = esc_url( self_admin_url( 'nav-menus.php' ) );
  398. $attributes = '';
  399. }
  400. printf(
  401. '<a href="%1$s"%2$s>%3$s</a>',
  402. esc_attr( $url ),
  403. $attributes, /* phpcs:ignore */
  404. esc_html__( 'Create a menu?', 'pen' )
  405. );
  406. ?>
  407. </li>
  408. </ul>
  409. </nav>
  410. <?php
  411. }
  412. }
  413. }
  414. if ( ! function_exists( 'pen_html_content_information' ) ) {
  415. /**
  416. * Prints HTML with meta information for the current post-date/time and author.
  417. *
  418. * @param string $location The selected location for the element.
  419. *
  420. * @since Pen 1.0.0
  421. * @return string
  422. */
  423. function pen_html_content_information( $location ) {
  424. if ( 'post' !== get_post_type() ) {
  425. return;
  426. }
  427. if ( ! in_array( (string) $location, array( 'header', 'footer' ), true ) ) {
  428. $location = 'header';
  429. }
  430. $view = is_singular() ? 'content' : 'list';
  431. $post_id = get_the_ID();
  432. // Hide category for pages.
  433. $categories_list = '';
  434. $category_location = get_post_meta( $post_id, 'pen_' . $view . '_category_location_override', true );
  435. if ( ! $category_location || 'default' === $category_location ) {
  436. $category_location = pen_option_get( $view . '_category_location' );
  437. }
  438. if ( $location === $category_location || ( ! $category_location && 'header' === $location ) ) {
  439. /* Translators: used between list items, there is a space after the comma */
  440. $categories_list = get_the_category_list( '||' );
  441. if ( pen_option_get( 'pen_' . $view . '_category_only_first' ) && false !== strpos( $categories_list, '||' ) ) {
  442. $categories_list = explode( '||', $categories_list );
  443. $categories_list = $categories_list[0];
  444. }
  445. $categories_list = str_replace( '||', _x( ', ', 'Separates category links.', 'pen' ), $categories_list );
  446. if ( $categories_list ) {
  447. $categories_list = sprintf(
  448. '<span class="cat-links%1$s"><span class="screen-reader-text">%2$s</span>%3$s</span>',
  449. pen_class_lists( 'category_display_override' ),
  450. __( 'Categories:', 'pen' ),
  451. $categories_list
  452. ); /* phpcs:ignore */
  453. }
  454. }
  455. $posted_on = '';
  456. $date_location = get_post_meta( $post_id, 'pen_' . $view . '_date_location_override', true );
  457. if ( ! $date_location || 'default' === $date_location ) {
  458. $date_location = pen_option_get( $view . '_date_location' );
  459. }
  460. if ( $location === $date_location || ( ! $date_location && 'header' === $location ) ) {
  461. $time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
  462. if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
  463. $time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%4$s</time>';
  464. }
  465. $time_string = sprintf(
  466. $time_string,
  467. esc_attr( get_the_date( 'DATE_W3C' ) ),
  468. esc_html( get_the_date() ),
  469. esc_attr( get_the_modified_date( 'DATE_W3C' ) ),
  470. esc_html( get_the_modified_date() )
  471. );
  472. $posted_on = sprintf(
  473. /* Translators: %s: Post date. */
  474. esc_html_x( 'Posted on %s', 'post date', 'pen' ),
  475. '<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">' . $time_string . '</a>'
  476. );
  477. $posted_on = sprintf(
  478. '<span class="posted-on%1$s">%2$s</span>',
  479. pen_class_lists( 'date_display_override' ),
  480. $posted_on
  481. );
  482. }
  483. $byline = '';
  484. $author_location = get_post_meta( get_the_ID(), 'pen_' . $view . '_author_location_override', true );
  485. if ( ! $author_location || 'default' === $author_location ) {
  486. $author_location = pen_option_get( $view . '_author_location' );
  487. }
  488. if ( $location === $author_location || ( ! $author_location && 'header' === $location ) ) {
  489. $byline = sprintf(
  490. // Translators: %s: Post author's name.
  491. esc_html_x( 'by %s', 'post author', 'pen' ),
  492. '<span class="author vcard"><a class="url fn n" href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '">' . esc_html( get_the_author() ) . '</a></span>'
  493. );
  494. $byline = sprintf(
  495. '<span class="byline%1$s"> %2$s</span>',
  496. pen_class_lists( 'author_display_override' ),
  497. $byline
  498. );
  499. }
  500. $output = trim( $posted_on . $byline . $categories_list );
  501. $classes = trim(
  502. implode(
  503. ' ',
  504. array(
  505. 'entry-meta',
  506. is_singular() ? 'pen_animate_on_scroll pen_custom_animation_fadeIn' : '',
  507. )
  508. )
  509. );
  510. if ( '' !== trim( $output ) ) {
  511. return '<div class="' . $classes . '">' . $output . '</div>';
  512. }
  513. }
  514. }
  515. if ( ! function_exists( 'pen_html_author' ) ) {
  516. /**
  517. * Generates author profile.
  518. *
  519. * @param array $variables Profile parameteres.
  520. *
  521. * @since Pen 1.0.0
  522. * @return void
  523. */
  524. function pen_html_author( $variables = array() ) {
  525. $view = is_singular() ? 'content' : 'list';
  526. $display = get_post_meta( get_the_ID(), 'pen_' . $view . '_profile_display_override', true );
  527. if ( ! $display || 'default' === $display ) {
  528. $display = pen_option_get( $view . '_profile_display' );
  529. }
  530. if ( ! $display ) {
  531. return;
  532. }
  533. $avatar = get_avatar( get_the_author_meta( 'email' ), '90' );
  534. $user_url = get_the_author_meta( 'user_url' );
  535. $add_link = ( $user_url && ( ! isset( $variables['add_url'] ) || $variables['add_url'] ) ) ? true : false;
  536. $classes = trim(
  537. implode(
  538. ' ',
  539. array(
  540. 'pen_author_profile',
  541. pen_class_animation( ( is_singular() ? 'content' : 'list' ) . '_author', false ),
  542. $avatar ? 'pen_has_avatar' : '',
  543. )
  544. )
  545. );
  546. ?>
  547. <div class="<?php echo esc_attr( $classes ); ?>">
  548. <?php
  549. if ( $avatar && ( ! isset( $variables['add_avatar'] ) || $variables['add_avatar'] ) ) {
  550. ?>
  551. <div class="pen_author_avatar">
  552. <?php
  553. if ( $add_link ) {
  554. ?>
  555. <a href="<?php echo esc_url( $user_url ); ?>">
  556. <?php
  557. }
  558. echo $avatar; /* phpcs:ignore */
  559. if ( $add_link ) {
  560. ?>
  561. </a>
  562. <?php
  563. }
  564. ?>
  565. </div>
  566. <?php
  567. }
  568. $description = wp_kses( get_the_author_meta( 'description' ), wp_kses_allowed_html( 'post' ) );
  569. $classes = trim(
  570. implode(
  571. ' ',
  572. array(
  573. 'pen_author_about',
  574. ( ! $description ) ? 'pen_no_description' : '',
  575. )
  576. )
  577. );
  578. ?>
  579. <div class="<?php echo esc_attr( $classes ); ?>">
  580. <h3>
  581. <?php
  582. the_author_link();
  583. ?>
  584. </h3>
  585. <?php
  586. ob_start( 'trim' );
  587. if ( $user_url && ( ! isset( $variables['add_url'] ) || $variables['add_url'] ) ) {
  588. $site_name = wp_parse_url( $user_url );
  589. if ( isset( $site_name['host'] ) ) {
  590. $site_name = $site_name['host'];
  591. } else {
  592. $site_name = $user_url;
  593. }
  594. ?>
  595. <a href="<?php echo esc_url( $user_url ); ?>" class="pen_author_url">
  596. <?php
  597. echo esc_html( $site_name );
  598. ?>
  599. </a>
  600. <?php
  601. }
  602. if ( $description ) {
  603. ?>
  604. <p>
  605. <?php
  606. echo $description; /* phpcs:ignore */
  607. ?>
  608. </p>
  609. <?php
  610. }
  611. $about = ob_get_clean();
  612. if ( $about ) {
  613. ?>
  614. <div>
  615. <?php
  616. echo $about; /* phpcs:ignore */
  617. ?>
  618. </div>
  619. <?php
  620. }
  621. ?>
  622. </div>
  623. </div>
  624. <?php
  625. }
  626. }
  627. if ( ! function_exists( 'pen_html_share' ) ) {
  628. /**
  629. * Social sharing buttons.
  630. *
  631. * @global $post
  632. * @param string $location The selected location.
  633. *
  634. * @since Pen 1.0.0
  635. * @return string
  636. */
  637. function pen_html_share( $location ) {
  638. ob_start( 'pen_compress_html' );
  639. if ( ! is_singular() ) {
  640. return;
  641. }
  642. if ( ! in_array( (string) $location, array( 'header', 'content', 'footer' ), true ) ) {
  643. $location = 'header';
  644. }
  645. $share_location = get_post_meta( get_the_ID(), 'pen_content_share_location_override', true );
  646. if ( ! $share_location || 'default' === $share_location ) {
  647. $share_location = pen_option_get( 'content_share_location' );
  648. }
  649. if ( $share_location !== $location ) {
  650. return;
  651. }
  652. $display = get_post_meta( get_the_ID(), 'pen_content_share_display_override', true );
  653. if ( ! $display || 'default' === $display ) {
  654. $display = pen_option_get( 'content_share_display' );
  655. }
  656. if ( ! $display || 'no' === $display ) {
  657. return;
  658. }
  659. global $post;
  660. $url = rawurlencode( esc_url( get_permalink( $post->ID ) ) );
  661. $title = rawurlencode( $post->post_title );
  662. $facebook_url = sprintf( 'https://www.facebook.com/sharer/sharer.php?u=%1$s', $url );
  663. $twitter_url = sprintf( 'https://twitter.com/intent/tweet?text=%2$s&url=%1$s', $url, $title );
  664. ?>
  665. <div class="pen_share">
  666. <h4>
  667. <?php
  668. esc_html_e( 'Share this!', 'pen' );
  669. ?>
  670. </h4>
  671. <ul>
  672. <li class="pen_facebook">
  673. <a href="<?php echo esc_url( $facebook_url ); ?>" title="<?php esc_attr_e( 'Share on Facebook', 'pen' ); ?>" target="_blank" class="pen_button pen_button_share">
  674. <span>
  675. <?php
  676. esc_html_e( 'Facebook', 'pen' );
  677. ?>
  678. </span>
  679. </a>
  680. </li>
  681. <li class="pen_twitter">
  682. <a href="<?php echo esc_url( $twitter_url ); ?>" title="<?php esc_attr_e( 'Share on Twitter', 'pen' ); ?>" target="_blank" class="pen_button pen_button_share">
  683. <span>
  684. <?php
  685. esc_html_e( 'Twitter', 'pen' );
  686. ?>
  687. </span>
  688. </a>
  689. </li>
  690. </ul>
  691. </div><!-- .pen_share -->
  692. <?php
  693. return ob_get_clean();
  694. }
  695. }
  696. if ( ! function_exists( 'pen_html_configuration_overview' ) ) {
  697. /**
  698. * Displays an overview of the post meta settings.
  699. *
  700. * @param integer $post_id The post ID.
  701. * @since Pen 1.0.0
  702. * @return string
  703. */
  704. function pen_html_configuration_overview( $post_id = false ) {
  705. if ( ! current_user_can( 'edit_posts' ) ) {
  706. return;
  707. }
  708. if ( ! $post_id ) {
  709. $post_id = get_the_ID();
  710. }
  711. ob_start( 'pen_compress_html' );
  712. $overview_list = array();
  713. $overview_content = array();
  714. $overview_sidebars = array();
  715. $customize_display = false;
  716. $edit_post_display = false;
  717. $options_list = pen_post_meta_options( 'list' );
  718. foreach ( $options_list as $option => $label ) {
  719. $value = get_post_meta( $post_id, $option, true );
  720. if ( $value && 'default' !== $value ) {
  721. $edit_post_display = true;
  722. $overview_list[ $option ] = array(
  723. 'status' => ( 'no' === $value ) ? 'disabled' : 'enabled',
  724. 'label' => $label,
  725. 'value' => $value,
  726. 'help' => __( 'You can change this by editing this post.', 'pen' ),
  727. );
  728. }
  729. }
  730. $options_content = pen_post_meta_options( 'content' );
  731. foreach ( $options_content as $option => $label ) {
  732. $value = get_post_meta( $post_id, $option, true );
  733. if ( $value && 'default' !== $value ) {
  734. $edit_post_display = true;
  735. $overview_content[ $option ] = array(
  736. 'status' => ( 'no' === $value ) ? 'disabled' : 'enabled',
  737. 'label' => $label,
  738. 'value' => $value,
  739. 'help' => __( 'You can change this by editing this post.', 'pen' ),
  740. );
  741. }
  742. }
  743. $options_sidebars = pen_post_meta_options( 'sidebar' );
  744. foreach ( $options_sidebars as $sidebar => $name ) {
  745. if ( ( is_home() || is_front_page() ) && is_singular() ) {
  746. if ( pen_option_get( str_replace( 'pen_', 'pen_front_', $sidebar ) ) ) {
  747. $customize_display = true;
  748. $overview_sidebars[ $sidebar ] = array(
  749. 'status' => 'disabled',
  750. 'label' => sprintf(
  751. /* Translators: %s: Sidebar name. */
  752. esc_html__( '%s if on home:', 'pen' ),
  753. $name
  754. ),
  755. 'value' => __( 'Hidden', 'pen' ),
  756. 'help' => __( 'You can change this through Appearance &rarr; Customize &rarr; Front page &rarr; Sidebars.', 'pen' ),
  757. );
  758. }
  759. }
  760. if ( get_post_meta( $post_id, $sidebar, true ) ) {
  761. $edit_post_display = true;
  762. $overview_sidebars[ $sidebar ] = array(
  763. 'status' => 'disabled',
  764. 'label' => sprintf(
  765. /* Translators: %s: Sidebar name. */
  766. __( '%s:', 'pen' ),
  767. ucfirst( str_replace( array( 'pen_sidebar_', '_display', '_' ), array( '', '', ' ' ), $sidebar ) )
  768. ),
  769. 'value' => __( 'Hidden', 'pen' ),
  770. 'help' => __( 'You can change this by editing this post.', 'pen' ),
  771. );
  772. }
  773. }
  774. if ( empty( $overview_list ) && empty( $overview_content ) && empty( $overview_sidebars ) ) {
  775. ob_end_clean();
  776. return;
  777. }
  778. ?>
  779. <div class="pen_options_overview" id="pen_post_overview_<?php echo esc_attr( $post_id ); ?>">
  780. <h3>
  781. <?php
  782. esc_html_e( 'Content settings', 'pen' );
  783. ?>
  784. </h3>
  785. <table>
  786. <?php
  787. if ( ! empty( $overview_list ) ) {
  788. ?>
  789. <tr>
  790. <th scope="col" colspan="2">
  791. <?php
  792. esc_html_e( 'List views', 'pen' );
  793. ?>
  794. </th>
  795. </tr>
  796. <?php
  797. foreach ( $overview_list as $item ) {
  798. ?>
  799. <tr class="pen_option_<?php echo esc_attr( $item['status'] ); ?>" title="<?php echo esc_attr( $item['help'] ); ?>">
  800. <?php
  801. $value = $item['value'];
  802. if ( '#000000' === $value ) {
  803. $value = __( 'Dark', 'pen' );
  804. } elseif ( '#ffffff' === $value ) {
  805. $value = __( 'Light', 'pen' );
  806. }
  807. ?>
  808. <td class="pen_overview_item">
  809. <?php
  810. echo esc_html( $item['label'] );
  811. ?>
  812. </td>
  813. <td class="pen_overview_value">
  814. <?php
  815. echo esc_html( $value );
  816. ?>
  817. </td>
  818. </tr>
  819. <?php
  820. }
  821. }
  822. if ( $overview_content || $overview_sidebars ) {
  823. ?>
  824. <tr>
  825. <th scope="col" colspan="2">
  826. <?php
  827. esc_html_e( 'Full content view', 'pen' );
  828. ?>
  829. </th>
  830. </tr>
  831. <?php
  832. foreach ( $overview_content as $item ) {
  833. ?>
  834. <tr class="pen_option_<?php echo esc_attr( $item['status'] ); ?>" title="<?php echo esc_attr( $item['help'] ); ?>">
  835. <?php
  836. $value = $item['value'];
  837. if ( '#000000' === $value ) {
  838. $value = __( 'Dark', 'pen' );
  839. } elseif ( '#ffffff' === $value ) {
  840. $value = __( 'Light', 'pen' );
  841. }
  842. ?>
  843. <td class="pen_overview_item">
  844. <?php
  845. echo esc_html( $item['label'] );
  846. ?>
  847. </td>
  848. <td class="pen_overview_value">
  849. <?php
  850. echo esc_html( $value );
  851. ?>
  852. </td>
  853. </tr>
  854. <?php
  855. }
  856. }
  857. foreach ( $overview_sidebars as $item ) {
  858. ?>
  859. <tr class="pen_option_<?php echo esc_attr( $item['status'] ); ?>" title="<?php echo esc_attr( $item['help'] ); ?>">
  860. <td class="pen_overview_item">
  861. <?php
  862. echo esc_html(
  863. sprintf(
  864. /* Translators: %s: sidebar name. */
  865. __( '"%s" Area', 'pen' ),
  866. esc_html( $item['label'] )
  867. )
  868. );
  869. ?>
  870. </td>
  871. <td class="pen_overview_value">
  872. <?php
  873. echo esc_html( $item['value'] );
  874. ?>
  875. </td>
  876. </tr>
  877. <?php
  878. }
  879. ?>
  880. </table>
  881. <?php
  882. if ( $edit_post_display ) {
  883. ?>
  884. <a href="<?php echo esc_url( get_edit_post_link( get_the_ID() ) ); ?>" class="pen_button">
  885. <?php
  886. echo esc_html(
  887. sprintf(
  888. /* Translators: %s: content type, such as "Page", or "Post". */
  889. __( 'Edit this %s', 'pen' ),
  890. get_post_type()
  891. )
  892. );
  893. ?>
  894. </a>
  895. <?php
  896. }
  897. if ( $customize_display ) {
  898. ?>
  899. <a href="<?php echo add_query_arg( 'url', rawurlencode( pen_filter_input( 'SERVER', 'REQUEST_URI' ) ), wp_customize_url() ); /* phpcs:ignore */ ?>" class="pen_button">
  900. <?php
  901. esc_html_e( 'Edit defaults', 'pen' );
  902. ?>
  903. </a>
  904. <?php
  905. }
  906. ?>
  907. </div>
  908. <?php
  909. return ob_get_clean();
  910. }
  911. }
  912. if ( ! function_exists( 'pen_html_jump_menu' ) ) {
  913. /**
  914. * Jump menus for easier access to various parts of the backend.
  915. *
  916. * @param string $element Layout section or template part.
  917. *
  918. * @since Pen 1.0.8
  919. * @return void
  920. */
  921. function pen_html_jump_menu( $element ) {
  922. if ( ! current_user_can( 'edit_theme_options' ) ) {
  923. return;
  924. }
  925. $menu = pen_jump_menu( $element );
  926. // This menu has to be hidden when JavaScript is disabled (too many links) unless it's a screen-reader.
  927. ?>
  928. <div id="pen_jump_menu_<?php echo esc_attr( $element ); ?>" class="pen_jump_menu clearfix screen-reader-text">
  929. <div class="pen_menu_wrapper clearfix screen-reader-text">
  930. <h4>
  931. <?php
  932. printf(
  933. wp_kses(
  934. /* Translators: %s: layout section name, like Footer, Header, etc. */
  935. __( 'Customize <span>%s</span>', 'pen' ),
  936. wp_kses_allowed_html( 'post' )
  937. ),
  938. esc_html( $menu['name'] )
  939. );
  940. ?>
  941. </h4>
  942. <ul>
  943. <?php
  944. foreach ( $menu['items'] as $target => $label ) {
  945. ?>
  946. <li>
  947. <?php
  948. if ( filter_var( $target, FILTER_VALIDATE_URL ) ) {
  949. $url = esc_url( $target );
  950. printf(
  951. '<a href="%1$s">%2$s</a>',
  952. esc_attr( $url ), // No need to esc_url.
  953. wp_kses( $label, wp_kses_allowed_html( 'post' ) )
  954. );
  955. } else {
  956. $url = pen_url_customizer( $target );
  957. list( $container_type, $container_name ) = explode( ',', $target );
  958. $generic = array(
  959. 'background_image',
  960. 'header_image',
  961. 'nav_menus',
  962. 'title_tagline',
  963. 'widgets',
  964. );
  965. if ( ! in_array( $container_name, $generic, true ) && false === strpos( $container_name, 'sidebar-widgets-' ) ) {
  966. $container_name = 'pen_' . $container_type . '_' . $container_name;
  967. }
  968. printf(
  969. '<a href="%1$s" class="pen_customizer_shortcut"%2$s>%3$s</a>',
  970. esc_attr( $url ), // No need to esc_url.
  971. sprintf(
  972. ' data-type="%1$s" data-target="%2$s"',
  973. esc_attr( $container_type ),
  974. esc_attr( $container_name )
  975. ),
  976. wp_kses( $label, wp_kses_allowed_html( 'post' ) )
  977. );
  978. }
  979. ?>
  980. </li>
  981. <?php
  982. }
  983. ?>
  984. </ul>
  985. </div>
  986. </div>
  987. <?php
  988. }
  989. }
  990. if ( ! function_exists( 'pen_html_pagination_content' ) ) {
  991. /**
  992. * Inline content pagination.
  993. *
  994. * @since Pen 1.4.3
  995. * @return void
  996. */
  997. function pen_html_pagination_content() {
  998. ob_start( 'pen_compress_html' );
  999. if ( function_exists( 'wp_pagenavi' ) ) {
  1000. wp_pagenavi(
  1001. array(
  1002. 'type' => 'multipart',
  1003. )
  1004. );
  1005. } else {
  1006. wp_link_pages(
  1007. array(
  1008. 'before' => sprintf(
  1009. '<div class="page-links %1$s"><span class="screen-reader-text">%2$s</span>',
  1010. pen_class_animation( 'content_pager', false ),
  1011. esc_html__( 'Pages:', 'pen' )
  1012. ),
  1013. 'after' => '</div>',
  1014. 'next_or_number' => 'next',
  1015. )
  1016. );
  1017. }
  1018. $pagination = ob_get_clean();
  1019. if ( $pagination ) {
  1020. printf(
  1021. '<div class="pen_content_pagination">%s</div>',
  1022. $pagination /* phpcs:ignore */
  1023. );
  1024. }
  1025. }
  1026. }