?> class Akismet_REST_API { /** * Register the REST API routes. */ public static function init() { if ( ! function_exists( 'register_rest_route' ) ) { // The REST API wasn't integrated into core until 4.4, and we support 4.0+ (for now). return false; } register_rest_route( 'akismet/v1', '/key', array( array( 'methods' => WP_REST_Server::READABLE, 'permission_callback' => array( 'Akismet_REST_API', 'privileged_permission_callback' ), 'callback' => array( 'Akismet_REST_API', 'get_key' ), ), array( 'methods' => WP_REST_Server::EDITABLE, 'permission_callback' => array( 'Akismet_REST_API', 'privileged_permission_callback' ), 'callback' => array( 'Akismet_REST_API', 'set_key' ), 'args' => array( 'key' => array( 'required' => true, 'type' => 'string', 'sanitize_callback' => array( 'Akismet_REST_API', 'sanitize_key' ), 'description' => __( 'A 12-character Akismet API key. Available at akismet.com/get/', 'akismet' ), ), ), ), array( 'methods' => WP_REST_Server::DELETABLE, 'permission_callback' => array( 'Akismet_REST_API', 'privileged_permission_callback' ), 'callback' => array( 'Akismet_REST_API', 'delete_key' ), ) ) ); register_rest_route( 'akismet/v1', '/settings/', array( array( 'methods' => WP_REST_Server::READABLE, 'permission_callback' => array( 'Akismet_REST_API', 'privileged_permission_callback' ), 'callback' => array( 'Akismet_REST_API', 'get_settings' ), ), array( 'methods' => WP_REST_Server::EDITABLE, 'permission_callback' => array( 'Akismet_REST_API', 'privileged_permission_callback' ), 'callback' => array( 'Akismet_REST_API', 'set_boolean_settings' ), 'args' => array( 'akismet_strictness' => array( 'required' => false, 'type' => 'boolean', 'description' => __( 'If true, Akismet will automatically discard the worst spam automatically rather than putting it in the spam folder.', 'akismet' ), ), 'akismet_show_user_comments_approved' => array( 'required' => false, 'type' => 'boolean', 'description' => __( 'If true, show the number of approved comments beside each comment author in the comments list page.', 'akismet' ), ), ), ) ) ); register_rest_route( 'akismet/v1', '/stats', array( 'methods' => WP_REST_Server::READABLE, 'permission_callback' => array( 'Akismet_REST_API', 'privileged_permission_callback' ), 'callback' => array( 'Akismet_REST_API', 'get_stats' ), 'args' => array( 'interval' => array( 'required' => false, 'type' => 'string', 'sanitize_callback' => array( 'Akismet_REST_API', 'sanitize_interval' ), 'description' => __( 'The time period for which to retrieve stats. Options: 60-days, 6-months, all', 'akismet' ), 'default' => 'all', ), ), ) ); register_rest_route( 'akismet/v1', '/stats/(?P[\w+])', array( 'args' => array( 'interval' => array( 'description' => __( 'The time period for which to retrieve stats. Options: 60-days, 6-months, all', 'akismet' ), 'type' => 'string', ), ), array( 'methods' => WP_REST_Server::READABLE, 'permission_callback' => array( 'Akismet_REST_API', 'privileged_permission_callback' ), 'callback' => array( 'Akismet_REST_API', 'get_stats' ), ) ) ); register_rest_route( 'akismet/v1', '/alert', array( array( 'methods' => WP_REST_Server::READABLE, 'permission_callback' => array( 'Akismet_REST_API', 'remote_call_permission_callback' ), 'callback' => array( 'Akismet_REST_API', 'get_alert' ), 'args' => array( 'key' => array( 'required' => false, 'type' => 'string', 'sanitize_callback' => array( 'Akismet_REST_API', 'sanitize_key' ), 'description' => __( 'A 12-character Akismet API key. Available at akismet.com/get/', 'akismet' ), ), ), ), array( 'methods' => WP_REST_Server::EDITABLE, 'permission_callback' => array( 'Akismet_REST_API', 'remote_call_permission_callback' ), 'callback' => array( 'Akismet_REST_API', 'set_alert' ), 'args' => array( 'key' => array( 'required' => false, 'type' => 'string', 'sanitize_callback' => array( 'Akismet_REST_API', 'sanitize_key' ), 'description' => __( 'A 12-character Akismet API key. Available at akismet.com/get/', 'akismet' ), ), ), ), array( 'methods' => WP_REST_Server::DELETABLE, 'permission_callback' => array( 'Akismet_REST_API', 'remote_call_permission_callback' ), 'callback' => array( 'Akismet_REST_API', 'delete_alert' ), 'args' => array( 'key' => array( 'required' => false, 'type' => 'string', 'sanitize_callback' => array( 'Akismet_REST_API', 'sanitize_key' ), 'description' => __( 'A 12-character Akismet API key. Available at akismet.com/get/', 'akismet' ), ), ), ) ) ); } /** * Get the current Akismet API key. * * @param WP_REST_Request $request * @return WP_Error|WP_REST_Response */ public static function get_key( $request = null ) { return rest_ensure_response( Akismet::get_api_key() ); } /** * Set the API key, if possible. * * @param WP_REST_Request $request * @return WP_Error|WP_REST_Response */ public static function set_key( $request ) { if ( defined( 'WPCOM_API_KEY' ) ) { return rest_ensure_response( new WP_Error( 'hardcoded_key', __( 'This site\'s API key is hardcoded and cannot be changed via the API.', 'akismet' ), array( 'status'=> 409 ) ) ); } $new_api_key = $request->get_param( 'key' ); if ( ! self::key_is_valid( $new_api_key ) ) { return rest_ensure_response( new WP_Error( 'invalid_key', __( 'The value provided is not a valid and registered API key.', 'akismet' ), array( 'status' => 400 ) ) ); } update_option( 'wordpress_api_key', $new_api_key ); return self::get_key(); } /** * Unset the API key, if possible. * * @param WP_REST_Request $request * @return WP_Error|WP_REST_Response */ public static function delete_key( $request ) { if ( defined( 'WPCOM_API_KEY' ) ) { return rest_ensure_response( new WP_Error( 'hardcoded_key', __( 'This site\'s API key is hardcoded and cannot be deleted.', 'akismet' ), array( 'status'=> 409 ) ) ); } delete_option( 'wordpress_api_key' ); return rest_ensure_response( true ); } /** * Get the Akismet settings. * * @param WP_REST_Request $request * @return WP_Error|WP_REST_Response */ public static function get_settings( $request = null ) { return rest_ensure_response( array( 'akismet_strictness' => ( get_option( 'akismet_strictness', '1' ) === '1' ), 'akismet_show_user_comments_approved' => ( get_option( 'akismet_show_user_comments_approved', '1' ) === '1' ), ) ); } /** * Update the Akismet settings. * * @param WP_REST_Request $request * @return WP_Error|WP_REST_Response */ public static function set_boolean_settings( $request ) { foreach ( array( 'akismet_strictness', 'akismet_show_user_comments_approved', ) as $setting_key ) { $setting_value = $request->get_param( $setting_key ); if ( is_null( $setting_value ) ) { // This setting was not specified. continue; } // From 4.7+, WP core will ensure that these are always boolean // values because they are registered with 'type' => 'boolean', // but we need to do this ourselves for prior versions. $setting_value = Akismet_REST_API::parse_boolean( $setting_value ); update_option( $setting_key, $setting_value ? '1' : '0' ); } return self::get_settings(); } /** * Parse a numeric or string boolean value into a boolean. * * @param mixed $value The value to convert into a boolean. * @return bool The converted value. */ public static function parse_boolean( $value ) { switch ( $value ) { case true: case 'true': case '1': case 1: return true; case false: case 'false': case '0': case 0: return false; default: return (bool) $value; } } /** * Get the Akismet stats for a given time period. * * Possible `interval` values: * - all * - 60-days * - 6-months * * @param WP_REST_Request $request * @return WP_Error|WP_REST_Response */ public static function get_stats( $request ) { $api_key = Akismet::get_api_key(); $interval = $request->get_param( 'interval' ); $stat_totals = array(); $response = Akismet::http_post( Akismet::build_query( array( 'blog' => get_option( 'home' ), 'key' => $api_key, 'from' => $interval ) ), 'get-stats' ); if ( ! empty( $response[1] ) ) { $stat_totals[$interval] = json_decode( $response[1] ); } return rest_ensure_response( $stat_totals ); } /** * Get the current alert code and message. Alert codes are used to notify the site owner * if there's a problem, like a connection issue between their site and the Akismet API, * invalid requests being sent, etc. * * @param WP_REST_Request $request * @return WP_Error|WP_REST_Response */ public static function get_alert( $request ) { return rest_ensure_response( array( 'code' => get_option( 'akismet_alert_code' ), 'message' => get_option( 'akismet_alert_msg' ), ) ); } /** * Update the current alert code and message by triggering a call to the Akismet server. * * @param WP_REST_Request $request * @return WP_Error|WP_REST_Response */ public static function set_alert( $request ) { delete_option( 'akismet_alert_code' ); delete_option( 'akismet_alert_msg' ); // Make a request so the most recent alert code and message are retrieved. Akismet::verify_key( Akismet::get_api_key() ); return self::get_alert( $request ); } /** * Clear the current alert code and message. * * @param WP_REST_Request $request * @return WP_Error|WP_REST_Response */ public static function delete_alert( $request ) { delete_option( 'akismet_alert_code' ); delete_option( 'akismet_alert_msg' ); return self::get_alert( $request ); } private static function key_is_valid( $key ) { $response = Akismet::http_post( Akismet::build_query( array( 'key' => $key, 'blog' => get_option( 'home' ) ) ), 'verify-key' ); if ( $response[1] == 'valid' ) { return true; } return false; } public static function privileged_permission_callback() { return current_user_can( 'manage_options' ); } /** * For calls that Akismet.com makes to the site to clear outdated alert codes, use the API key for authorization. */ public static function remote_call_permission_callback( $request ) { $local_key = Akismet::get_api_key(); return $local_key && ( strtolower( $request->get_param( 'key' ) ) === strtolower( $local_key ) ); } public static function sanitize_interval( $interval, $request, $param ) { $interval = trim( $interval ); $valid_intervals = array( '60-days', '6-months', 'all', ); if ( ! in_array( $interval, $valid_intervals ) ) { $interval = 'all'; } return $interval; } public static function sanitize_key( $key, $request, $param ) { return trim( $key ); } } /** * Twenty Twenty-Five functions and definitions. * * @link https://developer.wordpress.org/themes/basics/theme-functions/ * * @package WordPress * @subpackage Twenty_Twenty_Five * @since Twenty Twenty-Five 1.0 */ if ( ! function_exists( 'twentytwentyfive_post_format_setup' ) ) : /** * Adds theme support for post formats. * * @since Twenty Twenty-Five 1.0 * * @return void */ function twentytwentyfive_post_format_setup() { add_theme_support( 'post-formats', array( 'aside', 'audio', 'chat', 'gallery', 'image', 'link', 'quote', 'status', 'video' ) ); } endif; add_action( 'after_setup_theme', 'twentytwentyfive_post_format_setup' ); if ( ! function_exists( 'twentytwentyfive_editor_style' ) ) : /** * Enqueues editor-style.css in the editors. * * @since Twenty Twenty-Five 1.0 * * @return void */ function twentytwentyfive_editor_style() { add_editor_style( 'assets/css/editor-style.css' ); } endif; add_action( 'after_setup_theme', 'twentytwentyfive_editor_style' ); if ( ! function_exists( 'twentytwentyfive_enqueue_styles' ) ) : /** * Enqueues the theme stylesheet on the front. * * @since Twenty Twenty-Five 1.0 * * @return void */ function twentytwentyfive_enqueue_styles() { $suffix = SCRIPT_DEBUG ? '' : '.min'; $src = 'style' . $suffix . '.css'; wp_enqueue_style( 'twentytwentyfive-style', get_parent_theme_file_uri( $src ), array(), wp_get_theme()->get( 'Version' ) ); wp_style_add_data( 'twentytwentyfive-style', 'path', get_parent_theme_file_path( $src ) ); } endif; add_action( 'wp_enqueue_scripts', 'twentytwentyfive_enqueue_styles' ); if ( ! function_exists( 'twentytwentyfive_block_styles' ) ) : /** * Registers custom block styles. * * @since Twenty Twenty-Five 1.0 * * @return void */ function twentytwentyfive_block_styles() { register_block_style( 'core/list', array( 'name' => 'checkmark-list', 'label' => __( 'Checkmark', 'twentytwentyfive' ), 'inline_style' => ' ul.is-style-checkmark-list { list-style-type: "\2713"; } ul.is-style-checkmark-list li { padding-inline-start: 1ch; }', ) ); } endif; add_action( 'init', 'twentytwentyfive_block_styles' ); if ( ! function_exists( 'twentytwentyfive_pattern_categories' ) ) : /** * Registers pattern categories. * * @since Twenty Twenty-Five 1.0 * * @return void */ function twentytwentyfive_pattern_categories() { register_block_pattern_category( 'twentytwentyfive_page', array( 'label' => __( 'Pages', 'twentytwentyfive' ), 'description' => __( 'A collection of full page layouts.', 'twentytwentyfive' ), ) ); register_block_pattern_category( 'twentytwentyfive_post-format', array( 'label' => __( 'Post formats', 'twentytwentyfive' ), 'description' => __( 'A collection of post format patterns.', 'twentytwentyfive' ), ) ); } endif; add_action( 'init', 'twentytwentyfive_pattern_categories' ); if ( ! function_exists( 'twentytwentyfive_register_block_bindings' ) ) : /** * Registers the post format block binding source. * * @since Twenty Twenty-Five 1.0 * * @return void */ function twentytwentyfive_register_block_bindings() { register_block_bindings_source( 'twentytwentyfive/format', array( 'label' => _x( 'Post format name', 'Label for the block binding placeholder in the editor', 'twentytwentyfive' ), 'get_value_callback' => 'twentytwentyfive_format_binding', ) ); } endif; add_action( 'init', 'twentytwentyfive_register_block_bindings' ); if ( ! function_exists( 'twentytwentyfive_format_binding' ) ) : /** * Callback function for the post format name block binding source. * * @since Twenty Twenty-Five 1.0 * * @return string|void Post format name, or nothing if the format is 'standard'. */ function twentytwentyfive_format_binding() { $post_format_slug = get_post_format(); if ( $post_format_slug && 'standard' !== $post_format_slug ) { return get_post_format_string( $post_format_slug ); } } endif; Tuan – Page 5 – Five F's of Life

Author: Tuan

  • Random Act of Kindness

    3 Things I am happy about:

    1. Happy I met some new people at JAST
    2. Figured out how to transfer movies finally in iTunes
    3. Follow through on the random act of kindness

    I received this tag on facebook from a friend of my mine concerning “The Happy Secret to Better Work”

    “my friend, Tuan Ta, sent this to me, because he is the best… and i wouldn’t live my life any other way.”

    I sent her the post yesterday because I thought she would appreciate it. She did!

    I am truly getting the benefits of trying the process. I was able to focus more than ever on work and yet get other stuff done too. I struggle a little bit with the random act of kindness portion, but I found at least two. One was just praying for a friend’s problem with another friend and buying a drink for a friend.

  • I am going to find a Happy Place…

    3 + 1 Things I am Happy About:

    1. I stumble upon Katie Melua on youtube. Her voice simply amazing!
    2. I am happy I started my homework early.
    3. I am happy to find out other people want to try my social “Better Work” Social Experiment with me
    4. I am happy I had soda for more than 3 weeks!

    I have posted a video “Happy Place” by Katie Melua … just listen =)


  • Holding Yourself for Accountable for Success

    I have decided to start off all of my blogs with at least three things I am joyful about that happen to me in a day.
    1. I am thankful that I was able to donate can foods at Stretch’s Superbowl Party.
    2. I appreciate a Costco employee taking time putting air in wheels.
    3. I am happy I can afford to replace my Ipad 2 screen I broke yesterday.

    For today’s blog…
    I have posted on my facebook a challenge to my friends, to join me in “The Happy Secret to  Better Work” . I have received some initial takers, but we will see how many will take the challenge.

    I found this article today:

    “Smiling is good for you – and an area of scientific study by some seriously smart researchers”

     http://www.mercurynews.com/bay-area-news/ci_19898741?source=rss

    Seems like we should try to at least smile once a day =)

     

  • Money and Happiness

    I was in my Managerial Finance class today and had a discussion about Money and Happiness

    There is data that indicates we do get some level of happiness with money; however, if you carefully close on the graph you will notice Denmark is happier than the US, but with less GDP per capital. Hmmm…

    Money does not bring or create happiness. You need to be joyful inside without the desire to seek money only.

    Read the full article here.

  • The happy secret to better work + Flashmob

    It’s been a whole year since I posted something on the blog. I have been busy with work and school. But I wanted to post something because I am helping a friend fund raise in Africa.  Please donate if you can!

    I watched this TED video concerning happiness. I think Shawn is on to something…

    I am going to try to work on long lasting positive change…

     

  • Half Marathon

    Today I ran 3 miles. It’s been awhile, but I am training again for the half marathon. It’s a lot harder this year simply because I am not as focus, but part of life is always sacrificing time now in order to have time later. But keep in mind to balance this otherwise you will mess up the order.

    As Nike would say it….Just Do It….

    13.4 miles is a typical trip driving to work….you spend 20 minutes a day on it….why not ride a bike if you can?

  • Dedication to the beginning of 2011 and Friends

    It’s been over a month since my last blog. It’s a great start to a New Year because with a
    New Year brings a new start. A new start with hope and goals that you can do what you
    should have done last year. I believe this year I need to continue balance seeing friends
    and family.

    I will be turning 30 this year and it’s suppose to be a big milestone in our lives. But to me it’s just another number and another opportunity to spend with friends. we always make a big deal about it, but why can’t we just simply celebrate it? Maybe it will be a bigger party, but nevertheless it’s simple a milestones in our lives.

    It’s always the people you meet and the books you read that will make the most difference. This year I plan to make more new people whom I can influence and they can influence me.

    I am still challenge by my friends, especially my old college roommate Darius. He is always challenging me to get the financial stuff done. I do it because he reminds me.

  • Happy Holidays 2010

    Holidays are best time to catch up with family and friends. It’s one part of the year that brings out the very best of people and the very worst. For example, while shopping in a typical mall, people are always fighting for a closer parking spot. Do you really need to be that much closer? Couldn’t we all used a little more exercise to help us loose in America?Then again, we live in a world that we place value on buying gifts above all else in order to show we care for people we love. But is that what really matters?

    It’s great that people give during the holidays, but that excuses from not giving throughout the year? I hope not, because there are many many people out there who needs our help beyond the simple gift giving we embark once a year. Could we not create a fund or teach people a new skill?

    I feel challenge every year with this epidemic ‘giving’ of materials goods. However, if it brings you closer to your friends and family why not? I think at the end of the day the most important thing is that you do make time even with all the traffic and craziness that is out there.

    I feel really thankful for the upcoming New Year because there is hope for a better year. I have friends that will be getting married, having babies, and who knows what else? Time is short… go spend time with your family/friends, but remember it’s not always about a present, but perhaps the action is just as valuable as a gift.

    Some ideas…
    -Enjoy coffee with your friends
    -Take your family out for dinner
    -Buy gifts that your family needs….I bought my mom a new dresser
    -Look for the best deals, but don’t buy to just buy

    Something happy to see….

    Happy Holiday Tunes….

  • Odyssey Dinner – Helping the Homeless in Nashville

    I went to volunteer after work today downtown for the homeless shelter.  They have a program called Odyssey [program to help the homeless get back on their feet]. I admit I wish I can do more than just donate my time and some drinks tonight. But what exactly can one do?

    At the dinner, all the people at the dinner [including volunteers], gave their high’s and low’s for the week. It was really touching to hear everyone describe their situations.  Mine was about how I got a chance to spend it with family and friends.  Of course, their testimony were truly inspiring because they were grateful for the simple things in life.  Someone saw their grand daughter for the first time in awhile. We also got a chance to celebrate two birthdays.

    One of the homeless named Mark asked if the economy was getting better. I paused because I had a dilemma. The economy through conventional definition was better, but for individuals it was the same. What to tell him? I told him exactly how it was, but I don’t think he understood.  But what is there to understand, but simply “I am NOT doing OK even if the economy is OK.”

    In the end, I am glad to hear about programs like this to try to help the homeless get back on their feet. If they can find a job, anyone can with determination. They have the faith that it can happen….I believe we can too….

  • Black Friday 2010 @ ATL

    This year sales were crazy compared to last year. The crazy part is that they started on Thanksgiving Day!!! Is it just me or should people be off with their family and friends?

    I know some of us have traditions of waking up early  to look for the best deals, but are we pushing it too much now? I was tempted to join my friend go to Toys R Us, but ended up not going because I was at my 2nd Thnx Day Dinner (Turkey was great =)

    Of course, I participated in the mayhem of Black Friday. But I really couldn’t buy anything because simply I already ‘stuff’.  I couldn’t help notice everyone were still in a buying frenzy. There was someone foreign arguing with the manager over some item not having the right color. I didn’t stay, but I was surprise to see even foreigners know how are system works by escalating the issue to the “Manager”.

    What have notice in our society? We are still one of the most bless countries in the world. We fight over small things, but what about the big things of helping others? I found the best way is to start with the small things. For example, I bought toys that were on sale to donate unprivilege kids. The sad part, I won’t be able to see them open them up…

    Message today: Start small by doing something for someone even though you may never see the joy in their eyes..