* @copyright 2012 TXTImpact Texting https://www.txtimpact.com * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0 * @since 1.0 */ /** * Utility: provides the URL to something in this plugin dir. * * @param string $path The path within this plugin dir * @return string The absolute URL **/ function txtimpact_url( $path ) { $folder = rtrim( basename( dirname( __FILE__ ) ), '/' ); $dir = trailingslashit( WP_PLUGIN_DIR ) . $folder; $url = plugins_url( $folder ); return $url . $path; } /** * generate paginator html controll * * @param integer $current_page * @param integer $page_size * @param integer $total_items * @param integer $total_page * @return html of paginator */ function txtimpact_build_pager_controll($current_page, $page_size = 10, $total_items, $total_page,$type="subscriber") { $base_link = txtimpact_current_page_url(); if($type == "message") $pager_content = __('Messages', 'txtimpact') . ' : '; else $pager_content = __('Subscribers', 'txtimpact') . ' : '; $pager_content .= ( ( ($current_page) * $page_size ) - $page_size ) + 1 . ' - '. ( ( $current_page ) * $page_size ); $pager_content .= ' ' . __( 'of', 'txtimpact' ) . ' ' . $total_items; $base_link = remove_query_arg( array('p', 'pageSize'), $base_link); // build first link if( $current_page == 1 ) $first_link = '' . __('First', 'txtimpact') . ''; else $first_link = sprintf( '%s', esc_url( $base_link ), 'txtimpact-first', __( 'First', 'txtimpact' ) ); $pager_content .= ' | ' . $first_link; //build previous link if( $current_page == 1 ) $previous_link = '' . __('Previous', 'txtimpact') . ''; else $previous_link = sprintf( '%s', esc_url( add_query_arg('p', ( $current_page - 1 ), $base_link) ), 'txtimpact-previous', __('Previous', 'txtimpact') ); $pager_content .= ' | ' . $previous_link; //build next link if( $current_page == $total_page ) $next_page = '' . __( 'Next', 'txtimpact' ) . ''; else $next_page = sprintf( '%s', esc_url( add_query_arg( 'p', ($current_page + 1), $base_link ) ), 'txtimpact-next', __( 'Next', 'txtimpact' ) ); $pager_content .= ' | ' . $next_page; //build last link if( $current_page == $total_page) $last_link = '' . __( 'Last', 'txtimpact' ) . ''; else $last_link = sprintf( '%s', esc_url( add_query_arg('p', $total_page, $base_link) ), 'txtimpact-last', __( 'Last', 'txtimpact' ) ); $pager_content .= ' | ' . $last_link; $pager_container = "
$pager_content
"; return $pager_container; } /** * get current page url * * @return string url */ function txtimpact_current_page_url() { return ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; } /** * The database character collate. * * @return string The database character collate. **/ function txtimpact_db_charset_collate() { global $wpdb; $charset_collate = ''; if ( ! empty($wpdb->charset) ) $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset"; if ( ! empty($wpdb->collate) ) $charset_collate .= " COLLATE $wpdb->collate"; return $charset_collate; }