categories as $term ) { if ( $term->parent == $id ) $result_api[] = $term; } return $result_api; } return; } // ******************************* GET POSTS *****************************// /** * * RETURN 'ALL' THE POSTS, FILTERED BY PARAMETERS * * @param int $postperpage quantity of posts * @param string $orderby type | name | author | ID | ... * @param string $order asc | desc * @param int $category ID of specific category * * @return empty | JSON Decoded String */ // ***********************************************************************// function get_posts( $postperpage = 10, $orderby = 'name', $order = 'asc', $category = null ) { $finalURL = self::API_URL_POSTS.'?per_page='.$postperpage.'&orderby='.$orderby.'&order='.$order.'&categories='.$category; $result_api = json_decode( wp_remote_retrieve_body( self::connect_api( $finalURL ) ) ); if ( empty( $result_api ) ) { return; } return $result_api; } // ****************************** GET IMAGE POST ***************************// /** * * RETURN IMAGE OBJECT * * @param int $id image ID to get image object * * @return empty | image object */ // ***********************************************************************// function get_post_media( $id ) { $finalURL = self::API_URL_POST_MEDIA.'/'.$id; $result_api = json_decode( wp_remote_retrieve_body( self::connect_api( $finalURL ) ) ); if ( empty( $result_api ) ) { return; } return $result_api; } // ****************************** GET CATEGORY ***************************// /** * * RETURN CATEGORY SLUG OF POST ID * * @param int $id post ID to get category * * @return empty | category slug */ // ***********************************************************************// function get_category( $id ) { $finalURL = self::API_URL_CATEGORIES.'/'.$id; $result_api = json_decode( wp_remote_retrieve_body( self::connect_api( $finalURL ) ) ); if ( empty( $result_api ) ) { return; } return $result_api->slug; } // ***************************** GET META SUBS ***************************// /** * * RETURN LIST BASED IN META OF POSTS * * @param int $id post ID to get list * * @return empty | string "
  • " */ // ***********************************************************************// function get_meta_subs( $id ) { $finalURL = self::API_URL_CHECKMETA.'/'.$id; $result_api = json_decode( wp_remote_retrieve_body( self::connect_api( $finalURL ) ) ); if ( empty( $result_api ) ) { return; } return $result_api; } // ****************************** GET MODALS *****************************// /** * * RETURN MODAL IF HAS * * @param int $id post ID to get list * * @return empty | JSON Decoded String */ // ***********************************************************************// /*function get_modals() { $result_api = json_decode( wp_remote_retrieve_body( self::connect_api( self::API_URL_MODALS ) ) ); if ( empty( $result_api ) ) { return; } return $result_api; }*/ // ****************************** GET PUSH ******************************// /** * * RETURN PUSH NOTIFICATIONS * * @param none * * @return json push notifications */ // ***********************************************************************// function get_push() { $result_api = json_decode( wp_remote_retrieve_body( self::connect_api( self::API_URL_PUSH_NOT ) ) ); if ( empty( $result_api ) ) { return; } return $result_api; } }