/** * Adds a "Snapshot in Dashboard" link to the Toolbar when in Snapshot mode. * * @param \WP_Admin_Bar $wp_admin_bar WP_Admin_Bar instance. */ public function add_post_edit_screen_link($wp_admin_bar) { if (!$this->snapshot) { return; } $post = $this->snapshot->post(); if (!$post) { return; } $wp_admin_bar->add_menu(array('id' => 'inspect-customize-snapshot', 'title' => __('Inspect Snapshot', 'customize-snapshots'), 'href' => get_edit_post_link($post->ID, 'raw'), 'meta' => array('class' => 'ab-item ab-customize-snapshots-item'))); }
/** * Test that the snapshot object is passed as the second filter param. * * @see Customize_Snapshot::save() */ function test_filter_customize_snapshot_save() { $manager = new Customize_Snapshot_Manager($this->plugin); $manager->ensure_customize_manager(); $manager->init(); $snapshot = new Customize_Snapshot($manager, self::UUID); $that = $this; // For PHP 5.3. add_filter('customize_snapshot_save', function ($data, $test_snapshot) use($that) { $that->filtered_snapshot = $test_snapshot; return $data; }, 10, 2); $snapshot->save(array('uuid' => self::UUID, 'data' => array('foo' => array('value' => 'bar')))); $this->assertEquals($snapshot, $this->filtered_snapshot); }