Download the PHP package sitecrafting/sitka-insights-wordpress without Composer

On this page you can find all versions of the php package sitecrafting/sitka-insights-wordpress. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package sitka-insights-wordpress

Sitka Insights for WordPress

Travis CI build status

Integrate your WordPress site seamlessly with the Sitka Insights suite.

Installation

Installing Manually

Go to the GitHub releases page and download the .zip archive of the latest release. Make sure you download the release archive, not the source code archive. For example, if the latest release is called v2.x.x, click the download link that says sitka-insights-v2.x.x.zip. (You can also use the tar.gz archive if you want - they are the same code.)

Once downloaded and unzipped, place the extracted directory in wp-content/plugins. Activate the plugin from the WP Admin as you normally would.

Installing via Composer

Add the requirement to your composer.json:

NOTE: if you are tracking your WordPress codebase as one big monorepo, the --prefer-dist flag is important! It tells Composer to find and download the .zip archive instead of the full Git repository. Without this flag, it will create the plugin directory as a Git submodule and strange things will happen.

Usage

Getting Started

After installing and activating the plugin, go to the Sitka Insights section of the WP Admin. Enter your API Key, Collection ID, and Base URI as provided by Sitka. All settings are required.

Search

With Sitka Insights, you can override the default WordPress search functionality, which is extremely limited by default, with results from the ElasticSearch crawler that powers Sitka Search. To do this you must first enter your settings as described above, in Getting Started.

Once you've entered your Sitka Insights settings, but before enabling overriding WordPress search globally, you can test from the command line to see if you get results. To do this, run wp sitka search <search term>. You should see a JSON object like this:

Once you've entered the settings above correctly, you're ready to enable Sitka Insights Search to override the default WP search. Enable the option Override default WordPress search and save the settings again. You should now see a basic search results page rendered by Sitka Insights whenever you perform a search.

Search Shortcode

Out of the box, you can use the [sitka_search] shortcode in any RTE that supports shortcodes. This is the recommended approach for most cases.

However, basic searches (using WordPress's standard s query param), will still render your theme's default search.php template (assuming there is one). You can redirect global searches to the page your shortcode lives on in the Settings. Go to Settings > Sitka Insights and select Redirect searches to a specific page. Type the URI, e.g. /search, in the text box that appears.

Save your changes and you're good to go! Default searches will now redirect to your page. Note that all query string parameters will be preserved except s, which will be renamed to sitka_search to avoid conflicting with WordPress's default functionality.

Using the Sitka WordPress API directly

If you want a bit more control, you can use the provided WordPress API directly. Place something like the following in your theme at search.php:

For more custom behavior, you can pass params directly to Sitka\search():

Theme overrides

When rendering frontend code, such as markup for search results, Sitka checks the root directory of your theme (where your style.css lives) for a special sitka-insights folder. If a given file, for example search-result.php, exists within this folder, Sitka renders that version instead. Otherwise, it renders its own default implementation.

Sitka works out of the box without any theme overrides, but if you need to customize the markup rendered, this is how to do it.

There are currently three frontend files you can override from your theme:

When you do this, Sitka will require your theme file, setting a variable called $data which is an array of all the data available to you inside your override template. This will vary between templates.

Pagination

Sitka implements its own logic for paginating results that, unlike the core paginate_links() function, is not coupled to WordPress's internal query logic. In fact, it is much simpler to use than the built-in WordPress function.

Here is the default return value (not echoed output) of the function when there are ten pages of results (and the user is on page 1):

Customizing pagination markup

You can override this markup using a standard Theme Override (see the previous section about this).

Here is the default implementation:

$paginator is an object that implements most of the complex logic for which prev/next/number links, or "markers," should be displayed. Note that almost all the information you need about each marker lives inside the marker array itself.

Crucially, remember to always pass the $url_params array to the Paginator methods page_markers(), previous_page_url() and next_page_url(). Otherwise your links will be wrong.

Here's an example markers array, returned when we're on page 4 of the results, with 25 total pages:

Customizing pagination parameters

If the template markup is fine but you need to affect the pagination logic itself, you probably want the sitka/pagination/construct filter, so named because it controls the array passed to the Sitka\Plugin\Paginator::__construct method. This hook can be used to customize things like:

Here's an example of overriding the number adjacent pages rendered:

Search Autocomplete

In addition to providing superior search results, Sitka Insights also adds search autocomplete to your search template out of the box. You don't need to do anything to make this work, although you may want to override the default jquery-ui-autocomplete styles.

The only assumption this module makes about your HTML is that the search input can be found at the selector form [name="s"], i.e. a form element whose name attribute is "s". Because of how WordPress search is implemented, this assumption will hold true unless your search functionality is overriding WordPress core in an advanced way.

For the curious, this feature works by registering a custom WP REST route at /wp-json/sitka/v2/completions and telling jquery-ui-autocomplete to grab its autocomplete suggestions from that route.

WP-CLI Custom Commands

The plugin implements WP-CLI commands for major Sitka Insights REST endpoints, such as search:

This will automatically use the credentials you've configured in the plugin settings.

Run wp sitka --help to list subcommands.

As with other WordPress options, you can configure the plugin options with wp option:

Development

To build a new release, choose the Git tag name and run:

This will create a .tar.gz and a .zip archive which you can upload to a new release on GitHub.

If you have hub installed, the script will detect it and prompt you to optionally create a GitHub release directly.


All versions of sitka-insights-wordpress with dependencies

PHP Build Version
Package Version
Requires php Version >=7.3
composer/installers Version ~1.0
sitecrafting/gearlab-tools-php Version ^3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package sitecrafting/sitka-insights-wordpress contains the following files

Loading the files please wait ....