Skip to content

Commit 9596010

Browse files
New version 2.3
1 parent fad4a82 commit 9596010

18 files changed

Lines changed: 195 additions & 144 deletions

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# WordPress Plugin Ninja Forms Mergetag Add-on 2.2
1+
# WordPress Plugin Ninja Forms Mergetag Add-on 2.3
22

33
**Ninja Forms Admin Mail Customizer - New Tag "THE_Content"**
44

inc/i18n/index.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?php
2+
//silence is golden.

inc/i18n/nf-translation.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
// Languages
4+
if ( ! function_exists( 'nfmta_multiligual_textdomain' ) ) {
5+
function nfmta_multiligual_textdomain() {
6+
load_plugin_textdomain( 'nfmta' , false, dirname( plugin_basename( __FILE__ ) ).'/languages' );
7+
}
8+
add_action( 'plugins_loaded', 'nfmta_multiligual_textdomain' );
9+
}

inc/index.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?php
2+
//silence is golden.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
// Add WP Content Merge Tag
4+
class NFMTA_AddonTag extends NF_Abstracts_MergeTags {
5+
6+
protected $id = 'nfmta_merge_tags';
7+
8+
public function __construct(){
9+
parent::__construct();
10+
$this->title = __( 'Merge Addon', 'nfmta' );
11+
$this->merge_tags = array(
12+
'nfmtacontent' => array(
13+
'id' => 'nfmta_merge_content',
14+
'tag' => '{nfmta:nfmtacontent}',
15+
'label' => __( 'WordPress Single Page Content', 'nfmta' ),
16+
'callback' => 'nfmta_merge_content'
17+
),
18+
);
19+
add_action( 'init', array( $this, 'init' ) );
20+
add_action( 'admin_init', array( $this, 'admin_init' ) );
21+
}
22+
23+
// Add Post Meta from WordPress
24+
protected function post_id(){
25+
global $post;
26+
27+
if ( is_admin() && defined( 'DOING_AJAX' ) && DOING_AJAX ) {
28+
$post_id = url_to_postid( wp_get_referer() );
29+
} elseif( $post ) {
30+
$post_id = $post->ID;
31+
} else {
32+
return false;
33+
}
34+
return $post_id;
35+
}
36+
37+
// Return the Content
38+
protected function nfmta_merge_content(){
39+
$post_id = $this->post_id();
40+
41+
if( ! $post_id ) return;
42+
$post = get_post( $post_id );
43+
return ( $post ) ? $post->post_content : '';
44+
}
45+
}

inc/merges/contents/index.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?php
2+
//silence is golden.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
function nfm_pluginchecker() {
4+
if ( !class_exists('NF_Abstracts_MergeTags') && !is_plugin_active('ninja-forms/ninja-forms.php') ) {
5+
add_action( 'admin_notices', 'ninja_form_no_installed' );
6+
}
7+
8+
if( !class_exists('NF_Abstracts_MergeTags') && is_plugin_active('ninja-forms/ninja-forms.php') ) {
9+
add_action( 'admin_notices', 'nfmta_notice_no_plugin_support');
10+
}
11+
}
12+
add_action( 'admin_init', 'nfm_pluginchecker' );
13+
14+
15+
if( class_exists('NF_Abstracts_MergeTags') ) {
16+
17+
function nfmta_register_merge_tags(){
18+
require_once 'class.nfmergecontent.php';
19+
Ninja_Forms()->merge_tags[ 'nfmta_merge_tags' ] = new NFMTA_AddonTag();
20+
}
21+
add_action( 'ninja_forms_loaded', 'nfmta_register_merge_tags' );
22+
23+
}else {
24+
add_action( 'admin_notices', 'ninja_form_no_installed' );
25+
}

inc/merges/index.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?php
2+
//silence is golden.

inc/plugin-check/index.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?php
2+
//silence is golden.

inc/class-tgm-plugin-activation.php renamed to inc/plugin-check/plugin-install/class-tgm-plugin-activation.php

File renamed without changes.

0 commit comments

Comments
 (0)