" class="ui sha label" href="/tum/whitesports/commit/d01d7cf85d91a5a348d3c2b81cc93097ca7ba935">d01d7cf85d first commit 4 yıl önce woocommerce-th-a65b4ddf263e8c410e9bcbfd6e6d72e4.json d01d7cf85d first commit 4 yıl önce woocommerce-th-a8b73b087444470c8f4396b7142908f6.json d01d7cf85d first commit 4 yıl önce woocommerce-th-abb904b047b7be3be9d638e2c6144691.json d01d7cf85d first commit 4 yıl önce woocommerce-th-ae1c49c8c0597593a9c36e106a04bd60.json d01d7cf85d first commit 4 yıl önce woocommerce-th-aed4ce3ede1d44a8fecfe0edfbf8421c.json d01d7cf85d first commit 4 yıl önce woocommerce-th-af52ab8cb2e7713cf3037751dd593965.json d01d7cf85d first commit 4 yıl önce woocommerce-th-afbede9cda22f594a80ae8b178e0e98c.json d01d7cf85d first commit 4 yıl önce woocommerce-th-afd1e270efc2e8283acfd50ccab18d2b.json d01d7cf85d first commit 4 yıl önce woocommerce-th-b007baff76144318d6c33cd26f4bfdb9.json d01d7cf85d first commit 4 yıl önce woocommerce-th-b0a592b6fe83588c5d1b8ed6850b6a74.json d01d7cf85d first commit 4 yıl önce woocommerce-th-b155b7bf28890099b74a84417cbaafe9.json d01d7cf85d first commit 4 yıl önce woocommerce-th-b1bb8fbd24d68a9c893faf1a6f7b493b.json d01d7cf85d first commit 4 yıl önce woocommerce-th-b1bcbab1d6a7ca6b0433d67776f347f1.json d01d7cf85d first commit 4 yıl önce woocommerce-th-b239ff15197a133498a4b025f002dee5.json d01d7cf85d first commit 4 yıl önce woocommerce-th-b2e956ee35340f6e47f27f8a54309ac3.json d01d7cf85d first commit 4 yıl önce woocommerce-th-b31f51fa0bb40ceb060aaa9f77ca1771.json d01d7cf85d first commit 4 yıl önce woocommerce-th-b3f83696a2cb49f571043ce14a384a76.json d01d7cf85d first commit 4 yıl önce woocommerce-th-b4bf1e55ca6145f38f1b2f104201da21.json d01d7cf85d first commit 4 yıl önce woocommerce-th-b826befd7acca93e8e4c12b7cd2fc7f1.json d01d7cf85d first commit 4 yıl önce woocommerce-th-b9bf1ca91d393a30e2461ef709f8fa10.json d01d7cf85d first commit 4 yıl önce woocommerce-th-ba8d2fb7c85928310d4f3a907b7d9bdd.json d01d7cf85d first commit 4 yıl önce woocommerce-th-bb0f027faa1257de4b730158475093de.json d01d7cf85d first commit 4 yıl önce woocommerce-th-bb5c5935ec0d64e8880b1c7794470460.json d01d7cf85d first commit 4 yıl önce woocommerce-th-bc1f4f7aec77a0a6dd229cc910f601f1.json d01d7cf85d first commit 4 yıl önce woocommerce-th-bc9c3f9eda462d6d9968c1dca51e7c62.json d01d7cf85d first commit 4 yıl önce woocommerce-th-bcb06ab6e8931a862dec9c07c66df45b.json d01d7cf85d first commit 4 yıl önce woocommerce-th-c06829f63f73ae430c10ae700fb1eb6d.json d01d7cf85d first commit 4 yıl önce woocommerce-th-c0faba84c7842505f8893c2c327a9f78.json d01d7cf85d first commit 4 yıl önce woocommerce-th-c13acd243559529a685813d9871026a1.json d01d7cf85d first commit 4 yıl önce woocommerce-th-c1bc39bcdee2da3c0b62bcd5372120f4.json d01d7cf85d first commit 4 yıl önce woocommerce-th-c22945301f466e2d78d6e80404a22664.json d01d7cf85d first commit 4 yıl önce woocommerce-th-c2435bc8dfd186b147aba658416d115e.json d01d7cf85d first commit 4 yıl önce woocommerce-th-c257c024e3db4e010644d2c7be3c7090.json d01d7cf85d first commit 4 yıl önce woocommerce-th-c2d9a34cf502bd5b5a80ca646a1420b3.json d01d7cf85d first commit 4 yıl önce woocommerce-th-c5702ace609dd30ccabd4c999de43096.json d01d7cf85d first commit 4 yıl önce woocommerce-th-c608fe5deda8db7667c8431ca6fd222a.json d01d7cf85d first commit 4 yıl önce woocommerce-th-c6c5331d3afe1391f2ca83e991ccc086.json d01d7cf85d first commit 4 yıl önce woocommerce-th-c70671124b0e00661f88fe1616dfc9f0.json d01d7cf85d first commit 4 yıl önce woocommerce-th-c8cbe8ef95155db152b270d441fc8528.json d01d7cf85d first commit 4 yıl önce woocommerce-th-c8ddf2164475a213274d06873bfbb73a.json d01d7cf85d first commit 4 yıl önce woocommerce-th-c93706e596cbd46fb0d621f4fe3efb80.json d01d7cf85d first commit 4 yıl önce woocommerce-th-ca3cd4394cb082bde7555ebd3bb5f143.json d01d7cf85d first commit 4 yıl önce woocommerce-th-cb71ce5ddcc7c808172e80a0dc9833d5.json d01d7cf85d first commit 4 yıl önce woocommerce-th-cc16013df9d4b0a0ba45297b90b06f20.json d01d7cf85d first commit 4 yıl önce woocommerce-th-ccc500b0b722a0c96712f1634cbb7289.json d01d7cf85d first commit 4 yıl önce woocommerce-th-cd9fc1d9fc46b55bb32d0fd471457690.json d01d7cf85d first commit 4 yıl önce woocommerce-th-ce3f8f2f3e0f3c58f8aea5b7aa5cc6f4.json d01d7cf85d first commit 4 yıl önce woocommerce-th-d05ee634b22d05f0055b724443f05a68.json d01d7cf85d first commit 4 yıl önce woocommerce-th-d0d05e0dda872b433f260969b4d53b30.json d01d7cf85d first commit 4 yıl önce woocommerce-th-d0fa7cd1cd624e53cc7b4fde655c20af.json d01d7cf85d first commit 4 yıl önce woocommerce-th-d2b4400b6de0e69404e0f7f61d16bc55.json d01d7cf85d first commit 4 yıl önce woocommerce-th-d3e57c518feb58ab8ea4f9d2d8e66160.json d01d7cf85d first commit 4 yıl önce woocommerce-th-d4c505e96199e8c818fc6d24151d9c4a.json d01d7cf85d first commit 4 yıl önce woocommerce-th-d5ea33028f13b50f40bbcce807e37fc0.json d01d7cf85d first commit 4 yıl önce woocommerce-th-d6f4faa954a31ef3d5b74c2dfe13f141.json d01d7cf85d first commit 4 yıl önce woocommerce-th-d7bbe90eb59636eb8a6f31c7979ab6f5.json d01d7cf85d first commit 4 yıl önce woocommerce-th-d80020dab74131d7f0c108526c0fbebe.json d01d7cf85d first commit 4 yıl önce woocommerce-th-da92a9b2d4c08762c60d7c4c569eb5db.json d01d7cf85d first commit 4 yıl önce woocommerce-th-de12a4697822740a2fbaeb47c5062af1.json d01d7cf85d first commit 4 yıl önce woocommerce-th-deed2aed3392b43c83c7cea296b154af.json d01d7cf85d first commit 4 yıl önce woocommerce-th-df51042cba56a4e9fcac0e5db643906a.json d01d7cf85d first commit 4 yıl önce woocommerce-th-dfb09f9953676bbc1de4eb2b9f232c6d.json d01d7cf85d first commit 4 yıl önce woocommerce-th-dfbfe3d556f60ebbd62c2b5c8e0fa466.json d01d7cf85d first commit 4 yıl önce woocommerce-th-e03ec35386c2705c11cebd6288b33cf8.json d01d7cf85d first commit 4 yıl önce woocommerce-th-e0bde0ac58f55fc6b1426844e6697db3.json d01d7cf85d first commit 4 yıl önce woocommerce-th-e0f9c7d89b1b130a9023c5c2fde2815e.json d01d7cf85d first commit 4 yıl önce woocommerce-th-e41c58d5fb39f750efcbf65a2b55460b.json d01d7cf85d first commit 4 yıl önce woocommerce-th-e44671e4528b0da3a0fd6feaf8abadca.json d01d7cf85d first commit 4 yıl önce woocommerce-th-e4fbc8d7fc7a16bd8cf2e0522a199de0.json d01d7cf85d first commit 4 yıl önce woocommerce-th-e690486b33a7bb1944a37f6e734d734f.json d01d7cf85d first commit 4 yıl önce woocommerce-th-e80539b9960e930bf0dcd334d99eb128.json d01d7cf85d first commit 4 yıl önce woocommerce-th-e885442559cb44e8b827f0e0ca0a14c9.json d01d7cf85d first commit 4 yıl önce woocommerce-th-e88dc35c02f6fa832e90fac5a122323c.json d01d7cf85d first commit 4 yıl önce woocommerce-th-ea6fb371f81c4d3584bbc795fa4ac09c.json d01d7cf85d first commit 4 yıl önce woocommerce-th-ed9b16000a6d37c51bf23c61f4df878e.json d01d7cf85d first commit 4 yıl önce woocommerce-th-ef5798395d7601ab6fea0f1efd60f40a.json d01d7cf85d first commit 4 yıl önce woocommerce-th-f31b0aa0c71dd74b7103120610ca6253.json d01d7cf85d first commit 4 yıl önce woocommerce-th-f34924aeff974b0bdbfac124c23fbfe3.json d01d7cf85d first commit 4 yıl önce woocommerce-th-f39008456fd28b2f79cdb0964ff294e1.json d01d7cf85d first commit 4 yıl önce woocommerce-th-f3f1cc4f5811d4bf8a04a58feca06858.json d01d7cf85d first commit 4 yıl önce woocommerce-th-f56e66fd08c07abc78cd844f7e83af8c.json d01d7cf85d first commit 4 yıl önce woocommerce-th-f60049653c419cfb1e3dc8876e7a8bdb.json d01d7cf85d first commit 4 yıl önce woocommerce-th-f686a272add740773cdcb730afdb5454.json d01d7cf85d first commit 4 yıl önce woocommerce-th-f976da155dfdd080588c50ccda5af747.json d01d7cf85d first commit 4 yıl önce woocommerce-th-f9c56a0cbb6710505047e6c835953c82.json d01d7cf85d first commit 4 yıl önce woocommerce-th-fb2ef023bdd44902b5a309e25e0b7792.json d01d7cf85d first commit 4 yıl önce woocommerce-th-fc1fe56fadfdeeb25d1bc441581d92b6.json d01d7cf85d first commit 4 yıl önce woocommerce-th-fc4895b6508f32c16c4d8bc69f8162b6.json d01d7cf85d first commit 4 yıl önce woocommerce-th-fd20fc8ea1484781160e8ea0d229d5e9.json d01d7cf85d first commit 4 yıl önce woocommerce-th-fffdec5db595ec0ca7d043c87bae79b8.json d01d7cf85d first commit 4 yıl önce woocommerce-th-wc-admin-app.json d01d7cf85d first commit 4 yıl önce woocommerce-th.mo d01d7cf85d first commit 4 yıl önce woocommerce-th.po d01d7cf85d first commit 4 yıl önce tum/whitesports - Gogs: Simplico Git Service

Geen omschrijving

revisions.php 9.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458
  1. <?php
  2. if ( ! defined( 'ABSPATH' ) ) {
  3. exit; // Exit if accessed directly
  4. }
  5. if ( ! class_exists( 'acf_revisions' ) ) :
  6. class acf_revisions {
  7. // vars
  8. var $cache = array();
  9. /*
  10. * __construct
  11. *
  12. * A good place to add actions / filters
  13. *
  14. * @type function
  15. * @date 11/08/13
  16. *
  17. * @param N/A
  18. * @return N/A
  19. */
  20. function __construct() {
  21. // actions
  22. add_action( 'wp_restore_post_revision', array( $this, 'wp_restore_post_revision' ), 10, 2 );
  23. // filters
  24. add_filter( 'wp_save_post_revision_check_for_changes', array( $this, 'wp_save_post_revision_check_for_changes' ), 10, 3 );
  25. add_filter( '_wp_post_revision_fields', array( $this, 'wp_preview_post_fields' ), 10, 2 );
  26. add_filter( '_wp_post_revision_fields', array( $this, 'wp_post_revision_fields' ), 10, 2 );
  27. add_filter( 'acf/validate_post_id', array( $this, 'acf_validate_post_id' ), 10, 2 );
  28. }
  29. /*
  30. * wp_preview_post_fields
  31. *
  32. * This function is used to trick WP into thinking that one of the $post's fields has changed and
  33. * will allow an autosave to be updated.
  34. * Fixes an odd bug causing the preview page to render the non autosave post data on every odd attempt
  35. *
  36. * @type function
  37. * @date 21/10/2014
  38. * @since 5.1.0
  39. *
  40. * @param $fields (array)
  41. * @return $fields
  42. */
  43. function wp_preview_post_fields( $fields ) {
  44. // bail early if not previewing a post
  45. if ( acf_maybe_get_POST( 'wp-preview' ) !== 'dopreview' ) {
  46. return $fields;
  47. }
  48. // add to fields if ACF has changed
  49. if ( acf_maybe_get_POST( '_acf_changed' ) ) {
  50. $fields['_acf_changed'] = 'different than 1';
  51. }
  52. // return
  53. return $fields;
  54. }
  55. /*
  56. * wp_save_post_revision_check_for_changes
  57. *
  58. * This filter will return false and force WP to save a revision. This is required due to
  59. * WP checking only post_title, post_excerpt and post_content values, not custom fields.
  60. *
  61. * @type filter
  62. * @date 19/09/13
  63. *
  64. * @param $return (boolean) defaults to true
  65. * @param $last_revision (object) the last revision that WP will compare against
  66. * @param $post (object) the $post that WP will compare against
  67. * @return $return (boolean)
  68. */
  69. function wp_save_post_revision_check_for_changes( $return, $last_revision, $post ) {
  70. // if acf has changed, return false and prevent WP from performing 'compare' logic
  71. if ( acf_maybe_get_POST( '_acf_changed' ) ) {
  72. return false;
  73. }
  74. // return
  75. return $return;
  76. }
  77. /*
  78. * wp_post_revision_fields
  79. *
  80. * This filter will add the ACF fields to the returned array
  81. * Versions 3.5 and 3.6 of WP feature different uses of the revisions filters, so there are
  82. * some hacks to allow both versions to work correctly
  83. *
  84. * @type filter
  85. * @date 11/08/13
  86. *
  87. * @param $post_id (int)
  88. * @return $post_id (int)
  89. */
  90. function wp_post_revision_fields( $fields, $post = null ) {
  91. // validate page
  92. if ( acf_is_screen( 'revision' ) || acf_is_ajax( 'get-revision-diffs' ) ) {
  93. // bail early if is restoring
  94. if ( acf_maybe_get_GET( 'action' ) === 'restore' ) {
  95. return $fields;
  96. }
  97. // allow
  98. } else {
  99. // bail early (most likely saving a post)
  100. return $fields;
  101. }
  102. // vars
  103. $append = array();
  104. $order = array();
  105. $post_id = acf_maybe_get( $post, 'ID' );
  106. // compatibility with WP < 4.5 (test)
  107. if ( ! $post_id ) {
  108. global $post;
  109. $post_id = $post->ID;
  110. }
  111. // get all postmeta
  112. $meta = get_post_meta( $post_id );
  113. // bail early if no meta
  114. if ( ! $meta ) {
  115. return $fields;
  116. }
  117. // loop
  118. foreach ( $meta as $name => $value ) {
  119. // attempt to find key value
  120. $key = acf_maybe_get( $meta, '_' . $name );
  121. // bail ealry if no key
  122. if ( ! $key ) {
  123. continue;
  124. }
  125. // update vars
  126. $value = $value[0];
  127. $key = $key[0];
  128. // Load field.
  129. $field = acf_get_field( $key );
  130. if ( ! $field ) {
  131. continue;
  132. }
  133. // get field
  134. $field_title = $field['label'] . ' (' . $name . ')';
  135. $field_order = $field['menu_order'];
  136. $ancestors = acf_get_field_ancestors( $field );
  137. // ancestors
  138. if ( ! empty( $ancestors ) ) {
  139. // vars
  140. $count = count( $ancestors );
  141. $oldest = acf_get_field( $ancestors[ $count - 1 ] );
  142. // update vars
  143. $field_title = str_repeat( '- ', $count ) . $field_title;
  144. $field_order = $oldest['menu_order'] . '.1';
  145. }
  146. // append
  147. $append[ $name ] = $field_title;
  148. $order[ $name ] = $field_order;
  149. // hook into specific revision field filter and return local value
  150. add_filter( "_wp_post_revision_field_{$name}", array( $this, 'wp_post_revision_field' ), 10, 4 );
  151. }
  152. // append
  153. if ( ! empty( $append ) ) {
  154. // vars
  155. $prefix = '_';
  156. // add prefix
  157. $append = acf_add_array_key_prefix( $append, $prefix );
  158. $order = acf_add_array_key_prefix( $order, $prefix );
  159. // sort by name (orders sub field values correctly)
  160. array_multisort( $order, $append );
  161. // remove prefix
  162. $append = acf_remove_array_key_prefix( $append, $prefix );
  163. // append
  164. $fields = $fields + $append;
  165. }
  166. // return
  167. return $fields;
  168. }
  169. /*
  170. * wp_post_revision_field
  171. *
  172. * This filter will load the value for the given field and return it for rendering
  173. *
  174. * @type filter
  175. * @date 11/08/13
  176. *
  177. * @param $value (mixed) should be false as it has not yet been loaded
  178. * @param $field_name (string) The name of the field
  179. * @param $post (mixed) Holds the $post object to load from - in WP 3.5, this is not passed!
  180. * @param $direction (string) to / from - not used
  181. * @return $value (string)
  182. */
  183. function wp_post_revision_field( $value, $field_name, $post = null, $direction = false ) {
  184. // bail ealry if is empty
  185. if ( empty( $value ) ) {
  186. return $value;
  187. }
  188. // value has not yet been 'maybe_unserialize'
  189. $value = maybe_unserialize( $value );
  190. // vars
  191. $post_id = $post->ID;
  192. // load field
  193. $field = acf_maybe_get_field( $field_name, $post_id );
  194. // default formatting
  195. if ( is_array( $value ) ) {
  196. $value = implode( ', ', $value );
  197. } elseif ( is_object( $value ) ) {
  198. $value = serialize( $value );
  199. }
  200. // image
  201. if ( $field['type'] == 'image' || $field['type'] == 'file' ) {
  202. $url = wp_get_attachment_url( $value );
  203. $value = $value . ' (' . $url . ')';
  204. }
  205. // return
  206. return $value;
  207. }
  208. /*
  209. * wp_restore_post_revision
  210. *
  211. * This action will copy and paste the metadata from a revision to the post
  212. *
  213. * @type action
  214. * @date 11/08/13
  215. *
  216. * @param $parent_id (int) the destination post
  217. * @return $revision_id (int) the source post
  218. */
  219. function wp_restore_post_revision( $post_id, $revision_id ) {
  220. // copy postmeta from revision to post (restore from revision)
  221. acf_copy_postmeta( $revision_id, $post_id );
  222. // Make sure the latest revision is also updated to match the new $post data
  223. // get latest revision
  224. $revision = acf_get_post_latest_revision( $post_id );
  225. // save
  226. if ( $revision ) {
  227. // copy postmeta from revision to latest revision (potentialy may be the same, but most likely are different)
  228. acf_copy_postmeta( $revision_id, $revision->ID );
  229. }
  230. }
  231. /*
  232. * acf_validate_post_id
  233. *
  234. * This function will modify the $post_id and allow loading values from a revision
  235. *
  236. * @type function
  237. * @date 6/3/17
  238. * @since 5.5.10
  239. *
  240. * @param $post_id (int)
  241. * @param $_post_id (int)
  242. * @return $post_id (int)
  243. */
  244. function acf_validate_post_id( $post_id, $_post_id ) {
  245. // bail early if no preview in URL
  246. if ( ! isset( $_GET['preview'] ) ) {
  247. return $post_id;
  248. }
  249. // bail early if $post_id is not numeric
  250. if ( ! is_numeric( $post_id ) ) {
  251. return $post_id;
  252. }
  253. // vars
  254. $k = $post_id;
  255. $preview_id = 0;
  256. // check cache
  257. if ( isset( $this->cache[ $k ] ) ) {
  258. return $this->cache[ $k ];
  259. }
  260. // validate
  261. if ( isset( $_GET['preview_id'] ) ) {
  262. $preview_id = (int) $_GET['preview_id'];
  263. } elseif ( isset( $_GET['p'] ) ) {
  264. $preview_id = (int) $_GET['p'];
  265. } elseif ( isset( $_GET['page_id'] ) ) {
  266. $preview_id = (int) $_GET['page_id'];
  267. }
  268. // bail early id $preview_id does not match $post_id
  269. if ( $preview_id != $post_id ) {
  270. return $post_id;
  271. }
  272. // attempt find revision
  273. $revision = acf_get_post_latest_revision( $post_id );
  274. // save
  275. if ( $revision && $revision->post_parent == $post_id ) {
  276. $post_id = (int) $revision->ID;
  277. }
  278. // set cache
  279. $this->cache[ $k ] = $post_id;
  280. // return
  281. return $post_id;
  282. }
  283. }
  284. // initialize
  285. acf()->revisions = new acf_revisions();
  286. endif; // class_exists check
  287. /*
  288. * acf_save_post_revision
  289. *
  290. * This function will copy meta from a post to it's latest revision
  291. *
  292. * @type function
  293. * @date 26/09/2016
  294. * @since 5.4.0
  295. *
  296. * @param $post_id (int)
  297. * @return n/a
  298. */
  299. function acf_save_post_revision( $post_id = 0 ) {
  300. // get latest revision
  301. $revision = acf_get_post_latest_revision( $post_id );
  302. // save
  303. if ( $revision ) {
  304. acf_copy_postmeta( $post_id, $revision->ID );
  305. }
  306. }
  307. /*
  308. * acf_get_post_latest_revision
  309. *
  310. * This function will return the latest revision for a given post
  311. *
  312. * @type function
  313. * @date 25/06/2016
  314. * @since 5.3.8
  315. *
  316. * @param $post_id (int)
  317. * @return $post_id (int)
  318. */
  319. function acf_get_post_latest_revision( $post_id ) {
  320. // vars
  321. $revisions = wp_get_post_revisions( $post_id );
  322. // shift off and return first revision (will return null if no revisions)
  323. $revision = array_shift( $revisions );
  324. // return
  325. return $revision;
  326. }