Bez popisu

deprecated.php 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480
  1. <?php
  2. /*******************************************************************************
  3. * Copyright (c) 2019, Code Atlantic LLC
  4. ******************************************************************************/
  5. if ( ! defined( 'ABSPATH' ) ) {
  6. exit; // Exit if accessed directly
  7. }
  8. /**
  9. * @deprecated 1.8.0 use pum_get_theme_generated_styles
  10. *
  11. * @param int $popup_theme_id
  12. *
  13. * @return array
  14. */
  15. function popmake_generate_theme_styles( $popup_theme_id = 0 ) {
  16. return pum_get_theme_generated_styles( $popup_theme_id );
  17. }
  18. /**
  19. * Get theme meta defaults from data model 1.
  20. *
  21. * @since 1.8.0
  22. *
  23. * @param null|string $group
  24. *
  25. * @return array|bool|mixed
  26. */
  27. function pum_get_theme_v1_meta_defaults() {
  28. }
  29. # TODO LEFT OFF HERE
  30. # REFACTOR v1 meta getter & defaults.
  31. # CONTINUE PURGING CODE.
  32. /**
  33. * Fetches theme meta group data from v1 data format.
  34. *
  35. * @deprecated 1.1.0
  36. * @since 1.8.0
  37. *
  38. * @param $group
  39. * @param null $popup_theme_id
  40. * @param null $key
  41. * @param null $default
  42. *
  43. * @return mixed
  44. */
  45. function pum_get_theme_v1_meta( $group, $popup_theme_id = null, $key = null, $default = null ) {
  46. if ( ! $popup_theme_id ) {
  47. $popup_theme_id = get_the_ID();
  48. }
  49. $post_meta = get_post_custom( $popup_theme_id );
  50. if ( ! is_array( $post_meta ) ) {
  51. $post_meta = array();
  52. }
  53. $default_check_key = 'popup_theme_defaults_set';
  54. if ( ! in_array( $group, array( 'overlay', 'close', 'display', 'targeting_condition' ) ) ) {
  55. $default_check_key = "popup_{$group}_defaults_set";
  56. }
  57. $group_values = array_key_exists( $default_check_key, $post_meta ) ? array() : apply_filters( "popmake_popup_theme_{$group}_defaults", array() );
  58. foreach ( $post_meta as $meta_key => $value ) {
  59. if ( strpos( $meta_key, "popup_theme_{$group}_" ) !== false ) {
  60. $new_key = str_replace( "popup_theme_{$group}_", '', $meta_key );
  61. if ( count( $value ) == 1 ) {
  62. $group_values[ $new_key ] = $value[0];
  63. } else {
  64. $group_values[ $new_key ] = $value;
  65. }
  66. }
  67. }
  68. if ( $key ) {
  69. $key = str_replace( '.', '_', $key );
  70. if ( ! isset( $group_values[ $key ] ) ) {
  71. $value = $default;
  72. } else {
  73. $value = $group_values[ $key ];
  74. }
  75. return apply_filters( "popmake_get_popup_theme_{$group}_$key", $value, $popup_theme_id );
  76. } else {
  77. return apply_filters( "popmake_get_popup_theme_{$group}", $group_values, $popup_theme_id );
  78. }
  79. }
  80. /**
  81. * Get theme meta defaults from data model 2.
  82. *
  83. * @since 1.8.0
  84. *
  85. * @param null|string $group
  86. *
  87. * @return array|bool|mixed
  88. */
  89. function pum_get_theme_v2_meta_defaults( $group = null ) {
  90. $defaults = array(
  91. 'overlay' => array(
  92. 'background_color' => '#ffffff',
  93. 'background_opacity' => 100,
  94. ),
  95. 'container' => array(
  96. 'padding' => 18,
  97. 'background_color' => '#f9f9f9',
  98. 'background_opacity' => 100,
  99. 'border_style' => 'none',
  100. 'border_color' => '#000000',
  101. 'border_width' => 1,
  102. 'border_radius' => 0,
  103. 'boxshadow_inset' => 'no',
  104. 'boxshadow_horizontal' => 1,
  105. 'boxshadow_vertical' => 1,
  106. 'boxshadow_blur' => 3,
  107. 'boxshadow_spread' => 0,
  108. 'boxshadow_color' => '#020202',
  109. 'boxshadow_opacity' => 23,
  110. ),
  111. 'title' => array(
  112. 'font_color' => '#000000',
  113. 'line_height' => 36,
  114. 'font_size' => 32,
  115. 'font_family' => 'inherit',
  116. 'font_weight' => 'inherit',
  117. 'font_style' => 'normal',
  118. 'text_align' => 'left',
  119. 'textshadow_horizontal' => 0,
  120. 'textshadow_vertical' => 0,
  121. 'textshadow_blur' => 0,
  122. 'textshadow_color' => '#020202',
  123. 'textshadow_opacity' => 23,
  124. ),
  125. 'content' => array(
  126. 'font_color' => '#8c8c8c',
  127. 'font_family' => 'inherit',
  128. 'font_weight' => 'inherit',
  129. 'font_style' => 'normal',
  130. ),
  131. 'close' => array(
  132. 'text' => __( 'CLOSE', 'popup-maker' ),
  133. 'location' => 'topright',
  134. 'position_top' => 0,
  135. 'position_left' => 0,
  136. 'position_bottom' => 0,
  137. 'position_right' => 0,
  138. 'padding' => 8,
  139. 'height' => 0,
  140. 'width' => 0,
  141. 'background_color' => '#00b7cd',
  142. 'background_opacity' => 100,
  143. 'font_color' => '#ffffff',
  144. 'line_height' => 14,
  145. 'font_size' => 12,
  146. 'font_family' => 'inherit',
  147. 'font_weight' => 'inherit',
  148. 'font_style' => 'normal',
  149. 'border_style' => 'none',
  150. 'border_color' => '#ffffff',
  151. 'border_width' => 1,
  152. 'border_radius' => 0,
  153. 'boxshadow_inset' => 'no',
  154. 'boxshadow_horizontal' => 0,
  155. 'boxshadow_vertical' => 0,
  156. 'boxshadow_blur' => 0,
  157. 'boxshadow_spread' => 0,
  158. 'boxshadow_color' => '#020202',
  159. 'boxshadow_opacity' => 23,
  160. 'textshadow_horizontal' => 0,
  161. 'textshadow_vertical' => 0,
  162. 'textshadow_blur' => 0,
  163. 'textshadow_color' => '#000000',
  164. 'textshadow_opacity' => 23,
  165. ),
  166. );
  167. // Here for backward compatibility with extensions.
  168. foreach ( $defaults as $key => $values ) {
  169. $defaults[ $key ] = apply_filters( "popmake_popup_theme_{$key}_defaults", $values );
  170. }
  171. return isset( $group ) ? ( isset( $defaults[ $group ] ) ? $defaults[ $group ] : false ) : $defaults;
  172. }
  173. /**
  174. * Fetch themes v2 meta as a single array.
  175. *
  176. * @param null|int $theme_id
  177. *
  178. * @return array|bool
  179. */
  180. function pum_get_theme_v2_meta( $theme_id = null ) {
  181. $theme = pum_get_theme( $theme_id );
  182. if ( ! pum_is_theme( $theme ) ) {
  183. return false;
  184. }
  185. $defaults = pum_get_theme_v2_meta_defaults();
  186. $values = array(
  187. 'overlay' => $theme->get_meta( 'popup_theme_overlay' ),
  188. 'container' => $theme->get_meta( 'popup_theme_container' ),
  189. 'title' => $theme->get_meta( 'popup_theme_title' ),
  190. 'content' => $theme->get_meta( 'popup_theme_content' ),
  191. 'close' => $theme->get_meta( 'popup_theme_close' ),
  192. );
  193. foreach ( array_keys( $values ) as $array_key ) {
  194. $values[ $array_key ] = wp_parse_args( $values[ $array_key ], $defaults[ $array_key ] );
  195. }
  196. return $values;
  197. }
  198. /**
  199. * Fetches theme meta group data from v2 data format.
  200. *
  201. * @deprecated 1.3.0
  202. * @since 1.8.0
  203. *
  204. * @param string $meta_group
  205. * @param null|int $theme_id
  206. * @param null|string $option_key
  207. * @param null|mixed $default
  208. *
  209. * @return mixed
  210. */
  211. function pum_get_theme_v2_meta_group( $meta_group, $theme_id = null, $option_key = null, $default = null ) {
  212. $theme_meta = pum_get_theme_v2_meta( $theme_id );
  213. if ( ! $theme_meta ) {
  214. return false;
  215. }
  216. $group_meta = ! empty( $theme_meta[ $meta_group ] ) ? $theme_meta[ $meta_group ] : false;
  217. if ( ! $group_meta ) {
  218. return $default;
  219. }
  220. if ( isset( $option_key ) ) {
  221. $value = isset( $group_meta[ $option_key ] ) ? $group_meta[ $option_key ] : $default;
  222. return apply_filters( "popmake_get_popup_theme_{$meta_group}_$option_key", $value, $theme_id );
  223. } else {
  224. return apply_filters( "popmake_get_popup_theme_{$meta_group}", $group_meta, $theme_id );
  225. }
  226. }
  227. /**
  228. * Returns the overlay meta of a theme.
  229. *
  230. * @since 1.0
  231. * @deprecated 1.8.0
  232. * @remove 2.0.0
  233. *
  234. * @param int $popup_theme_id ID number of the popup to retrieve a overlay meta for
  235. *
  236. * @param null $key
  237. * @param null $default
  238. *
  239. * @return mixed array|string of the popup overlay meta
  240. */
  241. function popmake_get_popup_theme_overlay( $popup_theme_id = null, $key = null, $default = null ) {
  242. return pum_get_theme_v2_meta_group( 'overlay', $popup_theme_id, $key, $default );
  243. }
  244. /**
  245. * Returns the container meta of a theme.
  246. *
  247. * @since 1.0
  248. * @deprecated 1.8.0
  249. * @remove 2.0.0
  250. *
  251. * @param int $popup_theme_id ID number of the popup to retrieve a container meta for
  252. *
  253. * @param null $key
  254. * @param null $default
  255. *
  256. * @return mixed array|string of the popup container meta
  257. */
  258. function popmake_get_popup_theme_container( $popup_theme_id = null, $key = null, $default = null ) {
  259. return pum_get_theme_v2_meta_group( 'container', $popup_theme_id, $key, $default );
  260. }
  261. /**
  262. * Returns the title meta of a theme.
  263. *
  264. * @since 1.0
  265. * @deprecated 1.8.0
  266. * @remove 2.0.0
  267. *
  268. * @param int $popup_theme_id ID number of the popup to retrieve a title meta for
  269. * @param null $key
  270. * @param null $default
  271. *
  272. * @return mixed array|string of the popup title meta
  273. */
  274. function popmake_get_popup_theme_title( $popup_theme_id = null, $key = null, $default = null ) {
  275. return pum_get_theme_v2_meta_group( 'title', $popup_theme_id, $key, $default );
  276. }
  277. /**
  278. * Returns the content meta of a theme.
  279. *
  280. * @since 1.0
  281. * @deprecated 1.8.0
  282. * @remove 2.0.0
  283. *
  284. * @param int $popup_theme_id ID number of the popup to retrieve a content meta for
  285. *
  286. * @param null $key
  287. * @param null $default
  288. *
  289. * @return mixed array|string of the popup content meta
  290. */
  291. function popmake_get_popup_theme_content( $popup_theme_id = null, $key = null, $default = null ) {
  292. return pum_get_theme_v2_meta_group( 'content', $popup_theme_id, $key, $default );
  293. }
  294. /**
  295. * Returns the close meta of a theme.
  296. *
  297. * @since 1.0
  298. * @deprecated 1.8.0
  299. * @remove 2.0.0
  300. *
  301. * @param int $popup_theme_id ID number of the popup to retrieve a close meta for
  302. *
  303. * @param null $key
  304. * @param null $default
  305. *
  306. * @return mixed array|string of the popup close meta
  307. */
  308. function popmake_get_popup_theme_close( $popup_theme_id = null, $key = null, $default = null ) {
  309. return pum_get_theme_v2_meta_group( 'close', $popup_theme_id, $key, $default );
  310. }
  311. /**\
  312. * @deprecated 1.8.0
  313. *
  314. * @param int $theme_id
  315. *
  316. * @return mixed
  317. */
  318. function popmake_get_popup_theme_data_attr( $theme_id = 0 ) {
  319. $data_attr = pum_get_theme_v2_meta( $theme_id );
  320. return apply_filters( 'popmake_get_popup_theme_data_attr', $data_attr, $theme_id );
  321. }
  322. /**
  323. * @deprecated 1.8.0 Do not use!
  324. * @remove 1.9.0
  325. *
  326. * @return mixed
  327. */
  328. function popmake_get_popup_themes_data() {
  329. $themes = pum_get_all_themes();
  330. $popmake_themes = array();
  331. foreach ( $themes as $theme ) {
  332. $popmake_themes[ $theme->ID ] = popmake_get_popup_theme_data_attr( $theme->ID );
  333. }
  334. wp_reset_postdata();
  335. return apply_filters( 'popmake_get_popup_themes_data', $popmake_themes );
  336. }
  337. /**
  338. * Returns the meta group of a theme or value if key is set.
  339. *
  340. * @since 1.0
  341. * @deprecated 1.3.0
  342. * @remove 2.0.0
  343. *
  344. * @param $group
  345. * @param int $popup_theme_id ID number of the popup to retrieve a overlay meta for
  346. * @param null $key
  347. * @param null $default
  348. *
  349. * @return mixed array|string of the popup overlay meta
  350. */
  351. function popmake_get_popup_theme_meta_group( $group, $popup_theme_id = null, $key = null, $default = null ) {
  352. return pum_get_theme_v1_meta( $group, $popup_theme_id, $key, $default );
  353. }
  354. /**
  355. * Fetches theme meta group data from v2 data format.
  356. *
  357. * @since 1.3.0
  358. * @deprecated 1.7.0
  359. * @remove 2.0.0
  360. *
  361. * @param $group
  362. * @param null $popup_theme_id
  363. * @param null $key
  364. * @param null $default
  365. *
  366. * @return mixed
  367. */
  368. function popmake_get_popup_theme_meta( $group, $popup_theme_id = null, $key = null, $default = null ) {
  369. return pum_get_theme_v2_meta_group( $group, $popup_theme_id, $key, $default );
  370. }
  371. /**
  372. * @deprecated 1.3.0
  373. * @remove 2.0.0
  374. *
  375. * @return array|bool|mixed
  376. */
  377. function popmake_popup_theme_overlay_defaults() {
  378. return pum_get_theme_v2_meta_defaults( 'overlay' );
  379. }
  380. /**
  381. * @deprecated 1.3.0
  382. * @remove 2.0.0
  383. *
  384. * @return array|bool|mixed
  385. */
  386. function popmake_popup_theme_container_defaults() {
  387. return pum_get_theme_v2_meta_defaults( 'container' );
  388. }
  389. /**
  390. * @deprecated 1.3.0
  391. * @remove 2.0.0
  392. *
  393. * @return array|bool|mixed
  394. */
  395. function popmake_popup_theme_title_defaults() {
  396. return pum_get_theme_v2_meta_defaults( 'title' );
  397. }
  398. /**
  399. * @deprecated 1.3.0
  400. * @remove 2.0.0
  401. *
  402. * @return array|bool|mixed
  403. */
  404. function popmake_popup_theme_content_defaults() {
  405. return pum_get_theme_v2_meta_defaults( 'content' );
  406. }
  407. /**
  408. * @deprecated 1.3.0
  409. * @remove 2.0.0
  410. *
  411. * @return array|bool|mixed
  412. */
  413. function popmake_popup_theme_close_defaults() {
  414. return pum_get_theme_v2_meta_defaults( 'close' );
  415. }
  416. /**
  417. * @deprecated 1.8.0
  418. *
  419. * @return \PUM_Model_Theme[]
  420. */
  421. function popmake_get_all_popup_themes() {
  422. return pum_get_all_themes();
  423. }
  424. /**
  425. * @deprecated 1.8.0
  426. *
  427. * @return false|int
  428. */
  429. function popmake_get_default_popup_theme() {
  430. return pum_get_default_theme_id();
  431. }