Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

cpereiramt

Erro must take exactly 2 arguments - PHP/Wordpress/visual composer

Recommended Posts

                   Olá, estou tentando criar um componente personalizado para visual composer um dropdown, tenho o arquivo php pesquisa.php que cria o componente personalizado,  e tenho o arquivo Receita.php que retorna os dados para serem exibidos no componente, o problema é que quando executo a pagina não aparece o componente e nem os dados do arquivo Receita.php.

                   Pelo DEBUG do Wordpress apresenta a seguinte mensagem abaixo:

 

[03-Feb-2018 02:33:07 UTC] PHP Fatal error:  Method ImmutableValueObject::__set() must take exactly 2 arguments in /var/www/html/wp-content/themes/n2go-2014/visual-composer/elements/Receita.php on line 33
                   Por fim segue o conteúdo dos arquivos PHP mencionados : 

Pesquisa.php

<?php
include 'Receita.php'; 

class Pesquisa extends WPBakeryShortCode
{  

}

$atts = Integration::instance()->get_default_shortcode_attrs();
vc_map([
	'name' => __('N2Go Integrations', 'js_composer'),
	'base' => 'n2go_integrations',
	'icon' => 'icon-heart',
	'category' => [__('Content', 'js_composer')],
	'params' => array_map(
	
	
		function($key, $default){
			return [
				'type' => 'Dropdown',
				'heading' => ucwords(str_replace('_', ' ', $key)),
				'param_name' => $key,
				'value' => $default,
			];
		},
		array_keys($att),
		$atts
	),
	'descrição' => 'alguma descrição',
]);

?>

 

Receita.php

<?php

/**
 * Utility base class that makes it easier to fill in readonly value objects.
 * @internal
 */
abstract class ImmutableValueObject
{
    protected $data = [];

    final public function __construct(array $properties = [])
    {
        $this->data = array_merge($this->data, $properties);
    }

    final public function __get($name)
    {
        if (!array_key_exists($name, $this->data)) {
            throw new RuntimeException(sprintf('Undefined property: %s::%s', __CLASS__, $name));
        }

        return $this->data[$name];
    }

    final public function __set($name)
    {
        throw new RuntimeException(sprintf(
            '%s property: %s::%s',
            array_key_exists($name, $this->data) ? 'Readonly' : 'Undefined',
            __CLASS__,
            $name
        ));
    }
}

/**
 * @internal This is just a stub.
 *
 * @property string $id Unique ID of the integration
 * @property string $name Full name of integration, eg; 'WordPress'
 * @property string $abbreviation Short code of integration, eg; 'MAG' for Magento or 'WP' for WordPress
 * @property string $imageUrl Logo of the integration, usually in SVG format
 * @property string $helpUrl User guide URL - can be empty, in which case disable or hide help link
 * @property string $type A value from: 'CRM', 'CMS' or 'Webshop'
 * @property IntegrationSystem[] $items List of supported integrations (plugins or connectors bound to one system)
 */
class Integration extends ImmutableValueObject {}

/**
 * @internal This is just a stub.
 *
 * @property string $id Unique ID of the integration system
 * @property string $edition Eg; 'v4.2', 'v3 and older' or 'All Versions' - used in combination with integration
 * @property int $position Used for ordering
 * @property IntegrationPlugin[] $plugins List of plugins that support this edition.
 * @property IntegrationConnector[] $connectors List of connectors that support this edition.
 */
class IntegrationSystem extends ImmutableValueObject {}

/**
 * @internal This is just a stub.
 *
 * @property string $id Unique ID of the plugin
 * @property string $version Eg; '4000' or '4.0.0.0' - if it is 4 chars and no dots, then it should be formatted with dots between each char.
 * @property string $url Full URL for download the plugin. This may be a direct download or a page showcasing the plugin in a marketplace.
 */
class IntegrationPlugin extends ImmutableValueObject {}

/**
 * @internal This is just a stub.
 *
 * @property string $id Unique ID of the connector
 * @property string $version Eg; '4000' or '4.0.0.0' - if it is 4 chars and no dots, then it should be formatted with dots between each char.
 */
class IntegrationConnector extends ImmutableValueObject {}

/** @var Integration[] $sampleData */
$sampleData = [
    new Integration([
        'id' => '1',
        'name' => 'Amazon',
        'abbreviation' => 'AM',
        'imageUrl' => '//files-staging.newsletter2go.com/integration/amazon.svg',
        'helpUrl' => 'https://www.newsletter2go.de/features/amazon-newsletter-integration/',
        'type' => 'Webshop',
        'items' => [
            new IntegrationSystem([
                'id' => '1',
                'edition' => 'All Versions',
                'position' => 0,
                'plugins' => [],
                'connectors' => [
                    new IntegrationConnector(['id' => '1', 'version' => '3000']),
                ],
            ])
        ]
    ]),
    new Integration([
        'id' => '2',
        'name' => 'Lightspeed eCom',
        'abbreviation' => 'LS',
        'imageUrl' => '//files-staging.newsletter2go.com/integration/lightspeed.svg',
        'helpUrl' => '',
        'type' => 'Webshop',
        'items' => [
            new IntegrationSystem([
                'id' => '2',
                'edition' => 'All Versions',
                'position' => 0,
                'plugins' => [],
                'connectors' => [
                    new IntegrationConnector(['id' => '2', 'version' => '3000']),
                    new IntegrationConnector(['id' => '3', 'version' => '3001']),
                    new IntegrationConnector(['id' => '4', 'version' => '3002']),
                    new IntegrationConnector(['id' => '5', 'version' => '3003']),
                ],
            ])
        ]
    ]),
    new Integration([
        'id' => '3',
        'name' => 'WordPress',
        'abbreviation' => 'WP',
        'imageUrl' => '//files-staging.newsletter2go.com/integration/wordpress.svg',
        'helpUrl' => 'https://www.newsletter2go.com/help/integration-api/set-up-wordpress-plug-in/',
        'type' => 'CMS',
        'items' => [
            new IntegrationSystem([
                'id' => '2',
                'edition' => 'All Versions',
                'position' => 0,
                'plugins' => [
                    new IntegrationPlugin(['id' => '1', 'version' => '2100', 'url' => 'https://www.newsletter2go.de/plugins/wordpress/wp_v2_1_00.zip']),
                    new IntegrationPlugin(['id' => '2', 'version' => '3000', 'url' => 'https://www.newsletter2go.de/plugins/wordpress/wp_v3_0_00.zip']),
                    new IntegrationPlugin(['id' => '3', 'version' => '3003', 'url' => 'https://www.newsletter2go.de/plugins/wordpress/wp_v3_0_03.zip']),
                    new IntegrationPlugin(['id' => '4', 'version' => '3005', 'url' => 'https://www.newsletter2go.de/plugins/wordpress/wp_v3_0_05.zip']),
                    new IntegrationPlugin(['id' => '5', 'version' => '4006', 'url' => 'https://www.newsletter2go.de/plugins/wordpress/wp_latest.zip']),
                ],
                'connectors' => [
                    new IntegrationConnector(['id' => '6', 'version' => '3000']),
                ],
            ])
        ]
    ]),
];

return $sampleData;

 

Compartilhar este post


Link para o post
Compartilhar em outros sites

  • Conteúdo Similar

    • Por Gdonato
      Ola pessoal, baixei um tema wordpress Profolio e alterei ja grande parte do tema, porem estou com 2 problemas, um que os icones das redes sociais nao aparecem, altero, publico e nao aparece e  nao estou achando onde alterar a parte OUR PORTFOLIO onde esta em ingles, alguem pode me ajudar onde acho para editar e alterar?
    • Por Gdonato
      Ola pessoal, baixei um tema wordpress Profolio e alterei ja grande parte do tema, porem estou com 2 problemas, um que os icones das redes sociais nao aparecem, altero, publico e nao aparece e  nao estou achando onde alterar a parte OUR PORTFOLIO onde esta em ingles, alguem pode me ajudar onde acho para editar e alterar?
    • Por Gdonato
      Ola pessoal, baixei um tema wordpress Profolio e alterei ja grande parte do tema, porem estou com 2 problemas, um que os icones das redes socias nao aparecem, altero, publico e nao aparece e  nao estou achando onde alterar a parte OUR PORTFOLIO onde esta em ingles, alguem pode me ajudar onde acho para editar e alterar?
    • Por Rafael_Ferreira
      Não consigo carregar a imagem do captcha do meu formulário. Foi testado com o xampp e easyphp. Também não carregou a imagem de outros captcha. 
       
       
    • Por luiz monteiro
      Olá, tudo bem?
       
      Estou melhorando meu conhecimento em php e mysql e, me deparei com o seguinte. A tabela da base de dados tem um campo do tipo varchar(8) o qual armazena números. Eu não posso alterar o tipo desse campo. O que preciso é fazer um select para retornar o números que contenham zeros a direita ou a esquerda.
      O que tentei até agora
       
      Ex1
      $busca = $conexao->prepare("select campo form tabela where (campo = :campo) ");
      $busca->bindParam('campo', $_REQUEST['campo_form']);
       
      Se a direita da string $_REQUEST['campo_form'] termina ou inicia com zero ou zeros, a busca retorna vazio.
      Inseri dados numéricos, da seguinte maneira para testar: 01234567;  12345670: 12345678: 12340000... entre outros nessa coluna. Todos os valores que não terminam ou não iniciam com zero ou zeros, o select funciona.
       
       
      Ex2
      $busca = $conexao->prepare("select campo form tabela where (campo = 0340000) ");
      Esse número está cadastrado, mas não retorna.
       
      Ex3
      $busca = $conexao->prepare("select campo form tabela where (campo = '02340001' ) ");
      Esse número está cadastrado, mas não retorna.
       
       
      Ex4
      $busca = $conexao->prepare("select campo form tabela where (campo like 2340000) ");
      Esse número está cadastrado, mas não retorna.
       
      Ex5
      $busca = $conexao->prepare("select campo form tabela where (campo like '12340000') ");
      Esse número está cadastrado, mas não retorna.
       
      Ex6
      $busca = $conexao->prepare("select campo form tabela where (campo like '"12340000"' ) ");
      Esse número está cadastrado, mas não retorna.
       
       
      Ex7
      $busca = $conexao->prepare("select campo form tabela where (campo like :campo) ");
      $busca->bindParam('campo', $_REQUEST['campo_form'])
      Não retorna dados.
       
      O  $_REQUEST['campo_form'] é envio via AJAX de um formulário. 
      Usei o gettype para verificar o post, e ele retorna string.
      Fiz uma busca com número 12345678 para verificar o que o select retorna, e também retrona como string.
       
      Esse tipo de varchar foi usado porque os números que serão gravados nesse campo,  terão zeros a direita ou na esquerda. Os tipos number do mysql não gravam zeros, então estou usando esse. O problema é a busca.
      Agradeço desde já.
       
       
×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.