From 6d51bb45ec71daba4682bd9291d60e90fc360f1c Mon Sep 17 00:00:00 2001 From: David Yahalomi Date: Tue, 8 Dec 2015 20:39:37 +0200 Subject: [PATCH 1/7] Added custom fields and hooks around actions code --- hookpress.php | 8 +++-- includes.php | 91 +++++++++++++++++++++++++++++++-------------------- readme.txt | 10 ++++-- services.php | 12 ++++--- 4 files changed, 76 insertions(+), 45 deletions(-) diff --git a/hookpress.php b/hookpress.php index 9cab3ee..6642bfc 100644 --- a/hookpress.php +++ b/hookpress.php @@ -3,14 +3,14 @@ Plugin Name: HookPress Plugin URI: http://mitcho.com/code/hookpress/ Description: HookPress turns all of your WordPress-internal hooks into webhooks. Possible uses include generating push notifications or using non-PHP web technology to extend WordPress. Read more about webhooks at the webhooks site. -Version: 1.14 +Version: 1.15 Author: mitcho (Michael Yoshitaka Erlewine) Author URI: http://mitcho.com/ Donate link: http://tinyurl.com/donatetomitcho */ define('HOOKPRESS_PRIORITY',12838790321); -$hookpress_version = "1.14"; +$hookpress_version = "1.15"; require('includes.php'); function hookpress_init() { @@ -21,9 +21,11 @@ function hookpress_init() { update_option('hookpress_version',$hookpress_version); add_action('admin_menu', 'hookpress_config_page'); + hookpress_register_hooks(); + } + add_action('init', 'hookpress_init'); -hookpress_register_hooks(); // register ajax service add_action('wp_ajax_hookpress_get_fields', 'hookpress_ajax_get_fields'); diff --git a/includes.php b/includes.php index 467b3d7..314623e 100644 --- a/includes.php +++ b/includes.php @@ -27,15 +27,23 @@ function hookpress_get_fields( $type ) { } // if it's a POST, we have a URL for it as well. - if ($type == 'POST' || $type == 'PARENT_POST') + if ($type == 'POST' || $type == 'PARENT_POST') { + $fields[] = 'post_url'; + $meta_keys = $wpdb->get_col("select distinct(meta_key) from $wpdb->postmeta"); + + $fields = array_merge($fields, $meta_keys); + } + if ($type == 'PARENT_POST') $fields = array_map(create_function('$x','return "parent_$x";'),$fields); if ($type == 'OLD_USER_OBJ') $fields = array_map(create_function('$x','return "old_$x";'),$fields); + $fields = apply_filters('hookpress_get_fields', $fields, $type); + return array_unique($fields); } @@ -43,12 +51,14 @@ function hookpress_print_edit_webhook( $id ){ ?> @@ -58,7 +68,7 @@ function hookpress_print_edit_webhook( $id ){ -
> +> >