{"id":19894589,"url":"https://github.com/amarkal/amarkal-widget","last_synced_at":"2026-05-09T22:04:13.372Z","repository":{"id":62488694,"uuid":"86005906","full_name":"amarkal/amarkal-widget","owner":"amarkal","description":"Develop WordPress widgets based on Amarkal UI","archived":false,"fork":false,"pushed_at":"2017-12-25T21:29:41.000Z","size":23,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-12T00:04:52.252Z","etag":null,"topics":["amarkal","wodpress","wordpress-framework"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/amarkal.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-23T23:07:18.000Z","updated_at":"2022-09-20T07:08:27.000Z","dependencies_parsed_at":"2022-11-02T09:31:09.430Z","dependency_job_id":null,"html_url":"https://github.com/amarkal/amarkal-widget","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amarkal%2Famarkal-widget","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amarkal%2Famarkal-widget/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amarkal%2Famarkal-widget/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amarkal%2Famarkal-widget/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/amarkal","download_url":"https://codeload.github.com/amarkal/amarkal-widget/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241322532,"owners_count":19944073,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["amarkal","wodpress","wordpress-framework"],"created_at":"2024-11-12T18:33:55.898Z","updated_at":"2026-05-09T22:04:13.293Z","avatar_url":"https://github.com/amarkal.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# amarkal-widget [![Build Status](https://scrutinizer-ci.com/g/amarkal/amarkal-widget/badges/build.png?b=master)](https://scrutinizer-ci.com/g/amarkal/amarkal-widget/build-status/master) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/amarkal/amarkal-widget/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/amarkal/amarkal-widget/?branch=master) [![License](https://img.shields.io/badge/license-GPL--3.0%2B-red.svg)](https://raw.githubusercontent.com/amarkal/amarkal-widget/master/LICENSE)\nDevelop WordPress widgets based on Amarkal UI.\n\n**Tested up to:** WordPress 4.7  \n**Dependencies**: *[amarkal-ui](https://github.com/amarkal/amarkal-ui)*\n\n![amarkal-widget](https://askupasoftware.com/wp-content/uploads/2015/04/amarkal-widget.png)\n\n## Overview\n**amarkal-widget** lets you develop widgets for your WordPress theme or plugin, using [amarkal-ui](https://github.com/amarkal/amarkal-ui). **amarkal-widget** takes care of building the admin user form and saving the user input, so you can concentrate on building the widget itself!\n\n## Installation\n\n### Via Composer\n\nIf you are using the command line:  \n```\n$ composer require askupa-software/amarkal-widget:dev-master\n```\n\nOr simply add the following to your `composer.json` file:\n```javascript\n\"require\": {\n    \"askupa-software/amarkal-widget\": \"dev-master\"\n}\n```\nAnd run the command \n```\n$ composer install\n```\n\nThis will install the package in the directory `vendors/askupa-software/amarkal-widget`.\nNow all you need to do is include the composer autoloader.\n\n```php\nrequire_once 'path/to/vendor/autoload.php';\n```\n\n### Manually\n\nDownload [amarkal-ui](https://github.com/amarkal/amarkal-ui/archive/master.zip) and [amarkal-widget](https://github.com/amarkal/amarkal-widget/archive/master.zip) from github and include them in your project.\n\n```php\nrequire_once 'path/to/amarkal-ui/bootstrap.php';\nrequire_once 'path/to/amarkal-widget/bootstrap.php';\n```\n\n## Usage\n\nCreate a class that inherits from `\\Amarkal\\Widget\\AbstractWidget`. This class should implement 2 methods:\n\n * `config()` - a public function that returns an array with the widget's configuration.\n * `widget( $args, $instance )` - a public function that prints the widget's front-end HTML.\n \n ### Configuration Arguments\n \nName | Type | Default | Required | Description\n---|---|---|:---:|---\n`id`|*string*|`''`|Yes|Specifies the widget's id.\n`name`|*string*|`''`|Yes|Specifies the widget's name.\n`widget_options`|*array*|`array()`|No|Specifies a list of widget options, like a description.\n`control_options`|*array*|`array()`|No|Specifies a list of widget control options.\n`fields`|*array*|`array()`|No|Specifies a list of `amarkal-ui` components to be used for the widget's admin form. Each item in this array should be an array and have the original UI component arguments as specified in `amarkal-ui`, as well as the following: `default`, `title`, `description`.\n\n### Example Code\n\nCreate a class for your widget:\n\n```php\nclass MyCoolWidget \nextends \\Amarkal\\Widget\\AbstractWidget\n{   \n    /**\n     * The widget's configuration\n     */\n    public function config()\n    {\n        return array(\n            'id'              =\u003e 'm-cool-widget',   // The widget's id\n            'name'            =\u003e 'My Cool Widget',  // The widget's id\n            'widget_options'  =\u003e array(\n                'description' =\u003e 'Just a very very cool widget...'  // The widget's description\n            ),\n            'control_options' =\u003e array(),           // Optional\n            \n            /**\n             * The 'fields' argument specifies a list of amarkal-ui components to be used for the widget's admin form.\n             */\n            'fields'          =\u003e array(\n                array(\n                    'name'          =\u003e 'title',\n                    'title'         =\u003e __( 'Title:', 'slug' ),\n                    'default'       =\u003e 'My Cool Widget',\n                    'description'   =\u003e 'Specifies the widget\\'s title',\n                    'type'          =\u003e 'text'\n                ),\n                array(\n                    'name'          =\u003e 'content',\n                    'title'         =\u003e __( 'Text:', 'slug' ),\n                    'default'       =\u003e 'My cool widget content',\n                    'description'   =\u003e 'Specifies the widget\\'s content',\n                    'type'          =\u003e 'text'\n                ),\n            )\n        );\n    }\n    \n    /**\n     * The front-end display of widget. User data is accesible through the $instance variable.\n     */\n    public function widget( $args, $instance ) \n    {\n        $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this-\u003eid_base );        \n        \n        echo $args['before_widget'];\n        \n        // Echo the widget's title if not empty\n        if ( $title ) {\n            echo $args['before_title'] . $title . $args['after_title'];\n        }\n        \n        // Echo the widget's content if not empty\n        if( $instance['content'] ) {\n            echo '\u003cp\u003e'.$instance['content'].'\u003c/p\u003e';\n        }\n        \n        echo $args['after_widget'];\n    }\n}\n```\n\nThen register the widget as you would register any other widget:\n\n```php\nfunction register_widgets() {\n    register_widget( 'MyCoolWidget' );\n}\nadd_action( 'widgets_init', 'register_widgets' );\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famarkal%2Famarkal-widget","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famarkal%2Famarkal-widget","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famarkal%2Famarkal-widget/lists"}