| @@ 117-136 (lines=20) @@ | ||
| 114 | * |
|
| 115 | * @return array "message" key has the message. |
|
| 116 | */ |
|
| 117 | public function update( $data ) { |
|
| 118 | ||
| 119 | $options = isset( $data['fields'] ) ? $data['fields'] : false; |
|
| 120 | $postid = !empty( $options ) ? (int) $options['id'] : false; |
|
| 121 | $gallery_ids = isset( $data['gallery_ids'] ) ? $data['gallery_ids'] : false; |
|
| 122 | if ( ! empty( $data ) && $data[ 'gallery_type' ] ) { |
|
| 123 | $type = $data[ 'gallery_type' ]; |
|
| 124 | }elseif ( ! empty( $options ) && $options[ 'galleryType' ] ) { |
|
| 125 | $type = $options[ 'galleryType' ]; |
|
| 126 | }else{ |
|
| 127 | $type = false; |
|
| 128 | } |
|
| 129 | ||
| 130 | save_gallery::save_gallery_options( $postid, $gallery_ids, $options, $type ); |
|
| 131 | ||
| 132 | return array( |
|
| 133 | 'message' => 'gallery-updated' |
|
| 134 | ); |
|
| 135 | ||
| 136 | } |
|
| 137 | ||
| 138 | /** |
|
| 139 | * When the user clicks the settings icon in the gallery component it |
|
| @@ 727-746 (lines=20) @@ | ||
| 724 | exit; |
|
| 725 | } |
|
| 726 | ||
| 727 | public function update_gallery( ) { |
|
| 728 | ||
| 729 | $options = isset( $_POST['fields'] ) ? $_POST['fields'] : false; |
|
| 730 | ||
| 731 | $postid = !empty( $options ) ? (int) $options['id'] : false; |
|
| 732 | $gallery_ids = isset( $_POST['gallery_ids'] ) ? $_POST['gallery_ids'] : false; |
|
| 733 | if ( $_POST[ 'gallery_type' ] ) { |
|
| 734 | $type = $_POST[ 'gallery_type' ]; |
|
| 735 | }elseif ( ! empty( $options ) && $options[ 'galleryType' ] ) { |
|
| 736 | $type = $options[ 'galleryType' ]; |
|
| 737 | }else{ |
|
| 738 | $type = false; |
|
| 739 | } |
|
| 740 | ||
| 741 | self::save_gallery_options( $postid, $gallery_ids, $options, $type ); |
|
| 742 | ||
| 743 | echo json_encode( array('message' => 'gallery-updated') ); |
|
| 744 | ||
| 745 | exit; |
|
| 746 | } |
|
| 747 | ||
| 748 | public function save_gallery_options( $postid, $gallery_ids, $options, $type = false ) { |
|
| 749 | ||