Нема описа

portability.php 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /*******************************************************************************
  3. * Copyright (c) 2019, Code Atlantic LLC
  4. ******************************************************************************/
  5. /**
  6. * @param $name
  7. * @param null $settings
  8. * @param array $extra_meta
  9. *
  10. * @return int|\WP_Error
  11. */
  12. function pum_install_theme( $name, $settings = null, $extra_meta = array() ) {
  13. if ( ! isset( $settings ) ) {
  14. $settings = PUM_Admin_Themes::defaults();
  15. }
  16. $new_theme_id = @wp_insert_post( array(
  17. 'post_title' => $name,
  18. 'post_author' => get_current_user_id(),
  19. 'post_status' => 'publish',
  20. 'post_type' => 'popup_theme',
  21. 'comment_status' => 'closed',
  22. 'meta_input' => array_merge( (array) $extra_meta, array(
  23. 'popup_theme_settings' => $settings,
  24. ) ),
  25. ) );
  26. pum_reset_assets();
  27. return $new_theme_id;
  28. }
  29. /**
  30. * @param $hash
  31. *
  32. * @return mixed
  33. */
  34. function pum_import_theme_from_repo( $hash ) {
  35. $theme_data = array(
  36. 'name' => __( 'Imported Theme', 'popup-maker' ),
  37. 'settings' => PUM_Admin_Themes::defaults(),
  38. 'original_author' => 'Daniel',
  39. );
  40. return pum_install_theme( $theme_data['name'], $theme_data['settings'], array(
  41. '_pum_theme_repo_hash' => $hash,
  42. '_pum_theme_repo_author' => $theme_data['original_author'],
  43. ) );
  44. }
  45. /**
  46. * Installs a default theme and returns the new theme ID.
  47. *
  48. * @since 1.8.0
  49. *
  50. * @return int|\WP_Error
  51. */
  52. function pum_install_default_theme() {
  53. return pum_install_theme( __( 'Default Theme', 'popup-maker' ), null, array(
  54. '_pum_built_in' => 'default-theme',
  55. '_pum_default_theme' => true,
  56. 'popup_theme_data_version' => 3,
  57. ) );
  58. }