Plugin Directory

Changeset 3115835

Timestamp:
07/10/2024 05:43:19 PM (3 weeks ago)
Author:
apos37
Message:

1.1.0

  • Update: New method for connecting to MS Teams
Location:
gf-msteams
Files:
15 added
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • gf-msteams/trunk/class-gf-msteams.php

    r2898818 r3115835  
    343343                'fields'      => [
    344344                    [
     345
     346
     347
     348
     349
     350
     351
     352
     353
     354
     355
     356
     357
    345358                        'name'              => 'site_name',
    346359                        'tooltip'           => esc_html__( 'The site name displayed on the messages. Limited to 50 characters.', 'gf-msteams' ),
     
    392405            [
    393406                'title'       => esc_html__( 'Instructions', 'gf-msteams' ),
    394                 'description' => '<p>'.esc_html__( 'How to add a webhook to Microsoft Teams and setting up feeds.', 'gf-msteams' ).'</p><br>',
     407                'description' => '',
    395408                'fields'      => [
    396409                    [
     
    680693     */
    681694    public function settings_instructions( $field, $echo = true ) {
     695
    682696        echo '</pre>
    683         <div><h2>'.esc_html__( 'On Microsoft Teams:', 'gf-msteams' ).'</h2><ol>
    684             <li>'.esc_html__( 'Go to Apps', 'gf-msteams' ).'</li>
    685             <li>'.esc_html__( 'Search for Incoming Webhook', 'gf-msteams' ).'</li>
    686             <li>'.esc_html__( 'Click on the Incoming Webhook app', 'gf-msteams' ).'</li>
    687             <li>'.esc_html__( 'Click on "Add to a team"', 'gf-msteams' ).'</li>
    688             <li>'.esc_html__( 'Choose a channel to add the messages to', 'gf-msteams' ).'</li>
    689             <li>'.esc_html__( 'Click on "Set up connector"', 'gf-msteams' ).'</li>
    690             <li>'.esc_html__( 'Name your webhook (this will be used as the name that the messages are posted by)', 'gf-msteams' ).'</li>
    691             <li>'.esc_html__( 'Upload a logo for your webhook', 'gf-msteams' ).'</li>
    692             <li>'.esc_html__( 'Click on "Create"', 'gf-msteams' ).'</li>
    693             <li>'.esc_html__( 'Copy the webhook URL and save it; you will be needing this to add to your form feed', 'gf-msteams' ).'</li>
    694             <li>'.esc_html__( 'Click on "Done"', 'gf-msteams' ).'</li>
    695         </ol></div>
     697        <p><span style="font-weight: bold; color: red;">** IMPORTANT UPDATE **</span> If you installed this plugin prior to v1.1.0, you would have had to set up an Incoming Webhook app on MS Teams. If you still have it set up this way, you might be seeing a message from Microsoft at the bottom of your channel messages that says "<code>Action Required: O365 connectors... will be deprecated...</code>" <strong>Prior to August 15th, 2024</strong>, you will need to remove the Incoming Webhook app on Teams and use a Workflow instead. Instructions are below:</p>
    696698        <br><br>
    697         <div><h2>'.esc_html__( 'On Gravity Forms:', 'gf-msteams' ).'</h2><ol>
    698             <li>'.esc_html__( 'Go to your form settings', 'gf-msteams' ).'</li>
    699             <li>'.esc_html__( 'Click on Microsoft Teams', 'gf-msteams' ).'</li>
    700             <li>'.esc_html__( 'Add a new feed', 'gf-msteams' ).'</li>
    701             <li>'.esc_html__( 'Choose a title', 'gf-msteams' ).'</li>
    702             <li>'.esc_html__( 'Enter the webhook URL you copied from Microsoft Teams', 'gf-msteams' ).'</li>
    703             <li>'.esc_html__( 'Select the fields you need to map', 'gf-msteams' ).'</li>
    704             <li>'.esc_html__( 'Save the settings', 'gf-msteams' ).'</li>
    705             <li>'.esc_html__( 'Complete the form and see your entry appear!', 'gf-msteams' ).'</li>
    706         </ol></div>
     699        <div>
     700            <h2>'.esc_html__( 'Removing Incoming Webhook (if still using the old method)', 'gf-msteams' ).'</h2><ol>
     701                <li>'.esc_html__( 'On Microsoft Teams, go to Apps > Manage your apps', 'gf-msteams' ).'</li>
     702                <li>'.esc_html__( 'Find and click on Incoming Webhook in the list', 'gf-msteams' ).'</li>
     703                <li>'.esc_html__( 'If you see your channel listed under "Recently used," simply click on the trash can icon to delete it. That\'s all.', 'gf-msteams' ).'</li>
     704                <li>'.esc_html__( 'If you do not see your channel listed, on the left side of Teams, locate the team and the channel where the Incoming Webhook is configured', 'gf-msteams' ).'</li>
     705                <li>'.esc_html__( 'Go to the channel name, select More options > Manage channel', 'gf-msteams' ).'</li>
     706                <li>'.esc_html__( 'In the Manage channel window, select Edit', 'gf-msteams' ).'</li>
     707                <li>'.esc_html__( 'In the left pane, select Configured', 'gf-msteams' ).'</li>
     708                <li>'.esc_html__( 'Under Incoming Webhook, select 1 Configured', 'gf-msteams' ).'</li>
     709                <li>'.esc_html__( 'Select Manage', 'gf-msteams' ).'</li>
     710                <li>'.esc_html__( 'Select Remove and follow the prompt', 'gf-msteams' ).'</li>
     711            </ol></div>
     712            <br><br>
     713            <h2>'.esc_html__( 'Connecting to Microsoft Teams (new method):', 'gf-msteams' ).'</h2><ol>
     714            <li>'.esc_html__( 'At the top of this page, enable "Use Workflow (New Method)', 'gf-msteams' ).'</li>
     715                <li>'.esc_html__( 'From Teams, go to Apps > Workflows > Manage Workflows (or from Power Automate, go to My flows)', 'gf-msteams' ).'</li>
     716                <li>'.esc_html__( 'Add a New Flow using a template', 'gf-msteams' ).'</li>
     717                <li>'.esc_html__( 'Search templates for "webhook" and choose "Post to a channel when a webhook request is received"', 'gf-msteams' ).'</li>
     718                <li>'.esc_html__( 'Connect the flow to Microsoft Teams if it is not already connected', 'gf-msteams' ).'</li>
     719                <li>'.esc_html__( 'Click on Next (or Continue)', 'gf-msteams' ).'</li>
     720                <li>'.esc_html__( 'Click on Create', 'gf-msteams' ).'</li>
     721                <li>'.esc_html__( 'If setting up on Teams, your HTTP POST URL should be given right away; copy and save for later', 'gf-msteams' ).'</li>
     722                <li>'.esc_html__( 'If setting up on Power Automate, go to Edit > click on the "When a Teams webhook request is received" trigger, then copy the HTTP URL and save for later', 'gf-msteams' ).'</li>
     723            </ol></div>
     724            <br><br>
     725            <div><h2>'.esc_html__( 'On Gravity Forms:', 'gf-msteams' ).'</h2><ol>
     726                <li>'.esc_html__( 'Go to your form settings', 'gf-msteams' ).'</li>
     727                <li>'.esc_html__( 'Click on Microsoft Teams', 'gf-msteams' ).'</li>
     728                <li>'.esc_html__( 'Add a new feed', 'gf-msteams' ).'</li>
     729                <li>'.esc_html__( 'Choose a title', 'gf-msteams' ).'</li>
     730                <li>'.esc_html__( 'Enter the HTTP POST URL you copied from Microsoft Teams', 'gf-msteams' ).'</li>
     731                <li>'.esc_html__( 'Select the fields you need to map', 'gf-msteams' ).'</li>
     732                <li>'.esc_html__( 'Save the settings', 'gf-msteams' ).'</li>
     733                <li>'.esc_html__( 'Complete the form and see your entry appear!', 'gf-msteams' ).'</li>
     734            </ol>
     735        </div>
    707736        <pre>';
    708737    } // End settings_instructions()
     
    748777                    [
    749778                        'name'     => 'webhook',
    750                         'label'    => esc_html__( 'Incoming Webhook URL', 'gf-msteams' ),
     779                        'label'    => esc_html__( ' URL', 'gf-msteams' ),
    751780                        'type'     => 'text',
    752781                        'required' => true,
    753                         'tooltip'  => esc_html__( 'Add the Incoming Webhook URL. You will find this in your Microsoft Teams Incoming Webhook App setup.', 'gf-msteams' ),
     782                        'tooltip'  => esc_html__( 'Add the HTTP POST URL. You will find this in your Workflow trigger.', 'gf-msteams' ),
     783                        'validation_callback' => [ $this, 'validate_request_url' ],
    754784                    ],
    755785                    [
     
    760790                        'tooltip'  => esc_html__( 'The Microsoft Teams channel name. For reference only.', 'gf-msteams' ),
    761791                    ],
    762                     [
    763                         'name'          => 'color',
    764                         'label'         => esc_html__( 'Accent Color', 'gf-msteams' ),
    765                         'type'          => 'text',
    766                         'required'      => false,
    767                         'tooltip'       => esc_html__( 'Choose a color for the top bar of the messages using a hex code. Default is red (#FF0000).', 'gf-msteams' ),
    768                         'default_value' => '#FF0000',
    769                     ],
     792                    [
     793                    'name'          => 'color',
     794                    'label'         => esc_html__( 'Accent Color', 'gf-msteams' ),
     795                    'type'          => 'text',
     796                    'required'      => false,
     797                    'tooltip'       => esc_html__( 'Choose a color for the top bar of the messages using a hex code. Default is red (#FF0000).', 'gf-msteams' ),
     798                    'default_value' => '#FF0000',
     799                    ],
    770800                    [
    771801                        'name'    => 'message',
     
    11261156        $facts = [];
    11271157
     1158
     1159
     1160
     1161
     1162
     1163
     1164
     1165
    11281166        // Iter the fields
    11291167        foreach ( $form[ 'fields' ] as $field ) {
     
    11961234            if ( !$hiding || ( $hiding && $value != '' ) ) {
    11971235                $facts[] = [
    1198                     'name' => $label,
    1199                     'value' => $value
     1236                    => $label,
     1237                    'value' => $value
    12001238                ];
    12011239            }
     
    12351273        if ( isset( $feed[ 'meta' ][ 'user_id' ] ) && $feed[ 'meta' ][ 'user_id' ] && $user_id ) {
    12361274            $facts[] = [
    1237                 'name'  => 'User ID:',
    1238                 'value' => $user_id
     1275                ',
     1276                'value' => $user_id
    12391277            ];
    12401278        }
     
    12431281        if ( !$hiding && isset( $feed[ 'meta' ][ 'source_url' ] ) && $feed[ 'meta' ][ 'source_url' ] ) {
    12441282            $facts[] = [
    1245                 'name'  => 'Source URL:',
    1246                 'value' => $entry[ 'source_url' ]
     1283                ',
     1284                'value' => $entry[ 'source_url' ]
    12471285            ];
    12481286        }
     
    13121350        if ( $get_message && $get_message != '' ) {
    13131351            $message = GFCommon::replace_variables( $get_message, $form, $entry, false, true, false, 'text' );
    1314             $message = '<br><br>'.$message;
     1352            $message = $message;
    13151353        } else {
    13161354            $message = '';
     
    13201358        $color = $this->sanitize_and_validate_color( $feed[ 'meta' ][ 'color' ], $this->default_accent_color );
    13211359
    1322         // Put the message card together
    1323         $data = [
    1324             '@type'      => 'MessageCard',
    1325             '@context'   => 'https://schema.org/extensions',
    1326             'summary'    => 'Gravity Forms Microsoft Teams Integration',
    1327             'themeColor' => $color,
    1328             'title'      => $title,
    1329             'sections'   => [
    1330                 [
    1331                     'activityTitle'    => $site_name,
    1332                     'activitySubtitle' => home_url(),
    1333                     'activityImage'    => $image,
    1334                     'text'             => $this->convert_timezone( date( 'Y-m-d H:i:s', strtotime( $args[ 'date' ] ) ) ).$message,
    1335                     'facts'            => $facts,
    1336                 ]
    1337             ],
    1338         ];
    1339 
    1340         // Visit Site Button
    1341         if ( isset( $feed[ 'meta' ][ 'visit_site' ] ) && $feed[ 'meta' ][ 'visit_site' ] ) {
    1342             $data[ 'potentialAction' ][] = [
    1343                 '@type'   => 'OpenUri',
    1344                 'name'    => esc_html__( 'Visit Site', 'gf-msteams' ),
    1345                 'targets' => [
    1346                     [
    1347                         'os'  => 'default',
    1348                         'uri' => home_url()
     1360        // Which method are we using?
     1361        $workflow = filter_var( $this->get_plugin_setting( 'workflow' ), FILTER_VALIDATE_BOOLEAN );
     1362
     1363        // New method of using Power Automate Workflow
     1364        if ( $workflow ) {
     1365            $data = [
     1366                'attachments' => [
     1367                    [
     1368                        'contentType' => 'application/vnd.microsoft.card.adaptive',
     1369                        'content'     => [
     1370                            'type'    => 'AdaptiveCard',
     1371                            'body'    => [
     1372                                [
     1373                                    'type'   => 'TextBlock',
     1374                                    'size'   => 'ExtraLarge',
     1375                                    'weight' => 'Bolder',
     1376                                    'text'   => $title
     1377                                ],
     1378                                [
     1379                                    'type'    => 'ColumnSet',
     1380                                    'columns' => [
     1381                                        [
     1382                                            'type'  => 'Column',
     1383                                            'items' => [
     1384                                                [
     1385                                                    'type'    => 'Image',
     1386                                                    'url'     => $image,
     1387                                                    'altText' => $site_name.' logo',
     1388                                                    'size'    => 'Small'
     1389                                                ]
     1390                                            ],
     1391                                            'width' => 'auto'
     1392                                        ],
     1393                                        [
     1394                                            'type'  => 'Column',
     1395                                            'items' => [
     1396                                                [
     1397                                                    'type'   => 'TextBlock',
     1398                                                    'weight' => 'Bolder',
     1399                                                    'text'   => $site_name,
     1400                                                    'wrap'   => true
     1401                                                ],
     1402                                                [
     1403                                                    'type'     => 'TextBlock',
     1404                                                    'spacing'  => 'None',
     1405                                                    'text'     => $this->convert_timezone( date( 'Y-m-d H:i:s', strtotime( $args[ 'date' ] ) ) ),
     1406                                                    'isSubtle' => true,
     1407                                                    'wrap'     => true
     1408                                                ]
     1409                                            ],
     1410                                            'width' => 'stretch'
     1411                                        ]
     1412                                    ]
     1413                                ],
     1414                                [
     1415                                    'type' => 'TextBlock',
     1416                                    'text' => $message,
     1417                                    'wrap' => true
     1418                                ],
     1419                                [
     1420                                    'type'  => 'FactSet',
     1421                                    'facts' => $facts
     1422                                ]
     1423                            ],
     1424                            'actions' => [],
     1425                            'msteams' => [
     1426                                'width' => 'Full'
     1427                            ],
     1428                            '$schema' => 'http://adaptivecards.io/schemas/adaptive-card.json',
     1429                            'version' => '1.4'
     1430                        ]
    13491431                    ]
    13501432                ]
    13511433            ];
    1352         }
    1353 
    1354         // View Entry Button
    1355         if ( isset( $feed[ 'meta' ][ 'view_entry' ] ) && $feed[ 'meta' ][ 'view_entry' ] ) {
    1356             $data[ 'potentialAction' ][] = [
    1357                 '@type'   => 'OpenUri',
    1358                 'name'    => esc_html__( 'View Entry', 'gf-msteams' ),
    1359                 'targets' => [
    1360                     [
    1361                         'os'  => 'default',
    1362                         'uri' => home_url().'/wp-admin/admin.php?page=gf_entries&view=entry&id='.$form[ 'id' ].'&lid='.$entry[ 'id' ]
    1363                     ]
    1364                 ]
     1434
     1435            // Visit Site Button
     1436            if ( isset( $feed[ 'meta' ][ 'visit_site' ] ) && $feed[ 'meta' ][ 'visit_site' ] ) {
     1437                $data[ 'attachments' ][0][ 'content' ][ 'actions' ][] = [
     1438                    'type'  => 'Action.OpenUrl',
     1439                    'title' => esc_html__( 'Visit Site', 'gf-msteams' ),
     1440                    'url'   => home_url()
     1441                ];
     1442            }
     1443
     1444            // View Entry Button
     1445            if ( isset( $feed[ 'meta' ][ 'view_entry' ] ) && $feed[ 'meta' ][ 'view_entry' ] ) {
     1446                $data[ 'attachments' ][0][ 'content' ][ 'actions' ][] = [
     1447                    'type'  => 'Action.OpenUrl',
     1448                    'title' => esc_html__( 'View Entry', 'gf-msteams' ),
     1449                    'url'   => home_url().'/wp-admin/admin.php?page=gf_entries&view=entry&id='.$form[ 'id' ].'&lid='.$entry[ 'id' ]
     1450                ];
     1451            }
     1452
     1453            // View User Button
     1454            if ( isset( $feed[ 'meta' ][ 'view_entry' ] ) && $feed[ 'meta' ][ 'view_user' ] && $args[ 'user_id' ] > 0 ) {
     1455                $data[ 'attachments' ][0][ 'content' ][ 'actions' ][] = [
     1456                    'type'  => 'Action.OpenUrl',
     1457                    'title' => esc_html__( 'View User', 'gf-msteams' ),
     1458                    'url'   => admin_url( 'user-edit.php?user_id='.$args[ 'user_id' ] )
     1459                ];
     1460            }
     1461
     1462            // Custom Button
     1463            if ( isset( $feed[ 'meta' ][ 'custom_button' ] ) && $feed[ 'meta' ][ 'custom_button' ] &&
     1464                 isset( $feed[ 'meta' ][ 'custom_button_text' ] ) && sanitize_text_field( $feed[ 'meta' ][ 'custom_button_text' ] ) != '' &&
     1465                 isset( $feed[ 'meta' ][ 'custom_button_url' ] ) && filter_var( $feed[ 'meta' ][ 'custom_button_url' ] , FILTER_SANITIZE_URL ) != '' ) {
     1466
     1467                // Let's check if we are showing this to users only
     1468                if ( isset( $feed[ 'meta' ][ 'custom_button_users_only' ] ) && $feed[ 'meta' ][ 'custom_button_users_only' ] ) {
     1469                    $users_only = true;
     1470                } else {
     1471                    $users_only = false;
     1472                }
     1473                if ( $users_only && $args[ 'user_id' ] > 0 || !$users_only ) {
     1474
     1475                    // Replace merge tag variables
     1476                    $text = sanitize_text_field( $feed[ 'meta' ][ 'custom_button_text' ] );
     1477                    $text = GFCommon::replace_variables( $text, $form, $entry, false, true, false, 'text' );
     1478                    $url = filter_var( $feed[ 'meta' ][ 'custom_button_url' ] , FILTER_SANITIZE_URL );
     1479                    $url = GFCommon::replace_variables( $url, $form, $entry, true, true, false, 'text' );
     1480                   
     1481                    // The button
     1482                    $data[ 'attachments' ][0][ 'content' ][ 'actions' ][] = [
     1483                        'type'  => 'Action.OpenUrl',
     1484                        'title' => $text,
     1485                        'url'   => $url
     1486                    ];
     1487                }
     1488            }
     1489
     1490        // Old method Incoming Webhook app
     1491        } else {
     1492
     1493            // Put the message card together
     1494            $data = [
     1495                '@type'      => 'MessageCard',
     1496                '@context'   => 'https://schema.org/extensions',
     1497                'summary'    => 'Gravity Forms Microsoft Teams Integration',
     1498                'themeColor' => $color,
     1499                'title'      => $title,
     1500                'sections'   => [
     1501                    [
     1502                        'activityTitle'    => $site_name,
     1503                        'activitySubtitle' => home_url(),
     1504                        'activityImage'    => $image,
     1505                        'text'             => $this->convert_timezone( date( 'Y-m-d H:i:s', strtotime( $args[ 'date' ] ) ) ).$message,
     1506                        'facts'            => $facts,
     1507                    ]
     1508                ],
    13651509            ];
    1366         }
    1367 
    1368         // View User Button
    1369         if ( isset( $feed[ 'meta' ][ 'view_entry' ] ) && $feed[ 'meta' ][ 'view_user' ] && $args[ 'user_id' ] > 0 ) {
    1370             $data[ 'potentialAction' ][] = [
    1371                 '@type'   => 'OpenUri',
    1372                 'name'    => esc_html__( 'View User', 'gf-msteams' ),
    1373                 'targets' => [
    1374                     [
    1375                         'os'  => 'default',
    1376                         'uri' => admin_url( 'user-edit.php?user_id='.$args[ 'user_id' ] )
    1377                     ]
    1378                 ]
    1379             ];
    1380         }
    1381 
    1382         // Custom Button
    1383         if ( isset( $feed[ 'meta' ][ 'custom_button' ] ) && $feed[ 'meta' ][ 'custom_button' ] &&
    1384              isset( $feed[ 'meta' ][ 'custom_button_text' ] ) && sanitize_text_field( $feed[ 'meta' ][ 'custom_button_text' ] ) != '' &&
    1385              isset( $feed[ 'meta' ][ 'custom_button_url' ] ) && filter_var( $feed[ 'meta' ][ 'custom_button_url' ] , FILTER_SANITIZE_URL ) != '' ) {
    1386 
    1387             // Let's check if we are showing this to users only
    1388             if ( isset( $feed[ 'meta' ][ 'custom_button_users_only' ] ) && $feed[ 'meta' ][ 'custom_button_users_only' ] ) {
    1389                 $users_only = true;
    1390             } else {
    1391                 $users_only = false;
    1392             }
    1393             if ( $users_only && $args[ 'user_id' ] > 0 || !$users_only ) {
    1394 
    1395                 // Replace merge tag variables
    1396                 $text = sanitize_text_field( $feed[ 'meta' ][ 'custom_button_text' ] );
    1397                 $text = GFCommon::replace_variables( $text, $form, $entry, false, true, false, 'text' );
    1398                 $url = filter_var( $feed[ 'meta' ][ 'custom_button_url' ] , FILTER_SANITIZE_URL );
    1399                 $url = GFCommon::replace_variables( $url, $form, $entry, true, true, false, 'text' );
    1400                
    1401                 // The button
     1510
     1511            // Visit Site Button
     1512            if ( isset( $feed[ 'meta' ][ 'visit_site' ] ) && $feed[ 'meta' ][ 'visit_site' ] ) {
    14021513                $data[ 'potentialAction' ][] = [
    14031514                    '@type'   => 'OpenUri',
    1404                     'name'    => $text,
     1515                    'name'    => ,
    14051516                    'targets' => [
    14061517                        [
    14071518                            'os'  => 'default',
    1408                             'uri' => $url
     1519                            'uri' =>
    14091520                        ]
    14101521                    ]
    14111522                ];
    14121523            }
    1413    
    1414            
    1415         }
    1416 
    1417         // Encode
    1418         $json_data = json_encode( $data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE );
    1419 
     1524
     1525            // View Entry Button
     1526            if ( isset( $feed[ 'meta' ][ 'view_entry' ] ) && $feed[ 'meta' ][ 'view_entry' ] ) {
     1527                $data[ 'potentialAction' ][] = [
     1528                    '@type'   => 'OpenUri',
     1529                    'name'    => esc_html__( 'View Entry', 'gf-msteams' ),
     1530                    'targets' => [
     1531                        [
     1532                            'os'  => 'default',
     1533                            'uri' => home_url().'/wp-admin/admin.php?page=gf_entries&view=entry&id='.$form[ 'id' ].'&lid='.$entry[ 'id' ]
     1534                        ]
     1535                    ]
     1536                ];
     1537            }
     1538
     1539            // View User Button
     1540            if ( isset( $feed[ 'meta' ][ 'view_entry' ] ) && $feed[ 'meta' ][ 'view_user' ] && $args[ 'user_id' ] > 0 ) {
     1541                $data[ 'potentialAction' ][] = [
     1542                    '@type'   => 'OpenUri',
     1543                    'name'    => esc_html__( 'View User', 'gf-msteams' ),
     1544                    'targets' => [
     1545                        [
     1546                            'os'  => 'default',
     1547                            'uri' => admin_url( 'user-edit.php?user_id='.$args[ 'user_id' ] )
     1548                        ]
     1549                    ]
     1550                ];
     1551            }
     1552
     1553            // Custom Button
     1554            if ( isset( $feed[ 'meta' ][ 'custom_button' ] ) && $feed[ 'meta' ][ 'custom_button' ] &&
     1555                 isset( $feed[ 'meta' ][ 'custom_button_text' ] ) && sanitize_text_field( $feed[ 'meta' ][ 'custom_button_text' ] ) != '' &&
     1556                 isset( $feed[ 'meta' ][ 'custom_button_url' ] ) && filter_var( $feed[ 'meta' ][ 'custom_button_url' ] , FILTER_SANITIZE_URL ) != '' ) {
     1557
     1558                // Let's check if we are showing this to users only
     1559                if ( isset( $feed[ 'meta' ][ 'custom_button_users_only' ] ) && $feed[ 'meta' ][ 'custom_button_users_only' ] ) {
     1560                    $users_only = true;
     1561                } else {
     1562                    $users_only = false;
     1563                }
     1564                if ( $users_only && $args[ 'user_id' ] > 0 || !$users_only ) {
     1565
     1566                    // Replace merge tag variables
     1567                    $text = sanitize_text_field( $feed[ 'meta' ][ 'custom_button_text' ] );
     1568                    $text = GFCommon::replace_variables( $text, $form, $entry, false, true, false, 'text' );
     1569                    $url = filter_var( $feed[ 'meta' ][ 'custom_button_url' ] , FILTER_SANITIZE_URL );
     1570                    $url = GFCommon::replace_variables( $url, $form, $entry, true, true, false, 'text' );
     1571                   
     1572                    // The button
     1573                    $data[ 'potentialAction' ][] = [
     1574                        '@type'   => 'OpenUri',
     1575                        'name'    => $text,
     1576                        'targets' => [
     1577                            [
     1578                                'os'  => 'default',
     1579                                'uri' => $url
     1580                            ]
     1581                        ]
     1582                    ];
     1583                }
     1584            }
     1585        }
     1586       
     1587        // Encode
     1588        $json_data = json_encode( $data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE );
     1589       
    14201590        // Remote post options
    1421         $options = [
    1422             'body'        => $json_data,
    1423             'headers'     => [
    1424                 'Content-Type' => 'application/json',
    1425             ],
    1426             'timeout'     => 60,
    1427             'redirection' => 5,
    1428             'blocking'    => true,
    1429             'httpversion' => '1.0',
    1430             'sslverify'   => false,
    1431             'data_format' => 'body',
    1432         ];
    1433        
     1591$options = [
     1592'body'        => $json_data,
     1593'headers'     => [
     1594'Content-Type' => 'application/json',
     1595],
     1596'timeout'     => 60,
     1597'redirection' => 5,
     1598'blocking'    => true,
     1599'httpversion' => '1.0',
     1600'sslverify'   => false,
     1601'data_format' => 'body',
     1602];
     1603       
    14341604        // Send the message
    1435         $response = wp_remote_post( $webhook, $options );
     1605        $response = wp_remote_post( $webhook, $options );       
    14361606
    14371607        // Did we get a response?
     
    16311801        return $color;
    16321802    } // End sanitize_and_validate_color()
     1803
     1804
     1805
     1806
     1807
     1808
     1809
     1810
     1811
     1812
     1813
     1814
     1815
     1816
     1817
     1818
     1819
     1820
     1821
     1822
     1823
     1824
     1825
     1826
    16331827}
  • gf-msteams/trunk/gf-msteams.php

    r3033334 r3115835  
    44 * Plugin URI:          https://apos37.com/wordpress-addon-for-ms-teams-gravity-forms/
    55 * Description:         Send Gravity Form entries to Microsoft Teams channel
    6  * Version:             1.0.9
     6 * Version:             1.
    77 * Requires at least:   5.9.0
    8  * Tested up to:        6.4.3
     8 * Tested up to:        6.
    99 * Author:              Apos37
    1010 * Author URI:          https://apos37.com/
    1111 * Text Domain:         gf-msteams
    12  * License:             GPL v2 or later
     12 * License:             GPLv2 or later
    1313 * License URI:         http://www.gnu.org/licenses/gpl-2.0.txt
    1414 */
     
    2525define( 'MSTEAMS_NAME', 'Add-On for Microsoft Teams and Gravity Forms' );
    2626define( 'MSTEAMS_TEXTDOMAIN', 'gf-msteams' );
    27 define( 'MSTEAMS_VERSION', '1.0.9' );
     27define( 'MSTEAMS_VERSION', '1.' );
    2828define( 'MSTEAMS_PLUGIN_ROOT', plugin_dir_path( __FILE__ ) );                                                   // /home/.../public_html/wp-content/plugins/gf-msteams/
    2929define( 'MSTEAMS_PLUGIN_DIR', plugins_url( '/'.MSTEAMS_TEXTDOMAIN.'/' ) );                                      // https://domain.com/wp-content/plugins/gf-msteams/
     
    104104    } // End str_ends_with()
    105105}
     106
     107
     108
     109
     110
     111
  • gf-msteams/trunk/readme.txt

    r3033334 r3115835  
    11=== Add-On for Microsoft Teams and Gravity Forms ===
    22Contributors: apos37
    3 Donate link: https://paypal.com/donate/?business=3XHJUEHGTMK3N
    43Tags: microsoft, teams, gravity, forms, chat, webhook
    54Requires at least: 5.9.0
    6 Tested up to: 6.4.3
    7 Stable tag: 1.0.9
    8 License: GPL v2 or later
     5Tested up to: 6.
     6Stable tag: 1.
     7License: GPLv2 or later
    98License URI: http://www.gnu.org/licenses/gpl-2.0.txt
    109
     
    1211
    1312== Description ==
    14 Automatically send Gravity Form entries to a Microsoft Teams channel using an Incoming Webhook.
     13The "Add-On for Microsoft Teams and Gravity Forms" WordPress plugin is a powerful integration tool that connects your website's forms with Microsoft Teams, a popular communication and collaboration platform. This plugin bridges the gap between Gravity Forms, a leading form builder plugin, and Microsoft Teams, enabling seamless communication and workflow automation.
     14
     15With this add-on, you can:
     16
     17* Automatically send form submissions to a designated Microsoft Teams channel
     18* Map form fields to Teams message cards, making it easy to display user-submitted data
     19* Trigger custom notifications and messages based on form responses
     20* Enhance team collaboration and response times
     21
     22This plugin is ideal for:
     23
     24* Businesses using Microsoft Teams for team communication and collaboration
     25* Developers seeking to streamline form data and notifications
     26* Site owners wanting to centralize form submissions and team discussions
     27* Those that have unreliable email systems
     28
     29By integrating Gravity Forms and Microsoft Teams, this add-on simplifies communication, boosts team productivity, and enhances user experience! It's a perfect solution for anyone looking to supercharge their team's workflow and responsiveness!
    1530
    1631== Installation ==
     
    2035
    2136= Where can I request features and get further support? =
    22 Join my [WordPress Support Discord server](https://discord.gg/3HnzNEJVnR)
     37Join my [ server](https://discord.gg/3HnzNEJVnR)
    2338
    2439== Screenshots ==
     
    3045
    3146== Changelog ==
     47
     48
     49
    3250= 1.0.9 =
    3351* Tweak: Removed some comments
Note: See TracChangeset for help on using the changeset viewer.