Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Arcath committed Mar 2, 2021
0 parents commit cc95427
Show file tree
Hide file tree
Showing 5 changed files with 153 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
vendor/
20 changes: 20 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "ed-itsolutions/wp-fontawesome",
"description": "Simple easy to bundle font-awesome for WordPress",
"require": {
"php": "^5.3.3 || ^7.0",
"fortawesome/font-awesome": "^5.15"
},
"license": "MIT",
"authors": [
{
"name": "Adam Laycock",
"email": "[email protected]",
"homepage": "https://www.arcath.net",
"role": "Developer"
}
],
"autoload": {
"files": ["fontawesome.php"]
}
}
90 changes: 90 additions & 0 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions fontawesome.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
function wp_fontawesome_get_base_url(){
$base = get_template_directory_uri();

$parts = explode(get_template(), dirname(__FILE__));

$url = str_replace('\\', '/', $base . $parts[1]);

return $url;
}

function wp_fontawesome_register_font_awesome(){
$basePath = apply_filters('wp_fontawesome_base_url', wp_fontawesome_get_base_url());

wp_register_script(
'font-awesome',
$basePath . '/vendor/fortawesome/font-awesome/js/all.js',
array(),
'5.15.2',
true
);
}

add_action('init', 'wp_fontawesome_register_font_awesome');
18 changes: 18 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# WP-FontAwesome

WP-FontAwesome adds Font Awesome to WordPress form Composer.

The main reason for this is to help with dependencies. Instead of having Font Awesome bundled in both a theme and composer module this allows both to require a single module which by registering the styles/scripts itself means no overlap between multiple installs.

## Usage

```
composer require ed-itsolutions/wp-fontawesome
```

```php
//functions.php, in your wp_enqeue_scripts action:

wp_enqueue_script('font-awesome');
```

0 comments on commit cc95427

Please sign in to comment.