">2 years ago 16793 058f31828c first commit 2 years ago 16795 058f31828c first commit 2 years ago 16797 058f31828c first commit 2 years ago 16800 058f31828c first commit 2 years ago 16802 058f31828c first commit 2 years ago 16803 058f31828c first commit 2 years ago 16805 058f31828c first commit 2 years ago 16807 058f31828c first commit 2 years ago 16810 058f31828c first commit 2 years ago 16812 058f31828c first commit 2 years ago 16814 058f31828c first commit 2 years ago 16817 058f31828c first commit 2 years ago 16819 058f31828c first commit 2 years ago 16821 058f31828c first commit 2 years ago 16824 058f31828c first commit 2 years ago 16831 058f31828c first commit 2 years ago 16832 058f31828c first commit 2 years ago 16843 058f31828c first commit 2 years ago 16844 058f31828c first commit 2 years ago 16850 058f31828c first commit 2 years ago 16856 058f31828c first commit 2 years ago 16862 058f31828c first commit 2 years ago 16868 058f31828c first commit 2 years ago 16869 058f31828c first commit 2 years ago 16871 058f31828c first commit 2 years ago 16874 058f31828c first commit 2 years ago 16876 058f31828c first commit 2 years ago 16877 058f31828c first commit 2 years ago 16879 058f31828c first commit 2 years ago 16887 058f31828c first commit 2 years ago 16889 058f31828c first commit 2 years ago 16892 058f31828c first commit 2 years ago 16896 058f31828c first commit 2 years ago 16898 058f31828c first commit 2 years ago 16901 058f31828c first commit 2 years ago 16903 058f31828c first commit 2 years ago 16911 058f31828c first commit 2 years ago 16917 058f31828c first commit 2 years ago 16918 058f31828c first commit 2 years ago 16922 058f31828c first commit 2 years ago 16924 058f31828c first commit 2 years ago 16926 058f31828c first commit 2 years ago 16927 058f31828c first commit 2 years ago 16928 058f31828c first commit 2 years ago 16929 058f31828c first commit 2 years ago 16932 058f31828c first commit 2 years ago 16934 058f31828c first commit 2 years ago 16941 058f31828c first commit 2 years ago 16942 058f31828c first commit 2 years ago 16944 058f31828c first commit 2 years ago 16947 058f31828c first commit 2 years ago 16949 058f31828c first commit 2 years ago 16951 058f31828c first commit 2 years ago 16952 058f31828c first commit 2 years ago 16962 058f31828c first commit 2 years ago 16964 058f31828c first commit 2 years ago 16967 058f31828c first commit 2 years ago 16969 058f31828c first commit 2 years ago 16971 058f31828c first commit 2 years ago 16974 058f31828c first commit 2 years ago 16976 058f31828c first commit 2 years ago 16978 058f31828c first commit 2 years ago 16981 058f31828c first commit 2 years ago 16983 058f31828c first commit 2 years ago 16984 058f31828c first commit 2 years ago 16986 058f31828c first commit 2 years ago 16996 058f31828c first commit 2 years ago 17008 058f31828c first commit 2 years ago 17009 058f31828c first commit 2 years ago 17020 058f31828c first commit 2 years ago 17021 058f31828c first commit 2 years ago 17022 058f31828c first commit 2 years ago 17024 058f31828c first commit 2 years ago 17034 058f31828c first commit 2 years ago 17037 058f31828c first commit 2 years ago 17039 058f31828c first commit 2 years ago 17040 058f31828c first commit 2 years ago 17041 058f31828c first commit 2 years ago 17042 058f31828c first commit 2 years ago 174 058f31828c first commit 2 years ago 175 058f31828c first commit 2 years ago 2187 058f31828c first commit 2 years ago 2224 058f31828c first commit 2 years ago 2328 058f31828c first commit 2 years ago 2336 058f31828c first commit 2 years ago 2337 058f31828c first commit 2 years ago 2579 058f31828c first commit 2 years ago 2600 058f31828c first commit 2 years ago 2600_fsm 058f31828c first commit 2 years ago 2600_vm 058f31828c first commit 2 years ago 2601 058f31828c first commit 2 years ago 2601_fsm 058f31828c first commit 2 years ago 2601_vm 058f31828c first commit 2 years ago 2602 058f31828c first commit 2 years ago 2602_fsm 058f31828c first commit 2 years ago 2602_vm 058f31828c first commit 2 years ago 2603 058f31828c first commit 2 years ago 2603_fsm 058f31828c first commit 2 years ago 2603_vm 058f31828c first commit 2 years ago 2604 058f31828c first commit 2 years ago 2605 058f31828c first commit 2 years ago 2605_fsm 058f31828c first commit 2 years ago 2605_vm 058f31828c first commit 2 years ago 2606 058f31828c first commit 2 years ago 2606_fsm 058f31828c first commit 2 years ago 2606_vm 058f31828c first commit 2 years ago 2607 058f31828c first commit 2 years ago 2607_fsm 058f31828c first commit 2 years ago 2607_vm 058f31828c first commit 2 years ago 2608 058f31828c first commit 2 years ago 2608_fsm 058f31828c first commit 2 years ago 2608_vm 058f31828c first commit 2 years ago 2609 058f31828c first commit 2 years ago 2609_fsm 058f31828c first commit 2 years ago 2609_vm 058f31828c first commit 2 years ago 2610 058f31828c first commit 2 years ago 2610_fsm 058f31828c first commit 2 years ago 2610_vm 058f31828c first commit 2 years ago 2611 058f31828c first commit 2 years ago 2612 058f31828c first commit 2 years ago 2612_fsm 058f31828c first commit 2 years ago 2612_vm 058f31828c first commit 2 years ago 2613 058f31828c first commit 2 years ago 2615 058f31828c first commit 2 years ago 2615_fsm 058f31828c first commit 2 years ago 2615_vm 058f31828c first commit 2 years ago 2616 058f31828c first commit 2 years ago 2616_fsm 058f31828c first commit 2 years ago 2616_vm 058f31828c first commit 2 years ago 2617 058f31828c first commit 2 years ago 2617_fsm 058f31828c first commit 2 years ago 2617_vm 058f31828c first commit 2 years ago 2618 058f31828c first commit 2 years ago 2618_fsm 058f31828c first commit 2 years ago 2618_vm 058f31828c first commit 2 years ago 2619 058f31828c first commit 2 years ago 2619_fsm 058f31828c first commit 2 years ago 2619_vm 058f31828c first commit 2 years ago 2620 058f31828c first commit 2 years ago 2620_fsm 058f31828c first commit 2 years ago 2650 058f31828c first commit 2 years ago 2651 058f31828c first commit 2 years ago 2652 058f31828c first commit 2 years ago 2653 058f31828c first commit 2 years ago 2654 058f31828c first commit 2 years ago 2655 058f31828c first commit 2 years ago 2656 058f31828c first commit 2 years ago 2657 058f31828c first commit 2 years ago 2658 058f31828c first commit 2 years ago 2659 058f31828c first commit 2 years ago 2660 058f31828c first commit 2 years ago 2661 058f31828c first commit 2 years ago 2662 058f31828c first commit 2 years ago 2663 058f31828c first commit 2 years ago 2664 058f31828c first commit 2 years ago 2665 058f31828c first commit 2 years ago 2666 058f31828c first commit 2 years ago 2667 058f31828c first commit 2 years ago 2668 058f31828c first commit 2 years ago 2669 058f31828c first commit 2 years ago 2670 058f31828c first commit 2 years ago 2673 058f31828c first commit 2 years ago 2674 058f31828c first commit 2 years ago 2675 058f31828c first commit 2 years ago 2678 058f31828c first commit 2 years ago 2679 058f31828c first commit 2 years ago 2680 058f31828c first commit 2 years ago 2681 058f31828c first commit 2 years ago 2682 058f31828c first commit 2 years ago 2683 058f31828c first commit 2 years ago 2684 058f31828c first commit 2 years ago 2685 058f31828c first commit 2 years ago 2686 058f31828c first commit 2 years ago 2687 058f31828c first commit 2 years ago 2688 058f31828c first commit 2 years ago 2689 058f31828c first commit 2 years ago 2690 058f31828c first commit 2 years ago 2691 058f31828c first commit 2 years ago 2692 058f31828c first commit 2 years ago 2693 058f31828c first commit 2 years ago 2696 058f31828c first commit 2 years ago 2699 058f31828c first commit 2 years ago 2701 058f31828c first commit 2 years ago 2702 058f31828c first commit 2 years ago 2703 058f31828c first commit 2 years ago 2704 058f31828c first commit 2 years ago 2753 058f31828c first commit 2 years ago 2753_fsm 058f31828c first commit 2 years ago 2753_vm 058f31828c first commit 2 years ago 2754 058f31828c first commit 2 years ago 2755 058f31828c first commit 2 years ago 2756 058f31828c first commit 2 years ago 2757 058f31828c first commit 2 years ago 2830 058f31828c first commit 2 years ago 2831 058f31828c first commit 2 years ago 2832 058f31828c first commit 2 years ago 2833 058f31828c first commit 2 years ago 2834 058f31828c first commit 2 years ago 2835 058f31828c first commit 2 years ago 2836 058f31828c first commit 2 years ago 2837 058f31828c first commit 2 years ago 2838 058f31828c first commit 2 years ago 2838_fsm 058f31828c first commit 2 years ago 2838_vm 058f31828c first commit 2 years ago 2839 058f31828c first commit 2 years ago 2840 058f31828c first commit 2 years ago 2840_fsm 058f31828c first commit 2 years ago 2840_vm 058f31828c first commit 2 years ago 2841 058f31828c first commit 2 years ago 2995 058f31828c first commit 2 years ago 2996 058f31828c first commit 2 years ago 3079 058f31828c first commit 2 years ago 3079_fsm 058f31828c first commit 2 years ago 3079_vm 058f31828c first commit 2 years ago 3080 058f31828c first commit 2 years ago 3081 058f31828c first commit 2 years ago 3085 058f31828c first commit 2 years ago 3118 058f31828c first commit 2 years ago 3119 058f31828c first commit 2 years ago 3164 058f31828c first commit 2 years ago 3256 058f31828c first commit 2 years ago 3257 058f31828c first commit 2 years ago 3258 058f31828c first commit 2 years ago 3350 058f31828c first commit 2 years ago 3351 058f31828c first commit 2 years ago 3379 058f31828c first commit 2 years ago 3380 058f31828c first commit 2 years ago 3381 058f31828c first commit 2 years ago 3394 058f31828c first commit 2 years ago 3394_fsm 058f31828c first commit 2 years ago 3394_vm 058f31828c first commit 2 years ago 3395 058f31828c first commit 2 years ago 3429 058f31828c first commit 2 years ago 3430 058f31828c first commit 2 years ago 3431 058f31828c first commit 2 years ago 3433 058f31828c first commit 2 years ago 3439 058f31828c first commit 2 years ago 3440 058f31828c first commit 2 years ago 3455 058f31828c first commit 2 years ago 3456 058f31828c first commit 2 years ago 3456_fsm 058f31828c first commit 2 years ago 3456_vm 058f31828c first commit 2 years ago 3466 058f31828c first commit 2 years ago 3467 058f31828c first commit 2 years ago 3468 058f31828c first commit 2 years ago 3501 058f31828c first commit 2 years ago 3502 058f31828c first commit 2 years ago 3503 058f31828c first commit 2 years ago 3534 058f31828c first commit 2 years ago 3541 058f31828c first commit 2 years ago 3541_fsm 058f31828c first commit 2 years ago 3541_vm 058f31828c first commit 2 years ago 3542 058f31828c first commit 2 years ago 3574 058f31828c first commit 2 years ago 3575 058f31828c first commit 2 years ago 3576 058f31828c first commit 2 years ago 3596 058f31828c first commit 2 years ago 3597 058f31828c first commit 2 years ago 3598 058f31828c first commit 2 years ago 3599 058f31828c first commit 2 years ago 3600 058f31828c first commit 2 years ago 3600_fsm 058f31828c first commit 2 years ago 3600_vm 058f31828c first commit 2 years ago 3601 058f31828c first commit 2 years ago 3601_fsm 058f31828c first commit 2 years ago 3601_vm 058f31828c first commit 2 years ago 3602 058f31828c first commit 2 years ago 3602_fsm 058f31828c first commit 2 years ago 3602_vm 058f31828c first commit 2 years ago 3603 058f31828c first commit 2 years ago 3603_fsm 058f31828c first commit 2 years ago 3603_vm 058f31828c first commit 2 years ago 3604 058f31828c first commit 2 years ago 3605 058f31828c first commit 2 years ago 3606 058f31828c first commit 2 years ago 3607 058f31828c first commit 2 years ago 3608 058f31828c first commit 2 years ago 3609 058f31828c first commit 2 years ago 3712 058f31828c first commit 2 years ago 3764 058f31828c first commit 2 years ago 3764_fsm 058f31828c first commit 2 years ago 3764_vm 058f31828c first commit 2 years ago 3766 058f31828c first commit 2 years ago 3767 058f31828c first commit 2 years ago 3997 058f31828c first commit 2 years ago 4143 058f31828c first commit 2 years ago 4144 058f31828c first commit 2 years ago 4145 058f31828c first commit 2 years ago 4146 058f31828c first commit 2 years ago 4147 058f31828c first commit 2 years ago 4148 058f31828c first commit 2 years ago 4149 058f31828c first commit 2 years ago 4150 058f31828c first commit 2 years ago 4151 058f31828c first commit 2 years ago 4152 058f31828c first commit 2 years ago 4153 058f31828c first commit 2 years ago 4154 058f31828c first commit 2 years ago 4155 058f31828c first commit 2 years ago 4156 058f31828c first commit 2 years ago 4157 058f31828c first commit 2 years ago 4158 058f31828c first commit 2 years ago 4159 058f31828c first commit 2 years ago 4160 058f31828c first commit 2 years ago 4161 058f31828c first commit 2 years ago 4162 058f31828c first commit 2 years ago 4163 058f31828c first commit 2 years ago 4164 058f31828c first commit 2 years ago 4165 058f31828c first commit 2 years ago 4166 058f31828c first commit 2 years ago 4167 058f31828c first commit 2 years ago 4168 058f31828c first commit 2 years ago 4169 058f31828c first commit 2 years ago 4170 058f31828c first commit 2 years ago 4171 058f31828c first commit 2 years ago 4172 058f31828c first commit 2 years ago 4173 058f31828c first commit 2 years ago 4174 058f31828c first commit 2 years ago 5002 058f31828c first commit 2 years ago 548 058f31828c first commit 2 years ago 549 058f31828c first commit 2 years ago 6102 058f31828c first commit 2 years ago 6104 058f31828c first commit 2 years ago 6106 058f31828c first commit 2 years ago 6110 058f31828c first commit 2 years ago 6111 058f31828c first commit 2 years ago 6112 058f31828c first commit 2 years ago 6113 058f31828c first commit 2 years ago 6117 058f31828c first commit 2 years ago 826 058f31828c first commit 2 years ago 827 058f31828c first commit 2 years ago 828 058f31828c first commit 2 years ago PG_VERSION 058f31828c first commit 2 years ago pg_filenode.map 058f31828c first commit 2 years ago pg_internal.init 058f31828c first commit 2 years ago tum/whitesports - Gogs: Simplico Git Service

No Description

import.php 6.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. <?php
  2. /**
  3. * WordPress Administration Importer API.
  4. *
  5. * @package WordPress
  6. * @subpackage Administration
  7. */
  8. /**
  9. * Retrieve list of importers.
  10. *
  11. * @since 2.0.0
  12. *
  13. * @global array $wp_importers
  14. * @return array
  15. */
  16. function get_importers() {
  17. global $wp_importers;
  18. if ( is_array( $wp_importers ) ) {
  19. uasort( $wp_importers, '_usort_by_first_member' );
  20. }
  21. return $wp_importers;
  22. }
  23. /**
  24. * Sorts a multidimensional array by first member of each top level member
  25. *
  26. * Used by uasort() as a callback, should not be used directly.
  27. *
  28. * @since 2.9.0
  29. * @access private
  30. *
  31. * @param array $a
  32. * @param array $b
  33. * @return int
  34. */
  35. function _usort_by_first_member( $a, $b ) {
  36. return strnatcasecmp( $a[0], $b[0] );
  37. }
  38. /**
  39. * Register importer for WordPress.
  40. *
  41. * @since 2.0.0
  42. *
  43. * @global array $wp_importers
  44. *
  45. * @param string $id Importer tag. Used to uniquely identify importer.
  46. * @param string $name Importer name and title.
  47. * @param string $description Importer description.
  48. * @param callable $callback Callback to run.
  49. * @return void|WP_Error Void on success. WP_Error when $callback is WP_Error.
  50. */
  51. function register_importer( $id, $name, $description, $callback ) {
  52. global $wp_importers;
  53. if ( is_wp_error( $callback ) ) {
  54. return $callback;
  55. }
  56. $wp_importers[ $id ] = array( $name, $description, $callback );
  57. }
  58. /**
  59. * Cleanup importer.
  60. *
  61. * Removes attachment based on ID.
  62. *
  63. * @since 2.0.0
  64. *
  65. * @param string $id Importer ID.
  66. */
  67. function wp_import_cleanup( $id ) {
  68. wp_delete_attachment( $id );
  69. }
  70. /**
  71. * Handle importer uploading and add attachment.
  72. *
  73. * @since 2.0.0
  74. *
  75. * @return array Uploaded file's details on success, error message on failure
  76. */
  77. function wp_import_handle_upload() {
  78. if ( ! isset( $_FILES['import'] ) ) {
  79. return array(
  80. 'error' => sprintf(
  81. /* translators: 1: php.ini, 2: post_max_size, 3: upload_max_filesize */
  82. __( 'File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your %1$s file or by %2$s being defined as smaller than %3$s in %1$s.' ),
  83. 'php.ini',
  84. 'post_max_size',
  85. 'upload_max_filesize'
  86. ),
  87. );
  88. }
  89. $overrides = array(
  90. 'test_form' => false,
  91. 'test_type' => false,
  92. );
  93. $_FILES['import']['name'] .= '.txt';
  94. $upload = wp_handle_upload( $_FILES['import'], $overrides );
  95. if ( isset( $upload['error'] ) ) {
  96. return $upload;
  97. }
  98. // Construct the object array.
  99. $object = array(
  100. 'post_title' => wp_basename( $upload['file'] ),
  101. 'post_content' => $upload['url'],
  102. 'post_mime_type' => $upload['type'],
  103. 'guid' => $upload['url'],
  104. 'context' => 'import',
  105. 'post_status' => 'private',
  106. );
  107. // Save the data.
  108. $id = wp_insert_attachment( $object, $upload['file'] );
  109. /*
  110. * Schedule a cleanup for one day from now in case of failed
  111. * import or missing wp_import_cleanup() call.
  112. */
  113. wp_schedule_single_event( time() + DAY_IN_SECONDS, 'importer_scheduled_cleanup', array( $id ) );
  114. return array(
  115. 'file' => $upload['file'],
  116. 'id' => $id,
  117. );
  118. }
  119. /**
  120. * Returns a list from WordPress.org of popular importer plugins.
  121. *
  122. * @since 3.5.0
  123. *
  124. * @return array Importers with metadata for each.
  125. */
  126. function wp_get_popular_importers() {
  127. // Include an unmodified $wp_version.
  128. require ABSPATH . WPINC . '/version.php';
  129. $locale = get_user_locale();
  130. $cache_key = 'popular_importers_' . md5( $locale . $wp_version );
  131. $popular_importers = get_site_transient( $cache_key );
  132. if ( ! $popular_importers ) {
  133. $url = add_query_arg(
  134. array(
  135. 'locale' => $locale,
  136. 'version' => $wp_version,
  137. ),
  138. 'http://api.wordpress.org/core/importers/1.1/'
  139. );
  140. $options = array( 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ) );
  141. if ( wp_http_supports( array( 'ssl' ) ) ) {
  142. $url = set_url_scheme( $url, 'https' );
  143. }
  144. $response = wp_remote_get( $url, $options );
  145. $popular_importers = json_decode( wp_remote_retrieve_body( $response ), true );
  146. if ( is_array( $popular_importers ) ) {
  147. set_site_transient( $cache_key, $popular_importers, 2 * DAY_IN_SECONDS );
  148. } else {
  149. $popular_importers = false;
  150. }
  151. }
  152. if ( is_array( $popular_importers ) ) {
  153. // If the data was received as translated, return it as-is.
  154. if ( $popular_importers['translated'] ) {
  155. return $popular_importers['importers'];
  156. }
  157. foreach ( $popular_importers['importers'] as &$importer ) {
  158. // phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText
  159. $importer['description'] = translate( $importer['description'] );
  160. if ( 'WordPress' !== $importer['name'] ) {
  161. // phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText
  162. $importer['name'] = translate( $importer['name'] );
  163. }
  164. }
  165. return $popular_importers['importers'];
  166. }
  167. return array(
  168. // slug => name, description, plugin slug, and register_importer() slug.
  169. 'blogger' => array(
  170. 'name' => __( 'Blogger' ),
  171. 'description' => __( 'Import posts, comments, and users from a Blogger blog.' ),
  172. 'plugin-slug' => 'blogger-importer',
  173. 'importer-id' => 'blogger',
  174. ),
  175. 'wpcat2tag' => array(
  176. 'name' => __( 'Categories and Tags Converter' ),
  177. 'description' => __( 'Convert existing categories to tags or tags to categories, selectively.' ),
  178. 'plugin-slug' => 'wpcat2tag-importer',
  179. 'importer-id' => 'wp-cat2tag',
  180. ),
  181. 'livejournal' => array(
  182. 'name' => __( 'LiveJournal' ),
  183. 'description' => __( 'Import posts from LiveJournal using their API.' ),
  184. 'plugin-slug' => 'livejournal-importer',
  185. 'importer-id' => 'livejournal',
  186. ),
  187. 'movabletype' => array(
  188. 'name' => __( 'Movable Type and TypePad' ),
  189. 'description' => __( 'Import posts and comments from a Movable Type or TypePad blog.' ),
  190. 'plugin-slug' => 'movabletype-importer',
  191. 'importer-id' => 'mt',
  192. ),
  193. 'rss' => array(
  194. 'name' => __( 'RSS' ),
  195. 'description' => __( 'Import posts from an RSS feed.' ),
  196. 'plugin-slug' => 'rss-importer',
  197. 'importer-id' => 'rss',
  198. ),
  199. 'tumblr' => array(
  200. 'name' => __( 'Tumblr' ),
  201. 'description' => __( 'Import posts &amp; media from Tumblr using their API.' ),
  202. 'plugin-slug' => 'tumblr-importer',
  203. 'importer-id' => 'tumblr',
  204. ),
  205. 'wordpress' => array(
  206. 'name' => 'WordPress',
  207. 'description' => __( 'Import posts, pages, comments, custom fields, categories, and tags from a WordPress export file.' ),
  208. 'plugin-slug' => 'wordpress-importer',
  209. 'importer-id' => 'wordpress',
  210. ),
  211. );
  212. }