| @@ 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 |
|
| @@ 659-678 (lines=20) @@ | ||
| 656 | exit; |
|
| 657 | } |
|
| 658 | ||
| 659 | public function update_gallery( ) { |
|
| 660 | ||
| 661 | $options = isset( $_POST['fields'] ) ? $_POST['fields'] : false; |
|
| 662 | ||
| 663 | $postid = !empty( $options ) ? (int) $options['id'] : false; |
|
| 664 | $gallery_ids = isset( $_POST['gallery_ids'] ) ? $_POST['gallery_ids'] : false; |
|
| 665 | if ( $_POST[ 'gallery_type' ] ) { |
|
| 666 | $type = $_POST[ 'gallery_type' ]; |
|
| 667 | }elseif ( ! empty( $options ) && $options[ 'galleryType' ] ) { |
|
| 668 | $type = $options[ 'galleryType' ]; |
|
| 669 | }else{ |
|
| 670 | $type = false; |
|
| 671 | } |
|
| 672 | ||
| 673 | self::save_gallery_options( $postid, $gallery_ids, $options, $type ); |
|
| 674 | ||
| 675 | echo json_encode( array('message' => 'gallery-updated') ); |
|
| 676 | ||
| 677 | exit; |
|
| 678 | } |
|
| 679 | ||
| 680 | public function save_gallery_options( $postid, $gallery_ids, $options, $type = false ) { |
|
| 681 | ||