PageRenderTime 37ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 1ms

/wp-content/themes/mymaxiskirt/framework/php/wordpress-importer/avia-export-class.php

https://bitbucket.org/sanders_nick/my-maxi-skirt
PHP | 127 lines | 80 code | 27 blank | 20 comment | 16 complexity | a4184cd8e0da1ce7c7c107c54ae37623 MD5 | raw file
Possible License(s): GPL-2.0, BSD-3-Clause, AGPL-1.0, GPL-3.0, LGPL-2.1
  1. <?php if ( ! defined('AVIA_FW')) exit('No direct script access allowed');
  2. /**
  3. * This file holds the class that creates the options export file for the wordpress importer
  4. *
  5. *
  6. * @author Christian "Kriesi" Budschedl
  7. * @copyright Copyright (c) Christian Budschedl
  8. * @link http://kriesi.at
  9. * @link http://aviathemes.com
  10. * @since Version 1.1
  11. * @package AviaFramework
  12. */
  13. /**
  14. *
  15. */
  16. if( !class_exists( 'avia_wp_export' ) )
  17. {
  18. class avia_wp_export
  19. {
  20. function avia_wp_export($avia_superobject)
  21. {
  22. if(!isset($_GET['avia_export'])) return;
  23. $this->avia_superobject = $avia_superobject;
  24. $this->subpages = $avia_superobject->subpages;
  25. $this->options = $avia_superobject->options;
  26. $this->db_prefix = $avia_superobject->option_prefix;
  27. add_action('admin_init',array(&$this, 'initiate'),200);
  28. }
  29. function initiate()
  30. {
  31. //get the first subkey of the saved options array
  32. foreach($this->subpages as $subpage_key => $subpage)
  33. {
  34. $export[$subpage_key] = $this->export_array_generator($this->avia_superobject->option_page_data, $this->options[$subpage_key], $subpage);
  35. }
  36. //export of options
  37. $export = base64_encode(serialize($export));
  38. //export of dynamic pages
  39. $export_dynamic_pages = get_option($this->db_prefix.'_dynamic_pages');
  40. if($export_dynamic_pages) $export_dynamic_pages = base64_encode(serialize($export_dynamic_pages));
  41. //export of dynamic elements
  42. $export_dynamic_elements = get_option($this->db_prefix.'_dynamic_elements');
  43. if($export_dynamic_elements) $export_dynamic_elements = base64_encode(serialize($export_dynamic_elements));
  44. echo '<pre>&#60?php '."\n\n";
  45. echo '/*this is a base64 encoded option set for the default dummy data. If you choose to import the dummy.xml file with the help of the framework importer this options will also be imported*/'."\n\n";
  46. echo '$options = "';
  47. print_r($export);
  48. echo '";</pre>'."\n\n";
  49. echo '<pre>'."\n";
  50. echo '$dynamic_pages = "';
  51. print_r($export_dynamic_pages);
  52. echo '";</pre>';
  53. echo '<pre>'."\n";
  54. echo '$dynamic_elements = "';
  55. print_r($export_dynamic_elements);
  56. echo '";</pre>';
  57. exit();
  58. }
  59. function export_array_generator($elements, $options, $subpage, $grouped = false)
  60. {
  61. $export = array();
  62. //iterate over all option page elements
  63. foreach($elements as $element)
  64. {
  65. if((in_array($element['slug'], $subpage) || $grouped) && isset($element['id']) && isset($options[$element['id']]))
  66. {
  67. if($element['type'] != 'group')
  68. {
  69. if(isset($element['subtype']) && !is_array($element['subtype']))
  70. {
  71. //pass id-value and subtype
  72. $taxonomy = false;
  73. if(isset($element['taxonomy'])) $taxonomy = $element['taxonomy'];
  74. $value = avia_backend_get_post_page_cat_name_by_id($options[$element['id']] , $element['subtype'], $taxonomy);
  75. }
  76. else
  77. {
  78. $value = $options[$element['id']];
  79. }
  80. if(isset($value))
  81. {
  82. $element['std'] = $value;
  83. $export[$element['id']] = $element;
  84. }
  85. }
  86. else
  87. {
  88. $iterations = count($options[$element['id']]);
  89. $export[$element['id']] = $element;
  90. for($i = 0; $i < $iterations; $i++)
  91. {
  92. $export[$element['id']]['std'][$i] = $this->export_array_generator($element['subelements'], $options[$element['id']][$i], $subpage, true);
  93. }
  94. }
  95. }
  96. }
  97. return $export;
  98. }
  99. }
  100. }