Skip to content

Commit

Permalink
Merge branch 'release/v1.1.12'
Browse files Browse the repository at this point in the history
  • Loading branch information
sourovroy committed Sep 1, 2020
2 parents b313bf8 + beed1ac commit c0d3dcc
Show file tree
Hide file tree
Showing 4 changed files with 161 additions and 134 deletions.
20 changes: 15 additions & 5 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,14 @@ Make sure you call this function directly, never use any action hook to call thi
## More Usage

Sometimes you wouldn't want to show the notice, or want to customize the notice message. You can do that as well.

```php
$client = new Appsero\Client( 'a4a8da5b-b419-4656-98e9-4a42e9044892', 'Twenty Twelve', __FILE__ );
```

#### 1. Hiding the notice

Sometimes you wouldn't want to show the notice, or want to customize the notice message. You can do that as well.

```php
$client->insights()
->hide_notice()
Expand Down Expand Up @@ -135,20 +135,30 @@ $client->insights()
->init();
```

or
Or if you want to run a query then pass callback, we will call the function when it is necessary.

```php
$metadata = function () {
$total_posts = wp_count_posts();

return array(
'key' => 'value',
'another' => 'another_value'
'total_posts' => $total_posts,
'another' => 'another_value'
);
};
$client->insights()
->add_extra( $metadata )
->init();
```

#### 4. Set textdomain

You may set your own textdomain to translate text.

```php
$client->set_textdomain( 'your-project-textdomain' );
```

---

### Check License Validity
Expand Down
19 changes: 12 additions & 7 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Client {
*
* @var string
*/
public $version = '1.1.11';
public $version = '1.1.12';

/**
* Hash identifier of the plugin
Expand Down Expand Up @@ -150,7 +150,6 @@ public function endpoint() {
protected function set_basename_and_slug() {

if ( strpos( $this->file, WP_CONTENT_DIR . '/themes/' ) === false ) {

$this->basename = plugin_basename( $this->file );

list( $this->slug, $mainfile) = explode( '/', $this->basename );
Expand All @@ -161,10 +160,7 @@ protected function set_basename_and_slug() {

$this->project_version = $plugin_data['Version'];
$this->type = 'plugin';
$this->textdomain = $this->slug;

} else {

$this->basename = str_replace( WP_CONTENT_DIR . '/themes/', '', $this->file );

list( $this->slug, $mainfile) = explode( '/', $this->basename );
Expand All @@ -173,8 +169,9 @@ protected function set_basename_and_slug() {

$this->project_version = $theme->version;
$this->type = 'theme';

}

$this->textdomain = $this->slug;
}

/**
Expand Down Expand Up @@ -213,7 +210,9 @@ public function send_request( $params, $route, $blocking = false ) {
* @return boolean
*/
public function is_local_server() {
return in_array( $_SERVER['REMOTE_ADDR'], array( '127.0.0.1', '::1' ) );
$is_local = in_array( $_SERVER['REMOTE_ADDR'], array( '127.0.0.1', '::1' ) );

return apply_filters( 'appsero_is_local', $is_local );
}

/**
Expand All @@ -230,4 +229,10 @@ public function __trans( $text ) {
return call_user_func( '__', $text, $this->textdomain );
}

/**
* Set project textdomain
*/
public function set_textdomain( $textdomain ) {
$this->textdomain = $textdomain;
}
}
Loading

0 comments on commit c0d3dcc

Please sign in to comment.