Skip to content

Commit

Permalink
Merge pull request #931 from khromov/log-acf-options
Browse files Browse the repository at this point in the history
Add support for ACF Options pages
  • Loading branch information
lukecarbis authored Sep 7, 2017
2 parents 98554f1 + 950f83a commit 768e39b
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions connectors/class-connector-acf.php
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,9 @@ public function check_meta_values( $type, $action, $meta_id, $object_id, $key, $
list( , $taxonomy, $term_id, $key ) = $matches; // Skips 0 index

$object_key = $taxonomy . '_' . $term_id;
} elseif ( 'option' === $type ) {
$object_key = 'options';
$key = preg_replace( '/^options_/', '', $key );
}

if ( isset( $this->cached_field_values_updates[ $object_key ][ $key ] ) ) {
Expand All @@ -385,6 +388,9 @@ public function check_meta_values( $type, $action, $meta_id, $object_id, $key, $
$title = $term->name;
$tax_obj = get_taxonomy( $taxonomy );
$type_name = strtolower( get_taxonomy_labels( $tax_obj )->singular_name );
} elseif ( 'option' === $type ) {
$title = 'settings page';
$type_name = 'option';
} else {
return false;
}
Expand Down Expand Up @@ -517,7 +523,7 @@ public function callback_pre_post_update( $post_id, $data ) {
* @param string $value Option value
*/
public function callback_added_option( $key, $value ) {
$this->check_meta_values( 'taxonomy', 'added', null, null, $key, $value );
$this->check_meta_values( self::get_saved_option_type( $key ), 'added', null, null, $key, $value );
}

/**
Expand All @@ -529,7 +535,7 @@ public function callback_added_option( $key, $value ) {
*/
public function callback_updated_option( $key, $old, $value ) {
unset( $old );
$this->check_meta_values( 'taxonomy', 'updated', null, null, $key, $value );
$this->check_meta_values( self::get_saved_option_type( $key ), 'updated', null, null, $key, $value );
}

/**
Expand All @@ -538,6 +544,16 @@ public function callback_updated_option( $key, $old, $value ) {
* @param $key
*/
public function callback_deleted_option( $key ) {
$this->check_meta_values( 'taxonomy', 'deleted', null, null, $key, null );
$this->check_meta_values( self::get_saved_option_type( $key ), 'deleted', null, null, $key, null );
}

/**
* Determines the type of option that is saved
*
* @param $key
* @return string
*/
private function get_saved_option_type( $key ) {
return substr( $key,0, 8 ) === 'options_' ? 'option' : 'taxonomy';
}
}

0 comments on commit 768e39b

Please sign in to comment.