ID ] = $page->post_title; } } return $pages; } /** * Get current address bar URL. * * @since 1.0.0 * * @return string Current Page URL. */ function aec_get_current_url() { $current_url = ( isset( $_SERVER["HTTPS"] ) && $_SERVER["HTTPS"] == "on" ) ? "https://" : "http://"; $current_url .= $_SERVER["SERVER_NAME"]; if( $_SERVER["SERVER_PORT"] != "80" && $_SERVER["SERVER_PORT"] != "443" ) { $current_url .= ":".$_SERVER["SERVER_PORT"]; } $current_url .= $_SERVER["REQUEST_URI"]; return $current_url; } /* * Provides a simple login form. * * @since 1.0.0 * * @return string Login form. */ function aec_login_form() { $form = wp_login_form(); $form .= sprintf( '
', wp_lostpassword_url( get_permalink() ), __( 'Forgot your password?', 'another-events-calendar' ) ); $form .= sprintf( '', wp_registration_url(), __( 'Create an account', 'another-events-calendar' ) ); return $form; } /* * Whether the current user has a specific capability. * * @since 1.5.0 * * @param string $capability Capability name. * @param int $post_id Post ID. * @return bool True if the current user has the permission, false if not. */ function aec_current_user_can( $capability, $post_id = 0 ) { $current_user_id = get_current_user_id(); $post_author_id = get_post_field( 'post_author', $post_id ); return ( $current_user_id == $post_author_id ) ? true : false; } /** * Find days between 2 dates. * * @since 1.0.0 * * @param string $start Start date. * @param string $end End date. * @return array $dates Array of date strings. */ function aec_get_dates_from_range( $start, $end ) { $interval = new DateInterval('P1D'); $real_end = new DateTime( $end ); $real_end->add( $interval ); $period = new DatePeriod( new DateTime( $start ), $interval, $real_end ); $dates = array(); foreach( $period as $date ) { $dates[] = $date->format('Y-m-d'); } return $dates; } /** * Get AEC categories list. * * @since 1.0.0 * * @param int $parent Term ID. * @return string $html AEC Categories List. */ function aec_list_categories( $parent = 0 ) { $general_settings = get_option( 'aec_general_settings' ); $categories_settings = get_option( 'aec_categories_settings' ); $show_events_count = empty( $categories_settings['show_events_count'] ) ? 0 : 1; $show_past_events = empty( $general_settings['show_past_events'] ) ? 0 : 1; $args = array( 'hide_empty' => empty( $categories_settings['hide_empty_categories'] ) ? false : true, 'orderby' => $categories_settings['orderby'], 'order' => $categories_settings['order'], 'parent' => $parent, 'hierarchical' => 0 ); $terms = get_terms( 'aec_categories', $args ); $li = array(); foreach( $terms as $term ) { $count = aec_get_events_count_by_category( $term->term_id, $show_past_events ); $child_terms = aec_list_categories( $term->term_id ); if( $show_events_count ) { $li[] = sprintf( '