/** * Print the content for the modal * * @uses "admin_footer" * * @since 1.1.0 */ public static function modal() { $screen = get_current_screen(); if ($screen->base === 'post') { $groups = group::get_items(['type' => 'click']); echo admin::get_partial('shortcode-modal.php', ['groups' => $groups]); } }
/** * Get groups * * @since 0.4.0 * * @param \WP_REST_Request $request Full data about the request. * @return \WP_Error|\WP_REST_Response */ public function get_items($request) { $args = array('page' => $request->get_param('page'), 'limit' => $request->get_param('limit'), 'type' => $request->get_param('type')); $groups = group::get_items($args); if (!empty($groups)) { foreach ($groups as $i => $group) { if (is_array($group)) { $groups[$i] = $this->prepare_group($group, $request->get_param('context')); } } } return ingot_rest_response($groups, 200, (int) group::total()); }
/** * Test that when we ask for too high of a page, we get nothing back * * @since 0.0.7 * * @group crud * @group group * @group group_crud * * @covers \ingot\testing\crud\group::get_items() */ public function testGetItemsPaginationTooHigh() { \ingot\testing\crud\group::delete('all'); for ($i = 1; $i <= 11; $i++) { $params = array('name' => $i, 'type' => 'click', 'sub_type' => 'button', 'meta' => ['link' => 'https://bats.com']); $created[$i] = \ingot\testing\crud\group::create($params); } $params = array('limit' => 5, 'page' => 4); $items = \ingot\testing\crud\group::get_items($params); $this->assertEmpty($items); }
/** * Test that when we can create price tests properly * * @since 0.4.0 * * @group crud * @group group * @group group_crud * @group price * * @covers \ingot\testing\crud\group::get_items() */ public function testQueryByType() { $data = ingot_test_data_price::edd_tests(); ingot_tests_make_groups(false, 11, 1); $data = ingot_test_data_price::edd_tests(); $group_id = $data['group_ID']; $items = \ingot\testing\crud\group::get_items(['type' => 'price', 'limit' => 5]); $this->assertTrue(is_array($items)); $this->assertNotEmpty($items); $this->assertSame(2, count($items)); foreach ($items as $item) { $this->assertEquals('price', $item['type']); } }