Wordpress - Remove submenu from admin panel - wordpress

I'm trying to remove a "Tags" submenu from my Portfolio menu, this is what I'm using:
add_action( 'admin_menu', 'my_remove_menu_pages' );
function my_remove_menu_pages() {
if(!current_user_can('create_users')) {
remove_submenu_page( 'edit.php', 'tags.php' );
remove_submenu_page( 'edit.php?post_type=portfolio', 'edit-tags.php?taxonomy=post_tag&post_type=portfolio' );
}
}
But it simply won't go. Here's the output of a var_dump($submenu); function:
Stackoverflow requires more text to the post ¬¬ so text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
array(12) {
["index.php"]=>
array(1) {
[0]=>
array(3) {
[0]=>
string(7) "Início"
[1]=>
string(4) "read"
[2]=>
string(9) "index.php"
}
}
["edit.php"]=>
array(4) {
[5]=>
array(3) {
[0]=>
string(14) "Todos os Posts"
[1]=>
string(10) "edit_posts"
[2]=>
string(8) "edit.php"
}
[10]=>
array(3) {
[0]=>
string(14) "Adicionar Novo"
[1]=>
string(10) "edit_posts"
[2]=>
string(12) "post-new.php"
}
[15]=>
array(3) {
[0]=>
string(10) "Categorias"
[1]=>
string(17) "manage_categories"
[2]=>
string(31) "edit-tags.php?taxonomy=category"
}
[16]=>
array(3) {
[0]=>
string(4) "Tags"
[1]=>
string(17) "manage_categories"
[2]=>
string(31) "edit-tags.php?taxonomy=post_tag"
}
}
["upload.php"]=>
array(1) {
[5]=>
array(3) {
[0]=>
string(10) "Biblioteca"
[1]=>
string(12) "upload_files"
[2]=>
string(10) "upload.php"
}
}
["link-manager.php"]=>
array(3) {
[5]=>
array(3) {
[0]=>
string(14) "Todos os Links"
[1]=>
string(12) "manage_links"
[2]=>
string(16) "link-manager.php"
}
[10]=>
array(3) {
[0]=>
string(14) "Adicionar novo"
[1]=>
string(12) "manage_links"
[2]=>
string(12) "link-add.php"
}
[15]=>
array(3) {
[0]=>
string(19) "Categorias de Links"
[1]=>
string(17) "manage_categories"
[2]=>
string(36) "edit-tags.php?taxonomy=link_category"
}
}
["edit.php?post_type=page"]=>
array(2) {
[5]=>
array(3) {
[0]=>
string(17) "Todas as Páginas"
[1]=>
string(10) "edit_pages"
[2]=>
string(23) "edit.php?post_type=page"
}
[10]=>
array(3) {
[0]=>
string(14) "Adicionar Nova"
[1]=>
string(10) "edit_pages"
[2]=>
string(27) "post-new.php?post_type=page"
}
}
["edit-comments.php"]=>
array(1) {
[0]=>
array(3) {
[0]=>
string(21) "Todos os Comentários"
[1]=>
string(10) "edit_posts"
[2]=>
string(17) "edit-comments.php"
}
}
["edit.php?post_type=portfolio"]=>
array(4) {
[5]=>
array(3) {
[0]=>
string(9) "Portfolio"
[1]=>
string(10) "edit_posts"
[2]=>
string(28) "edit.php?post_type=portfolio"
}
[10]=>
array(3) {
[0]=>
string(14) "Adicionar Novo"
[1]=>
string(10) "edit_posts"
[2]=>
string(32) "post-new.php?post_type=portfolio"
}
[15]=>
array(3) {
[0]=>
string(4) "Tags"
[1]=>
string(17) "manage_categories"
[2]=>
string(55) "edit-tags.php?taxonomy=post_tag&post_type=portfolio"
}
[16]=>
array(3) {
[0]=>
string(23) "Categorias de Portfolio"
[1]=>
string(17) "manage_categories"
[2]=>
string(65) "edit-tags.php?taxonomy=portfolio_category&post_type=portfolio"
}
}
["edit.php?post_type=slideshow"]=>
array(2) {
[5]=>
array(3) {
[0]=>
string(7) "Banners"
[1]=>
string(10) "edit_posts"
[2]=>
string(28) "edit.php?post_type=slideshow"
}
[10]=>
array(3) {
[0]=>
string(14) "Adicionar Novo"
[1]=>
string(10) "edit_posts"
[2]=>
string(32) "post-new.php?post_type=slideshow"
}
}
["themes.php"]=>
array(1) {
[10]=>
array(3) {
[0]=>
string(5) "Menus"
[1]=>
string(18) "edit_theme_options"
[2]=>
string(13) "nav-menus.php"
}
}
["profile.php"]=>
array(1) {
[5]=>
array(3) {
[0]=>
string(10) "Seu perfil"
[1]=>
string(4) "read"
[2]=>
string(11) "profile.php"
}
}
["tools.php"]=>
array(1) {
[5]=>
array(3) {
[0]=>
string(12) "Disponíveis"
[1]=>
string(10) "edit_posts"
[2]=>
string(9) "tools.php"
}
}
["options-general.php"]=>
array(1) {
[0]=>
array(4) {
[0]=>
string(16) "Support settings"
[1]=>
int(1)
[2]=>
string(16) "support_settings"
[3]=>
string(16) "Support settings"
}
}
}

The example put forth on the Codex page for remove_submenu_page sets the optional 3rd parameter on add_action to 999 for the "priority".
I'm not sure if adding this to your code will make it work, but its worth a try.
<?php
add_action( 'admin_menu', 'adjust_the_wp_menu', 999 );
function adjust_the_wp_menu() {
$page = remove_submenu_page( 'themes.php', 'widgets.php' );
}
?>

Related

QML scroll ListView by one row

I have a simple ListView. My goal is to use two buttons to scroll the view by one row.
I tried with ScrollBar.vertical.position or ScrollBar.increase() but I'm not able to scroll items one by one.
This is the code:
import QtQuick 2.15
import QtQuick.Window 2.15
import QtQuick.Controls 2.15
import QtQuick.VirtualKeyboard 2.15
Window {
id: window
width: 640
height: 480
visible: true
ListModel {
id: contactModel
ListElement {
name: "Bill Smith"
number: "555 3264"
}
ListElement {
name: "John Brown"
number: "555 8426"
}
ListElement {
name: "Sam Wise"
number: "555 0473"
}
ListElement {
name: "Gollum"
number: "555 3473"
}
ListElement {
name: "Bill Smith"
number: "555 3264"
}
ListElement {
name: "John Brown"
number: "555 8426"
}
ListElement {
name: "Sam Wise"
number: "555 0473"
}
ListElement {
name: "Gollum"
number: "555 3473"
}
ListElement {
name: "Bill Smith"
number: "555 3264"
}
ListElement {
name: "John Brown"
number: "555 8426"
}
ListElement {
name: "Sam Wise"
number: "555 0473"
}
ListElement {
name: "Gollum"
number: "555 3473"
}
ListElement {
name: "Bill Smith"
number: "555 3264"
}
ListElement {
name: "John Brown"
number: "555 8426"
}
ListElement {
name: "Sam Wise"
number: "555 0473"
}
ListElement {
name: "Gollum"
number: "555 3473"
}
}
Component {
id: contactDelegate
Item {
width: window.width
height: 40
Column {
Text {
text: '<b>Name:</b> ' + name
}
Text {
text: '<b>Number:</b> ' + number
}
}
Rectangle {
width: parent.width
height: 1
color: "black"
}
}
}
Column {
anchors.fill: parent
spacing: 10
ListView {
width: parent.width
height: parent.height - 80
model: contactModel
delegate: contactDelegate
clip: true
highlight: Rectangle {
color: "lightsteelblue"
radius: 5
}
ScrollBar.vertical: ScrollBar {
snapMode: ScrollBar.SnapAlways
policy: ScrollBar.AlwaysOn
}
focus: true
}
Row {
anchors.horizontalCenter: parent.horizontalCenter
spacing: 10
Button {
width: 150
height: 40
text: "Scroll UP"
}
Button {
width: 150
height: 40
text: "Scroll Down"
}
}
}
}
Since you know the height of a single row, you can simply manually adjust the contentY property of the ListView.
First, give the ListView an id.
ListView {
id: lv
...
}
Then update the contentY of your ListView whenever the Buttons are pressed:
Button {
width: 150
height: 40
text: "Scroll UP"
onClicked: {
lv.contentY -= 40
}
}
Button {
width: 150
height: 40
text: "Scroll Down"
onClicked: {
lv.contentY += 40
}
}

One or more parameter values were invalid: Missing the key Sensor in the item

I am trying to put items within the table and getting this error:
This is the objects.json file I am trying to insert into the db:
{
"Sensors":{
"L": [
{ "M": {
"Sensor": { "S": "Sensor1" },
"SensorDescription": { "S": "This is a description of a Sensor"},
"ImageFile": {"S": "/Sensors/image/Sensor1.txt"},
"SampleRate": {"N": "1"},
"Locations": {"S": "Orlando, FL"}
}
},
{ "M": {
"Sensor": { "S": "Sensor2" },
"SensorDescription": { "S": "This is a description of a Sensor"},
"ImageFile": {"S": "/Sensors/image/Sensor2.txt"},
"SampleRate": {"N": "2"},
"Locations": {"S": "Annapolis, MD"}
}
},
{ "M": {
"Sensor": { "S": "Sensor3" },
"SensorDescription": { "S": "This is a description of a Sensor"},
"ImageFile": {"S": "/Sensors/image/Sensor3.txt"},
"SampleRate": {"N": "3"},
"Locations": {"S": "Jacksonville, FL"}
}
},
{ "M": {
"Sensor": { "S": "Sensor4" },
"SensorDescription": { "S": "This is a description of a Sensor"},
"ImageFile": {"S": "/Sensors/image/Sensor4.txt"},
"SampleRate": {"N": "4"},
"Locations": {"S": "Balitimore, MD"}
}
},
{ "M": {
"Sensor": { "S": "Sensor5" },
"SensorDescription": { "S": "This is a description of a Sensor"},
"ImageFile": {"S": "/Sensors/image/Sensor5.txt"},
"SampleRate": {"N": "5"},
"Locations": {"S": "Washington DC"}
}
},
{ "M": {
"Sensor": { "S": "Sensor6" },
"SensorDescription": { "S": "This is a description of a Sensor"}
}
},
{ "M": {
"Sensor": { "S": "Sensor7" },
"SensorDescription": { "S": "This is a description of a Sensor" }
}
},
{ "M": {
"Sensor": { "S": "Sensor8" },
"SensorDescription": { "S": "This is a description of a Sensor"}
}
},
{ "M": {
"Sensor": { "S": "Sensor9" },
"SensorDescription": { "S": "This is a description of a Sensor"}
}
},
{ "M": {
"Sensor": { "S": "Sensor10" },
"SensorDescription": { "S": "This is a description of a Sensor"}
}
},
{ "M": {
"Sensor": { "S": "Sensor11" },
"SampleRate": {"N": "11"},
"Locations": {"S": "New York, NY"}
}
},
{ "M": {
"Sensor": { "S": "Sensor12" },
"SampleRate": {"N": "12"},
"Locations": {"S": "Buffalo, NY"}
}
},
{ "M": {
"Sensor": { "S": "Sensor13" },
"SampleRate": {"N": "13"},
"Locations": {"S": "Chicago, IL"}
}
},
{ "M": {
"Sensor": { "S": "Sensor14" },
"SampleRate": {"N": "14"},
"Locations": {"S": "Trenton, NJ"}
}
},
{ "M": {
"Sensor": { "S": "Sensor15" },
"SampleRate": {"N": "15"},
"Locations": {"S": "Los Angeles, CA"}
}
},
{ "M": {
"Sensor": { "S": "Sensor16" },
"SampleRate": {"N": "16"},
"SensorDescription": { "S": "This is a description of a Sensor"},
"AltName": {"S": "Sensor-16"}
}
},
{ "M": {
"Sensor": { "S": "Sensor17" },
"SampleRate": {"N": "17"},
"SensorDescription": { "S": "This is a description of a Sensor"},
"Date": {"S": "2022-09-11 15:00:00.000"}
}
},
{ "M": {
"Sensor": { "S": "Sensor18" },
"SampleRate": {"N": "18"},
"SensorDescription": { "S": "This is a description of a Sensor"},
"Working": {"BOOL": false }
}
},
{ "M": {
"Sensor": { "S": "Sensor19" },
"SampleRate": {"N": "19"},
"SensorDescription": { "S": "This is a description of a Sensor"},
"color": {"S": "Green" }
}
},
{ "M": {
"Sensor": { "S": "Sensor20" },
"SampleRate": {"N": "20"},
"SensorDescription": { "S": "This is a description of a Sensor"},
"Senor_type": {"S": "Type 2" }
}
}
]
}
}
Here is the table:
My eyes must be playing tricks on me because I can't see the issue or am I doing something else wrong? Any help is greatly appreciated.
Apparently my description of the issue is too short so I am writing this sentence so I may post..
While the previous answer by hunterhacker is correct, put-item cannot be used to insert batches of items. Instead, to insert a batch of items we must use batch-write-item which will allow us insert up to 25 items per batch:
https://docs.aws.amazon.com/cli/latest/reference/dynamodb/batch-write-item.html
For your use-case, you will need to alter your JSON slightly to make it work. I have edited your example given which you can further refer to and use:
{
"Sensors": [
{
"PutRequest": {
"Item": {
"Sensor": {
"S": "Sensor1"
},
"SensorDescription": {
"S": "This is a description of a Sensor"
},
"ImageFile": {
"S": "/Sensors/image/Sensor1.txt"
},
"SampleRate": {
"N": "1"
},
"Locations": {
"S": "Orlando, FL"
}
}
}
},
{
"PutRequest": {
"Item": {
"Sensor": {
"S": "Sensor2"
},
"SensorDescription": {
"S": "This is a description of a Sensor"
},
"ImageFile": {
"S": "/Sensors/image/Sensor2.txt"
},
"SampleRate": {
"N": "2"
},
"Locations": {
"S": "Annapolis, MD"
}
}
}
},
{
"PutRequest": {
"Item": {
"Sensor": {
"S": "Sensor3"
},
"SensorDescription": {
"S": "This is a description of a Sensor"
},
"ImageFile": {
"S": "/Sensors/image/Sensor3.txt"
},
"SampleRate": {
"N": "3"
},
"Locations": {
"S": "Jacksonville, FL"
}
}
}
},
{
"PutRequest": {
"Item": {
"Sensor": {
"S": "Sensor4"
},
"SensorDescription": {
"S": "This is a description of a Sensor"
},
"ImageFile": {
"S": "/Sensors/image/Sensor4.txt"
},
"SampleRate": {
"N": "4"
},
"Locations": {
"S": "Balitimore, MD"
}
}
}
},
{
"PutRequest": {
"Item": {
"Sensor": {
"S": "Sensor5"
},
"SensorDescription": {
"S": "This is a description of a Sensor"
},
"ImageFile": {
"S": "/Sensors/image/Sensor5.txt"
},
"SampleRate": {
"N": "5"
},
"Locations": {
"S": "Washington DC"
}
}
}
},
{
"PutRequest": {
"Item": {
"Sensor": {
"S": "Sensor6"
},
"SensorDescription": {
"S": "This is a description of a Sensor"
}
}
}
},
{
"PutRequest": {
"Item": {
"Sensor": {
"S": "Sensor7"
},
"SensorDescription": {
"S": "This is a description of a Sensor"
}
}
}
},
{
"PutRequest": {
"Item": {
"Sensor": {
"S": "Sensor8"
},
"SensorDescription": {
"S": "This is a description of a Sensor"
}
}
}
},
{
"PutRequest": {
"Item": {
"Sensor": {
"S": "Sensor9"
},
"SensorDescription": {
"S": "This is a description of a Sensor"
}
}
}
},
{
"PutRequest": {
"Item": {
"Sensor": {
"S": "Sensor10"
},
"SensorDescription": {
"S": "This is a description of a Sensor"
}
}
}
},
{
"PutRequest": {
"Item": {
"Sensor": {
"S": "Sensor11"
},
"SampleRate": {
"N": "11"
},
"Locations": {
"S": "New York, NY"
}
}
}
},
{
"PutRequest": {
"Item": {
"Sensor": {
"S": "Sensor12"
},
"SampleRate": {
"N": "12"
},
"Locations": {
"S": "Buffalo, NY"
}
}
}
},
{
"PutRequest": {
"Item": {
"Sensor": {
"S": "Sensor13"
},
"SampleRate": {
"N": "13"
},
"Locations": {
"S": "Chicago, IL"
}
}
}
},
{
"PutRequest": {
"Item": {
"Sensor": {
"S": "Sensor14"
},
"SampleRate": {
"N": "14"
},
"Locations": {
"S": "Trenton, NJ"
}
}
}
},
{
"PutRequest": {
"Item": {
"Sensor": {
"S": "Sensor15"
},
"SampleRate": {
"N": "15"
},
"Locations": {
"S": "Los Angeles, CA"
}
}
}
},
{
"PutRequest": {
"Item": {
"Sensor": {
"S": "Sensor16"
},
"SampleRate": {
"N": "16"
},
"SensorDescription": {
"S": "This is a description of a Sensor"
},
"AltName": {
"S": "Sensor-16"
}
}
}
},
{
"PutRequest": {
"Item": {
"Sensor": {
"S": "Sensor17"
},
"SampleRate": {
"N": "17"
},
"SensorDescription": {
"S": "This is a description of a Sensor"
},
"Date": {
"S": "2022-09-11 15:00:00.000"
}
}
}
},
{
"PutRequest": {
"Item": {
"Sensor": {
"S": "Sensor18"
},
"SampleRate": {
"N": "18"
},
"SensorDescription": {
"S": "This is a description of a Sensor"
},
"Working": {
"BOOL": false
}
}
}
},
{
"PutRequest": {
"Item": {
"Sensor": {
"S": "Sensor19"
},
"SampleRate": {
"N": "19"
},
"SensorDescription": {
"S": "This is a description of a Sensor"
},
"color": {
"S": "Green"
}
}
}
},
{
"PutRequest": {
"Item": {
"Sensor": {
"S": "Sensor20"
},
"SampleRate": {
"N": "20"
},
"SensorDescription": {
"S": "This is a description of a Sensor"
},
"Senor_type": {
"S": "Type 2"
}
}
}
}
]
}
Now to insert this into your table, you can use the following batch-write-item command:
aws dynamodb batch-write-item \
--request-items file://sensors.json \
--return-consumed-capacity TOTAL
Hope that helps :)
The put-item call takes a singular item and you’re trying to pass a list. You can see the docs and format definition at https://docs.aws.amazon.com/cli/latest/reference/dynamodb/put-item.html

Create QML components dinamically inside repeater

I have a ListModel which elements have information about a data type. I'm using this in a Repeater to show a label and a component according to the datatype, but I don't know how to change that TextField (in the case of "TEXT" datatype) with a; e.g. a button to call a file dialog in the case of "IMAGE"; or a TextField with a mask for double in the case I get datatype "REAL". How can I make this?
Here is my code:
Repeater {
id: r2
model: ListModel {
ListElement {
nombreCampo: "Name"
datoValor: "John Doe"
tipoDato: "TEXT"
}
ListElement {
nombreCampo: "Birth Date"
datoValor: "19910101"
tipoDato: "DATE"
}
ListElement {
nombreCampo: "Photo"
datoValor: "whatever.jpg"
tipoDato: "IMAGE"
}
ListElement {
nombreCampo: "Height"
datoValor: "1.55"
tipoDato: "REAL"
}
}
Text {
text: nombreCampo
}
// this would go well with "TEXT" but not with "DATE" (where I'd prefer a datepicker)
// or with "IMAGE" (where I'd prefer a button to call a file dialog).
// so this is the part where I need to generate it according to the case
TextField {
text: datoValor
placeholderText: nombreCampo
onTextChanged: {
r2.model.get( index ).datoValor = this.text;
}
}
}
Thanks in advance.
In Qt 5.12 you can use DelegateChooser + DelegateChoice:
import QtQuick 2.7
import QtQuick.Controls 2.3
import Qt.labs.qmlmodels 1.0
ApplicationWindow {
width: 500
height: 500
visible: true
Column {
anchors.fill: parent
Repeater {
id: r2
model: ListModel {
ListElement {
nombreCampo: "Name"
datoValor: "John Doe"
tipoDato: "TEXT"
}
ListElement {
nombreCampo: "Birth Date"
datoValor: "19910101"
tipoDato: "DATE"
}
ListElement {
nombreCampo: "Photo"
datoValor: "whatever.jpg"
tipoDato: "IMAGE"
}
ListElement {
nombreCampo: "Height"
datoValor: "1.55"
tipoDato: "REAL"
}
}
delegate: DelegateChooser {
role: "tipoDato"
DelegateChoice {
roleValue: "DATE"
// delegate: SomeDatePicker {
// date: datoValor
// }
}
DelegateChoice {
roleValue: "IMAGE"
delegate: Button {
text: "Select image"
}
}
DelegateChoice {
roleValue: "TEXT"
delegate: TextField {
text: model.datoValor
}
}
DelegateChoice {
roleValue: "REAL"
delegate: TextField {
text: model.datoValor
// inputMask: ...
}
}
}
}
}
}
In earlier versions, you can use Loader, and choose the source/sourceComponent based on the model data.
I would use a loader inside your delegate.
Column{
Repeater{
model: // your model
delegate: Loader{
anchors{
right: parent.right
left: parent.left
}
sourceComponent: {
if(tipoDato=== "TEXT") {return textFieldComponent;}
else if(tipoDato=== "DATE") {return datePickerComponent;}
else if(tipoDato=== "IMAGE"){return imagePickerPickerComponent;}
else if(tipoDato=== "REAL") {return floatPickerComponent;}
}
}
}
}
// Component definition
Component{
id: textFieldComponent
// Define your component here
}
Component{
id: datePickerComponent
// Define your component here
}
Component{
id: imagePickerPickerComponent
// Define your component here
}
Component{
id: floatPickerComponent
// Define your component here
}
If you use this example take into account that each component has to have their height defined and the top parent column has to have their width defined in order to render all the items correctly.

Retrieve post_title from WordPress object

I am trying to retrieve the Post Title from a WordPress object.
Here is a var_dump resulting from the WP_Query:
object(WP_Query)#4305 (49) { ["query"]=> array(2) { ["post_type"]=>
string(5) "cases" ["posts_per_page"]=> int(-1) } ["query_vars"]=>
array(64) { ["post_type"]=> string(5) "cases" ["posts_per_page"]=>
int(-1) ["error"]=> string(0) "" ["m"]=> string(0) "" ["p"]=> int(0)
["post_parent"]=> string(0) "" ["subpost"]=> string(0) ""
["subpost_id"]=> string(0) "" ["attachment"]=> string(0) ""
["attachment_id"]=> int(0) ["name"]=> string(0) "" ["static"]=>
string(0) "" ["pagename"]=> string(0) "" ["page_id"]=> int(0)
["second"]=> string(0) "" ["minute"]=> string(0) "" ["hour"]=>
string(0) "" ["day"]=> int(0) ["monthnum"]=> int(0) ["year"]=> int(0)
["w"]=> int(0) ["category_name"]=> string(0) "" ["tag"]=> string(0) ""
["cat"]=> string(0) "" ["tag_id"]=> string(0) "" ["author"]=>
string(0) "" ["author_name"]=> string(0) "" ["feed"]=> string(0) ""
["tb"]=> string(0) "" ["paged"]=> int(0) ["meta_key"]=> string(0) ""
["meta_value"]=> string(0) "" ["preview"]=> string(0) "" ["s"]=>
string(0) "" ["sentence"]=> string(0) "" ["title"]=> string(0) ""
["fields"]=> string(0) "" ["menu_order"]=> string(0) "" ["embed"]=>
string(0) "" ["category__in"]=> array(0) { } ["category__not_in"]=>
array(0) { } ["category__and"]=> array(0) { } ["post__in"]=> array(0)
{ } ["post__not_in"]=> array(0) { } ["post_name__in"]=> array(0) { }
["tag__in"]=> array(0) { } ["tag__not_in"]=> array(0) { }
["tag__and"]=> array(0) { } ["tag_slug__in"]=> array(0) { }
["tag_slug__and"]=> array(0) { } ["post_parent__in"]=> array(0) { }
["post_parent__not_in"]=> array(0) { } ["author__in"]=> array(0) { }
["author__not_in"]=> array(0) { } ["ignore_sticky_posts"]=>
bool(false) ["suppress_filters"]=> bool(false) ["cache_results"]=>
bool(true) ["update_post_term_cache"]=> bool(true)
["lazy_load_term_meta"]=> bool(true) ["update_post_meta_cache"]=>
bool(true) ["nopaging"]=> bool(true) ["comments_per_page"]=> string(2)
"50" ["no_found_rows"]=> bool(false) ["order"]=> string(4) "DESC" }
["tax_query"]=> object(WP_Tax_Query)#4307 (6) { ["queries"]=> array(0)
{ } ["relation"]=> string(3) "AND" ["table_aliases":protected]=>
array(0) { } ["queried_terms"]=> array(0) { } ["primary_table"]=>
string(8) "wp_posts" ["primary_id_column"]=> string(2) "ID" }
["meta_query"]=> object(WP_Meta_Query)#4303 (9) { ["queries"]=>
array(0) { } ["relation"]=> NULL ["meta_table"]=> NULL
["meta_id_column"]=> NULL ["primary_table"]=> NULL
["primary_id_column"]=> NULL ["table_aliases":protected]=> array(0) {
} ["clauses":protected]=> array(0) { } ["has_or_relation":protected]=>
bool(false) } ["date_query"]=> bool(false) ["request"]=> string(259)
"SELECT wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.post_type =
'cases' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status
= 'acf-disabled' OR wp_posts.post_author = 44 AND wp_posts.post_status = 'private') ORDER BY wp_posts.post_date DESC " ["posts"]=> array(42) { [0]=> object(WP_Post)#4270 (24) { ["ID"]=> int(19269)
["post_author"]=> string(1) "2" ["post_date"]=> string(19) "2018-10-02
10:46:05" ["post_date_gmt"]=> string(19) "2018-10-02 08:46:05"
["post_content"]=> string(0) "" ["post_title"]=> string(17) "Terberg -
ANNAbel" ["post_excerpt"]=> string(0) "" ["post_status"]=> string(7)
"publish" ["comment_status"]=> string(6) "closed" ["ping_status"]=>
string(6) "closed" ["post_password"]=> string(0) "" ["post_name"]=>
string(7) "annabel" ["to_ping"]=> string(0) "" ["pinged"]=> string(0)
"" ["post_modified"]=> string(19) "2018-11-15 12:37:10"
["post_modified_gmt"]=> string(19) "2018-11-15 11:37:10"
["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0)
["guid"]=> string(48) "https://www.zeo.nl/?post_type=cases&p=19269"
["menu_order"]=> int(0) ["post_type"]=> string(5) "cases"
["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0"
["filter"]=> string(3) "raw" } [1]=> object(WP_Post)#4269 (24) {
["ID"]=> int(19161) ["post_author"]=> string(1) "2" ["post_date"]=>
string(19) "2018-09-28 15:46:05" ["post_date_gmt"]=> string(19)
"2018-09-28 13:46:05" ["post_content"]=> string(0) "" ["post_title"]=>
string(19) "De Voordelige Groep" ["post_excerpt"]=> string(0) ""
["post_status"]=> string(7) "publish" ["comment_status"]=> string(6)
"closed" ["ping_status"]=> string(6) "closed" ["post_password"]=>
string(0) "" ["post_name"]=> string(19) "de-voordelige-groep"
["to_ping"]=> string(0) "" ["pinged"]=> string(0) ""
["post_modified"]=> string(19) "2018-11-15 12:28:00"
["post_modified_gmt"]=> string(19) "2018-11-15 11:28:00"
["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0)
["guid"]=> string(48) "https://www.zeo.nl/?post_type=cases&p=19161"
["menu_order"]=> int(0) ["post_type"]=> string(5) "cases"
["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0"
["filter"]=> string(3) "raw" } [2]=> object(WP_Post)#4268 (24) {
["ID"]=> int(19163) ["post_author"]=> string(1) "2" ["post_date"]=>
string(19) "2018-09-28 15:42:12" ["post_date_gmt"]=> string(19)
"2018-09-28 13:42:12" ["post_content"]=> string(0) "" ["post_title"]=>
string(16) "Global Factories" ["post_excerpt"]=> string(0) ""
["post_status"]=> string(7) "publish" ["comment_status"]=> string(6)
"closed" ["ping_status"]=> string(6) "closed" ["post_password"]=>
string(0) "" ["post_name"]=> string(16) "global-factories"
["to_ping"]=> string(0) "" ["pinged"]=> string(0) ""
["post_modified"]=> string(19) "2018-11-15 12:41:57"
["post_modified_gmt"]=> string(19) "2018-11-15 11:41:57"
["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0)
["guid"]=> string(48) "https://www.zeo.nl/?post_type=cases&p=19163"
["menu_order"]=> int(0) ["post_type"]=> string(5) "cases"
["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0"
["filter"]=> string(3) "raw" } [3]=> object(WP_Post)#4267 (24) {
["ID"]=> int(19167) ["post_author"]=> string(1) "2" ["post_date"]=>
string(19) "2018-09-21 14:58:50" ["post_date_gmt"]=> string(19)
"2018-09-21 12:58:50" ["post_content"]=> string(0) "" ["post_title"]=>
string(24) "Warmteservice Groep B.V." ["post_excerpt"]=> string(0) ""
["post_status"]=> string(7) "publish" ["comment_status"]=> string(6)
"closed" ["ping_status"]=> string(6) "closed" ["post_password"]=>
string(0) "" ["post_name"]=> string(13) "warmteservice" ["to_ping"]=>
string(0) "" ["pinged"]=> string(0) "" ["post_modified"]=> string(19)
"2018-11-15 12:00:56" ["post_modified_gmt"]=> string(19) "2018-11-15
11:00:56" ["post_content_filtered"]=> string(0) "" ["post_parent"]=>
int(0) ["guid"]=> string(48)
"https://www.zeo.nl/?post_type=cases&p=19167" ["menu_order"]=> int(0)
["post_type"]=> string(5) "cases" ["post_mime_type"]=> string(0) ""
["comment_count"]=> string(1) "0" ["filter"]=> string(3) "raw" } [4]=>
object(WP_Post)#4266 (24) { ["ID"]=> int(19157) ["post_author"]=>
string(1) "2" ["post_date"]=> string(19) "2018-09-21 11:26:12"
["post_date_gmt"]=> string(19) "2018-09-21 09:26:12"
["post_content"]=> string(0) "" ["post_title"]=> string(9) "Blauwtulp"
["post_excerpt"]=> string(0) "" ["post_status"]=> string(7) "publish"
["comment_status"]=> string(6) "closed" ["ping_status"]=> string(6)
"closed" ["post_password"]=> string(0) "" ["post_name"]=> string(11)
"blauwtulp-2" ["to_ping"]=> string(0) "" ["pinged"]=> string(0) ""
["post_modified"]=> string(19) "2018-11-15 12:46:48"
["post_modified_gmt"]=> string(19) "2018-11-15 11:46:48"
["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0)
["guid"]=> string(48) "https://www.zeo.nl/?post_type=cases&p=19157"
["menu_order"]=> int(0) ["post_type"]=> string(5) "cases"
["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0"
["filter"]=> string(3) "raw" } [5]=> object(WP_Post)#4265 (24) {
["ID"]=> int(19154) ["post_author"]=> string(1) "2" ["post_date"]=>
string(19) "2018-09-21 11:15:52" ["post_date_gmt"]=> string(19)
"2018-09-21 09:15:52" ["post_content"]=> string(0) "" ["post_title"]=>
string(22) "AO Smith International" ["post_excerpt"]=> string(0) ""
["post_status"]=> string(7) "publish" ["comment_status"]=> string(6)
"closed" ["ping_status"]=> string(6) "closed" ["post_password"]=>
string(0) "" ["post_name"]=> string(8) "ao-smith" ["to_ping"]=>
string(0) "" ["pinged"]=> string(0) "" ["post_modified"]=> string(19)
"2018-11-15 12:39:59" ["post_modified_gmt"]=> string(19) "2018-11-15
11:39:59" ["post_content_filtered"]=> string(0) "" ["post_parent"]=>
int(0) ["guid"]=> string(48)
"https://www.zeo.nl/?post_type=cases&p=19154" ["menu_order"]=> int(0)
["post_type"]=> string(5) "cases" ["post_mime_type"]=> string(0) ""
["comment_count"]=> string(1) "0" ["filter"]=> string(3) "raw" } [6]=>
object(WP_Post)#4264 (24) { ["ID"]=> int(19103) ["post_author"]=>
string(1) "3" ["post_date"]=> string(19) "2018-09-12 12:13:53"
["post_date_gmt"]=> string(19) "2018-09-12 10:13:53"
["post_content"]=> string(0) "" ["post_title"]=> string(10)
"FixFast.de" ["post_excerpt"]=> string(0) "" ["post_status"]=>
string(7) "publish" ["comment_status"]=> string(6) "closed"
["ping_status"]=> string(6) "closed" ["post_password"]=> string(0) ""
["post_name"]=> string(10) "fixfast-de" ["to_ping"]=> string(0) ""
["pinged"]=> string(0) "" ["post_modified"]=> string(19) "2018-11-15
12:23:55" ["post_modified_gmt"]=> string(19) "2018-11-15 11:23:55"
["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0)
["guid"]=> string(48) "https://www.zeo.nl/?post_type=cases&p=19103"
["menu_order"]=> int(0) ["post_type"]=> string(5) "cases"
["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0"
["filter"]=> string(3) "raw" } [7]=> object(WP_Post)#4263 (24) {
["ID"]=> int(19072) ["post_author"]=> string(1) "3" ["post_date"]=>
string(19) "2018-09-05 13:05:27" ["post_date_gmt"]=> string(19)
"2018-09-05 11:05:27" ["post_content"]=> string(0) "" ["post_title"]=>
string(8) "Shopware" ["post_excerpt"]=> string(0) "" ["post_status"]=>
string(7) "publish" ["comment_status"]=> string(6) "closed"
["ping_status"]=> string(6) "closed" ["post_password"]=> string(0) ""
["post_name"]=> string(8) "shopware" ["to_ping"]=> string(0) ""
["pinged"]=> string(0) "" ["post_modified"]=> string(19) "2018-09-05
13:30:52" ["post_modified_gmt"]=> string(19) "2018-09-05 11:30:52"
["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0)
["guid"]=> string(48) "https://www.zeo.nl/?post_type=cases&p=19072"
["menu_order"]=> int(0) ["post_type"]=> string(5) "cases"
["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0"
["filter"]=> string(3) "raw" } [8]=> object(WP_Post)#4262 (24) {
["ID"]=> int(18910) ["post_author"]=> string(1) "2" ["post_date"]=>
string(19) "2018-07-12 14:16:15" ["post_date_gmt"]=> string(19)
"2018-07-12 12:16:15" ["post_content"]=> string(0) "" ["post_title"]=>
string(11) "Burger King" ["post_excerpt"]=> string(0) ""
["post_status"]=> string(7) "publish" ["comment_status"]=> string(6)
"closed" ["ping_status"]=> string(6) "closed" ["post_password"]=>
string(0) "" ["post_name"]=> string(13) "burger-king-2" ["to_ping"]=>
string(0) "" ["pinged"]=> string(0) "" ["post_modified"]=> string(19)
"2018-11-15 11:59:50" ["post_modified_gmt"]=> string(19) "2018-11-15
10:59:50" ["post_content_filtered"]=> string(0) "" ["post_parent"]=>
int(0) ["guid"]=> string(48)
"https://www.zeo.nl/?post_type=cases&p=18910" ["menu_order"]=> int(0)
["post_type"]=> string(5) "cases" ["post_mime_type"]=> string(0) ""
["comment_count"]=> string(1) "0" ["filter"]=> string(3) "raw" } [9]=>
object(WP_Post)#4261 (24) { ["ID"]=> int(18907) ["post_author"]=>
string(1) "2" ["post_date"]=> string(19) "2018-07-12 13:50:43"
["post_date_gmt"]=> string(19) "2018-07-12 11:50:43"
["post_content"]=> string(0) "" ["post_title"]=> string(14) "Ideal
Standard" ["post_excerpt"]=> string(0) "" ["post_status"]=> string(7)
"publish" ["comment_status"]=> string(6) "closed" ["ping_status"]=>
string(6) "closed" ["post_password"]=> string(0) "" ["post_name"]=>
string(14) "ideal-standard" ["to_ping"]=> string(0) "" ["pinged"]=>
string(0) "" ["post_modified"]=> string(19) "2018-11-15 12:06:02"
["post_modified_gmt"]=> string(19) "2018-11-15 11:06:02"
["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0)
["guid"]=> string(48) "https://www.zeo.nl/?post_type=cases&p=18907"
["menu_order"]=> int(0) ["post_type"]=> string(5) "cases"
["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0"
["filter"]=> string(3) "raw" } [10]=> object(WP_Post)#4260 (24) {
["ID"]=> int(18760) ["post_author"]=> string(1) "3" ["post_date"]=>
string(19) "2018-07-11 12:29:18" ["post_date_gmt"]=> string(19)
"2018-07-11 10:29:18" ["post_content"]=> string(0) "" ["post_title"]=>
string(18) "Thomas Stofzuigers" ["post_excerpt"]=> string(0) ""
["post_status"]=> string(7) "publish" ["comment_status"]=> string(6)
"closed" ["ping_status"]=> string(6) "closed" ["post_password"]=>
string(0) "" ["post_name"]=> string(20) "thomas-stofzuigers-2"
["to_ping"]=> string(0) "" ["pinged"]=> string(0) ""
["post_modified"]=> string(19) "2018-11-15 12:44:26"
["post_modified_gmt"]=> string(19) "2018-11-15 11:44:26"
["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0)
["guid"]=> string(48) "https://www.zeo.nl/?post_type=cases&p=18760"
["menu_order"]=> int(0) ["post_type"]=> string(5) "cases"
["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0"
["filter"]=> string(3) "raw" } [11]=> object(WP_Post)#4259 (24) {
["ID"]=> int(18858) ["post_author"]=> string(1) "3" ["post_date"]=>
string(19) "2018-07-11 12:10:23" ["post_date_gmt"]=> string(19)
"2018-07-11 10:10:23" ["post_content"]=> string(0) "" ["post_title"]=>
string(22) "Waaijenberg Mobiliteit" ["post_excerpt"]=> string(0) ""
["post_status"]=> string(7) "publish" ["comment_status"]=> string(6)
"closed" ["ping_status"]=> string(6) "closed" ["post_password"]=>
string(0) "" ["post_name"]=> string(22) "waaijenberg-mobiliteit"
["to_ping"]=> string(0) "" ["pinged"]=> string(0) ""
["post_modified"]=> string(19) "2018-11-15 12:24:50"
["post_modified_gmt"]=> string(19) "2018-11-15 11:24:50"
["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0)
["guid"]=> string(48) "https://www.zeo.nl/?post_type=cases&p=18858"
["menu_order"]=> int(0) ["post_type"]=> string(5) "cases"
["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0"
["filter"]=> string(3) "raw" } [12]=> object(WP_Post)#4258 (24) {
["ID"]=> int(18852) ["post_author"]=> string(1) "3" ["post_date"]=>
string(19) "2018-07-11 10:04:06" ["post_date_gmt"]=> string(19)
"2018-07-11 08:04:06" ["post_content"]=> string(0) "" ["post_title"]=>
string(20) "Buiskoppelingshop.nl" ["post_excerpt"]=> string(0) ""
["post_status"]=> string(7) "publish" ["comment_status"]=> string(6)
"closed" ["ping_status"]=> string(6) "closed" ["post_password"]=>
string(0) "" ["post_name"]=> string(22) "buiskoppelingshop-nl-2"
["to_ping"]=> string(0) "" ["pinged"]=> string(0) ""
["post_modified"]=> string(19) "2018-11-15 12:26:55"
["post_modified_gmt"]=> string(19) "2018-11-15 11:26:55"
["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0)
["guid"]=> string(48) "https://www.zeo.nl/?post_type=cases&p=18852"
["menu_order"]=> int(0) ["post_type"]=> string(5) "cases"
["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0"
["filter"]=> string(3) "raw" } [13]=> object(WP_Post)#4257 (24) {
["ID"]=> int(18655) ["post_author"]=> string(1) "3" ["post_date"]=>
string(19) "2018-05-24 13:10:32" ["post_date_gmt"]=> string(19)
"2018-05-24 11:10:32" ["post_content"]=> string(0) "" ["post_title"]=>
string(8) "SprayPay" ["post_excerpt"]=> string(0) "" ["post_status"]=>
string(7) "publish" ["comment_status"]=> string(6) "closed"
["ping_status"]=> string(6) "closed" ["post_password"]=> string(0) ""
["post_name"]=> string(8) "spraypay" ["to_ping"]=> string(0) ""
["pinged"]=> string(0) "" ["post_modified"]=> string(19) "2018-05-24
13:13:14" ["post_modified_gmt"]=> string(19) "2018-05-24 11:13:14"
["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0)
["guid"]=> string(48) "https://www.zeo.nl/?post_type=cases&p=18655"
["menu_order"]=> int(0) ["post_type"]=> string(5) "cases"
["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0"
["filter"]=> string(3) "raw" } [14]=> object(WP_Post)#4256 (24) {
["ID"]=> int(18653) ["post_author"]=> string(1) "3" ["post_date"]=>
string(19) "2018-05-24 12:17:25" ["post_date_gmt"]=> string(19)
"2018-05-24 10:17:25" ["post_content"]=> string(0) "" ["post_title"]=>
string(5) "Sooqr" ["post_excerpt"]=> string(0) "" ["post_status"]=>
string(7) "publish" ["comment_status"]=> string(6) "closed"
["ping_status"]=> string(6) "closed" ["post_password"]=> string(0) ""
["post_name"]=> string(5) "sooqr" ["to_ping"]=> string(0) ""
["pinged"]=> string(0) "" ["post_modified"]=> string(19) "2018-05-24
12:17:25" ["post_modified_gmt"]=> string(19) "2018-05-24 10:17:25"
["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0)
["guid"]=> string(48) "https://www.zeo.nl/?post_type=cases&p=18653"
["menu_order"]=> int(0) ["post_type"]=> string(5) "cases"
["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0"
["filter"]=> string(3) "raw" } [15]=> object(WP_Post)#4255 (24) {
["ID"]=> int(18650) ["post_author"]=> string(1) "3" ["post_date"]=>
string(19) "2018-05-24 11:37:51" ["post_date_gmt"]=> string(19)
"2018-05-24 09:37:51" ["post_content"]=> string(0) "" ["post_title"]=>
string(6) "Pay.nl" ["post_excerpt"]=> string(0) "" ["post_status"]=>
string(7) "publish" ["comment_status"]=> string(6) "closed"
["ping_status"]=> string(6) "closed" ["post_password"]=> string(0) ""
["post_name"]=> string(6) "pay-nl" ["to_ping"]=> string(0) ""
["pinged"]=> string(0) "" ["post_modified"]=> string(19) "2018-05-24
11:43:57" ["post_modified_gmt"]=> string(19) "2018-05-24 09:43:57"
["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0)
["guid"]=> string(48) "https://www.zeo.nl/?post_type=cases&p=18650"
["menu_order"]=> int(0) ["post_type"]=> string(5) "cases"
["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0"
["filter"]=> string(3) "raw" } [16]=> object(WP_Post)#4254 (24) {
["ID"]=> int(18645) ["post_author"]=> string(1) "3" ["post_date"]=>
string(19) "2018-05-23 16:46:32" ["post_date_gmt"]=> string(19)
"2018-05-23 14:46:32" ["post_content"]=> string(0) "" ["post_title"]=>
string(11) "Hellodialog" ["post_excerpt"]=> string(0) ""
["post_status"]=> string(7) "publish" ["comment_status"]=> string(6)
"closed" ["ping_status"]=> string(6) "closed" ["post_password"]=>
string(0) "" ["post_name"]=> string(11) "hellodialog" ["to_ping"]=>
string(0) "" ["pinged"]=> string(0) "" ["post_modified"]=> string(19)
"2018-05-30 15:26:13" ["post_modified_gmt"]=> string(19) "2018-05-30
13:26:13" ["post_content_filtered"]=> string(0) "" ["post_parent"]=>
int(0) ["guid"]=> string(48)
"https://www.zeo.nl/?post_type=cases&p=18645" ["menu_order"]=> int(0)
["post_type"]=> string(5) "cases" ["post_mime_type"]=> string(0) ""
["comment_count"]=> string(1) "0" ["filter"]=> string(3) "raw" }
[17]=> object(WP_Post)#4253 (24) { ["ID"]=> int(18643)
["post_author"]=> string(1) "3" ["post_date"]=> string(19) "2018-05-23
16:32:09" ["post_date_gmt"]=> string(19) "2018-05-23 14:32:09"
["post_content"]=> string(0) "" ["post_title"]=> string(16) "Feedback
Company" ["post_excerpt"]=> string(0) "" ["post_status"]=> string(7)
"publish" ["comment_status"]=> string(6) "closed" ["ping_status"]=>
string(6) "closed" ["post_password"]=> string(0) "" ["post_name"]=>
string(16) "feedback-company" ["to_ping"]=> string(0) "" ["pinged"]=>
string(0) "" ["post_modified"]=> string(19) "2018-05-23 16:34:46"
["post_modified_gmt"]=> string(19) "2018-05-23 14:34:46"
["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0)
["guid"]=> string(48) "https://www.zeo.nl/?post_type=cases&p=18643"
["menu_order"]=> int(0) ["post_type"]=> string(5) "cases"
I am trying to get the post_title. This is what I have so far:
<?php
$args = array(
'post_type' => 'cases',
'posts_per_page' => -1,
);
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ):
while ( $the_query->have_posts() ): $the_query->the_post();
$case_title = get_field('post_title');
echo $case_title;
var_dump($the_query);
?>
<?php endwhile; wp_reset_postdata(); endif;?>
But it is not retrieving the title.
What should I be doing to retrieve the title?
To echo the Title you can do this <?php the_title(); ?> and to put the title in a var you can do this $title = get_the_title();
for more information: https://developer.wordpress.org/reference/functions/get_the_title/
<?php
$args = array(
'post_type' => 'cases',
'posts_per_page' => -1,
);
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ):
while ( $the_query->have_posts() ): $the_query->the_post();
$case_title = get_the_title();
echo $case_title;
// or
echo the_title();
var_dump($the_query);
?>
<?php endwhile; wp_reset_postdata(); endif;?>

Enabling subscription track for Sendgrid

This is really an extension of this question
but my code has changed a bit, so I thought I should start a new question. I am using the SMTP-API to speed up the delivery between our server and Sendgrid.
$hdr = new SmtpApiHeader();
$toList = $mailTo;
$hdr->addTo($toList);
$hdr->addFilterSetting('subscriptiontrack', 'enable', 1);
$to = array('email#email.edu'=>'Carey Estes');
$transport = $connection = Swift_SmtpTransport::newInstance('smtp.sendgrid.net', 465, 'ssl');
$transport ->setUsername($username);
$transport ->setPassword($password);
$swift = Swift_Mailer::newInstance($transport);
$message = new Swift_Message($subject);
$headers = $message->getHeaders();
$headers->addTextHeader('X-SMTPAPI', $hdr->asJSON());
$message->setFrom($mailFrom);
$message->setBody($contents, 'text/html');
$message->setTo($to);
if ($recipients = $swift->send($message, $failures))
{
return true;
}
Similar to the issue I had before, I cannot manipulate the unsubscribe link in the email. Before, I could not turn it off...and now with the new setup, I can't seem to turn it on.
$hdr->addFilterSetting('subscriptiontrack', 'enable', 1);
should make the unsubscribe link available in the email correct? Whether 0 or 1, the unsubscribe link does not appear.
In the previous question, I was structuring the JSON in the header incorrectly. Is this the case now?
UPDATE
Here is a var_dump of the $header variable, which looks wrong to me:
object(Swift_Mime_SimpleHeaderSet)#315 (5) { ["_factory":"Swift_Mime_SimpleHeaderSet":private]=> object(Swift_Mime_SimpleHeaderFactory)#316 (3) { ["_encoder":"Swift_Mime_SimpleHeaderFactory":private]=> object(Swift_Mime_HeaderEncoder_QpHeaderEncoder)#317 (2) { ["_charStream":protected]=> object(Swift_CharacterStream_NgCharacterStream)#318 (9) { ["_charReader":"Swift_CharacterStream_NgCharacterStream":private]=> NULL ["_charReaderFactory":"Swift_CharacterStream_NgCharacterStream":private]=> object(Swift_CharacterReaderFactory_SimpleCharacterReaderFactory)#319 (2) { ["_map":"Swift_CharacterReaderFactory_SimpleCharacterReaderFactory":private]=> array(15) { ["utf-?8"]=> array(2) { ["class"]=> string(32) "Swift_CharacterReader_Utf8Reader" ["constructor"]=> array(0) { } } ["(us-)?ascii"]=> array(2) { ["class"]=> string(45) "Swift_CharacterReader_GenericFixedWidthReader" ["constructor"]=> array(1) { [0]=> int(1) } } ["(iso|iec)-?8859-?[0-9]+"]=> array(2) { ["class"]=> string(45) "Swift_CharacterReader_GenericFixedWidthReader" ["constructor"]=> array(1) { [0]=> int(1) } } ["windows-?125[0-9]"]=> array(2) { ["class"]=> string(45) "Swift_CharacterReader_GenericFixedWidthReader" ["constructor"]=> array(1) { [0]=> int(1) } } ["cp-?[0-9]+"]=> array(2) { ["class"]=> string(45) "Swift_CharacterReader_GenericFixedWidthReader" ["constructor"]=> array(1) { [0]=> int(1) } } ["ansi"]=> array(2) { ["class"]=> string(45) "Swift_CharacterReader_GenericFixedWidthReader" ["constructor"]=> array(1) { [0]=> int(1) } } ["macintosh"]=> array(2) { ["class"]=> string(45) "Swift_CharacterReader_GenericFixedWidthReader" ["constructor"]=> array(1) { [0]=> int(1) } } ["koi-?7"]=> array(2) { ["class"]=> string(45) "Swift_CharacterReader_GenericFixedWidthReader" ["constructor"]=> array(1) { [0]=> int(1) } } ["koi-?8-?.+"]=> array(2) { ["class"]=> string(45) "Swift_CharacterReader_GenericFixedWidthReader" ["constructor"]=> array(1) { [0]=> int(1) } } ["mik"]=> array(2) { ["class"]=> string(45) "Swift_CharacterReader_GenericFixedWidthReader" ["constructor"]=> array(1) { [0]=> int(1) } } ["(cork|t1)"]=> array(2) { ["class"]=> string(45) "Swift_CharacterReader_GenericFixedWidthReader" ["constructor"]=> array(1) { [0]=> int(1) } } ["v?iscii"]=> array(2) { ["class"]=> string(45) "Swift_CharacterReader_GenericFixedWidthReader" ["constructor"]=> array(1) { [0]=> int(1) } } ["(ucs-?2|utf-?16)"]=> array(2) { ["class"]=> string(45) "Swift_CharacterReader_GenericFixedWidthReader" ["constructor"]=> array(1) { [0]=> int(2) } } ["(ucs-?4|utf-?32)"]=> array(2) { ["class"]=> string(45) "Swift_CharacterReader_GenericFixedWidthReader" ["constructor"]=> array(1) { [0]=> int(4) } } [".*"]=> array(2) { ["class"]=> string(45) "Swift_CharacterReader_GenericFixedWidthReader" ["constructor"]=> array(1) { [0]=> int(1) } } } ["_loaded":"Swift_CharacterReaderFactory_SimpleCharacterReaderFactory":private]=> array(0) { } } ["_charset":"Swift_CharacterStream_NgCharacterStream":private]=> string(5) "utf-8" ["_datas":"Swift_CharacterStream_NgCharacterStream":private]=> string(0) "" ["_datasSize":"Swift_CharacterStream_NgCharacterStream":private]=> int(0) ["_map":"Swift_CharacterStream_NgCharacterStream":private]=> NULL ["_mapType":"Swift_CharacterStream_NgCharacterStream":private]=> int(0) ["_charCount":"Swift_CharacterStream_NgCharacterStream":private]=> int(0) ["_currentPos":"Swift_CharacterStream_NgCharacterStream":private]=> int(0) } ["_filter":protected]=> NULL } ["_paramEncoder":"Swift_Mime_SimpleHeaderFactory":private]=> object(Swift_Encoder_Rfc2231Encoder)#320 (1) { ["_charStream":"Swift_Encoder_Rfc2231Encoder":private]=> object(Swift_CharacterStream_NgCharacterStream)#321 (9) { ["_charReader":"Swift_CharacterStream_NgCharacterStream":private]=> NULL ["_charReaderFactory":"Swift_CharacterStream_NgCharacterStream":private]=> object(Swift_CharacterReaderFactory_SimpleCharacterReaderFactory)#319 (2) { ["_map":"Swift_CharacterReaderFactory_SimpleCharacterReaderFactory":private]=> array(15) { ["utf-?8"]=> array(2) { ["class"]=> string(32) "Swift_CharacterReader_Utf8Reader" ["constructor"]=> array(0) { } } ["(us-)?ascii"]=> array(2) { ["class"]=> string(45) "Swift_CharacterReader_GenericFixedWidthReader" ["constructor"]=> array(1) { [0]=> int(1) } } ["(iso|iec)-?8859-?[0-9]+"]=> array(2) { ["class"]=> string(45) "Swift_CharacterReader_GenericFixedWidthReader" ["constructor"]=> array(1) { [0]=> int(1) } } ["windows-?125[0-9]"]=> array(2) { ["class"]=> string(45) "Swift_CharacterReader_GenericFixedWidthReader" ["constructor"]=> array(1) { [0]=> int(1) } } ["cp-?[0-9]+"]=> array(2) { ["class"]=> string(45) "Swift_CharacterReader_GenericFixedWidthReader" ["constructor"]=> array(1) { [0]=> int(1) } } ["ansi"]=> array(2) { ["class"]=> string(45) "Swift_CharacterReader_GenericFixedWidthReader" ["constructor"]=> array(1) { [0]=> int(1) } } ["macintosh"]=> array(2) { ["class"]=> string(45) "Swift_CharacterReader_GenericFixedWidthReader" ["constructor"]=> array(1) { [0]=> int(1) } } ["koi-?7"]=> array(2) { ["class"]=> string(45) "Swift_CharacterReader_GenericFixedWidthReader" ["constructor"]=> array(1) { [0]=> int(1) } } ["koi-?8-?.+"]=> array(2) { ["class"]=> string(45) "Swift_CharacterReader_GenericFixedWidthReader" ["constructor"]=> array(1) { [0]=> int(1) } } ["mik"]=> array(2) { ["class"]=> string(45) "Swift_CharacterReader_GenericFixedWidthReader" ["constructor"]=> array(1) { [0]=> int(1) } } ["(cork|t1)"]=> array(2) { ["class"]=> string(45) "Swift_CharacterReader_GenericFixedWidthReader" ["constructor"]=> array(1) { [0]=> int(1) } } ["v?iscii"]=> array(2) { ["class"]=> string(45) "Swift_CharacterReader_GenericFixedWidthReader" ["constructor"]=> array(1) { [0]=> int(1) } } ["(ucs-?2|utf-?16)"]=> array(2) { ["class"]=> string(45) "Swift_CharacterReader_GenericFixedWidthReader" ["constructor"]=> array(1) { [0]=> int(2) } } ["(ucs-?4|utf-?32)"]=> array(2) { ["class"]=> string(45) "Swift_CharacterReader_GenericFixedWidthReader" ["constructor"]=> array(1) { [0]=> int(4) } } [".*"]=> array(2) { ["class"]=> string(45) "Swift_CharacterReader_GenericFixedWidthReader" ["constructor"]=> array(1) { [0]=> int(1) } } } ["_loaded":"Swift_CharacterReaderFactory_SimpleCharacterReaderFactory":private]=> array(0) { } } ["_charset":"Swift_CharacterStream_NgCharacterStream":private]=> string(5) "utf-8" ["_datas":"Swift_CharacterStream_NgCharacterStream":private]=> string(0) "" ["_datasSize":"Swift_CharacterStream_NgCharacterStream":private]=> int(0) ["_map":"Swift_CharacterStream_NgCharacterStream":private]=> NULL ["_mapType":"Swift_CharacterStream_NgCharacterStream":private]=> int(0) ["_charCount":"Swift_CharacterStream_NgCharacterStream":private]=> int(0) ["_currentPos":"Swift_CharacterStream_NgCharacterStream":private]=> int(0) } } ["_charset":"Swift_Mime_SimpleHeaderFactory":private]=> string(5) "utf-8" } ["_headers":"Swift_Mime_SimpleHeaderSet":private]=> array(8) { ["content-transfer-encoding"]=> array(1) { [0]=> object(Swift_Mime_Headers_UnstructuredHeader)#314 (9) { ["_value":"Swift_Mime_Headers_UnstructuredHeader":private]=> string(16) "quoted-printable" ["_specials":"Swift_Mime_Headers_AbstractHeader":private]=> array(0) { } ["_grammar":"Swift_Mime_Headers_AbstractHeader":private]=> array(0) { } ["_name":"Swift_Mime_Headers_AbstractHeader":private]=> string(25) "Content-Transfer-Encoding" ["_encoder":"Swift_Mime_Headers_AbstractHeader":private]=> object(Swift_Mime_HeaderEncoder_QpHeaderEncoder)#317 (2) { ["_charStream":protected]=> object(Swift_CharacterStream_NgCharacterStream)#318 (9) { ["_charReader":"Swift_CharacterStream_NgCharacterStream":private]=> NULL ["_charReaderFactory":"Swift_CharacterStream_NgCharacterStream":private]=> object(Swift_CharacterReaderFactory_SimpleCharacterReaderFactory)#319 (2) { ["_map":"Swift_CharacterReaderFactory_SimpleCharacterReaderFactory":private]=> array(15) { ["utf-?8"]=> array(2) { ["class"]=> string(32) "Swift_CharacterReader_Utf8Reader" ["constructor"]=> array(0) { } } ["(us-)?ascii"]=> array(2) { ["class"]=> string(45) "Swift_CharacterReader_GenericFixedWidthReader" ["constructor"]=> array(1) { [0]=> int(1) } } ["(iso|iec)-?8859-?[0-9]+"]=> array(2) { ["class"]=> string(45) "Swift_CharacterReader_GenericFixedWidthReader" ["constructor"]=> array(1) { [0]=> int(1) } } ["windows-?125[0-9]"]=> array(2) { ["class"]=> string(45) "Swift_CharacterReader_GenericFixedWidthReader" ["constructor"]=> array(1) { [0]=> int(1) } } ["cp-?[0-9]+"]=> array(2) { ["class"]=> string(45) "Swift_CharacterReader_GenericFixedWidthReader" ["constructor"]=> array(1) { [0]=> int(1) } } ["ansi"]=> array(2) { ["class"]=> string(45) "Swift_CharacterReader_GenericFixedWidthReader" ["constructor"]=> array(1) { [0]=> int(1) } } ["macintosh"]=> array(2) { ["class"]=> string(45) "Swift_CharacterReader_GenericFixedWidthReader" ["constructor"]=> array(1) { [0]=> int(1) } } ["koi-?7"]=> array(2) { ["class"]=> string(45) "Swift_CharacterReader_GenericFixedWidthReader" ["constructor"]=> array(1) { [0]=> int(1) } } ["koi-?8-?.+"]=> array(2) { ["class"]=> string(45) "Swift_CharacterReader_GenericFixedWidthReader" ["constructor"]=> array(1) { [0]=> int(1) } } ["mik"]=> array(2) { ["class"]=> string(45) "Swift_CharacterReader_GenericFixedWidthReader" ["constructor"]=> array(1) { [0]=> int(1) } } ["(cork|t1)"]=> array(2) { ["class"]=> string(45) "Swift_CharacterReader_GenericFixedWidthReader" ["constructor"]=> array(1) { [0]=> int(1) } } ["v?iscii"]=> array(2) { ["class"]=> string(45) "Swift_CharacterReader_GenericFixedWidthReader" ["constructor"]=> array(1) { [0]=> int(1) } } ["(ucs-?2|utf-?16)"]=> array(2) { ["class"]=> string(45) "Swift_CharacterReader_GenericFixedWidthReader" ["constructor"]=> array(1) { [0]=> int(2) } } ["(ucs-?4|utf-?32)"]=> array(2) { ["class"]=> string(45) "Swift_CharacterReader_GenericFixedWidthReader" ["constructor"]=> array(1) { [0]=> int(4) } } [".*"]=> array(2) { ["class"]=> string(45) "Swift_CharacterReader_GenericFixedWidthReader" ["constructor"]=> array(1) { [0]=> int(1) } } } ["_loaded":"Swift_CharacterReaderFactory_SimpleCharacterReaderFactory":private]=> array(0) { } } ["_charset":"Swift_CharacterStream_NgCharacterStream":private]=> string(5) "utf-8" ["_datas":"Swift_CharacterStream_NgCharacterStream":private]=> string(0) "" ["_datasSize":"Swift_CharacterStream_NgCharacterStream":private]=> int(0) ["_map":"Swift_CharacterStream_NgCharacterStream":private]=> NULL ["_mapType":"Swift_CharacterStream_NgCharacterStream":private]=> int(0) ["_charCount":"Swift_CharacterStream_NgCharacterStream":private]=> int(0) ["_currentPos":"Swift_CharacterStream_NgCharacterStream":private]=> int(0) } ["_filter":protected]=> NULL } ["_lineLength":"Swift_Mime_Headers_AbstractHeader":private]=> int(78) ["_lang":"Swift_Mime_Headers_AbstractHeader":private]=> NULL ["_charset":"Swift_Mime_Headers_AbstractHeader":private]=> string(5) "utf-8" ["_cachedValue":"Swift_Mime_Headers_AbstractHeader":private]=> NULL } } ["content-type"]=> array(1) { [0]=> object(Swift_Mime_Headers_ParameterizedHeader)#327 (12) { ["_paramEncoder":"Swift_Mime_Headers_ParameterizedHeader":private]=> NULL ["_params":"Swift_Mime_Headers_ParameterizedHeader":private]=> array(1) { ["charset"]=> string(5) "utf-8" } ["_tokenRe":"Swift_Mime_Headers_ParameterizedHeader":private]=> string(63) "(?:[\x21\x23-\x27\x2A\x2B\x2D\x2E\x30-\x39\x41-\x5A\x5E-\x7E]+)" ["_value":"Swift_Mime_Headers_UnstructuredHeader":private]=> string(10) "text/plain" ["_specials":"Swift_Mime_Headers_AbstractHeader":private]=> array(12) { [0]=> string(1) "(" [1]=> string(1) ")" [2]=> string(1) "<" [3]=> string(1) ">" [4]=> string(1) "[" [5]=> string(1) "]" [6]=> string(1) ":" [7]=> string(1) ";" [8]=> string(1) "#" [9]=> string(1) "," [10]=> string(1) "." [11]=> string(1) """ }
UPDATE
Here is the SmtpApiHeader class:
<?php
class SmtpApiHeader
{
var $data;
function addTo($tos)
{
if (!isset($this->data['to'])) {
$this->data['to'] = array();
}
$this->data['to'] = array_merge($this->data['to'], (array) $tos);
}
function addSubVal($var, $val)
{
if (!isset($this->data['sub'])) {
$this->data['sub'] = array();
}
if (!isset($this->data['sub'][$var])) {
$this->data['sub'][$var] = array();
}
$this->data['sub'][$var] = array_merge($this->data['sub'][$var], (array) $val);
}
function setUniqueArgs($val)
{
if (!is_array($val))
return;
// checking for associative array
$diff = array_diff_assoc($val, array_values($val));
if (((empty($diff)) ? false : true)) {
$this->data['unique_args'] = $val;
}
}
function setCategory($cat)
{
$this->data['category'] = $cat;
}
function addFilterSetting($filter, $setting, $value)
{
if (!isset($this->data['filters'])) {
$this->data['filters'] = array();
}
if (!isset($this->data['filters'][$filter])) {
$this->data['filters'][$filter] = array();
}
if (!isset($this->data['filters'][$filter]['settings'])) {
$this->data['filters'][$filter]['settings'] = array();
}
$this->data['filters'][$filter]['settings'][$setting] = $value;
}
function asJSON()
{
$json = json_encode($this->data);
// Add spaces so that the field can be folded
$json = preg_replace('/(["\]}])([,:])(["\[{])/', '$1$2 $3', $json);
return $json;
}
function as_string()
{
$json = $this->asJSON();
$str = "X-SMTPAPI: " . wordwrap($json, 76, "\n ");
return $str;
}
}
which I got here
UPDATE 28.8.13
If I do as Nick suggests and remove the hdr call and run this:
$headers->addTextHeader('X-Test', 'Some Text');
echo $headers->toString();
Then I get this:
Message-ID: <1377710372.521e3124a5c6c#localhost> Date: Wed, 28 Aug 2013 13:19:32 -0400 Subject: Testing, More From: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Test: Some Text
It would seem as suggested that the issue is with the SmtpApiHeader class, but it is just a copy from the Sendgrid docs. strange.
UPDATE 30.8.13
I was able to get the Sendgrid php library (per Swift's rec in the previous question) to make this work properly. Seems to be the best way to handle the latency and adding filters. It is a bit tricky to incorporate this into Symfony 1.4, but a test on Friday showed significant increase in speed and consistency.
I was able to get the Sendgrid php library (per Swift's rec in the previous question) to make this work properly. Seems to be the best way to handle the latency and adding filters. It is a bit tricky to incorporate this into Symfony 1.4, but a test run showed significant increase in speed and consistency.

Resources