{"action":"created","issue":{"url":"https://api.github.com/repos/thursby/themetest/issues/2","repository_url":"https://api.github.com/repos/thursby/themetest","labels_url":"https://api.github.com/repos/thursby/themetest/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/thursby/themetest/issues/2/comments","events_url":"https://api.github.com/repos/thursby/themetest/issues/2/events","html_url":"https://github.com/thursby/themetest/issues/2","id":316131851,"number":2,"title":"Make Custom Post Type","user":{"login":"thursby","id":19896188,"avatar_url":"https://avatars2.githubusercontent.com/u/19896188?v=4","gravatar_id":"","url":"https://api.github.com/users/thursby","html_url":"https://github.com/thursby","followers_url":"https://api.github.com/users/thursby/followers","following_url":"https://api.github.com/users/thursby/following{/other_user}","gists_url":"https://api.github.com/users/thursby/gists{/gist_id}","starred_url":"https://api.github.com/users/thursby/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thursby/subscriptions","organizations_url":"https://api.github.com/users/thursby/orgs","repos_url":"https://api.github.com/users/thursby/repos","events_url":"https://api.github.com/users/thursby/events{/privacy}","received_events_url":"https://api.github.com/users/thursby/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-04-20T05:25:02Z","updated_at":"2018-05-06T07:52:19Z","closed_at":null,"author_association":"OWNER","body":"The WordPress plugin should be using a custom post type to display the data instead of a shortcode. Shortcodes are rendered when the post is \"saved\" or \"updated\" but a custom post type would display data dynamically."},"comment":{"url":"https://api.github.com/repos/thursby/themetest/issues/comments/386861156","html_url":"https://github.com/thursby/themetest/issues/2#issuecomment-386861156","issue_url":"https://api.github.com/repos/thursby/themetest/issues/2","id":386861156,"user":{"login":"a2wharrison","id":30225160,"avatar_url":"https://avatars2.githubusercontent.com/u/30225160?v=4","gravatar_id":"","url":"https://api.github.com/users/a2wharrison","html_url":"https://github.com/a2wharrison","followers_url":"https://api.github.com/users/a2wharrison/followers","following_url":"https://api.github.com/users/a2wharrison/following{/other_user}","gists_url":"https://api.github.com/users/a2wharrison/gists{/gist_id}","starred_url":"https://api.github.com/users/a2wharrison/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/a2wharrison/subscriptions","organizations_url":"https://api.github.com/users/a2wharrison/orgs","repos_url":"https://api.github.com/users/a2wharrison/repos","events_url":"https://api.github.com/users/a2wharrison/events{/privacy}","received_events_url":"https://api.github.com/users/a2wharrison/received_events","type":"User","site_admin":false},"created_at":"2018-05-06T07:52:19Z","updated_at":"2018-05-06T07:52:19Z","author_association":"NONE","body":"# File thursby.php #\r\n# 1st file #\r\n`class thursby {\r\n \r\n    static private $_self = null;\r\n    const POST_TYPE = 'url';\r\n \r\n    /**\r\n     * Always return the same instance of plugin so we can access its property and its method\r\n     * from anywhere\r\n     * @return thursby\r\n     */\r\n    static public function singleton() {\r\n        if (!self::$_self) {\r\n            $classname = __CLASS__;\r\n            self::$_self = new $classname;\r\n            self::$_self->_bootstrap();\r\n        }\r\n        return self::$_self;\r\n    }\r\n \r\n    /**\r\n     * Construct plugin and set useful property for later reference\r\n     */\r\n    public function __construct() {\r\n    }\r\n \r\n    /**\r\n     * Init cache class!\r\n     * Load all styles, script, define JavaScript var with useful URL\r\n     */\r\n    private function _bootstrap() {\r\n        //Add action, filter should be put here\r\n    }\r\n \r\n}\r\n \r\n$wp_thursby = thursby::singleton();`\r\n\r\n# second part - Post Type #\r\npublic function init() {\r\n    $args = array(\r\n        'labels' => array(\r\n            'name' => _x('Short Urls', 'post type general name'),\r\n            'singular_name' => _x('Short Url', 'post type singular name'),\r\n            'add_new' => _x('Add Url', self::POST_TYPE),\r\n            'add_new_item' => __('Add New Url'),\r\n            'edit_item' => __('Edit Url'),\r\n            'new_item' => __('New Url'),\r\n            'all_items' => __('All Urls'),\r\n            'view_item' => __('View Url'),\r\n            'search_items' => __('Search Urls'),\r\n            'not_found' =>  __('No url found'),\r\n            'not_found_in_trash' => __('No urls found in Trash'), \r\n            'parent_item_colon' => '',\r\n            'menu_name' => 'Urls'\r\n        ),\r\n        'public' => true,\r\n        'publicly_queryable' => true,\r\n        'show_ui' => true, \r\n        'show_in_menu' => true, \r\n        'query_var' => true,\r\n        'rewrite' => true,\r\n        'capability_type' => 'post',\r\n        'has_archive' => true, \r\n        'hierarchical' => false,\r\n        'menu_position' => null,\r\n        'supports' => array('title','author')\r\n      ); \r\n    register_post_type(self::POST_TYPE, $args);\r\n}\r\n\r\n# third thing custom post types #4 \r\nprivate function _bootstrap() {\r\n    add_action('init', array($this, 'init'));\r\n    add_action('add_meta_boxes', array($this, 'add_meta_box'));\r\n}\r\n \r\npublic function add_meta_box() {\r\n    add_meta_box(\"thursby-meta\", \"Short URL\", array($this, 'meta_box_content'), self::POST_TYPE, \"normal\", \"low\");\r\n}\r\n \r\npublic function meta_box_content() {\r\n    global $post;\r\n    wp_nonce_field('my_thursby_nonce', 'thursby_nonce');\r\n \r\n    $_thursby_key = get_post_meta($post->ID, '_thursby_key', true);\r\n \r\n    <p>\r\n        <label><?php echo __('URL Key') ?>:</label>\r\n        <input name=\"_thursby_key\" type=\"text\" value=\"<?php echo $_thursby_key ?>\" />\r\n        You can put your custom url key here if wanted!\r\n    </p>\r\n    <?php\r\n    if (!empty($_thursby_key)) :\r\n        ?>\r\n        <p>\r\n            <label><?php echo __('Your whole shorted url') ?>:</label>\r\n            <input size=\"50\" type=\"text\" value=\"<?php echo trailingslashit(get_bloginfo('url')), $_vanity_key ?>\" />\r\n            <a target=\"_blank\" href=\"<?php echo trailingslashit(get_bloginfo('url')), $_thursby_key ?>\">Try it</a>\r\n        </p>\r\n    <?php endif ?>\r\n \r\n    <?php\r\n}\r\n\r\n# 4 customer post type #4 \r\n\r\npublic function init() {\r\n    $args = array(\r\n        'labels' => array(\r\n            'name' => _x('Short Urls', 'post type general name'),\r\n            'singular_name' => _x('Short Url', 'post type singular name'),\r\n            'add_new' => _x('Add Url', self::POST_TYPE),\r\n            'add_new_item' => __('Add New Url'),\r\n            'edit_item' => __('Edit Url'),\r\n            'new_item' => __('New Url'),\r\n            'all_items' => __('All Urls'),\r\n            'view_item' => __('View Url'),\r\n            'search_items' => __('Search Urls'),\r\n            'not_found' =>  __('No url found'),\r\n            'not_found_in_trash' => __('No urls found in Trash'), \r\n            'parent_item_colon' => '',\r\n            'menu_name' => 'Urls'\r\n        ),\r\n        'public' => true,\r\n        'publicly_queryable' => true,\r\n        'show_ui' => true, \r\n        'show_in_menu' => true, \r\n        'query_var' => true,\r\n        'rewrite' => true,\r\n        'capability_type' => 'post',\r\n        'has_archive' => true, \r\n        'hierarchical' => false,\r\n        'menu_position' => null,\r\n        'supports' => array('title','author')\r\n      ); \r\n    register_post_type(self::POST_TYPE, $args);\r\n}\r\n\r\n# 5 brain fart name but will work # \r\n\r\nWe register with register_post_type and set a label and text for it. Now we'll let WordPress know we want to hook into it with the init hook! We use modified method _bootstrap():\r\n123 | private function _bootstrap() {    add_action('init', array($this, 'init'));}\r\n-- | --\r\n\r\nMORE TO COME!\r\n\r\n\r\n"}}
{"actor":{"display_login":"a2wharrison"}}