$char_number) { $text = substr($text, 0, $char_number); $text = substr($text,0,strrpos($text," ")); $punctuation = ".!?:;,-"; // punctuation you want removed $text = (strspn(strrev($text), $punctuation) != 0) ? substr($text, 0, -strspn(strrev($text), $punctuation)) : $text; $text = $text.$etc; } $text = htmlentities($text, ENT_QUOTES); return $text; } /* CUSTOM NAV MENU */ function edge_nav_menu() { wp_nav_menu(array( "container" => "nav", "container_class" => " ", "container_id" => "", "menu_class" => " ", "menu_id" => " ", )); } /* DATABASE CALL */ class Post { public static function find($args = null) { wp_reset_postdata(); if(empty($args) ) { $args = array( "post_type" => get_called_class() ); } return new WP_Query($args); } public static function find_by($key, $value) { wp_reset_postdata(); $args = array( $key => $value, "post_type" => get_called_class() ); return new WP_Query($args); } } class Page extends Post {} /* CUSTOM POST TYPE */ function add_post_type($name, $icon = "admin-post", $tax_name = null) { $plural = Inflector::pluralize($name); $singular = $name; $labels = array( "name" => $plural, "singular_name" => $singular, "add_new_item" => "Add New " . $singular, "edit_item" => "Edit " . $singular, "new_item" => "New " . $singular, "view_item" => "View " . $singular, "search_items" => "Search " . $plural, "not_found" => "No " . strtolower($plural) . " found", "not_found_in_trash" => "No " . strtolower($plural) . " found in Trash", "parent_item_colon" => "Parent " . $singular . ":", ); $post_args = array( "public" => true, "menu_icon" => "dashicons-".$icon, "labels" => $labels, "capability_type" => "post", "supports" => array( "title", "editor", "custom-fields", "revisions", "thumbnail", ), ); // If taxonomy is given if($tax_name) { add_taxonomy($tax_name, $name); } register_post_type(strtolower($name), $post_args); } /* CUSTOM TAXONOMY */ function add_taxonomy($name, $post_type) { $plural = Inflector::pluralize($name); $singular = $name; $labels = array( "name" => $plural, "singular_name" => $singular, "all_items" => "All " . $plural, "edit_item" => "Edit " . $singular, "view_item" => "View " . $singular, "update_item" => "Update " . $singular, "add_new_item" => "Add New " . $singular, "parent_item" => "Parent " . $singular, "search_items" => "Search " . $plural, "popular_items" => "Popular " . $plural, "add_or_remove_items" => "Add or remove " . strtolower($plural), "choose_from_most_used" => "Choose from the most used " . strtolower($plural), "not_found" => "No " . strtolower($plural) . " found" ); $tax_args = array( "labels" => $labels, "show_ui" => true, "query_var" => true, "show_admin_column" => false, "hierarchical" => true, ); register_taxonomy(strtolower($name), strtolower($post_type), $tax_args); } /* REMOVE MENU ITEMS */ add_action("admin_menu", "remove_menu_items"); /* AUTO ADD HEADER and FOOTER */ add_filter("template_include", function($template) { get_header(); include $template; get_footer(); return FALSE; });